Skip to content

Commit

Permalink
Merge pull request #1169 from tdtalbot/speedups
Browse files Browse the repository at this point in the history
Speedups
  • Loading branch information
poorva1209 authored Dec 12, 2019
2 parents c6f9b26 + 5a9c8b8 commit 78e91da
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 17 deletions.
2 changes: 1 addition & 1 deletion gov.pnnl.goss.gridappsd/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
osgi.enroute.base.api,\
org.mockito.mockito-all,\
httpcore,\
blazegraph.cim2glm;version=17.0.0,\
blazegraph.cim2glm;version=18.0.0,\
httpclient,\
com.bigdata.rdf,\
proven-client;version=0.2.3,\
Expand Down
2 changes: 1 addition & 1 deletion gov.pnnl.goss.gridappsd/run.bnd.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
httpcore,\
httpclient,\
xml-apis,\
blazegraph.cim2glm;version=17.0.0,\
blazegraph.cim2glm;version=18.0.0,\
org.eclipse.jetty.aggregate.jetty-all-server;version=7.6.9,\
javax.servlet-api,\
com.bigdata.rdf,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager{
private HashMap<String, ConfigurationHandler> configHandlers = new HashMap<String, ConfigurationHandler>();



public ConfigurationManagerImpl() {
}

Expand Down Expand Up @@ -178,6 +179,12 @@ public void generateConfiguration(String type, Properties parameters, PrintWrite
GridAppsDConstants.topic_platformLog);
throw new Exception("No configuration handler registered for '"+type+"'");
}



}




}
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public void generateConfig(Properties parameters, PrintWriter out, String proces

//CIM2GLM utility uses
CIMImporter cimImporter = new CIMImporter();
cimImporter.start(queryHandler, CONFIGTARGET, fRoot, scheduleName, loadScale, bWantSched, bWantZip, bWantRandomFractions, useHouses, zFraction, iFraction, pFraction, bHaveEventGen, modelState);
cimImporter.start(queryHandler, CONFIGTARGET, fRoot, scheduleName, loadScale, bWantSched, bWantZip, bWantRandomFractions, useHouses, zFraction, iFraction, pFraction, bHaveEventGen, modelState, false);

logRunning("Finished generating all DSS configuration files.", processId, username, logManager);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ public class GLDAllConfigurationHandler extends BaseConfigurationHandler impleme
public static final String MODEL_STATE = "model_state";
public static final int TIMEFILTER_YEAR = 2013;

public static final String CONFIGTARGET = "glm";
// public static final String CONFIGTARGET = "glm";
public static final String CONFIGTARGET = "both"; //will build files for both glm and dss

public static final String CIM2GLM_PREFIX = "model";
public static final String BASE_FILENAME = CIM2GLM_PREFIX+"_base.glm";
Expand Down Expand Up @@ -244,7 +245,7 @@ public void generateConfig(Properties parameters, PrintWriter out, String proces

//CIM2GLM utility uses
CIMImporter cimImporter = new CIMImporter();
cimImporter.start(queryHandler, CONFIGTARGET, fRoot, scheduleName, loadScale, bWantSched, bWantZip, bWantRandomFractions, useHouses, zFraction, iFraction, pFraction, bHaveEventGen, modelState);
cimImporter.start(queryHandler, CONFIGTARGET, fRoot, scheduleName, loadScale, bWantSched, bWantZip, bWantRandomFractions, useHouses, zFraction, iFraction, pFraction, bHaveEventGen, modelState, false);
String tempDataPath = dir.getAbsolutePath();

//If use climate, then generate gridlabd weather data file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,13 @@ simulationId, new Date().getTime(),
ProcessStatus.RUNNING,
true), username, GridAppsDConstants.topic_simulationLog+simulationId);

//Create DSS base file
PrintWriter basePrintWriter = new PrintWriter(new StringWriter());
DSSAllConfigurationHandler baseConfigurationHandler = new DSSAllConfigurationHandler(logManager,simulationManager,configManager);
baseConfigurationHandler.generateConfig(parameters, basePrintWriter, simulationId, username);
if(!dssBaseFile.exists()) {
//Create DSS base file if it doesn't already exist
PrintWriter basePrintWriter = new PrintWriter(new StringWriter());
DSSAllConfigurationHandler baseConfigurationHandler = new DSSAllConfigurationHandler(logManager,simulationManager,configManager);
baseConfigurationHandler.generateConfig(parameters, basePrintWriter, simulationId, username);
}


