Skip to content

Commit

Permalink
Merge pull request #1355 from GRIDAPPSD/releases/2020.08.0
Browse files Browse the repository at this point in the history
Release of version 2020.08.0
  • Loading branch information
poorva1209 authored Sep 14, 2020
2 parents bc8236d + 42e0cc6 commit 907f515
Show file tree
Hide file tree
Showing 25 changed files with 77 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void sanity_ServerStarted() {


/*
* File getSimulationFile(int simulationId, RequestSimulation powerSystemConfig) throws Exception;
* File getSimulationFile(String simulationId, RequestSimulation powerSystemConfig) throws Exception;
String getConfigurationProperty(String key);
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void sanity_ServerStarted() {


/*
* File getSimulationFile(int simulationId, RequestSimulation powerSystemConfig) throws Exception;
* File getSimulationFile(String simulationId, RequestSimulation powerSystemConfig) throws Exception;
String getConfigurationProperty(String key);
*/

Expand Down
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=18.0.3,\
blazegraph.cim2glm;version=19.1.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=18.0.3,\
blazegraph.cim2glm;version=19.1.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 @@ -58,7 +58,7 @@ public interface AppManager {
* @param message
* @throws Exception
*/
void process(int processId, DataResponse event, Serializable message) throws Exception;
void process(String processId, DataResponse event, Serializable message) throws Exception;

/**
* Register a new app with GridAPPS-D app manager, registered apps will be persisted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public interface ConfigurationManager {
* @return
* @throws Exception
*/
File getSimulationFile(int simulationId, RequestSimulation powerSystemConfig) throws Exception;
File getSimulationFile(String simulationId, RequestSimulation powerSystemConfig) throws Exception;
String getConfigurationProperty(String key);
void registerConfigurationHandler(String type, ConfigurationHandler handler);
void generateConfiguration(String type, Properties parameters, PrintWriter out, String processId, String username) throws Exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public interface DataManager {

void registerDataManagerHandler(DataManagerHandler handler, String name);

Response processDataRequest(Serializable request, String type, int simulationId, String tempDataPath, String username) throws Exception;
Response processDataRequest(Serializable request, String type, String simulationId, String tempDataPath, String username) throws Exception;

void registerConverter(String inputFormat, String outputFormat, DataFormatConverter converter);
DataFormatConverter getConverter(String inputFormat, String outputFormat);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import pnnl.goss.core.Response;

public interface GridAppsDataHandler {
public Response handle(Serializable request, int simulationId, String tempDataPath, LogManager logManager) throws Exception;
public Response handle(Serializable request, String simulationId, String tempDataPath, LogManager logManager) throws Exception;

public String getDescription();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public interface SimulationManager {
* @param simulationFile
* @param simulationConfig Map<String, Object> simulationContext
*/
void startSimulation(int simulationId, SimulationConfig simulationConfig, SimulationContext simContext, Map<String, Object> simulationContext);
void startSimulation(String simulationId, SimulationConfig simulationConfig, SimulationContext simContext, Map<String, Object> simulationContext);

SimulationContext getSimulationContextForId(String simulationId);

Expand All @@ -67,6 +67,5 @@ public interface SimulationManager {
void pauseSimulation(String simulationId);

void resumeSimulation(String simulationId);

void startServiceDependencies(SimulationConfig simulationConfig, SimulationContext simContext, Map<String, Object> simulationContext);

}
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public AppManagerImpl(LogManager logManager,
}

@Override
public void process(int processId, DataResponse event, Serializable message)
public void process(String processId, DataResponse event, Serializable message)
throws Exception {

// Get username from message's metadata e.g. event.getUserName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void start(){
* @return
*/
@Override
public synchronized File getSimulationFile(int simulationId, RequestSimulation powerSystemConfig) throws Exception{
public synchronized File getSimulationFile(String simulationId, RequestSimulation powerSystemConfig) throws Exception{
logManager.log(
new LogMessage(this.getClass().getName(), new Integer(
simulationId).toString(), new Date().getTime(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@ public void generateConfig(Properties parameters, PrintWriter out, String proces
bgHost = BlazegraphQueryHandler.DEFAULT_ENDPOINT;
}
/*String simulationID = GridAppsDConstants.getStringProperty(parameters, SIMULATIONID, null);
int simId = -1;
String simId = "1";
if(simulationID==null || simulationID.trim().length()==0){
logError("No "+SIMULATIONID+" parameter provided", processId, username, logManager);
throw new Exception("Missing parameter "+SIMULATIONID);
}
try{
simId = new Integer(simulationID);
simId = simulationID;
}catch (Exception e) {
logError("Simulation ID not a valid integer "+simulationID+", defaulting to "+simId, simulationID, username, logManager);
logError("Simulation ID not a valid "+simulationID+", defaulting to "+simId, simulationID, username, logManager);
}*/

ModelState modelState = new ModelState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,15 @@ public void generateConfig(Properties parameters, PrintWriter out, String proces
bgHost = BlazegraphQueryHandler.DEFAULT_ENDPOINT;
}
String simulationID = GridAppsDConstants.getStringProperty(parameters, SIMULATIONID, null);
int simId = -1;
String simId = "1";
if(simulationID==null || simulationID.trim().length()==0){
logError("No "+SIMULATIONID+" parameter provided", processId, username, logManager);
throw new Exception("Missing parameter "+SIMULATIONID);
}
try{
simId = new Integer(simulationID);
simId = simulationID;
}catch (Exception e) {
logError("Simulation ID not a valid integer "+simulationID+", defaulting to "+simId, simulationID, username, logManager);
logError("Simulation ID not a valid "+simulationID+", defaulting to "+simId, simulationID, username, logManager);
}

ModelState modelState = new ModelState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@ public void generateConfig(Properties parameters, PrintWriter out,

String simulationID = GridAppsDConstants.getStringProperty(parameters, SIMULATIONID, null);
String loadprofile = GridAppsDConstants.getStringProperty(parameters, SCHEDULENAME, "ieeezipload");
int simId = -1;
String simId = "1";
if(simulationID==null || simulationID.trim().length()==0){
logError("No "+SIMULATIONID+" parameter provided", processId, username, logManager);
throw new Exception("Missing parameter "+SIMULATIONID);
}
try{
simId = new Integer(simulationID);
simId = simulationID;
}catch (Exception e) {
logError("Simulation ID not a valid integer "+simulationID+", defaulting to "+simId, simulationID, username, logManager);
logError("Simulation ID not a valid "+simulationID+", defaulting to "+simId, simulationID, username, logManager);
}

RequestTimeseriesData request = new RequestTimeseriesData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void registerDataManagerHandler(DataManagerHandler handler, String name){
}

@Override
public Response processDataRequest(Serializable request, String type, int simulationId, String tempDataPath, String username) throws Exception {
public Response processDataRequest(Serializable request, String type, String simulationId, String tempDataPath, String username) throws Exception {


if(request!=null && type!=null){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ public void storeSimulationInput(String simulationId) throws Exception {

@Override
public void storeServiceOutput(String simulationId, String serviceId, String instanceId) throws Exception {
//TODO: Remove this once alarms are stored in Proven
if(!serviceId.equals("gridappsd-alarms"))
subscribeAndStoreDataFromTopic("/topic/"+GridAppsDConstants.topic_simulation+"."+serviceId+"."+simulationId+".output", serviceId, instanceId);
subscribeAndStoreDataFromTopic("/topic/"+GridAppsDConstants.topic_simulation+"."+serviceId+"."+simulationId+".output", serviceId, instanceId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void onMessage(Serializable message) {
DataResponse event = (DataResponse)message;
String username = event.getUsername();

int processId = ProcessManagerImpl.generateProcessId();
String processId = ProcessManagerImpl.generateProcessId();
this.debug(processId, "Received message: "+ event.getData() +" on topic "+event.getDestination()+" from user "+username, event.getDestination(), username);


Expand Down Expand Up @@ -182,10 +182,10 @@ public void onMessage(Serializable message) {
//if new simulation
if (simRequest.simulation_request_type==null || simRequest.simulation_request_type.equals(SimulationRequestType.NEW)){
RequestSimulationResponse response = new RequestSimulationResponse();
response.setSimulationId(Integer.toString(processId));
response.setSimulationId(processId);
//RequestSimulation config = RequestSimulation.parse(message.toString());
if(simRequest.getTest_config()!=null)
response.setEvents(testManager.sendEventsToSimulation(simRequest.getTest_config().getEvents(), Integer.toString(processId)));
response.setEvents(testManager.sendEventsToSimulation(simRequest.getTest_config().getEvents(), processId));
client.publish(event.getReplyDestination(), response);
//TODO also verify that we have the correct sub-configurations as part of the request
//newSimulationProcess.process(configurationManager, simulationManager, processId, event, event.getData(), appManager, serviceManager);
Expand Down Expand Up @@ -310,7 +310,7 @@ public void onMessage(Serializable message) {
}


private void sendData(Client client, Destination replyDestination, Serializable data, int processId, String username){
private void sendData(Client client, Destination replyDestination, Serializable data, String 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){
Expand All @@ -332,7 +332,7 @@ private void sendData(Client client, Destination replyDestination, Serializable
}


private void sendError(Client client, Destination replyDestination, String error, int processId, String username){
private void sendError(Client client, Destination replyDestination, String error, String processId, String username){
try {
DataResponse r = new DataResponse();
r.setError(new DataError(error));
Expand All @@ -347,11 +347,11 @@ private void sendError(Client client, Destination replyDestination, String error
}


private void debug(int processId, String message, String process_type, String username) {
private void debug(String processId, String message, String process_type, String username) {

LogMessage logMessage = new LogMessage();
logMessage.setSource(this.getClass().getSimpleName());
logMessage.setProcessId(Integer.toString(processId));
logMessage.setProcessId(processId);
logMessage.setLogLevel(LogLevel.DEBUG);
logMessage.setProcessStatus(ProcessStatus.RUNNING);
logMessage.setLogMessage(message);
Expand All @@ -363,11 +363,11 @@ private void debug(int processId, String message, String process_type, String us

}

private void error(int processId, String message, String username) {
private void error(String processId, String message, String username) {

LogMessage logMessage = new LogMessage();
logMessage.setSource(this.getClass().getSimpleName());
logMessage.setProcessId(Integer.toString(processId));
logMessage.setProcessId(processId);
logMessage.setLogLevel(LogLevel.ERROR);
logMessage.setProcessStatus(ProcessStatus.ERROR);
logMessage.setLogMessage(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ public void start(){
* Generates and returns process id
* @return process id
*/
static int generateProcessId(){
return Math.abs(new Random().nextInt());
static String generateProcessId(){
return Integer.toString(Math.abs(new Random().nextInt()));
}

public int assignSimulationPort(int simulationId) throws Exception {
public int assignSimulationPort(String simulationId) throws Exception {
Integer simIdKey = new Integer(simulationId);
if (!simulationPorts.containsKey(simIdKey)) {
int tempPort = 49152 + randPort.nextInt(16384);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import gov.pnnl.goss.gridappsd.dto.ModelCreationConfig;
import gov.pnnl.goss.gridappsd.dto.RequestSimulation;
import gov.pnnl.goss.gridappsd.dto.ServiceConfig;
import gov.pnnl.goss.gridappsd.dto.ServiceInfo;
import gov.pnnl.goss.gridappsd.dto.SimulationConfig;
import gov.pnnl.goss.gridappsd.dto.SimulationContext;
import gov.pnnl.goss.gridappsd.dto.SimulationOutput;
Expand Down Expand Up @@ -90,7 +91,7 @@ public ProcessNewSimulationRequest(LogManager logManager) {
private volatile LogManager logManager;

public void process(ConfigurationManager configurationManager,
SimulationManager simulationManager, int simulationId,
SimulationManager simulationManager, String simulationId,
DataResponse event, RequestSimulation simRequest, AppManager appManager,
ServiceManager serviceManager, TestManager testManager,
DataManager dataManager, String username) {
Expand All @@ -100,7 +101,7 @@ public void process(ConfigurationManager configurationManager,
}

public void process(ConfigurationManager configurationManager,
SimulationManager simulationManager, int simulationId,
SimulationManager simulationManager, String simulationId,
RequestSimulation simRequest, int simulationPort, AppManager appManager,
ServiceManager serviceManager, TestManager testManager,DataManager dataManager, String username) {

Expand Down Expand Up @@ -200,12 +201,12 @@ public void process(ConfigurationManager configurationManager,
Properties simulationParams = generateSimulationParameters(simRequest);
simulationParams.put(DSSAllConfigurationHandler.SIMULATIONID, simId);
simulationParams.put(DSSAllConfigurationHandler.DIRECTORY, tempDataPathDir.getAbsolutePath());
configurationManager.generateConfiguration(DSSAllConfigurationHandler.TYPENAME, simulationParams, new PrintWriter(new StringWriter()), new Integer(simulationId).toString(), username);
configurationManager.generateConfiguration(DSSAllConfigurationHandler.TYPENAME, simulationParams, new PrintWriter(new StringWriter()), simulationId, username);
} else { //otherwise use gridlabd
Properties simulationParams = generateSimulationParameters(simRequest);
simulationParams.put(GLDAllConfigurationHandler.SIMULATIONID, simId);
simulationParams.put(GLDAllConfigurationHandler.DIRECTORY, tempDataPathDir.getAbsolutePath());
configurationManager.generateConfiguration(GLDAllConfigurationHandler.TYPENAME, simulationParams, new PrintWriter(new StringWriter()), new Integer(simulationId).toString(), username);
configurationManager.generateConfiguration(GLDAllConfigurationHandler.TYPENAME, simulationParams, new PrintWriter(new StringWriter()), simulationId, username);
}

logManager
Expand Down Expand Up @@ -324,8 +325,16 @@ public void process(ConfigurationManager configurationManager,
simContext.serviceInstanceIds = connectServiceInstanceIds;
simContext.appInstanceIds = connectedAppInstanceIds;

dataManager.processDataRequest(simContext, "timeseries", simulationId, null, username);
ServiceInfo simulationServiceInfo = serviceManager.getService(simRequest.getSimulation_config().simulator);
List<String> serviceDependencies = simulationServiceInfo.getService_dependencies();
for(String service : serviceDependencies) {
String serviceInstanceId = serviceManager.startServiceForSimultion(service, null, simulationContext);
if(serviceInstanceId!=null)
simContext.addServiceInstanceIds(serviceInstanceId);
}

dataManager.processDataRequest(simContext, "timeseries", simulationId, null, username);

// start test if requested
testManager.handleTestRequest(simRequest.getTest_config(), simContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void onMessage(Serializable message) {

//Extract simulation id and simulation files from message
//TODO: Parse message to get simulationId and simulationFile
int simulationId = 1;
String simulationId = "1";
String simulationFile = "filename";

//Start FNCS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ public void start() throws Exception{
* @param simulationFile
*/
@Override
public void startSimulation(int simulationId, SimulationConfig simulationConfig, SimulationContext simContext, Map<String, Object> simulationContext){
public void startSimulation(String simulationId, SimulationConfig simulationConfig, SimulationContext simContext, Map<String, Object> simulationContext){
//TODO: remove simulationContext parameter after refactoring service manager

try {
logManager.log(new LogMessage(this.getClass().getSimpleName(),
Integer.toString(simulationId),
simulationId,
new Date().getTime(),
"Starting simulation "+simulationId,
LogLevel.INFO,
Expand All @@ -153,8 +153,6 @@ public void startSimulation(int simulationId, SimulationConfig simulationConfig,

simContexts.put(simContext.getSimulationId(), simContext);

startServiceDependencies(simulationConfig, simContext, simulationContext);

SimulationProcess simProc = new SimulationProcess(simContext, serviceManager,
simulationConfig, simulationId, logManager, appManager, client, securityConfig);
// simProcesses.put(simContext.getSimulationId(), simProc);
Expand Down Expand Up @@ -202,17 +200,5 @@ public SimulationContext getSimulationContextForId(String simulationId){
return this.simContexts.get(simulationId);
}

@Override
public void startServiceDependencies(SimulationConfig simulationConfig, SimulationContext simContext, Map<String, Object> simulationContext){
ServiceInfo simulationServiceInfo = serviceManager.getService(simulationConfig.simulator);
List<String> serviceDependencies = simulationServiceInfo.getService_dependencies();
for(String service : serviceDependencies) {
String serviceInstanceId = serviceManager.startServiceForSimultion(service, null, simulationContext);
if(serviceInstanceId!=null)
simContext.addServiceInstanceIds(serviceInstanceId);
}

}


}
Loading

0 comments on commit 907f515

Please sign in to comment.