Commit 655b2b34 authored by Kyriakos Kritikos's avatar Kyriakos Kritikos
Browse files

Small updates to the code

parent 3d27588b
......@@ -87,12 +87,12 @@ public abstract class MetricStorage {
//Add measurement
em.getMeasurements().add(m);
logger.info("2. Adding measurement: " + value + " for metric: " + metricId + " of instance: " + mi.getName());
logger.info("Adding measurement: " + value + " for metric: " + metricId + " of instance: " + mi.getName());
//Push measurement if hasServer & should push it
if (hasServer && mi instanceof CompositeMetricInstance && CDOUtils.canPush(ID, trans)){
server.submitValue(metricId, value);
logger.info("2. Can push measurement: " + value + " for metric: " + metricId);
logger.info("Can push measurement: " + value + " for metric: " + metricId);
}
}
}
......@@ -44,11 +44,11 @@ public class StorageRunnable implements Runnable{
logger.info("Starting my work: " + v);
for (int i = 0; i < times; i++){
//logger.info("Running the " + i + " measurement for thread: " + v);
/* Change to SynchronisedMetricStorage.storeMeasurement to run the other test for measurement
/* Change to MetricStorageWithBlockingQueue.storeMeasurement to run the other test for measurement
* storage according to the other implementation
*/
MetricStorageWithBlockingQueue.storeMeasurement(v, id, ecID, SynchronisedMetricStorage.MeasurementType.APPLICATION_MEASUREMENT, appID, null);
//SynchronisedMetricStorage.storeMeasurement(v, id, ecID, SynchronisedMetricStorage.MeasurementType.APPLICATION_MEASUREMENT, appID, null);
//MetricStorageWithBlockingQueue.storeMeasurement(v, id, ecID, SynchronisedMetricStorage.MeasurementType.APPLICATION_MEASUREMENT, appID, null);
SynchronisedMetricStorage.storeMeasurement(v, id, ecID, SynchronisedMetricStorage.MeasurementType.APPLICATION_MEASUREMENT, appID, null);
}
logger.info("Ended my work: " + v);
}
......
......@@ -654,8 +654,9 @@ public class Test {
cl.closeSession();
}
public static void main(String[] args){
if (args.length != 0) runClient = Boolean.parseBoolean(args[0]);
/* Testing the MetricCollector */
public static void testMetricCollector(String firstArg){
if (firstArg != null) runClient = Boolean.parseBoolean(firstArg);
EObject model = createTestModel();
CDOClient client = new CDOClient();
CDOTransaction trans = client.openTransaction();
......@@ -672,15 +673,7 @@ public class Test {
client.closeSession();
Set<CDOID> ids = getTopMetrics("test");
Set<CDOID> globalMetrics = getGlobalMetrics(ids);
/* Running multiple measurements storage test
* If normal MetricCollector test has to be executed then:
* (a) comment next line code and (b) uncomment the last
* commented lines of code
*/
//MetricStorage.initServer(1, 5563);
//runExcessiveTest(ids.iterator().next());
//ExecutorService lis = Executors.newFixedThreadPool(3);
//startCDOListeners("test",lis);
ExecutorService thr = Executors.newFixedThreadPool(2);
startRawMetricThreads("test", thr);
ExecutorService subscribers = Executors.newFixedThreadPool(3);
......@@ -707,15 +700,54 @@ public class Test {
logger.error("Something went wrong while main thread was sleeping",e);
//e.printStackTrace();
}
//deleteAllMetrics(ecID);
//lis.shutdownNow();
thr.shutdownNow();
subscribers.shutdown();
if (runClient) fap.terminate();
deleteAllMetrics(ecID);
//lis.shutdownNow();
//MetricStorage.terminateServer();
mc1.terminate();
mc2.terminate();
}
/* Test whether measurements are stored in CDO and whether publishing in 0MQ takes place */
public static void testCDOStoragePublishing(String firstArg){
if (firstArg != null) runClient = Boolean.parseBoolean(firstArg);
EObject model = createTestModel();
CDOClient client = new CDOClient();
CDOTransaction trans = client.openTransaction();
CDOResource res = trans.getOrCreateResource("test");
res.getContents().add(model);
try{
trans.commit();
}
catch(Exception e){
logger.error("Something went wrong while attempting to store the test model in CDO",e);
//e.printStackTrace();
}
trans.close();
client.closeSession();
Set<CDOID> ids = getTopMetrics("test");
Set<CDOID> globalMetrics = getGlobalMetrics(ids);
/* Running multiple measurements storage test
* If normal MetricCollector test has to be executed then:
* (a) comment next line code and (b) uncomment the last
* commented lines of code
*/
MetricStorage.initServer(1, 5563);
runExcessiveTest(ids.iterator().next());
ExecutorService lis = Executors.newFixedThreadPool(3);
startCDOListeners("test",lis);
deleteAllMetrics(ecID);
lis.shutdownNow();
MetricStorage.terminateServer();
}
public static void main(String[] args){
String firstArg = null;
if (args.length != 0) firstArg = args[0];
//testMetricCollector(firstArg);
testCDOStoragePublishing(firstArg);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment