The Trace Server is a prototype implementation of the Trace Server Protocol. It was built to decouple the front-end and back-end of Trace Compass and allow visualization of traces which are stored and analyzed on a remote machine.
Open traceserver.product and launch it as an Eclipse application.
mvn clean install
trace-server/org.eclipse.tracecompass.incubator.trace.server.product/target/products/traceserver/linux/gtk/x86_64/trace-compass-server/tracecompass-server
The Trace Server is ready to query once the following line is logged:
Server:app thread - org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.id.0: Started @1970ms
The Trace Server can be queried via any http client (curl, Postman, Jersey client). By default it's url will be:
http://localhost:8080
The Trace Server combines an Eclipse RCP with the backend program from Trace Compass and a Jetty server / servlet engine which runs the Jersey services which expose the relevant Trace Compass APIs as a REST protocol.
The current implementation of the Server exposes 5 services:
Being built on Eclipse RCP, the Trace Server supports the same extension mechanism as Trace Compass.
To add a service, it just needs to be registered programmatically in the WebApplication.
To serialize data from Java objects, these are the following options:
Just encapsulate the POJO in a Response, and it will most likely be directly serializable to JSON. However anything that is accessible via a getter will be serialized. This can be a problem if that represents a large volume of data, or if the objects returned by the getter are not serializable.
The following exceptions may indicate that a data type cannot be serialized:
com.fasterxml.jackson.databind.JsonMappingException
If the POJO to serialize is editable, javax.xml.bind.annotation and com.fasterxml.jackson.annotation annotations are supported.
Finally, if a packaged type requires custom serialization, we recommend implementing a com.fasterxml.jackson.databind.ser.std.StdSerializer and registering it to the data type in the web application.
The simplest way to test a new feature is to write a test extending:
org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests.utils.RestServerTest
which handles launching a trace server, and provides a client targeted at this server, as well as utilities to load traces and clean up after.
Typically one has to be able to read returned data to ensure that it is correct.
Most TraceCompass POJOs will not be readable out of the box as immutability was a key design decision, and Jersey deserializers require a default constructor and setters. The alternative is to implement a com.fasterxml.jackson.databind.deser.std.StdDeserializer<T> or annotate a POJO's constructor with @JsonCreator and @JsonProperty.