Skip to content

Commit 45872dc

Browse files
author
Neevo Lima
committed
Merge pull request #106 from PeterMerkert/master
Added a comment to the retrieveMEController() method
2 parents de2043e + 3a4780b commit 45872dc

26 files changed

Lines changed: 201 additions & 186 deletions

File tree

org.sopeco.analysis.wrapper/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99
<parent>
1010
<artifactId>org.sopeco.core.parent</artifactId>
1111
<groupId>org.sopeco.core</groupId>
12-
<version>5.0.2-SNAPSHOT</version>
12+
<version>5.0.3-SNAPSHOT</version>
1313
<relativePath>../org.sopeco.core.parent</relativePath>
1414
</parent>
1515

1616
<dependencies>
1717
<dependency>
1818
<groupId>org.sopeco.core</groupId>
1919
<artifactId>org.sopeco.config</artifactId>
20-
<version>5.0.2-SNAPSHOT</version>
20+
<version>5.0.3-SNAPSHOT</version>
2121
</dependency>
2222
<dependency>
2323
<groupId>org.sopeco.core</groupId>
2424
<artifactId>org.sopeco.persistence</artifactId>
25-
<version>5.0.2-SNAPSHOT</version>
25+
<version>5.0.3-SNAPSHOT</version>
2626
</dependency>
2727
<dependency>
2828
<groupId>org.sopeco.core</groupId>
2929
<artifactId>org.sopeco.engine</artifactId>
30-
<version>5.0.2-SNAPSHOT</version>
30+
<version>5.0.3-SNAPSHOT</version>
3131
</dependency>
3232
</dependencies>
3333

org.sopeco.config/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
<parent>
1111
<artifactId>org.sopeco.core.parent</artifactId>
1212
<groupId>org.sopeco.core</groupId>
13-
<version>5.0.2-SNAPSHOT</version>
13+
<version>5.0.3-SNAPSHOT</version>
1414
<relativePath>../org.sopeco.core.parent</relativePath>
1515
</parent>
1616

1717
<dependencies>
1818
<dependency>
1919
<groupId>org.sopeco.core</groupId>
2020
<artifactId>org.sopeco.util</artifactId>
21-
<version>5.0.2-SNAPSHOT</version>
21+
<version>5.0.3-SNAPSHOT</version>
2222
</dependency>
2323
</dependencies>
2424

org.sopeco.core.parent/pom.xml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.sopeco.core</groupId>
88
<artifactId>org.sopeco.core.parent</artifactId>
9-
<version>5.0.2-SNAPSHOT</version>
9+
<version>5.0.3-SNAPSHOT</version>
1010
<packaging>pom</packaging>
1111
<name>Software Performance Cockpit - Core</name>
1212

@@ -127,24 +127,17 @@
127127

128128
<!-- Jersey dependencies -->
129129
<dependency>
130-
<groupId>com.sun.jersey</groupId>
131-
<artifactId>jersey-server</artifactId>
132-
<version>1.17.1</version>
130+
<groupId>org.glassfish.jersey.containers</groupId>
131+
<artifactId>jersey-container-grizzly2-http</artifactId>
132+
<version>2.6</version>
133133
</dependency>
134134

135135
<dependency>
136-
<groupId>com.sun.jersey</groupId>
137-
<artifactId>jersey-client</artifactId>
138-
<version>1.17.1</version>
136+
<groupId>org.glassfish.jersey.core</groupId>
137+
<artifactId>jersey-client</artifactId>
138+
<version>2.6</version>
139139
</dependency>
140-
141-
142-
<dependency>
143-
<groupId>javax.ws.rs</groupId>
144-
<artifactId>jsr311-api</artifactId>
145-
<version>1.1.1</version>
146-
</dependency>
147-
140+
148141
<dependency>
149142
<groupId>asm</groupId>
150143
<artifactId>asm</artifactId>

org.sopeco.core/pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<parent>
1111
<artifactId>org.sopeco.core.parent</artifactId>
1212
<groupId>org.sopeco.core</groupId>
13-
<version>5.0.2-SNAPSHOT</version>
13+
<version>5.0.3-SNAPSHOT</version>
1414
<relativePath>../org.sopeco.core.parent</relativePath>
1515
</parent>
1616

