Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Delisle2018-03-15 14:22:48 -0400
committerSimon Delisle2018-04-06 13:25:07 -0400
commitd50b7d4deb579b251a231777519faa64339d761c (patch)
tree7c403632286504b5f519f120f5af96254e107376
parent61ad88e04821721bb6c3a003fe547f6721f77f74 (diff)
downloadorg.eclipse.tracecompass.incubator-d50b7d4deb579b251a231777519faa64339d761c.tar.gz
org.eclipse.tracecompass.incubator-d50b7d4deb579b251a231777519faa64339d761c.tar.xz
org.eclipse.tracecompass.incubator-d50b7d4deb579b251a231777519faa64339d761c.zip
rest: Add support for table provider
Change-Id: I5cab934fd6533f2a54fdbc05db0de06ec439d18a Signed-off-by: Simon Delisle <simon.delisle@ericsson.com> Reviewed-on: https://git.eclipse.org/r/119513 Reviewed-by: Loic Prieur-Drevon <loic.prieurdrevon@gmail.com> Tested-by: Loic Prieur-Drevon <loic.prieurdrevon@gmail.com> Tested-by: CI Bot
-rw-r--r--doc/org.eclipse.tracecompass.incubator.trace.server.doc.dev/doc/Developer-Guide.mediawiki3
-rw-r--r--trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/META-INF/MANIFEST.MF1
-rw-r--r--trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/views/EventView.java182
-rw-r--r--trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java124
-rw-r--r--trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/EventTableService.java234
-rw-r--r--trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/webapp/WebApplication.java2
6 files changed, 126 insertions, 420 deletions
diff --git a/doc/org.eclipse.tracecompass.incubator.trace.server.doc.dev/doc/Developer-Guide.mediawiki b/doc/org.eclipse.tracecompass.incubator.trace.server.doc.dev/doc/Developer-Guide.mediawiki
index ff987297..c7153d0d 100644
--- a/doc/org.eclipse.tracecompass.incubator.trace.server.doc.dev/doc/Developer-Guide.mediawiki
+++ b/doc/org.eclipse.tracecompass.incubator.trace.server.doc.dev/doc/Developer-Guide.mediawiki
@@ -34,8 +34,7 @@ The current implementation of the Server exposes 5 services:
* Trace Manager Service: to import and open and manage traces on the server's file system
* Experiment Manager Service: to combine traces into experiments
* Data Provider Service: to expose data provider APIs to access analysis results
-* Event Table Service (soon to be built into Data Provider Service): to expose the events of a trace.
-* XML Manager Service: to extend the server's features from XML analysis and views on the server's file system.
+* XML Manager Service: to extend the server's features from XML analysis and views on the server's file system
=== Extension model ===
Being built on Eclipse RCP, the Trace Server supports the same extension mechanism as Trace Compass.
diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/META-INF/MANIFEST.MF b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/META-INF/MANIFEST.MF
index 5f7aad72..05218c25 100644
--- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/META-INF/MANIFEST.MF
+++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/META-INF/MANIFEST.MF
@@ -39,6 +39,7 @@ Require-Bundle: org.eclipse.core.runtime,
com.fasterxml.jackson.jaxrs.jackson-jaxrs-base
Import-Package: com.google.common.base,
com.google.common.collect,
+ com.google.common.primitives,
org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module,
org.eclipse.tracecompass.tmf.analysis.xml.core.module
Bundle-ClassPath: .,
diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/views/EventView.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/views/EventView.java
deleted file mode 100644
index 5b20267b..00000000
--- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/views/EventView.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-
-package org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.MultivaluedMap;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
-import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
-/**
- * Encapsulate the result of a virtual table query
- *
- * @author Loic Prieur-Drevon
- */
-@XmlRootElement
-public class EventView {
-
- private ITmfTrace fTrace;
- private List<List<String>> fLines;
- private List<String> fColumns;
- private long fLow;
- private int fSize;
- private Map<String, String> fFilters;
- private long fFilteredSize;
-
- /**
- * empty constructor for Jackson
- */
- public EventView() {
- }
-
- /**
- * Build an EventView from the Trace that is queried and the queried range
- *
- * @param trace
- * the queried trace
- * @param low
- * lower bound for the query
- * @param size
- * number of events to return
- * @param lines
- * the array of event view values to include
- */
- public EventView(@NonNull ITmfTrace trace, long low, int size, List<List<String>> lines) {
- fTrace = trace;
- fColumns = Lists.newArrayList(Iterables.transform(trace.getEventAspects(), ITmfEventAspect::getName));
- fLow = low;
- fSize = size;
- fLines = lines;
- fFilters = Collections.emptyMap();
- fFilteredSize = trace.getNbEvents();
- }
-
- /**
- * Build an EventView from the Trace that is queried and the queried range
- *
- * @param trace
- * the queried trace
- * @param low
- * lower bound for the query
- * @param size
- * number of events to return
- * @param filters
- * the columns which will be queried, if null, the field will be
- * populated by the trace's columns
- * @param lines
- * the array of event view values to include
- * @param filteredSize
- * the number of events that match the filters
- */
- public EventView(@NonNull ITmfTrace trace, long low, int size, MultivaluedMap<String, String> filters, List<List<String>> lines, long filteredSize) {
- fTrace = trace;
- fColumns = Lists.newArrayList(Iterables.transform(trace.getEventAspects(), ITmfEventAspect::getName));
- fLow = low;
- fSize = size;
- fFilteredSize = filteredSize;
- fLines = lines;
- fFilters = multiValuedMapToMap(filters);
- }
-
- /**
- * Getter for the trace
- *
- * @return this query's trace
- */
- @XmlElement
- public ITmfTrace getTrace() {
- return fTrace;
- }
-
- /**
- * Getter for the events.
- *
- * @return a list of the view of events returned by the query, from low to low +
- * size, with a Map of column names to column values.
- */
- @XmlElementWrapper(name = "events")
- @XmlElement(name = "event")
- public List<List<String>> getLines() {
- return fLines;
- }
-
- /**
- * Getter for the column names
- *
- * @return get the list of column names
- */
- @XmlElement
- public List<String> getColumns() {
- return fColumns;
- }
-
- /**
- * Getter for the lower bound of the query
- *
- * @return the rank of the lowest event in this view
- */
- @XmlElement
- public long getLow() {
- return fLow;
- }
-
- /**
- * Getter for the number of events in this query
- *
- * @return the number of events in this query
- */
- @XmlElement
- public int getSize() {
- return fSize;
- }
-
- /**
- * Getter for the filter, for statelessness
- *
- * @return the columns which were queried
- */
- @XmlElement
- public Map<String, String> getFilters() {
- return fFilters;
- }
-
- /**
- * The total number of events in this trace after applying the filters
- *
- * @return number of filtered events in this trace
- */
- @XmlElement
- public long getFilteredSize() {
- return fFilteredSize;
- }
-
- private static Map<String, String> multiValuedMapToMap(MultivaluedMap<String, String> multivaluedMap) {
- Map<String, String> map = new HashMap<>();
- for (String key : multivaluedMap.keySet()) {
- String value = multivaluedMap.getFirst(key);
- if (value != null) {
- map.put(key, value);
- }
- }
- return map;
- }
-}
diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java
index 24f422ed..0d4678c8 100644
--- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java
+++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java
@@ -10,28 +10,42 @@
package org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services;
import java.util.EnumSet;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
+import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
+import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.GenericView;
+import org.eclipse.tracecompass.internal.provisional.tmf.core.model.events.TmfEventTableDataProvider;
+import org.eclipse.tracecompass.internal.provisional.tmf.core.model.events.TmfEventTableFilterModel;
+import org.eclipse.tracecompass.internal.provisional.tmf.core.model.filters.EventTableQueryFilter;
import org.eclipse.tracecompass.internal.provisional.tmf.core.model.filters.SelectionTimeQueryFilter;
import org.eclipse.tracecompass.internal.provisional.tmf.core.model.filters.TimeQueryFilter;
+import org.eclipse.tracecompass.internal.provisional.tmf.core.model.filters.VirtualTableQueryFilter;
+import org.eclipse.tracecompass.internal.provisional.tmf.core.model.table.EventTableLine;
+import org.eclipse.tracecompass.internal.provisional.tmf.core.model.table.ITmfVirtualTableDataProvider;
+import org.eclipse.tracecompass.internal.provisional.tmf.core.model.table.ITmfVirtualTableModel;
+import org.eclipse.tracecompass.internal.provisional.tmf.core.model.table.IVirtualTableLine;
import org.eclipse.tracecompass.internal.provisional.tmf.core.model.timegraph.ITimeGraphArrow;
import org.eclipse.tracecompass.internal.provisional.tmf.core.model.timegraph.ITimeGraphDataProvider;
import org.eclipse.tracecompass.internal.provisional.tmf.core.model.timegraph.ITimeGraphEntryModel;
@@ -51,6 +65,7 @@ import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.w3c.dom.Element;
import com.google.common.collect.Iterables;
+import com.google.common.primitives.Longs;
/**
* Service to query the {@link ITmfTreeDataProvider}s
@@ -293,6 +308,115 @@ public class DataProviderService {
}
/**
+ * Query the provider for table lines
+ *
+ * @param uuid
+ * Trace UUID
+ * @param providerId
+ * Eclipse extension point ID for the data provider to query
+ * @param low
+ * Low index
+ * @param size
+ * Number of lines to return
+ * @param columnIds
+ * Desired column IDs
+ * @return A {@link GenericView} with the results
+ */
+ @GET
+ @Path("/lines")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getLines(@PathParam("uuid") UUID uuid,
+ @PathParam("providerId") String providerId,
+ @QueryParam("low") @Min(0) long low,
+ @QueryParam("size") @Min(0) int size,
+ @QueryParam("columnId") List<@NonNull Long> columnIds) {
+
+ ITmfTrace trace = TraceManagerService.getTraceByUUID(uuid);
+ if (trace == null) {
+ return Response.status(Status.NOT_FOUND).entity(NO_SUCH_TRACE).build();
+ }
+
+ ITmfVirtualTableDataProvider<? extends IVirtualTableLine, ? extends ITmfTreeDataModel> provider = manager.getDataProvider(trace, providerId, ITmfVirtualTableDataProvider.class);
+ if (provider == null) {
+ return Response.status(Status.METHOD_NOT_ALLOWED).entity(NO_PROVIDER).build();
+ }
+
+ VirtualTableQueryFilter queryFilter = new VirtualTableQueryFilter(columnIds, low, size);
+ TmfModelResponse<?> response = provider.fetchLines(queryFilter, null);
+ return Response.ok(new GenericView<>(trace, response)).build();
+ }
+
+ /**
+ * Query the provider for event table lines with filters
+ *
+ * @param uuid
+ * Trace UUID
+ * @param providerId
+ * Eclipse extension point ID for the data provider to query
+ * @param low
+ * Low index
+ * @param size
+ * Number of lines to return
+ * @param columnIds
+ * Desired column IDs
+ * @param presetFilter
+ * List of preset filter IDs to apply
+ * @param isCollapseFilterEnabled
+ * True if a collapse filter should be applied
+ * @param multivaluedMap
+ * Map that contains the table filter (column ID with the associated
+ * regex)
+ * @return A {@link GenericView} with the results
+ */
+ @PUT
+ @Path("/lines")
+ @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getLines(@PathParam("uuid") UUID uuid,
+ @PathParam("providerId") String providerId,
+ @QueryParam("low") @Min(0) long low,
+ @QueryParam("size") @Min(0) int size,
+ @QueryParam("columnId") List<@NonNull Long> columnIds,
+ @FormParam("presetFilterId") List<@NonNull String> presetFilter,
+ @FormParam("collapseFilter") boolean isCollapseFilterEnabled,
+ MultivaluedMap<@NonNull String, @NonNull String> multivaluedMap) {
+
+ ITmfTrace trace = TraceManagerService.getTraceByUUID(uuid);
+ if (trace == null) {
+ return Response.status(Status.NOT_FOUND).entity(NO_SUCH_TRACE).build();
+ }
+
+ TmfEventTableDataProvider provider = manager.getDataProvider(trace, providerId, TmfEventTableDataProvider.class);
+ if (provider == null) {
+ return Response.status(Status.METHOD_NOT_ALLOWED).entity(NO_PROVIDER).build();
+ }
+
+ /*
+ * The multivaluedMap contains all the entry from the form, including the
+ * presetFilter list and the collapse boolean. In order to extract the table
+ * filters (mapping between column ID and regex) the tryParse is use to capture
+ * just the keys that are longs (column IDs)
+ */
+ Map<@NonNull Long, @NonNull String> tableFilter = null;
+ for (Entry<String, List<String>> paramEntry : multivaluedMap.entrySet()) {
+ Long columnId = Longs.tryParse(paramEntry.getKey());
+ if (columnId == null) {
+ continue;
+ }
+
+ if (tableFilter == null) {
+ tableFilter = new HashMap<>();
+ }
+ tableFilter.put(columnId, paramEntry.getValue().get(0));
+ }
+
+ TmfEventTableFilterModel filters = new TmfEventTableFilterModel(tableFilter, null, presetFilter, null, isCollapseFilterEnabled);
+ EventTableQueryFilter queryFilter = new EventTableQueryFilter(columnIds, low, size, filters);
+ TmfModelResponse<@NonNull ITmfVirtualTableModel<@NonNull EventTableLine>> response = provider.fetchLines(queryFilter, null);
+ return Response.ok(new GenericView<>(trace, response)).build();
+ }
+
+ /**
* Get the XML data provider for a trace, provider id and XML {@link OutputType}
*
* @param trace
diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/EventTableService.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/EventTableService.java
deleted file mode 100644
index 607a0b79..00000000
--- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/EventTableService.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import java.util.function.Predicate;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotNull;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.Activator;
-import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.EventView;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
-import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
-import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
-import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType;
-import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
-import org.eclipse.tracecompass.tmf.core.util.Pair;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
-/**
- * Trace Event Table Service.
- *
- * @author Loic Prieur-Drevon
- */
-@Path("/traces/{uuid}/eventTable")
-public class EventTableService {
-
- /**
- * Query a trace for a list of events to populate a virtual table
- *
- * @param uuid
- * The queried trace's uuid
- *
- * @param low
- * rank of the first event to return
- * @param size
- * total number of events to return
- * @return a {@link Response} encapsulating an error code and message, or the
- * trace model objects and the table of queried events
- */
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- public Response getEvents(@PathParam("uuid") @NotNull UUID uuid,
- @QueryParam("low") @Min(0) long low,
- @QueryParam("size") @Min(0) int size) {
- ITmfTrace trace = TraceManagerService.getTraceByUUID(uuid);
- if (trace == null) {
- return Response.status(Status.NOT_FOUND).entity("No trace with uuid: " + uuid).build(); //$NON-NLS-1$
- }
- try {
- List<List<String>> events = query(trace, low, size);
- EventView view = new EventView(trace, low, size, events);
- return Response.ok().entity(view).build();
- } catch (InterruptedException e) {
- Activator.getInstance().logError("Failed to query the trace", e); //$NON-NLS-1$
- return Response.serverError().entity(e.getMessage()).build();
- }
- }
-
- /**
- * Query a trace for a list of events to populate a virtual table
- *
- * @param uuid
- * The queried trace's {@link UUID}
- * @param low
- * rank of the first event to return
- * @param size
- * total number of events to return
- * @param multivaluedMap
- * map of columns to filters
- * @return a {@link Response} encapsulating an error code and message, or the
- * trace objects and the table of queried events
- */
- @PUT
- @Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
- @Produces({ MediaType.APPLICATION_JSON })
- public Response getFilteredEvents(@PathParam("uuid") @NotNull UUID uuid,
- @QueryParam("low") @Min(0) long low,
- @QueryParam("size") @Min(0) int size,
- MultivaluedMap<String, String> multivaluedMap) {
-
- if (multivaluedMap == null) {
- return Response.status(Status.BAD_REQUEST).entity("bad filter (null)").build(); //$NON-NLS-1$
- }
- ITmfTrace trace = TraceManagerService.getTraceByUUID(uuid);
- if (trace == null) {
- return Response.status(Status.NOT_FOUND).entity("No trace with uuid: " + uuid).build(); //$NON-NLS-1$
- }
- try {
- Pair<List<List<String>>, Integer> events = filteredQuery(trace, low, size, multivaluedMap);
- EventView view = new EventView(trace, low, size, multivaluedMap, events.getFirst(), events.getSecond());
- return Response.ok().entity(view).build();
- } catch (InterruptedException e) {
- Activator.getInstance().logError("Failed to query the trace", e); //$NON-NLS-1$
- return Response.serverError().entity(e.getMessage()).build();
- }
- }
-
- /**
- * Query the backing trace
- *
- * @param trace
- * the trace to query on
- * @param low
- * rank of the first event to return
- * @param size
- * total number of events to return
- * @return a list of events, where each is represented by a list of its column
- * values
- * @throws InterruptedException
- * if the request was cancelled
- */
- private static List<List<String>> query(ITmfTrace trace, long low, int size) throws InterruptedException {
- List<List<String>> events = new ArrayList<>(size);
- List<@NonNull ITmfEventAspect<?>> eventAspects = Lists.newArrayList(trace.getEventAspects());
- TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, TmfTimeRange.ETERNITY, low, size, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(ITmfEvent event) {
- events.add(Lists.transform(eventAspects, a -> String.valueOf(a.resolve(event))));
- }
- };
-
- trace.sendRequest(request);
- request.waitForCompletion();
- return events;
- }
-
- /**
- * Query the backing trace
- *
- * @param trace
- * the trace to query on
- * @param low
- * index of the lowest event in the filtered event list
- * @param size
- * number of filtered events to return
- * @param multivaluedMap
- * HTTP query form from which to extract filters
- * @return a list of events, where each is represented by a list of its column
- * values
- * @throws InterruptedException
- * if the request was cancelled
- */
- public Pair<List<List<String>>, Integer> filteredQuery(ITmfTrace trace, long low, int size, MultivaluedMap<String, String> multivaluedMap) throws InterruptedException {
- List<List<String>> events = new ArrayList<>(size);
- List<ITmfEventAspect<?>> eventAspects = Lists.newArrayList(trace.getEventAspects());
- List<Predicate<String>> predicates = Lists.transform(eventAspects, c -> compileReqexes(multivaluedMap.get(c.getName())));
- TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, TmfTimeRange.ETERNITY, 0, ITmfEventRequest.ALL_DATA, ExecutionType.FOREGROUND) {
- /**
- * Override number of read events with number of events that match filter
- */
- int nbRead = 0;
-
- @Override
- public void handleData(ITmfEvent event) {
-
- List<String> buildLine = buildLine(event, eventAspects, predicates);
- if (buildLine != null) {
- nbRead++;
- if (nbRead >= low && nbRead <= low + size) {
- events.add(buildLine);
- }
- }
- }
-
- @Override
- public synchronized int getNbRead() {
- return nbRead;
- }
- };
- trace.sendRequest(request);
- request.waitForCompletion();
- return new Pair<>(events, request.getNbRead());
- }
-
- private static Predicate<String> compileReqexes(List<String> regexes) {
- if (regexes == null || regexes.isEmpty()) {
- return t -> true;
- }
- List<Pattern> list = new ArrayList<>();
- for (String regex : regexes) {
- try {
- list.add(Pattern.compile(regex));
- } catch (PatternSyntaxException e) {
- }
- }
- return s -> Iterables.all(list, p -> p.matcher(s).find());
- }
-
- private static @Nullable List<String> buildLine(@NonNull ITmfEvent event, List<ITmfEventAspect<?>> aspects, List<Predicate<String>> predicates) {
- List<String> line = new ArrayList<>(aspects.size());
- int i = 0;
- for (ITmfEventAspect<?> aspect : aspects) {
- String text = String.valueOf(aspect.resolve(event));
- Predicate<String> predicate = predicates.get(i++);
- if (predicate.test(text)) {
- line.add(text);
- } else {
- // return null if one of the regular expressions does not match
- return null;
- }
- }
- return line;
- }
-
-} \ No newline at end of file
diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/webapp/WebApplication.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/webapp/WebApplication.java
index 2919ffba..09378c9f 100644
--- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/webapp/WebApplication.java
+++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/webapp/WebApplication.java
@@ -14,7 +14,6 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.DataProviderService;
-import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EventTableService;
import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.ExperimentManagerService;
import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.TraceManagerService;
import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.XmlManagerService;
@@ -80,7 +79,6 @@ public class WebApplication {
rc.register(TraceManagerService.class);
rc.register(ExperimentManagerService.class);
- rc.register(EventTableService.class);
rc.register(DataProviderService.class);
rc.register(XmlManagerService.class);
rc.register(CORSFilter.class);

Back to the top