diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/ConfigurationManagerServiceTest.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/ConfigurationManagerServiceTest.java index 2c36d4804..8aaee3132 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/ConfigurationManagerServiceTest.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/ConfigurationManagerServiceTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 Ericsson + * Copyright (c) 2023, 2024 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License 2.0 which @@ -256,7 +256,7 @@ public void testXmlDataProvider() { TmfConfigurationStub config = response.readEntity(CONFIGURATION); validateConfig(config); } - ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_KERNEL_STUB.getName(), CONTEXT_SWITCHES_KERNEL_STUB); + ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB.getName(), CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB); WebTarget xmlProviderPath = getXYTreeEndpoint(exp.getUUID().toString(), "org.eclipse.linuxtools.tmf.analysis.xml.core.tests.xy"); Map parameters = new HashMap<>(); try (Response xmlTree = xmlProviderPath.request().post(Entity.json(new QueryParameters(parameters, Collections.emptyList())))) { diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/DataProviderServiceTest.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/DataProviderServiceTest.java index b5cff7c31..4a48414a6 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/DataProviderServiceTest.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/DataProviderServiceTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018, 2021 Ericsson and others + * Copyright (c) 2018, 2024 Ericsson and others * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License 2.0 which @@ -125,7 +125,7 @@ public class DataProviderServiceTest extends RestServerTest { */ @Test public void testProviders() { - ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_STUB.getName(), CONTEXT_SWITCHES_UST_STUB); + ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB.getName(), CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB); WebTarget experiments = getApplicationEndpoint().path(EXPERIMENTS); WebTarget providers = experiments.path(exp.getUUID().toString()) @@ -142,7 +142,7 @@ public void testProviders() { */ @Test public void testCallStackDataProvider() { - ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_STUB.getName(), CONTEXT_SWITCHES_UST_STUB); + ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB.getName(), CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB); WebTarget callstackTree = getTimeGraphTreeEndpoint(exp.getUUID().toString(), CALL_STACK_DATAPROVIDER_ID); @@ -168,7 +168,7 @@ public void testXYDataProvider() throws InterruptedException { long start = 1412670961211260539L; long end = 1412670967217750839L; try { - ExperimentModelStub exp = assertPostExperiment(ARM_64_KERNEL_STUB.getName(), ARM_64_KERNEL_STUB); + ExperimentModelStub exp = assertPostExperiment(ARM_64_KERNEL_NOT_INITIALIZED_STUB.getName(), ARM_64_KERNEL_NOT_INITIALIZED_STUB); // Test getting the tree endpoint for an XY chart WebTarget xyTree = getXYTreeEndpoint(exp.getUUID().toString(), XY_DATAPROVIDER_ID); @@ -250,7 +250,7 @@ public void testHistogramDataProvider() throws InterruptedException { long start = 1412670961211260539L; long end = 1412670967217750839L; try { - ExperimentModelStub exp = assertPostExperiment(ARM_64_KERNEL_STUB.getName(), ARM_64_KERNEL_STUB); + ExperimentModelStub exp = assertPostExperiment(ARM_64_KERNEL_NOT_INITIALIZED_STUB.getName(), ARM_64_KERNEL_NOT_INITIALIZED_STUB); // Test getting the tree endpoint for an XY chart WebTarget xyTree = getXYTreeEndpoint(exp.getUUID().toString(), XY_HISTOGRAM_DATAPROVIDER_ID); @@ -312,7 +312,7 @@ public void testDataTreeDataProvider() throws InterruptedException { long start = 1450193697034689597L; long end = 1450193745774189602L; try { - ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_STUB.getName(), CONTEXT_SWITCHES_UST_STUB); + ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB.getName(), CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB); // Test getting the time graph tree WebTarget dataTree = getDataTreeEndpoint(exp.getUUID().toString(), STATISTICS_DATAPROVIDER_ID); @@ -363,7 +363,7 @@ public void testTimeGraphDataProvider() throws InterruptedException { long start = 1450193697034689597L; long end = 1450193745774189602L; try { - ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_STUB.getName(), CONTEXT_SWITCHES_UST_STUB); + ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB.getName(), CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB); // Test getting the time graph tree WebTarget callstackTree = getTimeGraphTreeEndpoint(exp.getUUID().toString(), CALL_STACK_DATAPROVIDER_ID); @@ -534,7 +534,7 @@ public void testTableDataProvider() throws InterruptedException { long start = 1412670961211260539L; long end = 1412670967217750839L; try { - ExperimentModelStub exp = assertPostExperiment(ARM_64_KERNEL_STUB.getName(), ARM_64_KERNEL_STUB); + ExperimentModelStub exp = assertPostExperiment(ARM_64_KERNEL_NOT_INITIALIZED_STUB.getName(), ARM_64_KERNEL_NOT_INITIALIZED_STUB); // Test getting the tree endpoint for an XY chart WebTarget tableColumns = getTableColumnsEndpoint(exp.getUUID().toString(), EVENTS_TABLE_DATAPROVIDER_ID); @@ -605,7 +605,7 @@ public void testTableDataProvider() throws InterruptedException { public void testTimeGraphMetaDataSerializer() { Response treeResponse = null; try { - ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_STUB.getName(), CONTEXT_SWITCHES_UST_STUB); + ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB.getName(), CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB); // Test getting the time graph tree WebTarget callstackTree = getTimeGraphTreeEndpoint(exp.getUUID().toString(), TestDataProviderService.INVALID_ENTRY_METADATA); diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/ExperimentManagerServiceTest.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/ExperimentManagerServiceTest.java index 6c78cdf5f..c1a968cbf 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/ExperimentManagerServiceTest.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/ExperimentManagerServiceTest.java @@ -60,6 +60,7 @@ public class ExperimentManagerServiceTest extends RestServerTest { private static final String TEST = "test"; private static final @NonNull ImmutableSet CONTEXT_SWITCH_SET = ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_STUB, CONTEXT_SWITCHES_UST_STUB); + private static final @NonNull ImmutableSet CONTEXT_SWITCH_NOT_INITIALIZED_SET = ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB, CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB); private static final @NonNull ExperimentModelStub EXPECTED = new ExperimentModelStub(TEST, CONTEXT_SWITCH_SET); /** @@ -71,9 +72,9 @@ public void testExperiment() { WebTarget traces = application.path(TRACES); WebTarget expTarget = application.path(EXPERIMENTS); - TraceModelStub ustStub = assertPost(traces, CONTEXT_SWITCHES_UST_STUB); - TraceModelStub kernelStub = assertPost(traces, CONTEXT_SWITCHES_KERNEL_STUB); - assertEquals(CONTEXT_SWITCH_SET, getTraces(traces)); + TraceModelStub ustStub = assertPost(traces, CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB); + TraceModelStub kernelStub = assertPost(traces, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB); + assertEquals(CONTEXT_SWITCH_NOT_INITIALIZED_SET, getTraces(traces)); assertEquals("experiment set should be empty at this point", Collections.emptySet(), getExperiments(expTarget)); @@ -89,12 +90,12 @@ public void testExperiment() { ExperimentModelStub expStub = response.readEntity(ExperimentModelStub.class); assertEquals("Failed to POST the experiment", EXPECTED, expStub); assertEquals("Failed to add experiment to set of experiments", Collections.singleton(EXPECTED), getExperiments(expTarget)); - assertEquals("Adding an experiment should not change the trace set", CONTEXT_SWITCH_SET, getTraces(traces)); + assertEquals("Adding an experiment should not change the trace set", CONTEXT_SWITCH_NOT_INITIALIZED_SET, getTraces(traces)); assertEquals("Failed to get the experiment by its UUID", EXPECTED, expTarget.path(expStub.getUUID().toString()).request().get(ExperimentModelStub.class)); assertEquals("Failed to DELETE the experiment", EXPECTED, expTarget.path(expStub.getUUID().toString()).request().delete().readEntity(ExperimentModelStub.class)); assertEquals("experiment set should be empty at this point", Collections.emptySet(), getExperiments(expTarget)); - assertEquals("Deleting an experiment should not change the trace set", CONTEXT_SWITCH_SET, getTraces(traces)); + assertEquals("Deleting an experiment should not change the trace set", CONTEXT_SWITCH_NOT_INITIALIZED_SET, getTraces(traces)); response.close(); } @@ -107,9 +108,9 @@ public void testRePost() { WebTarget traces = application.path(TRACES); WebTarget expTarget = application.path(EXPERIMENTS); - TraceModelStub ustStub = assertPost(traces, CONTEXT_SWITCHES_UST_STUB); - TraceModelStub kernelStub = assertPost(traces, CONTEXT_SWITCHES_KERNEL_STUB); - assertEquals(null, CONTEXT_SWITCH_SET, getTraces(traces)); + TraceModelStub ustStub = assertPost(traces, CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB); + TraceModelStub kernelStub = assertPost(traces, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB); + assertEquals(CONTEXT_SWITCH_NOT_INITIALIZED_SET, getTraces(traces)); assertEquals("experiment set should be empty at this point", Collections.emptySet(), getExperiments(expTarget)); @@ -125,7 +126,7 @@ public void testRePost() { ExperimentModelStub expStub = response.readEntity(ExperimentModelStub.class); assertEquals("Failed to POST the experiment", EXPECTED, expStub); assertEquals("Failed to add experiment to set of experiments", Collections.singleton(EXPECTED), getExperiments(expTarget)); - assertEquals("Adding an experiment should not change the trace set", CONTEXT_SWITCH_SET, getTraces(traces)); + assertEquals("Adding an experiment should not change the trace set", CONTEXT_SWITCH_NOT_INITIALIZED_SET, getTraces(traces)); assertEquals("Failed to get the experiment by its UUID", EXPECTED, expTarget.path(expStub.getUUID().toString()).request().get(ExperimentModelStub.class)); response.close(); @@ -135,13 +136,13 @@ public void testRePost() { assertEquals("Status of second post", Status.OK.getStatusCode(), response2.getStatus()); assertEquals("Failed to POST the experiment a second time", EXPECTED, expStub2); assertEquals("There should still be only one experiment", Collections.singleton(EXPECTED), getExperiments(expTarget)); - assertEquals("Adding an experiment should not change the trace set", CONTEXT_SWITCH_SET, getTraces(traces)); + assertEquals("Adding an experiment should not change the trace set", CONTEXT_SWITCH_NOT_INITIALIZED_SET, getTraces(traces)); assertEquals("Failed to get the experiment by its UUID", EXPECTED, expTarget.path(expStub2.getUUID().toString()).request().get(ExperimentModelStub.class)); response2.close(); assertEquals("Failed to DELETE the experiment", EXPECTED, expTarget.path(expStub.getUUID().toString()).request().delete().readEntity(ExperimentModelStub.class)); assertEquals("experiment set should be empty at this point", Collections.emptySet(), getExperiments(expTarget)); - assertEquals("Deleting an experiment should not change the trace set", CONTEXT_SWITCH_SET, getTraces(traces)); + assertEquals("Deleting an experiment should not change the trace set", CONTEXT_SWITCH_NOT_INITIALIZED_SET, getTraces(traces)); } @@ -154,10 +155,10 @@ public void testPostConflicts() { WebTarget traces = application.path(TRACES); WebTarget expTarget = application.path(EXPERIMENTS); - TraceModelStub ustStub = assertPost(traces, CONTEXT_SWITCHES_UST_STUB); - TraceModelStub kernelStub = assertPost(traces, CONTEXT_SWITCHES_KERNEL_STUB); - TraceModelStub arm64Stub = assertPost(traces, ARM_64_KERNEL_STUB); - ImmutableSet traceSet = ImmutableSet.of(CONTEXT_SWITCHES_UST_STUB, CONTEXT_SWITCHES_KERNEL_STUB, ARM_64_KERNEL_STUB); + TraceModelStub ustStub = assertPost(traces, CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB); + TraceModelStub kernelStub = assertPost(traces, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB); + TraceModelStub arm64Stub = assertPost(traces, ARM_64_KERNEL_NOT_INITIALIZED_STUB); + ImmutableSet traceSet = ImmutableSet.of(CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB, ARM_64_KERNEL_NOT_INITIALIZED_STUB); assertEquals(null, traceSet, getTraces(traces)); assertEquals("experiment set should be empty at this point", Collections.emptySet(), getExperiments(expTarget)); @@ -226,8 +227,8 @@ public void testWorkspaceStructure() throws CoreException, IOException { WebTarget tracesTarget = applicationTarget.path(TRACES); WebTarget experimentsTarget = applicationTarget.path(EXPERIMENTS); - TraceModelStub ustStub = assertPost(tracesTarget, CONTEXT_SWITCHES_UST_STUB); - TraceModelStub kernelStub = assertPost(tracesTarget, CONTEXT_SWITCHES_KERNEL_STUB); + TraceModelStub ustStub = assertPost(tracesTarget, CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB); + TraceModelStub kernelStub = assertPost(tracesTarget, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB); List traceUUIDs = new ArrayList<>(); traceUUIDs.add(ustStub.getUUID().toString()); diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/TraceManagerServiceTest.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/TraceManagerServiceTest.java index e91f26c92..d7c362815 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/TraceManagerServiceTest.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/TraceManagerServiceTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018, 2020 Ericsson + * Copyright (c) 2018, 2024 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License 2.0 which @@ -57,17 +57,17 @@ public void testWithOneTrace() { assertTrue("Expected empty set of traces", getTraces(traces).isEmpty()); - TraceModelStub kernelStub = assertPost(traces, CONTEXT_SWITCHES_KERNEL_STUB); + TraceModelStub kernelStub = assertPost(traces, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB); - assertEquals(CONTEXT_SWITCHES_KERNEL_STUB, traces.path(kernelStub.getUUID().toString()).request().get(TraceModelStub.class)); + assertEquals(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB, traces.path(kernelStub.getUUID().toString()).request().get(TraceModelStub.class)); assertEquals("Expected set of traces to contain trace2 stub", - Collections.singleton(CONTEXT_SWITCHES_KERNEL_STUB), getTraces(traces)); + Collections.singleton(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB), getTraces(traces)); Response deleteResponse = traces.path(kernelStub.getUUID().toString()).request().delete(); int deleteCode = deleteResponse.getStatus(); assertEquals("Failed to DELETE trace2, error code=" + deleteCode, 200, deleteCode); - assertEquals(CONTEXT_SWITCHES_KERNEL_STUB, deleteResponse.readEntity(TraceModelStub.class)); + assertEquals(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB, deleteResponse.readEntity(TraceModelStub.class)); assertEquals("Trace should have been deleted", Collections.emptySet(), getTraces(traces)); } @@ -79,10 +79,10 @@ public void testWithOneTrace() { public void testWithTwoTraces() { WebTarget traces = getApplicationEndpoint().path(TRACES); - assertPost(traces, CONTEXT_SWITCHES_KERNEL_STUB); - assertPost(traces, CONTEXT_SWITCHES_UST_STUB); + assertPost(traces, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB); + assertPost(traces, CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB); - assertEquals(ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_STUB, CONTEXT_SWITCHES_UST_STUB), getTraces(traces)); + assertEquals(ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB, CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB), getTraces(traces)); } /** @@ -93,17 +93,17 @@ public void testWithTwoTraces() { public void testConflictingTraces() throws IOException { WebTarget traces = getApplicationEndpoint().path(TRACES); - assertPost(traces, CONTEXT_SWITCHES_KERNEL_STUB); - assertEquals(ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_STUB), getTraces(traces)); + assertPost(traces, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB); + assertEquals(ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB), getTraces(traces)); // Post the trace a second time - assertPost(traces, CONTEXT_SWITCHES_KERNEL_STUB); - assertEquals(ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_STUB), getTraces(traces)); + assertPost(traces, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB); + assertEquals(ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB), getTraces(traces)); // Post a trace with the same name but another path, the name does not // matter if the path is different, the trace will be added - assertPost(traces, ARM_64_KERNEL_STUB); - assertEquals(ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_STUB, ARM_64_KERNEL_STUB), getTraces(traces)); + assertPost(traces, ARM_64_KERNEL_NOT_INITIALIZED_STUB); + assertEquals(ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB, ARM_64_KERNEL_NOT_INITIALIZED_STUB), getTraces(traces)); } /** @@ -118,8 +118,8 @@ public void testConflictingTraces() throws IOException { public void testWorkspaceStructure() throws CoreException, IOException { WebTarget traces = getApplicationEndpoint().path(TRACES); - assertPost(traces, CONTEXT_SWITCHES_KERNEL_STUB); - assertPost(traces, CONTEXT_SWITCHES_UST_STUB); + assertPost(traces, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB); + assertPost(traces, CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/utils/RestServerTest.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/utils/RestServerTest.java index 5f405101a..b0008d6a3 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/utils/RestServerTest.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/utils/RestServerTest.java @@ -157,6 +157,12 @@ public abstract class RestServerTest { */ protected static TraceModelStub CONTEXT_SWITCHES_UST_STUB; + /** + * {@link TraceModelStub} to represent the object returned by the server for + * {@link CtfTestTrace#CONTEXT_SWITCHES_UST} without metadata initialized. + */ + protected static TraceModelStub CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB; + /** * The name used when posting the trace. */ @@ -182,6 +188,12 @@ public abstract class RestServerTest { */ protected static TraceModelStub CONTEXT_SWITCHES_KERNEL_STUB; + /** + * {@link TraceModelStub} to represent the object returned by the server for + * {@link CtfTestTrace#CONTEXT_SWITCHES_KERNEL} without metadata initialized. + */ + protected static TraceModelStub CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB; + /** * The name used when posting the trace. */ @@ -211,6 +223,12 @@ public abstract class RestServerTest { */ protected static TraceModelStub ARM_64_KERNEL_STUB; + /** + * {@link TraceModelStub} to represent the object returned by the server for + * {@link CtfTestTrace#ARM_64_BIT_HEADER} without metadata initialized. + */ + protected static TraceModelStub ARM_64_KERNEL_NOT_INITIALIZED_STUB; + /** * The name used when posting the trace. */ @@ -248,12 +266,15 @@ public abstract class RestServerTest { @BeforeClass public static void beforeTest() throws IOException { String contextSwitchesUstPath = FileLocator.toFileURL(CtfTestTrace.CONTEXT_SWITCHES_UST.getTraceURL()).getPath().replaceAll("/$", ""); + CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB = new TraceModelStub(CONTEXT_SWITCHES_UST_NAME, contextSwitchesUstPath, Collections.EMPTY_MAP); CONTEXT_SWITCHES_UST_STUB = new TraceModelStub(CONTEXT_SWITCHES_UST_NAME, contextSwitchesUstPath, CONTEXT_SWITCHES_UST_PROPERTIES); String contextSwitchesKernelPath = FileLocator.toFileURL(CtfTestTrace.CONTEXT_SWITCHES_KERNEL.getTraceURL()).getPath().replaceAll("/$", ""); + CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB = new TraceModelStub(CONTEXT_SWITCHES_KERNEL_NAME, contextSwitchesKernelPath, Collections.EMPTY_MAP); CONTEXT_SWITCHES_KERNEL_STUB = new TraceModelStub(CONTEXT_SWITCHES_KERNEL_NAME, contextSwitchesKernelPath, CONTEXT_SWITCHES_KERNEL_PROPERTIES); String arm64Path = FileLocator.toFileURL(CtfTestTrace.ARM_64_BIT_HEADER.getTraceURL()).getPath().replaceAll("/$", ""); + ARM_64_KERNEL_NOT_INITIALIZED_STUB = new TraceModelStub(ARM_64_KERNEL_NAME, arm64Path, Collections.EMPTY_MAP); ARM_64_KERNEL_STUB = new TraceModelStub(ARM_64_KERNEL_NAME, arm64Path, ARM_64_KERNEL_PROPERTIES); ImmutableList.Builder b = ImmutableList.builder(); 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/Experiment.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/Experiment.java index 232bde236..d471ece03 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/Experiment.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/Experiment.java @@ -14,10 +14,13 @@ import java.io.Serializable; import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.UUID; +import java.util.stream.Collectors; import org.eclipse.core.resources.IResource; +import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import com.fasterxml.jackson.annotation.JsonCreator; @@ -82,8 +85,11 @@ public Experiment(@JsonProperty("name") String name, * @return the experiment model */ public static Experiment from(TmfExperiment experiment, UUID expUUID) { - List traceUUIDs = ExperimentManagerService.getTraceUUIDs(expUUID); - Set traces = new LinkedHashSet<>(Lists.transform(traceUUIDs, uuid -> Trace.from(TraceManagerService.getOrCreateTraceInstance(uuid), uuid))); + Map uuidToTraceInstances = ExperimentManagerService.getTraceInstances(expUUID); + Set traces = uuidToTraceInstances.entrySet().stream() + .map(entry -> Trace.from(entry.getValue(), entry.getKey())) + .collect(Collectors.toCollection(LinkedHashSet::new)); + return new Experiment(experiment.getName(), expUUID, experiment.getNbEvents(), 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/ExperimentManagerService.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/ExperimentManagerService.java index 26dffb2f2..b26dcb9e0 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/ExperimentManagerService.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/ExperimentManagerService.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -94,6 +95,7 @@ public class ExperimentManagerService { private static final Map> TRACE_UUIDS = Collections.synchronizedMap(new HashMap<>()); + private static final Map> TRACE_INSTANCES = Collections.synchronizedMap(new HashMap<>()); private static final Map EXPERIMENT_RESOURCES = Collections.synchronizedMap(initExperimentResources()); private static final Map EXPERIMENTS = Collections.synchronizedMap(new HashMap<>()); private static final Map TRACE_ANNOTATION_PROVIDERS = Collections.synchronizedMap(new HashMap<>()); @@ -218,6 +220,7 @@ public Response deleteExperiment(@Parameter(description = EXP_UUID) @PathParam(" } TRACE_ANNOTATION_PROVIDERS.remove(expUUID); TRACE_UUIDS.remove(expUUID); + TRACE_INSTANCES.remove(expUUID); boolean deleteResources = true; synchronized (EXPERIMENTS) { for (TmfExperiment e : EXPERIMENTS.values()) { @@ -348,14 +351,19 @@ public Response postExperiment(@RequestBody(content = { createSupplementaryFolder(resource); // Instantiate the experiment and return it - ITmfTrace[] traces = Lists.transform(traceUUIDs, uuid -> TraceManagerService.createTraceInstance(uuid)).toArray(new ITmfTrace[0]); + Map uuidToTraceInstances = new LinkedHashMap<>(); + for (UUID uuid : traceUUIDs) { + ITmfTrace trace = TraceManagerService.createTraceInstance(uuid); + uuidToTraceInstances.put(uuid, trace); + } // Determine cache size for experiments int cacheSize = Integer.MAX_VALUE; - for (ITmfTrace trace : traces) { + for (ITmfTrace trace : uuidToTraceInstances.values()) { cacheSize = Math.min(cacheSize, trace.getCacheSize()); } TmfExperiment experiment = null; try { + ITmfTrace[] traces = uuidToTraceInstances.values().toArray(new ITmfTrace[0]); String experimentTypeId = getOrDetectExerimentType(resource, traces); experiment = TmfTraceType.instantiateExperiment(experimentTypeId); if (experiment != null) { @@ -369,6 +377,7 @@ public Response postExperiment(@RequestBody(content = { TmfSignalManager.dispatchSignal(new TmfTraceOpenedSignal(ExperimentManagerService.class, experiment, null)); EXPERIMENTS.put(expUUID, experiment); + TRACE_INSTANCES.put(expUUID, uuidToTraceInstances); TRACE_ANNOTATION_PROVIDERS.put(expUUID, new TraceAnnotationProvider(experiment)); return experiment; } @@ -522,6 +531,17 @@ public static List getTraceUUIDs(UUID expUUID) { return TRACE_UUIDS.getOrDefault(expUUID, Collections.emptyList()); } + /** + * Get the list of trace instances of an experiment from the experiment manager. + * + * @param expUUID + * queried {@link UUID} + * @return the map from of trace UUID to trace instance. + */ + public static Map getTraceInstances(UUID expUUID) { + return TRACE_INSTANCES.getOrDefault(expUUID, Collections.emptyMap()); + } + /** * Returns true if the given trace is in use by any experiment * @@ -559,6 +579,7 @@ public static void dispose() { } EXPERIMENTS.clear(); TRACE_UUIDS.clear(); + TRACE_INSTANCES.clear(); EXPERIMENT_RESOURCES.clear(); TRACE_ANNOTATION_PROVIDERS.clear(); } 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/TraceManagerService.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/TraceManagerService.java index 7c8d4e097..55c708a58 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/TraceManagerService.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/TraceManagerService.java @@ -89,11 +89,6 @@ public class TraceManagerService { private static final Map TRACES = Collections.synchronizedMap(initTraces()); - /** - * The trace instance is created lazily, meaning it is only instantiated when its UUID is queried. - */ - private static final Map TRACE_INSTANCES = Collections.synchronizedMap(new HashMap<>()); - private static final String TRACES_FOLDER = "Traces"; //$NON-NLS-1$ /** @@ -247,23 +242,6 @@ public static UUID getTraceUUID(IResource resource) { return TRACES.get(uuid); } - /** - * Get or create an instance of a trace by its UUID. This trace instance lives - * as long as the trace is opened in the trace server. - * - * @param uuid - * the trace UUID - * @return the trace instance, or null if it could not be created - */ - public static @Nullable ITmfTrace getOrCreateTraceInstance(UUID uuid) { - if (TRACE_INSTANCES.containsKey(uuid)) { - return TRACE_INSTANCES.get(uuid); - } - ITmfTrace trace = createTraceInstance(uuid); - TRACE_INSTANCES.put(uuid, trace); - return trace; - } - /** * Create an instance of a trace by its UUID. The caller is responsible to * dispose the instance when it is no longer needed. @@ -301,8 +279,11 @@ public static UUID getTraceUUID(IResource resource) { } private static Trace createTraceModel(UUID uuid) { - ITmfTrace trace = getOrCreateTraceInstance(uuid); - return Trace.from(trace, uuid); + IResource resource = TRACES.get(uuid); + if (resource == null) { + return null; + } + return Trace.from(resource, uuid); } /** @@ -411,10 +392,6 @@ public Response deleteTrace(@Parameter(description = TRACE_UUID) @PathParam("uui if (ExperimentManagerService.isTraceInUse(uuid)) { return Response.status(Status.CONFLICT).entity(trace).build(); } - ITmfTrace traceInstance = TRACE_INSTANCES.remove(uuid); - if (traceInstance != null) { - traceInstance.dispose(); - } IResource resource = TRACES.remove(uuid); if (resource == null) { return Response.ok(trace).build();