Skip to content

Commit 2ed6056

Browse files
Christoph BodensteinChristoph Bodenstein
authored andcommitted
added clientside support for clientIDs of slave simulators
1 parent cca144b commit 2ed6056

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

TimeNETOptimizationEnvironment/src/toe/simulation/SimulatorWebSlave.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.io.FileWriter;
1616
import java.io.IOException;
1717
import java.util.Calendar;
18+
import java.util.Random;
1819
import java.util.concurrent.TimeUnit;
1920
import java.util.logging.Level;
2021
import java.util.logging.Logger;
@@ -29,6 +30,7 @@
2930
import org.apache.http.util.EntityUtils;
3031
import toe.HttpFactory;
3132
import toe.support;
33+
import toe.typedef;
3234

3335
/**
3436
*
@@ -44,6 +46,8 @@ public class SimulatorWebSlave implements Runnable {
4446
HttpClient client;
4547
HttpGet httpGet;
4648
HttpPost postRequest;
49+
String clientID;//ID of this client to be marked in server to append to download request
50+
String clientSkills;//Skills of Client in one String to append to download request
4751

4852
/**
4953
* Constructor
@@ -57,14 +61,23 @@ public SimulatorWebSlave() {
5761
* from server, checking for next files, starting loacal simulations and
5862
* uploading results
5963
*/
64+
@Override
6065
public void run() {
6166
support.setLogToWindow(false);//stop window-logging. this is not saved in properties
62-
while (!shouldEnd) {
63-
this.pathToTimeNet = support.getPathToTimeNet();// pathToTimeNetTMP;
67+
this.pathToTimeNet = support.getPathToTimeNet();// pathToTimeNetTMP;
68+
clientID=String.valueOf(Math.random())+Long.toString(Calendar.getInstance().getTimeInMillis());
69+
clientID=String.valueOf(Math.abs(clientID.hashCode()));
70+
//TODO set skill-string correctly!
71+
clientSkills="";
72+
if(support.checkTimeNetPath()){
73+
clientSkills+="_"+typedef.typeOfClientSkills.TIMENET.toString()+"_";
74+
}
75+
76+
while (!shouldEnd) {
6477
//Request the server Api to get the Status Code and response body.
6578
// Getting the status code.
6679
client = HttpFactory.getHttpClient();
67-
httpGet = HttpFactory.getGetRequest(support.getReMoteAddress() + "/rest/api/downloads/ND");
80+
httpGet = HttpFactory.getGetRequest(support.getReMoteAddress() + "/rest/api/downloads/ND?ID="+clientID+"&SKILLS="+clientSkills);
6881
HttpResponse response;
6982
String responseString;
7083
try {

TimeNETOptimizationEnvironment/src/toe/support.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
public class support {
4040

4141
//This Version of TimeNetExperimentGenerator
42-
public static final String VERSION = "2015-03-26";
42+
public static final String VERSION = "2015-04-02";
4343

4444
//Define some program-wide default values
4545
public static final double DEFAULT_STEPPING = 1.0;

TimeNETOptimizationEnvironment/src/toe/typedef.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,4 +467,26 @@ public enum typeOfRelativeDistanceCalculation{
467467
* use EULID Distance and calc relative value
468468
*/
469469
EUKLID}
470+
471+
/**
472+
* Skills of Client to be mentioned for distributed simulation
473+
* TimeNET, MLDesigner, Matlab ???
474+
*/
475+
public enum typeOfClientSkills{
476+
477+
/**
478+
* client can simulate SCPNs (with TimeNET)
479+
*/
480+
TIMENET,
481+
482+
/**
483+
* client can simulate MLD-Models
484+
*/
485+
MLDESIGNER,
486+
487+
/**
488+
* client can simulate Matlab models
489+
*/
490+
MATLAB
491+
}
470492
}

0 commit comments

Comments
 (0)