if(!dssBaseFile.exists())
throw new Exception("Error: Could not create DSS base file to export YBus matrix");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public String query(String modelId, String query, String resultFormat, String pr
public ResultSet queryResultSet(String modelId, String query, String processId, String username) {
String endpoint = getEndpointURL(modelId);
BlazegraphQueryHandler queryHandler = new BlazegraphQueryHandler(endpoint, logManager, processId, username);
return queryHandler.query(query);
return queryHandler.query(query, null);

}

Expand Down Expand Up @@ -231,7 +231,7 @@ public ResultSet queryObjectResultSet(String modelId, String mrid, String proces
String query = "select ?property ?value where {<"+getEndpointNS(mrid)+"> ?property ?value}";

BlazegraphQueryHandler queryHandler = new BlazegraphQueryHandler(getEndpointURL(modelId), logManager, processId, username);
ResultSet rs = queryHandler.query(query);
ResultSet rs = queryHandler.query(query, null);
return rs;

}
Expand All @@ -251,7 +251,7 @@ public List<String> queryObjectTypeList(String modelId, String processId, String
}
query = query + "}";
BlazegraphQueryHandler queryHandler = new BlazegraphQueryHandler(getEndpointURL(modelId), logManager, processId, username);
ResultSet rs = queryHandler.query(query);
ResultSet rs = queryHandler.query(query, null);

List<String> objectTypes = new ArrayList<String>();
while(rs.hasNext()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void setLogManager(LogManager logManager) {
this.logManager = logManager;
}
@Override
public ResultSetCloseable query(String szQuery) {
public ResultSetCloseable query(String szQuery, String szTag) {
Query query = QueryFactory.create (Q_PREFIX + szQuery);
GridAppsDConstants.logMessage(logManager, this.getClass().getName(), "Executing query "+szQuery, processID, username, LogLevel.DEBUG);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package gov.pnnl.goss.gridappsd.dto;

import java.io.Serializable;
import com.google.gson.Gson;

public class RoleRequest implements Serializable{

private static final long serialVersionUID = -3277794121736133832L;


public RoleRequest(){}

public String user;

public String getUser() {
return user;
}

public void setUser(String user) {
this.user = user;
}

@Override
public String toString() {
Gson gson = new Gson();
return gson.toJson(this);
}

public static RoleRequest parse(String jsonString){
Gson gson = new Gson();
RoleRequest obj = gson.fromJson(jsonString, RoleRequest.class);
return obj;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ public void onMessage(Serializable message) {

private void sendData(Client client, Destination replyDestination, Serializable data, int processId, String username){
try {
//Make sure it is sending back something in the data field for valid json (or if it is null maybe it should send error response instead???)
if(data==null || data.toString().length()==0){
data = "{}";
}
String r = "{\"data\":"+data+",\"responseComplete\":true,\"id\":\""+processId+"\"}";
/*DataResponse r = new DataResponse();
r.setData(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public String getFeeder() {
QueryHandler queryHandler = getQueryHandler();
String lineQuery = "SELECT ?name WHERE { " + "?s r:type c:Feeder. " + "?s c:IdentifiedObject.name ?name} "
+ "ORDER by ?name";
ResultSet results = queryHandler.query(lineQuery);
ResultSet results = queryHandler.query(lineQuery, null);
String feederName = getResultName(results);
return feederName;
}
Expand All @@ -34,7 +34,7 @@ public String getGeographicalRegion() {

String geoRegionQuery = "SELECT ?name WHERE { " + "?s r:type c:GeographicalRegion. " + "?s c:IdentifiedObject.name ?name} "
+ "ORDER by ?name";
ResultSet results = queryHandler.query(geoRegionQuery);
ResultSet results = queryHandler.query(geoRegionQuery, null);
String geoName = getResultName(results);
return geoName;
}
Expand All @@ -43,7 +43,7 @@ public String getSubGeographicalRegion() {
QueryHandler queryHandler = getQueryHandler();
String subGeoRegionQuery = "SELECT ?name WHERE { " + "?s r:type c:SubGeographicalRegion. " + "?s c:IdentifiedObject.name ?name} "
+ "ORDER by ?name";
ResultSet results = queryHandler.query(subGeoRegionQuery);
ResultSet results = queryHandler.query(subGeoRegionQuery, null);
String subGeoName = getResultName(results);
return subGeoName;
}
Expand Down Expand Up @@ -108,7 +108,7 @@ public void getMeasurements(){
"?s c:Measurement.phases ?phsraw ."+
" {bind(strafter(str(?phsraw),\"PhaseCode.\") as ?phases)}"+
"} ORDER BY ?class ?type ?name";
ResultSet results = queryHandler.query(query);
ResultSet results = queryHandler.query(query, null);
String subGeoName = getResultName(results);
System.out.println(subGeoName);
}
Expand Down

0 comments on commit 78e91da

Please sign in to comment.