Commit 99329897 authored by Florian Fittkau's avatar Florian Fittkau

fixed server not instrumented

parent a53d644f
......@@ -17,6 +17,8 @@ public final class DistributedMonitoringRecordWriter {
public static final String UNKNOWN_DESTINATION = "";
public static final String UNKNOWN_SENDER = "";
private static long beforeTime = 0;
private DistributedMonitoringRecordWriter() {
}
......@@ -29,6 +31,8 @@ public final class DistributedMonitoringRecordWriter {
MonitoringController.sendOutBuffer(buffer);
}
beforeTime = TimeProvider.getCurrentTimestamp();
buffer.put(BeforeSentRemoteCallRecord.CLAZZ_ID);
buffer.putLong(ownTraceId);
buffer.putInt(ownOrderId);
......@@ -44,7 +48,7 @@ public final class DistributedMonitoringRecordWriter {
}
buffer.put(AfterSentRemoteCallRecord.CLAZZ_ID);
buffer.putLong(TimeProvider.getCurrentTimestamp());
buffer.putLong(TimeProvider.getCurrentTimestamp() - beforeTime);
buffer.putLong(ownTraceId);
buffer.putInt(ownOrderId);
}
......@@ -59,6 +63,8 @@ public final class DistributedMonitoringRecordWriter {
MonitoringController.sendOutBuffer(buffer);
}
beforeTime = TimeProvider.getCurrentTimestamp();
buffer.put(BeforeReceivedRemoteCallRecord.CLAZZ_ID);
buffer.putLong(remoteTraceId);
buffer.putInt(remoteOrderId);
......@@ -75,7 +81,7 @@ public final class DistributedMonitoringRecordWriter {
}
buffer.put(AfterReceivedRemoteCallRecord.CLAZZ_ID);
buffer.putLong(TimeProvider.getCurrentTimestamp());
buffer.putLong(TimeProvider.getCurrentTimestamp() - beforeTime);
buffer.putLong(ownTraceId);
buffer.putInt(ownOrderId);
}
......@@ -90,6 +96,8 @@ public final class DistributedMonitoringRecordWriter {
MonitoringController.sendOutBuffer(buffer);
}
beforeTime = TimeProvider.getCurrentTimestamp();
buffer.put(BeforeUnknownReceivedRemoteCallRecord.CLAZZ_ID);
buffer.putLong(ownTraceId);
buffer.putInt(ownOrderId);
......@@ -107,7 +115,7 @@ public final class DistributedMonitoringRecordWriter {
}
buffer.put(AfterUnknownReceivedRemoteCallRecord.CLAZZ_ID);
buffer.putLong(TimeProvider.getCurrentTimestamp());
buffer.putLong(TimeProvider.getCurrentTimestamp() - beforeTime);
buffer.putLong(ownTraceId);
buffer.putInt(ownOrderId);
}
......
......@@ -2,8 +2,6 @@ package explorviz.live_trace_processing.probe.distributed.concrete;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -62,38 +60,28 @@ public class JAXWSProbeAdder {
}
};
try {
final Field field = Class.class.getDeclaredField("annotations");
final boolean isAccessible = field.isAccessible();
// Instantiate PrivilegedAction with Boolean as its type argument
// and return Boolean.TRUE to guarantee that the return value is
// never null. The return value of run is ignored.
AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
@Override
public Boolean run() {
field.setAccessible(true);
return Boolean.TRUE;
}
});
// java.lang.Field.get does not return null and it is annotation is
// wrong.
final Field annotationDataField = Class.class.getDeclaredField("annotationData");
annotationDataField.setAccessible(true);
final Object annotationData = annotationDataField.get(classFileObject.getClass());
final Field annotationsField = annotationData.getClass()
.getDeclaredField("annotations");
annotationsField.setAccessible(true);
@SuppressWarnings("unchecked")
final Map<Class<? extends Annotation>, Annotation> annotations = (Map<Class<? extends Annotation>, Annotation>) field
.get(classFileObject.getClass());
final Map<Class<? extends Annotation>, Annotation> annotations = (Map<Class<? extends Annotation>, Annotation>) annotationsField
.get(annotationData);
annotations.put(HandlerChain.class, newAnnotation);
// Instantiate PrivilegedAction with Boolean as its type argument
// and return Boolean.TRUE to guarantee that the return value is
// never null. The return value of run is ignored.
AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
@Override
public Boolean run() {
field.setAccessible(isAccessible);
return Boolean.TRUE;
}
});
} catch (final IllegalArgumentException e) {
e.printStackTrace();
} catch (final IllegalAccessException e) {
e.printStackTrace();
} catch (final NoSuchFieldException e) {
e.printStackTrace();
} catch (final SecurityException e) {
e.printStackTrace();
}
}
......
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