Skip to content
Snippets Groups Projects
Commit 32f5a4e2 authored by Tillmann Bielefeld's avatar Tillmann Bielefeld
Browse files

Merge branch 'master' of build.se.informatik.uni-kiel.de:kieker.opad

parents 2fee7472 c49053ca
No related branches found
No related tags found
No related merge requests found
......@@ -3,16 +3,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="src-servlet"/>
<classpathentry kind="src" path="tests"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 6 (MacOS X Default)">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="lib/activemq-all-5.5.0.jar"/>
......@@ -71,5 +61,10 @@
<classpathentry kind="lib" path="lib/org.eclipse.emf.common-2.7.0.v20120127-1122.jar"/>
<classpathentry kind="lib" path="lib/org.eclipse.emf.ecore-2.7.0.v20120127-1122.jar"/>
<classpathentry kind="lib" path="lib/org.eclipse.emf.ecore.xmi-2.7.0.v20120127-1122.jar"/>
<classpathentry kind="output" path="build/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="build-eclipse"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="Apache Tomcat v7.0"/>
<fixed facet="java"/>
<fixed facet="jst.web"/>
<fixed facet="wst.jsdt.web"/>
......
......
package com.tielefeld.opad.support;
import java.io.File;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rosuda.JRclient.REXP;
import org.rosuda.JRclient.RSrvException;
import org.rosuda.JRclient.Rconnection;
import sun.security.krb5.Config;
import com.tielefeld.opad.config.OPADConfiguration;
import com.tielefeld.rbridge.RBridgeControl;
......@@ -21,7 +14,7 @@ public class RBridgeTester {
* @param args
* @throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException {
public static void main(final String[] args) throws InterruptedException {
/*
* try { Rconnection c = new Rconnection(); REXP x; x =
......@@ -31,7 +24,7 @@ public class RBridgeTester {
* (Exception e) { e.printStackTrace(); }
*/
RBridgeControl r = OPADConfiguration.getRBridgeInstance();
final RBridgeControl r = OPADConfiguration.getRBridgeInstance();
// r.e("print('bridge control loaded') ");
// r.e("dprint('bridge control loaded') ");
// r.e("plot2()");
......@@ -50,7 +43,7 @@ public class RBridgeTester {
* +pdfFile+"', times, measures, forecasts, anomalies) ");
*/
String pdfFile = "/Users/till/Documents/repositories/uni/thesis-repos/Opad4lsssExperiments/r_scripts/plots/test/AspectTest.pdf";
final String pdfFile = "/Users/till/Documents/repositories/uni/thesis-repos/Opad4lsssExperiments/r_scripts/plots/test/AspectTest.pdf";
// r.e("pdf('" + pdfFile + "')");
// r.e("configPlotAnomaly(combined, -4000, 1000)");
// r.e("dev.off()" );
......
......
package com.tielefeld.opad.arch;
import static org.junit.Assert.*;
import static org.junit.Assert.fail;
import java.net.UnknownHostException;
import java.util.Date;
import java.util.concurrent.TimeUnit;
......@@ -10,12 +7,11 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import sun.security.krb5.Config;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
......@@ -27,9 +23,7 @@ import com.tielefeld.opad.config.AspectAttributes;
import com.tielefeld.opad.config.AspectsConfiguration;
import com.tielefeld.opad.config.OPADConfiguration;
import com.tielefeld.opad.operations.AttributeListenerGrid;
import com.tielefeld.opad.operations.Aspect;
import com.tielefeld.opad.operations.Timespan;
import com.tielefeld.opad.operations.beats.aggregation.AggregationDataBeat;
import com.tielefeld.tslib.ForecastMethod;
public class AspectGridTest {
......@@ -53,56 +47,56 @@ public class AspectGridTest {
Mongo mongoDB = null;
try {
mongoDB = new Mongo();
mongoConnection = mongoDB.getDB(OPADConfiguration.getInstance().get(
this.mongoConnection = mongoDB.getDB(OPADConfiguration.getInstance().get(
OPADConfiguration.DB_NAME));
this.coll = mongoConnection.getCollection(OPADConfiguration
this.coll = this.mongoConnection.getCollection(OPADConfiguration
.getInstance().get(OPADConfiguration.DB_COLLECTION));
} catch (UnknownHostException e) {
} catch (final UnknownHostException e) {
e.printStackTrace();
fail("Mongo not accessible!");
} catch (MongoException e) {
Assert.fail("Mongo not accessible!");
} catch (final MongoException e) {
e.printStackTrace();
fail("Mongo not accessible!");
Assert.fail("Mongo not accessible!");
}
this.coll.remove(new BasicDBObject());
assertEquals(0, this.coll.find().size());
Assert.assertEquals(0, this.coll.find().size());
}
@After
public void tearDown() throws Exception {
this.coll.remove(new BasicDBObject());
assertEquals(0, this.coll.find().size());
Assert.assertEquals(0, this.coll.find().size());
}
@Test
public void testDoubleInsertion() {
this.coll.remove(new BasicDBObject());
assertEquals(0, this.coll.find().size());
Assert.assertEquals(0, this.coll.find().size());
LOG.debug("AggregationDataBeat ____________________________________________ ");
long step = 1000;
long delta = step * 10;
long now = System.currentTimeMillis();
Timespan deltaSpan = new Timespan(delta, TimeUnit.MILLISECONDS);
final long step = 1000;
final long delta = step * 10;
final long now = System.currentTimeMillis();
final Timespan deltaSpan = new Timespan(delta, TimeUnit.MILLISECONDS);
// was: .start(new Date(now))
Timespan windowSize = new Timespan(delta * 5, TimeUnit.MILLISECONDS);
final Timespan windowSize = new Timespan(delta * 5, TimeUnit.MILLISECONDS);
// BUILD GRID
AttributeListenerGrid grid = new AttributeListenerGrid(mongoConnection);
final AttributeListenerGrid grid = new AttributeListenerGrid(this.mongoConnection);
// CONFIGURE GRID
AspectsConfiguration config = new AspectsConfiguration();
AspectAttributes aspect = AspectAttributes.getInstance()
.forecast(ForecastMethod.MEAN).identifier(IDENT)
.attribute(ATTR1)
final AspectsConfiguration config = new AspectsConfiguration();
final AspectAttributes aspect = AspectAttributes.getInstance()
.forecast(ForecastMethod.MEAN).identifier(this.IDENT)
.attribute(this.ATTR1)
.length(windowSize).delta(deltaSpan);
AspectAttributes aspect2 = AspectAttributes.getInstance()
.forecast(ForecastMethod.MEAN).identifier(IDENT_TWO)
.attribute(ATTR2)
final AspectAttributes aspect2 = AspectAttributes.getInstance()
.forecast(ForecastMethod.MEAN).identifier(this.IDENT_TWO)
.attribute(this.ATTR2)
.length(windowSize).delta(deltaSpan);
config.addAspect(aspect);
config.addAspect(aspect2);
......@@ -110,68 +104,68 @@ public class AspectGridTest {
grid.configure(config, new Date(now));
// ADD MEASURES
grid.pushMeasure(new Date(now + step), 100.0, ATTR1);
grid.pushMeasure(new Date(now + step), 10.0, ATTR1);
grid.pushMeasure(new Date(now + step), 1.0, ATTR1);
grid.pushMeasure(new Date(now + step), 100.0, this.ATTR1);
grid.pushMeasure(new Date(now + step), 10.0, this.ATTR1);
grid.pushMeasure(new Date(now + step), 1.0, this.ATTR1);
grid.pushMeasure(new Date(now + step), 200.0, ATTR2);
grid.pushMeasure(new Date(now + step), 20.0, ATTR2);
grid.pushMeasure(new Date(now + step), 2.0, ATTR2);
grid.pushMeasure(new Date(now + step), 200.0, this.ATTR2);
grid.pushMeasure(new Date(now + step), 20.0, this.ATTR2);
grid.pushMeasure(new Date(now + step), 2.0, this.ATTR2);
// just to close the current aggregaton:
grid.pushMeasure(new Date(now + delta + step), 42.0, ATTR1);
grid.pushMeasure(new Date(now + delta + step), 42.0, ATTR2);
grid.pushMeasure(new Date(now + delta + step), 42.0, this.ATTR1);
grid.pushMeasure(new Date(now + delta + step), 42.0, this.ATTR2);
assertEquals(new Double(111.0),
getAggregated(aspect.getIdentifier(), new Date(now + delta)));
assertEquals(new Double(222.0),
getAggregated(aspect2.getIdentifier(), new Date(now + delta)));
Assert.assertEquals(new Double(111.0),
this.getAggregated(aspect.getIdentifier(), new Date(now + delta)));
Assert.assertEquals(new Double(222.0),
this.getAggregated(aspect2.getIdentifier(), new Date(now + delta)));
}
@Test
public void testDifferentDeltaSameIdentifier() {
this.coll.remove(new BasicDBObject());
assertEquals(0, this.coll.find().size());
Assert.assertEquals(0, this.coll.find().size());
LOG.debug("AggregationDataBeat ____________________________________________ ");
long now = 10000;
final long now = 10000;
long step = 1000;
long delta1 = step * 10;
long delta2 = delta1 + delta1;
final long step = 1000;
final long delta1 = step * 10;
final long delta2 = delta1 + delta1;
Timespan d1 = new Timespan(delta1, TimeUnit.MILLISECONDS);
Timespan d2 = new Timespan(delta2, TimeUnit.MILLISECONDS);
final Timespan d1 = new Timespan(delta1, TimeUnit.MILLISECONDS);
final Timespan d2 = new Timespan(delta2, TimeUnit.MILLISECONDS);
Timespan length1 = d1.copyMultiple(4);
Timespan length2 = d1.copyMultiple(2);
final Timespan length1 = d1.copyMultiple(4);
final Timespan length2 = d1.copyMultiple(2);
long steps1 = length1.calcSteps(d1);
long steps2 = length2.calcSteps(d2);
final long steps1 = length1.calcSteps(d1);
final long steps2 = length2.calcSteps(d2);
// BUILD GRID
AttributeListenerGrid grid = new AttributeListenerGrid(mongoConnection);
final AttributeListenerGrid grid = new AttributeListenerGrid(this.mongoConnection);
// CONFIGURE GRID
AspectsConfiguration config = new AspectsConfiguration();
AspectAttributes aspect = AspectAttributes.getInstance()
.forecast(ForecastMethod.MEAN).identifier(IDENT)
.attribute(ATTR1)
final AspectsConfiguration config = new AspectsConfiguration();
final AspectAttributes aspect = AspectAttributes.getInstance()
.forecast(ForecastMethod.MEAN).identifier(this.IDENT)
.attribute(this.ATTR1)
.length(length1).delta(d1);
AspectAttributes aspect2 = AspectAttributes.getInstance()
.forecast(ForecastMethod.MEAN).identifier(IDENT_TWO)
.attribute(ATTR1)
final AspectAttributes aspect2 = AspectAttributes.getInstance()
.forecast(ForecastMethod.MEAN).identifier(this.IDENT_TWO)
.attribute(this.ATTR1)
.length(length2).delta(d2);
config.addAspect(aspect);
config.addAspect(aspect2);
grid.configure(config, new Date(now));
// ADD MEASURES
grid.pushMeasure(new Date(now + step), 100.0, ATTR1);
grid.pushMeasure(new Date(now + delta1 + step), 10.0, ATTR1);
grid.pushMeasure(new Date(now + delta1 + delta1 + step), 1.0, ATTR1); // just
grid.pushMeasure(new Date(now + step), 100.0, this.ATTR1);
grid.pushMeasure(new Date(now + delta1 + step), 10.0, this.ATTR1);
grid.pushMeasure(new Date(now + delta1 + delta1 + step), 1.0, this.ATTR1); // just
// that
// usual
// beacon
......@@ -181,20 +175,20 @@ public class AspectGridTest {
// 1 time value in d2
// assertEquals(steps1 + steps2 + 3, this.coll.find().size());
printAllMongo(coll);
AspectGridTest.printAllMongo(this.coll);
// first series is short and receives two window during delta2
assertEquals(
Assert.assertEquals(
new Double(100.0),
getAggregated(IDENT,
this.getAggregated(this.IDENT,
new Date(now + delta1)));
assertEquals(
Assert.assertEquals(
new Double(10.0),
getAggregated(IDENT,
this.getAggregated(this.IDENT,
new Date(now + delta1 + delta1)));
// second series is longer and receives one window
assertEquals(
Assert.assertEquals(
new Double(110.0),
getAggregated(IDENT_TWO,
this.getAggregated(this.IDENT_TWO,
new Date(now + delta1 + delta1)));
}
......@@ -202,36 +196,36 @@ public class AspectGridTest {
@Test
public void testOneAspectWithThreeDeltas() {
this.coll.remove(new BasicDBObject());
assertEquals(0, this.coll.find().size());
Assert.assertEquals(0, this.coll.find().size());
LOG.debug("AggregationDataBeat ____________________________________________ ");
long now = 60 * 1000;
long step = 1000;
final long now = 60 * 1000;
final long step = 1000;
Timespan delta3 = new Timespan(3, TimeUnit.SECONDS);
Timespan delta5 = new Timespan(5, TimeUnit.SECONDS);
Timespan delta6 = new Timespan(6, TimeUnit.SECONDS);
final Timespan delta3 = new Timespan(3, TimeUnit.SECONDS);
final Timespan delta5 = new Timespan(5, TimeUnit.SECONDS);
final Timespan delta6 = new Timespan(6, TimeUnit.SECONDS);
Timespan length3 = delta3.copyMultiple(31); // the multiple doesn't matter!
Timespan length5 = delta3.copyMultiple(21);
Timespan length6 = delta3.copyMultiple(21);
final Timespan length3 = delta3.copyMultiple(31); // the multiple doesn't matter!
final Timespan length5 = delta3.copyMultiple(21);
final Timespan length6 = delta3.copyMultiple(21);
// BUILD GRID
AttributeListenerGrid grid = new AttributeListenerGrid(mongoConnection);
final AttributeListenerGrid grid = new AttributeListenerGrid(this.mongoConnection);
// CONFIGURE GRID
AspectsConfiguration config = new AspectsConfiguration();
AspectAttributes aspect3 = AspectAttributes.getInstance()
final AspectsConfiguration config = new AspectsConfiguration();
final AspectAttributes aspect3 = AspectAttributes.getInstance()
.forecast(ForecastMethod.MEAN).identifier(delta3.toString())
.attribute(ATTR1)
.attribute(this.ATTR1)
.length(length3).delta(delta3);
AspectAttributes aspect5 = AspectAttributes.getInstance()
.attribute(ATTR1)
final AspectAttributes aspect5 = AspectAttributes.getInstance()
.attribute(this.ATTR1)
.forecast(ForecastMethod.MEAN).identifier(delta5.toString())
.length(length5).delta(delta5);
AspectAttributes aspect6 = AspectAttributes.getInstance()
.attribute(ATTR1)
final AspectAttributes aspect6 = AspectAttributes.getInstance()
.attribute(this.ATTR1)
.forecast(ForecastMethod.MEAN).identifier(delta6.toString())
.length(length6).delta(delta6);
config.addAspect(aspect3);
......@@ -240,54 +234,57 @@ public class AspectGridTest {
grid.configure(config, new Date(now));
// ADD MEASURES
grid.pushMeasure(new Date(now + 0 * step), 0, ATTR1);
grid.pushMeasure(new Date(now + 1 * step), 1, ATTR1);
grid.pushMeasure(new Date(now + 2 * step), 2, ATTR1);
grid.pushMeasure(new Date(now + 3 * step), 4, ATTR1);
grid.pushMeasure(new Date(now + 4 * step), 8, ATTR1);
grid.pushMeasure(new Date(now + 5 * step), 16, ATTR1);
grid.pushMeasure(new Date(now + 6 * step), 32, ATTR1);
grid.pushMeasure(new Date(now + 7 * step), 64, ATTR1);
grid.pushMeasure(new Date(now + 0 * step), 0, this.ATTR1);
grid.pushMeasure(new Date(now + 1 * step), 1, this.ATTR1);
grid.pushMeasure(new Date(now + 2 * step), 2, this.ATTR1);
grid.pushMeasure(new Date(now + 3 * step), 4, this.ATTR1);
grid.pushMeasure(new Date(now + 4 * step), 8, this.ATTR1);
grid.pushMeasure(new Date(now + 5 * step), 16, this.ATTR1);
grid.pushMeasure(new Date(now + 6 * step), 32, this.ATTR1);
grid.pushMeasure(new Date(now + 7 * step), 64, this.ATTR1);
// assertEquals(steps1 + steps2 + 3, this.coll.find().size());
printAllMongo(this.coll);
AspectGridTest.printAllMongo(this.coll);
// first series is short and receives two window during delta2
assertEquals(null, getAt(delta3.toString(), now + 5 * step));
assertEquals(null, getAt(delta6.toString(), now + 5 * step));
Assert.assertEquals(null, this.getAt(delta3.toString(), now + 5 * step));
Assert.assertEquals(null, this.getAt(delta6.toString(), now + 5 * step));
assertEquals(new Double(28), getAt(delta3.toString(), now + 6 * step));
assertEquals(null, getAt(delta5.toString(), now + 6 * step));
assertEquals(new Double(31), getAt(delta6.toString(), now + 6 * step));
Assert.assertEquals(new Double(28), this.getAt(delta3.toString(), now + 6 * step));
Assert.assertEquals(null, this.getAt(delta5.toString(), now + 6 * step));
Assert.assertEquals(new Double(31), this.getAt(delta6.toString(), now + 6 * step));
}
private Double getAt(String identifier, long time) {
return getAggregated(identifier,
private Double getAt(final String identifier, final long time) {
return this.getAggregated(identifier,
new Date(time));
}
private Double getAggregated(String ident, Date time) {
private Double getAggregated(final String ident, final Date time) {
LOG.debug(" >> getAggregated " + ident + " date: " + time);
DBObject findDoc = new BasicDBObject();
if (null != ident)
final DBObject findDoc = new BasicDBObject();
if (null != ident) {
findDoc.put("identifier", ident);
if (null != time)
}
if (null != time) {
findDoc.put("time", time);
}
DBObject found = this.coll.findOne(findDoc);
if (null == found)
final DBObject found = this.coll.findOne(findDoc);
if (null == found) {
return null;
}
return (Double) found.get("measure");
}
public final static void printAllMongo(DBCollection collection) {
public final static void printAllMongo(final DBCollection collection) {
LOG.info("printAllMongo MongoDB for everything ========");
DBCursor cur = collection.find();
final DBCursor cur = collection.find();
while (cur.hasNext()) {
DBObject dbo = cur.next();
final DBObject dbo = cur.next();
LOG.info("printAllMongo entry: " + dbo);
}
LOG.info("printAllMongo ========");
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment