Commit cb728f48 authored by Florian Fittkau's avatar Florian Fittkau

working towards instance counting

parent 2eaa79ba
......@@ -8,6 +8,7 @@
<aspects>
<concrete-aspect name="explorviz.live_trace_processing.probe.TargetedAspect" extends="explorviz.live_trace_processing.probe.AbstractAspect">
<pointcut name="monitoredOperation" expression="execution(* testpackage.TestClass*.*(..))" />
<pointcut name="monitoredConstructor" expression="execution(testpackage.TestClass*.new(..))" />
</concrete-aspect>
</aspects>
</aspectj>
......@@ -33,24 +33,48 @@ public abstract class AbstractAspect {
@Pointcut
public abstract void monitoredOperation();
@Pointcut("execution(new(..))")
public void monitoredConstructor() {
@Pointcut
public abstract void monitoredConstructor();
@Around("monitoredOperation() && this(thisObject) && notWithinExplorViz()")
public Object operation(final Object thisObject, final ProceedingJoinPoint thisJoinPoint)
throws Throwable {
return createEventRecords(thisJoinPoint,
BeforeOperationEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID,
BeforeOperationEventRecord.CLAZZ_ID,
AfterFailedOperationEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID,
AfterFailedOperationEventRecord.CLAZZ_ID,
AfterOperationEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID,
AfterOperationEventRecord.CLAZZ_ID, System.identityHashCode(thisObject));
}
@Around("monitoredOperation() && notWithinExplorViz()")
public Object operation(final ProceedingJoinPoint thisJoinPoint) throws Throwable {
@Around("monitoredOperation() && !this(java.lang.Object) && notWithinExplorViz()")
public Object staticOperation(final ProceedingJoinPoint thisJoinPoint) throws Throwable {
return createEventRecords(thisJoinPoint,
BeforeOperationEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID,
BeforeOperationEventRecord.CLAZZ_ID,
AfterFailedOperationEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID,
AfterFailedOperationEventRecord.CLAZZ_ID,
AfterOperationEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID,
AfterOperationEventRecord.CLAZZ_ID);
AfterOperationEventRecord.CLAZZ_ID, 0);
}
// @Around("monitoredConstructor() && this(thisObject) && notWithinExplorViz()")
public Object construction(final Object thisObject, final ProceedingJoinPoint thisJoinPoint)
throws Throwable {
return createEventRecords(thisJoinPoint,
BeforeConstructorEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID,
BeforeConstructorEventRecord.CLAZZ_ID,
AfterFailedConstructorEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID,
AfterFailedConstructorEventRecord.CLAZZ_ID,
AfterConstructorEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID,
AfterConstructorEventRecord.CLAZZ_ID, System.identityHashCode(thisObject));
}
private Object createEventRecords(final ProceedingJoinPoint thisJoinPoint,
final int beforeLength, final byte beforeId, final int afterFailedLength,
final byte afterFailedId, final int afterLength, final byte afterId) throws Throwable {
final byte afterFailedId, final int afterLength, final byte afterId, final int objectId)
throws Throwable {
if (!MonitoringController.isMonitoringEnabled()) {
return thisJoinPoint.proceed();
}
......@@ -75,6 +99,7 @@ public abstract class AbstractAspect {
buffer.putLong(TimeProvider.getCurrentTimestamp());
buffer.putLong(trace.getTraceId());
buffer.putInt(trace.getNextOrderId());
buffer.putInt(objectId);
buffer.putInt(signatureId);
final Object retval;
......@@ -91,6 +116,7 @@ public abstract class AbstractAspect {
buffer.putLong(TimeProvider.getCurrentTimestamp());
buffer.putLong(trace.getTraceId());
buffer.putInt(trace.getNextOrderId());
buffer.putInt(objectId);
buffer.putInt(signatureId);
final int errorId = MonitoringStringRegistry.getIdForString(th.toString());
......@@ -113,6 +139,7 @@ public abstract class AbstractAspect {
// int?
buffer.putLong(trace.getTraceId()); // TODO convert to int?
buffer.putInt(trace.getNextOrderId());
buffer.putInt(objectId); // TODO not needed
buffer.putInt(signatureId); // TODO not needed
if (newTrace) {
......@@ -126,16 +153,4 @@ public abstract class AbstractAspect {
return retval;
}
// HINT: This may be logged multiple times due to super constructor calls...
// @Around("monitoredConstructor() && notWithinExplorViz()")
public Object construction(final ProceedingJoinPoint thisJoinPoint) throws Throwable {
return createEventRecords(thisJoinPoint,
BeforeConstructorEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID,
BeforeConstructorEventRecord.CLAZZ_ID,
AfterFailedConstructorEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID,
AfterFailedConstructorEventRecord.CLAZZ_ID,
AfterConstructorEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID,
AfterConstructorEventRecord.CLAZZ_ID);
}
}
......@@ -34,12 +34,14 @@ public class AbstractAspectTest {
assertTrue((System.nanoTime() - 10000000) < buffer.getLong());
final long traceId = buffer.getLong();
assertEquals(0, buffer.getInt());
assertTrue(0 != buffer.getInt());
assertEquals(2, buffer.getInt());
assertEquals(AfterOperationEventRecord.CLAZZ_ID, buffer.get());
assertTrue((System.nanoTime() - 10000000) < buffer.getLong());
assertEquals(traceId, buffer.getLong());
assertEquals(1, buffer.getInt());
assertTrue(0 != buffer.getInt());
assertEquals(2, buffer.getInt());
}
......@@ -58,12 +60,14 @@ public class AbstractAspectTest {
assertTrue((System.nanoTime() - 10000000) < buffer.getLong());
final long traceId = buffer.getLong();
assertEquals(0, buffer.getInt());
assertTrue(0 != buffer.getInt());
assertEquals(0, buffer.getInt());
assertEquals(AfterFailedOperationEventRecord.CLAZZ_ID, buffer.get());
assertTrue((System.nanoTime() - 10000000) < buffer.getLong());
assertEquals(traceId, buffer.getLong());
assertEquals(1, buffer.getInt());
assertTrue(0 != buffer.getInt());
assertEquals(0, buffer.getInt());
assertEquals(1, buffer.getInt());
}
......@@ -72,20 +76,30 @@ public class AbstractAspectTest {
@Override
public void monitoredOperation() {
try {
super.operation(new ProceedingMock());
super.operation(this, new ProceedingMock());
} catch (final Throwable e) {
}
}
@Override
public void monitoredConstructor() {
// TODO Auto-generated method stub
}
}
class AspectFailingMock extends AbstractAspect {
@Override
public void monitoredOperation() {
try {
super.operation(new ProceedingFailingMock());
super.operation(this, new ProceedingFailingMock());
} catch (final Throwable e) {
}
}
@Override
public void monitoredConstructor() {
// TODO Auto-generated method stub
}
}
class SignatureMock implements Signature {
......
......@@ -11,7 +11,8 @@ public class MonitoringStarter {
@Override
public void run() {
for (int i = 0; i < 400000000; i++) {
TestClass.testMethod(9);
final TestClass testClass = new TestClass();
testClass.testMethod(9);
}
}
}).run();
......
package testpackage;
public class TestClass {
static public void testMethod(final int i) {
// TestClass2 testClass2 = new TestClass2();
// testClass2.testMethod2();
public void testMethod(final int i) {
if (i > 0) {
testMethod(i - 1);
}
......
Markdown is supported
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