@@ -19,22 +19,22 @@
1919
<dependency>
2020
<groupId>org.sopeco.core</groupId>
2121
<artifactId>org.sopeco.engine</artifactId>
22-
<version>5.0.2-SNAPSHOT</version>
22+
<version>5.0.3-SNAPSHOT</version>
2323
</dependency>
2424
<dependency>
2525
<groupId>org.sopeco.core</groupId>
2626
<artifactId>org.sopeco.util</artifactId>
27-
<version>5.0.2-SNAPSHOT</version>
27+
<version>5.0.3-SNAPSHOT</version>
2828
</dependency>
2929
<dependency>
3030
<groupId>org.sopeco.core</groupId>
3131
<artifactId>org.sopeco.config</artifactId>
32-
<version>5.0.2-SNAPSHOT</version>
32+
<version>5.0.3-SNAPSHOT</version>
3333
</dependency>
3434
<dependency>
3535
<groupId>org.sopeco.core</groupId>
3636
<artifactId>org.sopeco.persistence</artifactId>
37-
<version>5.0.2-SNAPSHOT</version>
37+
<version>5.0.3-SNAPSHOT</version>
3838
</dependency>
3939
</dependencies>
4040

org.sopeco.engine/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@
1010
<parent>
1111
<artifactId>org.sopeco.core.parent</artifactId>
1212
<groupId>org.sopeco.core</groupId>
13-
<version>5.0.2-SNAPSHOT</version>
13+
<version>5.0.3-SNAPSHOT</version>
1414
<relativePath>../org.sopeco.core.parent</relativePath>
1515
</parent>
1616

1717
<dependencies>
1818
<dependency>
1919
<groupId>org.sopeco.core</groupId>
2020
<artifactId>org.sopeco.util</artifactId>
21-
<version>5.0.2-SNAPSHOT</version>
21+
<version>5.0.3-SNAPSHOT</version>
2222
</dependency>
2323
<dependency>
2424
<groupId>org.sopeco.core</groupId>
2525
<artifactId>org.sopeco.config</artifactId>
26-
<version>5.0.2-SNAPSHOT</version>
26+
<version>5.0.3-SNAPSHOT</version>
2727
</dependency>
2828
<dependency>
2929
<groupId>org.sopeco.core</groupId>
3030
<artifactId>org.sopeco.persistence</artifactId>
31-
<version>5.0.2-SNAPSHOT</version>
31+
<version>5.0.3-SNAPSHOT</version>
3232
</dependency>
3333
</dependencies>
3434
</project>

org.sopeco.engine/src/org/sopeco/engine/EngineFactory.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,19 @@ public IEngine createEngine(String sessionId) {
9696
return engine;
9797
}
9898

99+
/**
100+
* Retrieves a MEC via the configurations with the passed session ID. <br />
101+
* First, the configuration is checked for the <code>CONF_MEASUREMENT_CONTROLLER_CLASS_NAME</code>.
102+
* If the name is available, it's tried to instantiate the MEC. Only if the name is
103+
* <code>null</code>, it's tried to directly connect to the MEC via the {@link MEConnectorFactory}
104+
* and the given URI in the configuration property <code>CONF_MEASUREMENT_CONTROLLER_URI</code>.
105+
*
106+
* @param sessionId
107+
* the session ID
108+
* @return
109+
* the {@link IMeasurementEnvironmentController} retrieved via
110+
* name or URI
111+
*/
99112
public IMeasurementEnvironmentController retrieveMEController(String sessionId) {
100113
final IConfiguration config = Configuration.getSessionSingleton(sessionId);
101114

org.sopeco.engine/src/org/sopeco/engine/experiment/impl/ExperimentController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ public class ExperimentController extends SessionAwareObject implements IExperim
7373
private static final String USE_CACHE_PROPERTY = "sopeco.config.engine.useExperimentResultCache";
7474

7575
/**
76-
* Constructor.
76+
* Constructor.<br />
77+
* Opens a connection to the persistence provider with the configuration data fetched via the
78+
* given session ID.
7779
*
7880
* @param sessionId
7981
* Session id to be used for this experiment controller.

org.sopeco.engine/src/org/sopeco/engine/imp/EngineImp.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ public class EngineImp extends SessionAwareObject implements IEngine {
8080

8181
/**
8282
* Constructor.
83+
* Opens a connection to the persistence provider with the configuration data fetched via the
84+
* given session ID.
8385
*
8486
* @param sessionId
8587
* Session id to be used by this session aware object
@@ -133,7 +135,7 @@ public ScenarioInstance run(ScenarioDefinition scenarioDefinition, Collection<St
133135
}
134136

135137
ScenarioInstance scenarioInstance = retrieveScenarioInstance(scenarioDefinition);
136-
scenarioInstance.getScenarioDefinition().getAllExperimentSeriesDefinitions();
138+
scenarioInstance.getScenarioDefinition().getAllExperimentSeriesDefinitions();
137139

138140
Map<MeasurementSpecification, List<ExperimentSeriesDefinition>> experimentSeries = new HashMap<MeasurementSpecification, List<ExperimentSeriesDefinition>>();
139141

@@ -186,6 +188,15 @@ public void abortExperimentRun() {
186188
new Boolean(true));
187189
}
188190

191+
/**
192+
* Tries to fetch the {@link ScenarioInstance} for the given {@link ScenarioDefinition}
193+
* out of the database.<br />
194+
* If the <code>ScenarioInstance</code> does not exist yet, it's created from the information
195+
* in the <code>ScenarioDefinition</code>. See more <code>createNewScenarioInstance()</code>.
196+
*
197+
* @param scenarioDefinition the {@link ScenarioDefinition}
198+
* @return the {@link ScenarioInstance} corresponding to the given definiton
199+
*/
189200
private ScenarioInstance retrieveScenarioInstance(ScenarioDefinition scenarioDefinition) {
190201
ScenarioInstance scenarioInstance = null;
191202

@@ -195,8 +206,9 @@ private ScenarioInstance retrieveScenarioInstance(ScenarioDefinition scenarioDef
195206
getConfiguration().getMeasurementControllerURIAsStr());
196207
LOGGER.debug("Loaded ScenarioInstance {} from database", scenarioInstance);
197208
LOGGER.debug("Compare Scenario definition defined in the specification with the one loaded from database");
198-
209+
199210
} catch (DataNotFoundException e) {
211+
LOGGER.debug("No ScenarioInstance for the given ScenarioDefinition found in the database.");
200212
scenarioInstance = createNewScenarioInstance(scenarioDefinition);
201213
}
202214
if (scenarioInstance == null) {

org.sopeco.engine/src/org/sopeco/engine/measurementenvironment/app/RESTServer.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@
2727
package org.sopeco.engine.measurementenvironment.app;
2828

2929
import java.io.IOException;
30+
import java.net.URI;
31+
import java.net.URISyntaxException;
3032

33+
import org.glassfish.grizzly.http.server.HttpServer;
34+
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
35+
import org.glassfish.jersey.server.ResourceConfig;
3136
import org.slf4j.Logger;
3237
import org.slf4j.LoggerFactory;
3338

34-
import com.sun.jersey.api.container.httpserver.HttpServerFactory;
35-
import com.sun.jersey.api.core.PackagesResourceConfig;
36-
import com.sun.net.httpserver.HttpServer;
37-
3839
/**
3940
*
4041
* @author Marius Oehler
@@ -62,8 +63,12 @@ public static synchronized void startREST(int pPort) {
6263
return;
6364
}
6465

65-
PackagesResourceConfig rescConfig = new PackagesResourceConfig(REST_SERVICE_PACKAGE);
66-
server = HttpServerFactory.create("http://localhost:" + pPort + "/", rescConfig);
66+
ResourceConfig resourceConfig = new ResourceConfig();
67+
resourceConfig.packages(REST_SERVICE_PACKAGE);
68+
69+
URI uri = new URI("http://localhost:" + pPort + "/");
70+
71+
server = GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig);
6772
server.start();
6873

6974
LOGGER.info("Available MEController:");
@@ -73,6 +78,8 @@ public static synchronized void startREST(int pPort) {
7378

7479
running = true;
7580
LOGGER.debug("Server started.", pPort);
81+
} catch (URISyntaxException e) {
82+
LOGGER.error("URI is invalid.");
7683
} catch (IOException e) {
7784
LOGGER.error("Server start on port {} has failed: {}", pPort, e.getLocalizedMessage());
7885
}

org.sopeco.engine/src/org/sopeco/engine/measurementenvironment/connector/RestMEConnector.java

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,17 @@
2929
import java.net.URI;
3030
import java.util.Arrays;
3131

32+
import javax.ws.rs.client.ClientBuilder;
33+
import javax.ws.rs.core.Response;
34+
import javax.ws.rs.core.Response.Status;
35+
3236
import org.slf4j.Logger;
3337
import org.slf4j.LoggerFactory;
3438
import org.sopeco.engine.measurementenvironment.IMeasurementEnvironmentController;
3539
import org.sopeco.engine.measurementenvironment.rest.RestMECWrapper;
3640
import org.sopeco.engine.measurementenvironment.rest.RestServices;
3741
import org.sopeco.engine.measurementenvironment.rest.TransferPackage;
3842

39-
import com.sun.jersey.api.client.Client;
40-
import com.sun.jersey.api.client.ClientHandlerException;
41-
import com.sun.jersey.api.client.ClientResponse;
42-
import com.sun.jersey.api.client.ClientResponse.Status;
43-
import com.sun.jersey.api.client.UniformInterfaceException;
44-
4543
/**
4644
*
4745
* @author Marius Oehler
@@ -64,20 +62,12 @@ public final class RestMEConnector implements IMEConnector {
6462
public static boolean isMECApplicationRunning(String url) {
6563
url += ALIVE_PREFIX;
6664

67-
ClientResponse response = null;
68-
try {
69-
response = Client.create().resource(url).get(ClientResponse.class);
70-
} catch (ClientHandlerException e) {
71-
LOGGER.error(e.getLocalizedMessage() + " - URL: " + url);
72-
return false;
73-
} catch (UniformInterfaceException e) {
74-
LOGGER.error(e.getLocalizedMessage() + " - URL: " + url);
75-
return false;
76-
}
65+
Response response = ClientBuilder.newClient().target(url).request().get();
66+
7767
if (response.getStatus() != Status.OK.getStatusCode()) {
7868
LOGGER.error("Request was not successful. Server returned: " + response.getStatus());
7969
return false;
80-
} else if (!response.hasEntity() || !response.getEntity(String.class).equals(RestServices.ALIVE_MESSAGE)) {
70+
} else if (!response.hasEntity() || !response.readEntity(String.class).equals(RestServices.ALIVE_MESSAGE)) {
8171
LOGGER.error("The host is probably not a valid MEController.");
8272
return false;
8373
}
@@ -94,19 +84,12 @@ public static boolean isMECApplicationRunning(String url) {
9484
public static String[] getAvailableMEController(String url) {
9585
url += AVAILABLE_CONTROLLER_PREFIX;
9686

97-
ClientResponse response = null;
98-
try {
99-
response = Client.create().resource(url).get(ClientResponse.class);
100-
} catch (ClientHandlerException e) {
101-
throw e;
102-
} catch (UniformInterfaceException e) {
103-
throw e;
104-
}
87+
Response response = ClientBuilder.newClient().target(url).request().get();
10588

10689
if (response.getStatus() != Status.OK.getStatusCode()) {
10790
LOGGER.info("Request was not successful. Server returned: " + response.getStatus());
10891
} else if (response.hasEntity()) {
109-
TransferPackage result = response.getEntity(TransferPackage.class);
92+
TransferPackage result = response.readEntity(TransferPackage.class);
11093
return result.getA( String[].class);
11194
}
11295
return new String[0];

0 commit comments

Comments
 (0)