/*******************************************************************************
* Copyright (c) 2009, 2010 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.tests.component;
-import java.io.IOException;
import java.util.Vector;
import junit.framework.TestCase;
TmfEventProviderStub fEventProvider;
TmfSyntheticEventProviderStub fSyntheticEventProvider;
- public TmfEventProviderTest(String name) throws IOException {
+ public TmfEventProviderTest(String name) {
super(name);
}
}
@SuppressWarnings("unchecked")
- private void getSyntheticData(final TmfTimeRange range, final int nbEvents, final int blockSize) throws InterruptedException {
+ private static void getSyntheticData(final TmfTimeRange range,
+ final int nbEvents, final int blockSize) throws InterruptedException {
final Vector<TmfSyntheticEventStub> requestedEvents = new Vector<TmfSyntheticEventStub>();
provider.sendRequest(request);
request.waitForCompletion();
- if (nbEvents != -1)
+ if (nbEvents != -1) {
assertEquals("nbEvents", nbEvents, requestedEvents.size());
+ }
assertTrue("isCompleted", request.isCompleted());
assertFalse("isCancelled", request.isCancelled());
*
* @generatedBy CodePro at 03/05/12 2:29 PM
*/
- @SuppressWarnings("static-method")
@Test
public void testCtfLocation_1() {
Long location = Long.valueOf(1);
*
* @generatedBy CodePro at 03/05/12 2:29 PM
*/
- @SuppressWarnings("static-method")
@Test
public void testCtfLocation_2() {
ITmfTimestamp timestamp = new TmfTimestamp();
*
* @generatedBy CodePro at 03/05/12 2:29 PM
*/
- @SuppressWarnings("static-method")
@Test
public void testClone_1() {
CtfLocation fixture = new CtfLocation(Long.valueOf(1));
*
* @generatedBy CodePro at 03/05/12 2:29 PM
*/
- @SuppressWarnings("static-method")
@Test
public void testGetLocation_1() {
CtfLocation fixture = new CtfLocation(Long.valueOf(1));
*
* @generatedBy CodePro at 03/05/12 2:29 PM
*/
- @SuppressWarnings("static-method")
@Test
public void testSetLocation_1() {
CtfLocation fixture = new CtfLocation(Long.valueOf(1));
// add additional test code here
}
- @SuppressWarnings("static-method")
@Test
public void testToString1(){
CtfLocation fixture = new CtfLocation(new Long(1337L));
assertEquals("CtfLocation: 1337",fixture.toString()); //$NON-NLS-1$
}
- @SuppressWarnings("static-method")
@Test
public void testToString2(){
CtfLocation fixture = new CtfLocation(new Long(-1L));
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import java.io.FileNotFoundException;
-
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
* @return
* @throws TmfTraceException
*/
- private CtfTmfTrace initTrace() throws TmfTraceException {
+ private static CtfTmfTrace initTrace() throws TmfTraceException {
CtfTmfTrace fixture = new CtfTmfTrace();
fixture.initTrace((IResource) null, PATH, CtfTmfEvent.class);
return fixture;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
/**
private final String fSource = "Source";
- private final String fContext = TmfEventType.DEFAULT_CONTEXT_ID;
+ private final String fContext = ITmfEventType.DEFAULT_CONTEXT_ID;
private final String fTypeId = "TestType";
private final String fLabel1 = "AString";
private final String fLabel2 = "AnInteger";
// Helper functions
// ------------------------------------------------------------------------
- private TmfTraceStub openTrace() {
+ private static TmfTraceStub openTrace() {
final String DIRECTORY = "testfiles";
final String TEST_STREAM = "A-Test-10K";
final String path = DIRECTORY + File.separator + TEST_STREAM;
public void testDefaultConstructor() {
final ITmfEvent event = new TmfEvent();
assertNull("getTrace", event.getTrace());
- assertEquals("getRank", TmfContext.UNKNOWN_RANK, event.getRank());
+ assertEquals("getRank", ITmfContext.UNKNOWN_RANK, event.getRank());
assertNull("getTimestamp", event.getTimestamp());
assertNull("getSource", event.getSource());
assertNull("getType", event.getType());
public void testNoRankConstructor() {
final TmfEvent event = new TmfEvent(null, fTimestamp1, fSource, fType, fContent1, fReference1);
assertNull("getTrace", event.getTrace());
- assertEquals("getRank", TmfContext.UNKNOWN_RANK, event.getRank());
+ assertEquals("getRank", ITmfContext.UNKNOWN_RANK, event.getRank());
assertEquals("getTimestamp", fTimestamp1, event.getTimestamp());
assertEquals("getSource", fSource, event.getSource());
assertEquals("getType", fType, event.getType());
/*******************************************************************************
* Copyright (c) 2009, 2012 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
* Francois Chouinard - Adjusted for new Event Model
public void testDefaultConstructor() {
final ITmfEventType type = new TmfEventType();
- assertEquals("getContext", TmfEventType.DEFAULT_CONTEXT_ID, type.getContext());
- assertEquals("getName", TmfEventType.DEFAULT_TYPE_ID, type.getName());
+ assertEquals("getContext", ITmfEventType.DEFAULT_CONTEXT_ID, type.getContext());
+ assertEquals("getName", ITmfEventType.DEFAULT_TYPE_ID, type.getName());
assertNull("getRootField", type.getRootField());
assertEquals("getFieldNames", 0, type.getFieldNames().length);
assertNull("getFieldName", type.getFieldName(0));
assertEquals("getRootField", TmfEventField.makeRoot(fLabels0), type0.getRootField());
final String[] labels0 = type0.getFieldNames();
assertEquals("getFieldNames length", fLabels0.length, labels0.length);
- for (int i = 0; i < labels0.length; i++)
+ for (int i = 0; i < labels0.length; i++) {
assertEquals("getFieldNames", fLabels0[i], labels0[i]);
+ }
assertNull("getFieldName", type0.getFieldName(labels0.length));
final ITmfEventType type1 = new TmfEventType(fContext1, fTypeId1, TmfEventField.makeRoot(fLabels1));
assertEquals("getRootField", TmfEventField.makeRoot(fLabels1), type1.getRootField());
final String[] labels1 = type1.getFieldNames();
assertEquals("getFieldNames length", fLabels1.length, labels1.length);
- for (int i = 0; i < labels1.length; i++)
+ for (int i = 0; i < labels1.length; i++) {
assertEquals("getFieldNames", fLabels1[i], labels1[i]);
+ }
assertNull("getFieldName", type1.getFieldName(labels1.length));
final ITmfEventType type2 = new TmfEventType(fContext2, fTypeId2, TmfEventField.makeRoot(fLabels2));
assertEquals("getRootField", TmfEventField.makeRoot(fLabels2), type2.getRootField());
final String[] labels2 = type2.getFieldNames();
assertEquals("getFieldNames length", fLabels2.length, labels2.length);
- for (int i = 0; i < labels2.length; i++)
+ for (int i = 0; i < labels2.length; i++) {
assertEquals("getFieldNames", fLabels2[i], labels2[i]);
+ }
assertNull("getFieldName", type2.getFieldName(labels2.length));
}
assertEquals("getRootField", TmfEventField.makeRoot(fLabels1), copy.getRootField());
final String[] labels1 = copy.getFieldNames();
assertEquals("getFieldNames length", fLabels1.length, labels1.length);
- for (int i = 0; i < labels1.length; i++)
+ for (int i = 0; i < labels1.length; i++) {
assertEquals("getFieldNames", fLabels1[i], labels1[i]);
+ }
assertNull("getFieldName", copy.getFieldName(labels1.length));
}
// ------------------------------------------------------------------------
public void testToString() {
- final String expected1 = "TmfEventType [fContext=" + TmfEventType.DEFAULT_CONTEXT_ID +
- ", fTypeId=" + TmfEventType.DEFAULT_TYPE_ID + "]";
+ final String expected1 = "TmfEventType [fContext=" + ITmfEventType.DEFAULT_CONTEXT_ID +
+ ", fTypeId=" + ITmfEventType.DEFAULT_TYPE_ID + "]";
final TmfEventType type1 = new TmfEventType();
assertEquals("toString", expected1, type1.toString());
/*******************************************************************************
* Copyright (c) 2009, 2010 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
private TmfCoalescedDataRequest<TmfEvent> fRequest1c;
private int fRequestCount;
-
+
// ------------------------------------------------------------------------
// Housekeeping
// ------------------------------------------------------------------------
super.tearDown();
}
- private TmfCoalescedDataRequest<TmfEvent> setupTestRequest(final boolean[] flags) {
-
+ private static TmfCoalescedDataRequest<TmfEvent> setupTestRequest(final boolean[] flags) {
+
TmfCoalescedDataRequest<TmfEvent> request = new TmfCoalescedDataRequest<TmfEvent>(TmfEvent.class, 10, 100, 200) {
@Override
public void handleCompleted() {
};
return request;
}
-
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
assertFalse("equals", fRequest3.equals(fRequest1));
assertFalse("equals", fRequest3.equals(fRequest2));
}
-
+
public void testEqualsTransivity() throws Exception {
assertTrue("equals", fRequest1.equals(fRequest1b));
assertTrue("equals", fRequest1b.equals(fRequest1c));
assertTrue("equals", fRequest1.equals(fRequest1c));
}
-
+
public void testEqualsNull() throws Exception {
assertFalse("equals", fRequest1.equals(null));
assertFalse("equals", fRequest2.equals(null));
assertTrue("hashCode", fRequest2.hashCode() == fRequest2.hashCode());
assertTrue("hashCode", fRequest1.hashCode() != fRequest2.hashCode());
}
-
+
// ------------------------------------------------------------------------
// toString
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
public void testDone() {
-
+
// Test request
final boolean[] crFlags = new boolean[4];
TmfCoalescedDataRequest<TmfEvent> request = setupTestRequest(crFlags);
// ------------------------------------------------------------------------
public void testFail() {
-
+
final boolean[] crFlags = new boolean[4];
TmfCoalescedDataRequest<TmfEvent> request = setupTestRequest(crFlags);
TmfDataRequest<TmfEvent> subRequest1 = new TmfDataRequestStub<TmfEvent>(TmfEvent.class, 10, 100, 200);
assertTrue ("isCancelled", subRequest2.isCancelled());
}
-
+
// ------------------------------------------------------------------------
// cancel sub-requests
// ------------------------------------------------------------------------
// Validate the coalescing request
assertFalse("isCompleted", request.isCompleted());
assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
+ assertFalse("isCancelled", request.isCancelled());
// Cancel second sub-request
subRequest2.cancel();
assertFalse("isFailed", request.isFailed());
assertTrue ("isCancelled", request.isCancelled());
- // Finalize coalescing request -
+ // Finalize coalescing request -
// Note: No need to check "request.isCancelled()" since it was verified above
request.cancel();
/*******************************************************************************
* Copyright (c) 2009, 2010 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
+import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
// Variables
// ------------------------------------------------------------------------
- private TmfTimeRange range1 = new TmfTimeRange(TmfTimeRange.ETERNITY);
- private TmfTimeRange range2 = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH);
-
+ private final TmfTimeRange range1 = new TmfTimeRange(TmfTimeRange.ETERNITY);
+ private final TmfTimeRange range2 = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH);
+
private TmfCoalescedEventRequest<TmfEvent> fRequest1;
private TmfCoalescedEventRequest<TmfEvent> fRequest2;
private TmfCoalescedEventRequest<TmfEvent> fRequest3;
private TmfCoalescedEventRequest<TmfEvent> fRequest1c;
private int fRequestCount;
-
+
// ------------------------------------------------------------------------
// Housekeeping
// ------------------------------------------------------------------------
@Override
public void setUp() throws Exception {
super.setUp();
- TmfEventRequest.reset();
+ TmfDataRequest.reset();
fRequest1 = new TmfCoalescedEventRequest<TmfEvent>(TmfEvent.class, range1, 100, 200);
fRequest2 = new TmfCoalescedEventRequest<TmfEvent>(TmfEvent.class, range2, 100, 200);
fRequest3 = new TmfCoalescedEventRequest<TmfEvent>(TmfEvent.class, range2, 200, 200);
}
private TmfCoalescedEventRequest<TmfEvent> setupTestRequest(final boolean[] flags) {
-
+
TmfCoalescedEventRequest<TmfEvent> request = new TmfCoalescedEventRequest<TmfEvent>(TmfEvent.class, range1, 100, 200) {
@Override
public void handleCompleted() {
};
return request;
}
-
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
assertEquals("getDataType", TmfEvent.class, request.getDataType());
assertEquals("getRange", range1, request.getRange());
- assertEquals("getNbRequestedEvents", TmfEventRequest.ALL_DATA, request.getNbRequested());
+ assertEquals("getNbRequestedEvents", TmfDataRequest.ALL_DATA, request.getNbRequested());
assertFalse("isCompleted", request.isCompleted());
assertFalse("isFailed", request.isFailed());
assertEquals("getDataType", TmfEvent.class, request.getDataType());
assertEquals("getRange", range1, request.getRange());
- assertEquals("getNbRequestedEvents", TmfEventRequest.ALL_DATA, request.getNbRequested());
+ assertEquals("getNbRequestedEvents", TmfDataRequest.ALL_DATA, request.getNbRequested());
assertFalse("isCompleted", request.isCompleted());
assertFalse("isFailed", request.isFailed());
assertFalse("equals", fRequest3.equals(fRequest1));
assertFalse("equals", fRequest3.equals(fRequest2));
}
-
+
public void testEqualsTransivity() throws Exception {
assertTrue("equals", fRequest1.equals(fRequest1b));
assertTrue("equals", fRequest1b.equals(fRequest1c));
assertTrue("equals", fRequest1.equals(fRequest1c));
}
-
+
public void testEqualsNull() throws Exception {
assertFalse("equals", fRequest1.equals(null));
assertFalse("equals", fRequest2.equals(null));
assertTrue("hashCode", fRequest2.hashCode() == fRequest2.hashCode());
assertTrue("hashCode", fRequest1.hashCode() != fRequest2.hashCode());
}
-
+
// ------------------------------------------------------------------------
// toString
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
public void testDone() {
-
+
// Test request
final boolean[] crFlags = new boolean[4];
TmfCoalescedEventRequest<TmfEvent> request = setupTestRequest(crFlags);
// ------------------------------------------------------------------------
public void testFail() {
-
+
final boolean[] crFlags = new boolean[4];
TmfCoalescedEventRequest<TmfEvent> request = setupTestRequest(crFlags);
TmfEventRequest<TmfEvent> subRequest1 = new TmfEventRequestStub<TmfEvent>(TmfEvent.class, range1, 100, 200);
super.handleData(event);
if (!isCompleted()) {
requestedEvents1.add(event);
- if (++nbRead >= BLOCK_SIZE && signal.forceCancel)
- cancel();
+ if (++nbRead >= BLOCK_SIZE && signal.forceCancel) {
+ cancel();
+ }
}
}
};
assertFalse ("Request3: isCancelled", request3.isCancelled());
// Ensure that we have distinct events.
- // Don't go overboard: we are not validating the stub!
+ // Don't go overboard: we are not validating the stub!
for (int i = 0; i < NB_EVENTS; i++) {
assertEquals("Distinct events", i+1, requestedEvents1.get(i).getTimestamp().getValue());
assertEquals("Distinct events", i+1, requestedEvents2.get(i).getTimestamp().getValue());
fTrace.dispose();
fTrace = null;
}
-
+
public void testCancelCoalescedRequest() throws Exception {
fTrace = setupTrace(DIRECTORY + File.separator + TEST_STREAM);
assertFalse ("Request3: isCancelled", request3.isCancelled());
// Ensure that we have distinct events.
- // Don't go overboard: we are not validating the stub!
+ // Don't go overboard: we are not validating the stub!
for (int i = 0; i < NB_EVENTS; i++) {
assertEquals("Distinct events", i+1, requestedEvents2.get(i).getTimestamp().getValue());
assertEquals("Distinct events", i+1, requestedEvents3.get(i).getTimestamp().getValue());
/*******************************************************************************
* Copyright (c) 2009, 2010 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
private static TmfDataRequest<TmfEvent> fRequest4;
private static int fRequestCount;
-
+
// ------------------------------------------------------------------------
// Housekeeping
// ------------------------------------------------------------------------
super.tearDown();
}
- private TmfDataRequest<TmfEvent> setupTestRequest(final boolean[] flags) {
-
+ private static TmfDataRequest<TmfEvent> setupTestRequest(final boolean[] flags) {
+
TmfDataRequest<TmfEvent> request = new TmfDataRequestStub<TmfEvent>(TmfEvent.class, 10, 100, 200) {
@Override
public void handleCompleted() {
};
return request;
}
-
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
assertFalse("equals", fRequest3.equals(fRequest1));
assertFalse("equals", fRequest3.equals(fRequest2));
}
-
+
public void testEqualsTransivity() throws Exception {
assertTrue("equals", fRequest1.equals(fRequest1b));
assertTrue("equals", fRequest1b.equals(fRequest1c));
assertTrue("equals", fRequest1.equals(fRequest1c));
}
-
+
public void testEqualsNull() throws Exception {
assertFalse("equals", fRequest1.equals(null));
assertFalse("equals", fRequest2.equals(null));
assertTrue("hashCode", fRequest2.hashCode() == fRequest2.hashCode());
assertTrue("hashCode", fRequest1.hashCode() != fRequest2.hashCode());
}
-
+
// ------------------------------------------------------------------------
// toString
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
public void testDone() {
-
+
final boolean[] flags = new boolean[4];
TmfDataRequest<TmfEvent> request = setupTestRequest(flags);
request.done();
// ------------------------------------------------------------------------
public void testFail() {
-
+
final boolean[] flags = new boolean[4];
TmfDataRequest<TmfEvent> request = setupTestRequest(flags);
request.fail();
// waitForCompletion
// ------------------------------------------------------------------------
-}
\ No newline at end of file
+}
/*******************************************************************************
* Copyright (c) 2009, 2010 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
private static TmfTimeRange range1 = new TmfTimeRange(TmfTimeRange.ETERNITY);
private static TmfTimeRange range2 = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH);
-
+
private static TmfEventRequest<TmfEvent> fRequest1;
private static TmfEventRequest<TmfEvent> fRequest1b;
private static TmfEventRequest<TmfEvent> fRequest1c;
private static TmfEventRequest<TmfEvent> fRequest4;
private static int fRequestCount;
-
+
// ------------------------------------------------------------------------
// Housekeeping
// ------------------------------------------------------------------------
super.tearDown();
}
- private TmfEventRequest<TmfEvent> setupTestRequest(final boolean[] flags) {
-
+ private static TmfEventRequest<TmfEvent> setupTestRequest(final boolean[] flags) {
+
TmfEventRequest<TmfEvent> request = new TmfEventRequestStub<TmfEvent>(TmfEvent.class, new TmfTimeRange(TmfTimeRange.ETERNITY), 100, 200) {
@Override
public void handleCompleted() {
};
return request;
}
-
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
assertFalse("equals", fRequest3.equals(fRequest1));
assertFalse("equals", fRequest3.equals(fRequest2));
}
-
+
public void testEqualsTransivity() throws Exception {
assertTrue("equals", fRequest1.equals(fRequest1b));
assertTrue("equals", fRequest1b.equals(fRequest1c));
assertTrue("equals", fRequest1.equals(fRequest1c));
}
-
+
public void testEqualsNull() throws Exception {
assertFalse("equals", fRequest1.equals(null));
assertFalse("equals", fRequest2.equals(null));
assertTrue("hashCode", fRequest2.hashCode() == fRequest2.hashCode());
assertTrue("hashCode", fRequest1.hashCode() != fRequest2.hashCode());
}
-
+
// ------------------------------------------------------------------------
// toString
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
public void testDone() {
-
+
final boolean[] flags = new boolean[4];
TmfEventRequest<TmfEvent> request = setupTestRequest(flags);
request.done();
// ------------------------------------------------------------------------
public void testFail() {
-
+
final boolean[] flags = new boolean[4];
TmfEventRequest<TmfEvent> request = setupTestRequest(flags);
request.fail();
// waitForCompletion
// ------------------------------------------------------------------------
-}
\ No newline at end of file
+}
/*******************************************************************************
* Copyright (c) 2009, 2010, 2012 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
* Francois Chouinard - Adapted for TMF Trace Model 1.0
public void testTmfContextDefault() {
final TmfContext context = new TmfContext();
assertEquals("getLocation", null, context.getLocation());
- assertEquals("getRank", TmfContext.UNKNOWN_RANK, context.getRank());
+ assertEquals("getRank", ITmfContext.UNKNOWN_RANK, context.getRank());
}
public void testTmfContextNoRank() {
assertEquals("getLocation", fLocation2, context2.getLocation());
assertEquals("getLocation", fLocation3, context3.getLocation());
- assertEquals("getRank", TmfContext.UNKNOWN_RANK, context1.getRank());
- assertEquals("getRank", TmfContext.UNKNOWN_RANK, context2.getRank());
- assertEquals("getRank", TmfContext.UNKNOWN_RANK, context3.getRank());
+ assertEquals("getRank", ITmfContext.UNKNOWN_RANK, context1.getRank());
+ assertEquals("getRank", ITmfContext.UNKNOWN_RANK, context2.getRank());
+ assertEquals("getRank", ITmfContext.UNKNOWN_RANK, context3.getRank());
}
public void testTmfContext() {
/*******************************************************************************
* Copyright (c) 2009, 2010, 2012 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
* Francois Chouinard - Adjusted for new Trace Model
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
// ------------------------------------------------------------------------
public void testSeekBadLocation() throws Exception {
- ITmfContext context = fExperiment.seekEvent((ITmfLocation<?>) new TmfLocation<Long>(0L));
+ ITmfContext context = fExperiment.seekEvent(new TmfLocation<Long>(0L));
assertNull("seekEvent", context);
}
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", midTrace + 1, event.getTimestamp().getValue());
assertEquals("Context rank", midTrace, context.getRank());
-
+
// Last event
context = fExperiment.seekEvent(1.0);
assertEquals("Context rank", NB_EVENTS, context.getRank());
event = fExperiment.parseEvent(context);
assertNull("Event timestamp", event);
assertEquals("Context rank", NB_EVENTS, context.getRank());
-
+
// Beyond last event
context = fExperiment.seekEvent(1.1);
assertEquals("Context rank", NB_EVENTS, context.getRank());
event = fExperiment.parseEvent(context);
assertNull("Event timestamp", event);
assertEquals("Context rank", NB_EVENTS, context.getRank());
-
+
// Negative ratio
context = fExperiment.seekEvent(-0.5);
assertEquals("Context rank", 0, context.getRank());
// ------------------------------------------------------------------------
public void testSeekLocationOnCacheBoundary() throws Exception {
-
+
long cacheSize = fExperiment.getCacheSize();
// Position trace at event rank 0
public void testProcessRequestForAllEvents() throws Exception {
- final int nbEvents = TmfEventRequest.ALL_DATA;
+ final int nbEvents = TmfDataRequest.ALL_DATA;
final int blockSize = 1;
final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
final long nbExpectedEvents = NB_EVENTS;
/*******************************************************************************
* Copyright (c) 2009, 2010, 2012 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
* Francois Chouinard - Adjusted for new Trace Model
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
super.setUp();
setupTrace(DIRECTORY + File.separator + TEST_STREAM1, DIRECTORY + File.separator + TEST_STREAM2);
if (fExperiment == null) {
- fExperiment = new TmfExperimentStub<TmfEvent>(EXPERIMENT, (ITmfTrace<TmfEvent>[]) fTraces, BLOCK_SIZE);
+ fExperiment = new TmfExperimentStub<TmfEvent>(EXPERIMENT, fTraces, BLOCK_SIZE);
fExperiment.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
}
}
// ------------------------------------------------------------------------
public void testSeekLocationOnCacheBoundary() throws Exception {
-
+
long cacheSize = fExperiment.getCacheSize();
// Position trace at event rank 0
public void testProcessRequestForAllEvents() throws Exception {
- final int nbEvents = TmfEventRequest.ALL_DATA;
+ final int nbEvents = TmfDataRequest.ALL_DATA;
final int blockSize = 1;
final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
final long nbExpectedEvents = NB_EVENTS;
// Helper functions
// ------------------------------------------------------------------------
- private TmfTraceStub setupTrace(final String path) {
+ private static TmfTraceStub setupTrace(final String path) {
if (fTrace == null) {
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
fail("IOException");
}
- assertFalse ("Open trace", trace == null);
assertEquals("getType", TmfEvent.class, trace.getType());
assertNull ("getResource", trace.getResource());
assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
public void testCopyConstructor() throws Exception {
TmfTraceStub original = null;
TmfTraceStub trace = null;
} catch (Exception e) {
fail("TmfTrace.initialize() - Exception thrown");
}
-
- assertFalse ("Open trace", trace == null);
+
assertEquals("getType", TmfEvent.class, trace.getType());
assertNull ("getResource", trace.getResource());
assertEquals("getPath", path, trace.getPath());
} catch (Exception e) {
fail("TmfTrace.initialize() - Exception thrown");
}
-
- assertFalse ("Open trace", trace == null);
+
assertEquals("getType", TmfEvent.class, trace.getType());
assertNull ("getResource", trace.getResource());
assertEquals("getPath", path, trace.getPath());
// Instantiate an "empty" trace
final TmfTraceStub trace = new TmfTraceStub();
- assertFalse ("Open trace", trace == null);
assertNull ("getType", trace.getType());
assertNull ("getResource", trace.getResource());
assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
assertEquals("toString", expected, fTrace.toString());
}
-}
\ No newline at end of file
+}
/*******************************************************************************
* Copyright (c) 2011 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
- *
+ *
* Contributors:
* Bernd Hufmann - Initial API and implementation
*******************************************************************************/
import junit.framework.TestCase;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEventType;
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
@SuppressWarnings("nls")
public class TmfAsyncSequenceDiagramEventTest extends TestCase {
- private final String fContext = TmfEventType.DEFAULT_CONTEXT_ID;
+ private final String fContext = ITmfEventType.DEFAULT_CONTEXT_ID;
private final String fTypeId = "Some type";
private final String fLabel0 = "label1";
private final String fLabel1 = "label2";
private final TmfEventField fContent1;
private final TmfEventField fContent2;
-
+
public TmfAsyncSequenceDiagramEventTest() {
fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, "Some content");
fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType, fContent1, fReference);
fContent2 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, "Some other content");
fEvent2 = new TmfEvent(null, fTimestamp2, fSource, fType, fContent2, fReference);
}
-
- @Override
+
+ @Override
public void setUp() throws Exception {
}
-
+
@Override
public void tearDown() throws Exception {
}
-
+
public void testTmfAsyncSequenceDiagramEvent() {
TmfAsyncSequenceDiagramEvent event = null;
-
- // Check for illegal arguments (i.e. null for the parameters)
+
+ // Check for illegal arguments (i.e. null for the parameters)
try {
event = new TmfAsyncSequenceDiagramEvent(null, null, null, null, null);
fail();
// success
assertTrue("TmfAsyncSequenceDiagramEvent", e.getMessage().contains("startEvent=null"));
}
-
+
try {
event = new TmfAsyncSequenceDiagramEvent(fEvent1, fEvent2, null, null, null);
fail();
// success
assertTrue("TmfAsyncSequenceDiagramEvent", e.getMessage().contains("sender=null"));
}
-
+
try {
event = new TmfAsyncSequenceDiagramEvent(fEvent1, fEvent2, null, null, null);
fail();
// success
assertTrue("TmfAsyncSequenceDiagramEvent", e.getMessage().contains("name=null"));
}
-
+
try {
event = new TmfAsyncSequenceDiagramEvent(fEvent1, null, "sender", "receiver", "signal");
fail();
assertEquals("testTmfAsyncSequenceDiagramEvent", "sender", event.getSender());
assertEquals("testTmfAsyncSequenceDiagramEvent", "receiver", event.getReceiver());
assertEquals("testTmfAsyncSequenceDiagramEvent", "signal", event.getName());
-
+
} catch (IllegalArgumentException e) {
fail();
}
/*******************************************************************************
* Copyright (c) 2011 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
- *
+ *
* Contributors:
* Bernd Hufmann - Initial API and implementation
*******************************************************************************/
import junit.framework.TestCase;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEventType;
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
@SuppressWarnings("nls")
public class TmfSyncSequenceDiagramEventTest extends TestCase {
- private final String fContext = TmfEventType.DEFAULT_CONTEXT_ID;
+ private final String fContext = ITmfEventType.DEFAULT_CONTEXT_ID;
private final String fTypeId = "Some type";
private final String fLabel0 = "label1";
private final String fLabel1 = "label2";
@Override
public void tearDown() throws Exception {
}
-
+
public void testTmfSyncSequenceDiagramEvent() {
TmfSyncSequenceDiagramEvent event = null;
try {
// success
assertTrue("testTmfSyncSequenceDiagramEvent", e.getMessage().contains("startEvent=null"));
}
-
+
try {
event = new TmfSyncSequenceDiagramEvent(fEvent1, null, null, null);
fail();
// success
assertTrue("testTmfSyncSequenceDiagramEvent", e.getMessage().contains("sender=null"));
}
-
+
try {
event = new TmfSyncSequenceDiagramEvent(fEvent1, "sender", null, null);
fail();
// success
assertTrue("testTmfSyncSequenceDiagramEvent", e.getMessage().contains("name=null"));
}
-
+
try {
event = new TmfSyncSequenceDiagramEvent(fEvent1, "sender", "receiver", "signal");
// success
assertEquals("testTmfSyncSequenceDiagramEvent", "sender", event.getSender());
assertEquals("testTmfSyncSequenceDiagramEvent", "receiver", event.getReceiver());
assertEquals("testTmfSyncSequenceDiagramEvent", "signal", event.getName());
-
+
} catch (IllegalArgumentException e) {
fail();
}
/*******************************************************************************
* Copyright (c) 2009, 2010 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
/*******************************************************************************
* Copyright (c) 2009, 2010 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.tmf.tests.stubs.trace;
-import java.io.FileNotFoundException;
-
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
/*******************************************************************************
* Copyright (c) 2012 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
* Implement me. Please.
* <p>
*/
-public class TmfExperimentStub<T extends ITmfEvent> extends TmfExperiment<TmfEvent> implements ITmfTrace<TmfEvent> {
+public class TmfExperimentStub<T extends ITmfEvent> extends TmfExperiment<TmfEvent> {
public TmfExperimentStub(String name, ITmfTrace<TmfEvent>[] traces, int blockSize) {
super(TmfEvent.class, name, traces, blockSize);
}
final TmfContext context = new TmfContext(getCurrentLocation(), rank);
return context;
- } else {
-
}
} catch (final IOException e) {
e.printStackTrace();
}
@Override
- public void setNbEvents(final long nbEvents) {
+ public synchronized void setNbEvents(final long nbEvents) {
super.setNbEvents(nbEvents);
}
}
@Override
- public void dispose() {
+ public synchronized void dispose() {
fLock.lock();
try {
if (fTrace != null) {
return fileExists(path);
}
-}
\ No newline at end of file
+}
import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;\r
import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;\r
\r
-@SuppressWarnings("nls")\r
+@SuppressWarnings({"nls", "javadoc"})\r
public class Tracer {\r
\r
private static String pluginID = Activator.PLUGIN_ID;\r
/**
* Registers [provider] as a provider of [eventType]
- *
- * @param eventType
- * @param provider
+ *
+ * @param eventType The event type
+ * @param provider The data provider
*/
public static <T extends ITmfEvent> void register(Class<T> eventType, TmfDataProvider<? extends ITmfEvent> provider) {
if (fProviders.get(eventType) == null)
/**
* Re-registers [provider] as a provider of [eventType]
- *
- * @param eventType
- * @param provider
+ *
+ * @param eventType The event type
+ * @param provider The data provider
*/
public static <T extends ITmfEvent> void deregister(Class<T> eventType, TmfDataProvider<? extends ITmfEvent> provider) {
List<TmfDataProvider<? extends ITmfEvent>> list = fProviders.get(eventType);
/**
* Returns the list of components that provide [eventType]
- *
- * @param eventType
+ *
+ * @param eventType The event type
* @return the list of components that provide [eventType]
*/
@SuppressWarnings("unchecked")
/**
* Returns the list of components of type [providerType] that provide [eventType]
- *
- * @param eventType
- * @param providerType
+ *
+ * @param eventType The event type
+ * @param providerType The data provider
* @return the list of components of type [providerType] that provide [eventType]
*/
@SuppressWarnings("unchecked")
/*******************************************************************************
* Copyright (c) 2010 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
/**
* Utility class to add an execution class to a simple Java thread
- *
+ *
* @version 1.0
* @author Francois Chouinard
*/
public class TmfThread extends Thread {
- private final ExecutionType fExecType;
-
- public TmfThread(ExecutionType execType) {
- fExecType = execType;
- }
-
- public ExecutionType getExecType() {
- return fExecType;
- }
-
- public void cancel() {
- }
+ private final ExecutionType fExecType;
+
+ /**
+ * Standard constructor
+ *
+ * @param execType
+ * The data request's ExecutionType
+ */
+ public TmfThread(ExecutionType execType) {
+ fExecType = execType;
+ }
+
+ /**
+ * @return The Execution type
+ */
+ public ExecutionType getExecType() {
+ return fExecType;
+ }
+
+ /**
+ * Cancel this request
+ */
+ public void cancel() {
+ }
}
/*******************************************************************************
* Copyright (c) 2009, 2010 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
/**
* The TMF coalesced data request
- *
+ *
* @version 1.0
* @author Francois Chouinard
*/
/**
* Request all the events of a given type (high priority)
* Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
+ *
* @param dataType the requested data type
*/
public TmfCoalescedDataRequest(Class<T> dataType) {
/**
* Request all the events of a given type (given priority)
* Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
+ *
* @param dataType the requested data type
* @param priority the requested execution priority
*/
/**
* Request all the events of a given type from the given index (high priority)
* Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
+ *
* @param dataType the requested data type
* @param index the index of the first event to retrieve
*/
/**
* Request all the events of a given type from the given index (given priority)
* Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
+ *
* @param dataType the requested data type
* @param index the index of the first event to retrieve
* @param priority the requested execution priority
/**
* Request 'n' events of a given type from the given index (high priority)
* Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
+ *
* @param dataType the requested data type
* @param index the index of the first event to retrieve
* @param nbRequested the number of events requested
/**
* Request 'n' events of a given type from the given index (given priority)
* Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
+ *
* @param dataType the requested data type
* @param index the index of the first event to retrieve
* @param nbRequested the number of events requested
/**
* Request 'n' events of a given type from the given index (high priority).
* Events are returned in blocks of the given size.
- *
+ *
* @param dataType the requested data type
* @param index the index of the first event to retrieve
* @param nbRequested the number of events requested
/**
* Request 'n' events of a given type from the given index (given priority).
* Events are returned in blocks of the given size.
- *
+ *
* @param dataType the requested data type
* @param index the index of the first event to retrieve
* @param nbRequested the number of events requested
// Management
// ------------------------------------------------------------------------
- public void addRequest(ITmfDataRequest<T> request) {
- fRequests.add(request);
+ /**
+ * Add a request to this one.
+ *
+ * @param request The request to add
+ */
+ public void addRequest(ITmfDataRequest<T> request) {
+ fRequests.add(request);
merge(request);
- }
+ }
- public boolean isCompatible(ITmfDataRequest<T> request) {
- if (request.getExecType() == getExecType()) {
- return overlaps(request);
- }
- return false;
- }
+ /**
+ * Check if a request is compatible with the current coalesced one
+ *
+ * @param request
+ * The request to verify
+ * @return If the request is compatible, true or false
+ */
+ public boolean isCompatible(ITmfDataRequest<T> request) {
+ if (request.getExecType() == getExecType()) {
+ return overlaps(request);
+ }
+ return false;
+ }
private boolean overlaps(ITmfDataRequest<T> request) {
long start = request.getIndex();
private void merge(ITmfDataRequest<T> request) {
long start = request.getIndex();
long end = Math.min(start + request.getNbRequested(), TmfDataRequest.ALL_DATA);
-
+
if (start < fIndex) {
if (fNbRequested != TmfDataRequest.ALL_DATA) {
fNbRequested += (fIndex - start);
}
}
+ /**
+ * @return The list of IDs of the sub-requests
+ */
@SuppressWarnings("nls")
public String getSubRequestIds() {
StringBuffer result = new StringBuffer("[");
for (int i = 0; i < fRequests.size(); i++) {
- if (i != 0) result.append(", ");
+ if (i != 0) {
+ result.append(", ");
+ }
result.append(fRequests.get(i).getRequestId());
}
result.append("]");
}
super.start();
}
-
+
@Override
public void done() {
for (ITmfDataRequest<T> request : fRequests) {
}
super.cancel();
}
-
+
@Override
- public boolean isCompleted() {
+ public synchronized boolean isCompleted() {
// Firstly, check if coalescing request is completed
if (super.isCompleted()) {
return true;
// Secondly, check if all sub-requests are finished
if (fRequests.size() > 0) {
- // If all sub requests are completed the coalesced request is
+ // If all sub requests are completed the coalesced request is
// treated as completed, too.
for (ITmfDataRequest<T> request : fRequests) {
if (!request.isCompleted()) {
}
@Override
- public boolean isCancelled() {
+ public synchronized boolean isCancelled() {
// Firstly, check if coalescing request is canceled
if (super.isCancelled()) {
return true;
// Secondly, check if all sub-requests are canceled
if (fRequests.size() > 0) {
- // If all sub requests are canceled the coalesced request is
+ // If all sub requests are canceled the coalesced request is
// treated as completed, too.
for (ITmfDataRequest<T> request : fRequests) {
if (!request.isCancelled()) {
}
-
+
// ------------------------------------------------------------------------
// Object
// ------------------------------------------------------------------------
@Override
@SuppressWarnings("nls")
public String toString() {
- return "[TmfCoalescedDataRequest(" + getRequestId() + "," + getDataType().getSimpleName()
+ return "[TmfCoalescedDataRequest(" + getRequestId() + "," + getDataType().getSimpleName()
+ "," + getIndex() + "," + getNbRequested() + "," + getBlockSize() + ")]";
}
}
/*******************************************************************************
* Copyright (c) 2009, 2010 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
/**
* The TMF coalesced event request
- *
+ *
* @version 1.0
* @author Francois Chouinard
*/
/**
* Request all the events of a given type (high priority)
* Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
+ *
* @param dataType the requested data type
*/
public TmfCoalescedEventRequest(Class<T> dataType) {
/**
* Request all the events of a given type (given priority)
* Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
+ *
* @param dataType the requested data type
* @param priority the requested execution priority
*/
/**
* Request all the events of a given type for the given time range (high priority)
* Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
+ *
* @param dataType the requested data type
* @param range the time range of the requested events
*/
/**
* Request all the events of a given type for the given time range (given priority)
* Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
+ *
* @param dataType the requested data type
* @param range the time range of the requested events
* @param priority the requested execution priority
/**
* Request 'n' events of a given type from the given time range (high priority)
* Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
+ *
* @param dataType the requested data type
* @param range the time range of the requested events
* @param nbRequested the number of events requested
/**
* Request 'n' events of a given type for the given time range (given priority)
* Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
+ *
* @param dataType the requested data type
* @param range the time range of the requested events
* @param nbRequested the number of events requested
/**
* Request 'n' events of a given type for the given time range (high priority).
* Events are returned in blocks of the given size.
- *
+ *
* @param dataType the requested data type
* @param range the time range of the requested events
* @param nbRequested the number of events requested
/**
* Request 'n' events of a given type for the given time range (given priority).
* Events are returned in blocks of the given size.
- *
+ *
* @param dataType the requested data type
* @param range the time range of the requested events
* @param nbRequested the number of events requested
/**
* Request 'n' events of a given type for the given time range (given priority).
* Events are returned in blocks of the given size.
- *
+ *
* @param dataType the requested data type
* @param range the time range of the requested events
* @param index the index of the first event to retrieve
String type = getClass().getName();
type = type.substring(type.lastIndexOf('.') + 1);
@SuppressWarnings("nls")
- String message = "CREATED "
- + (getExecType() == ITmfDataRequest.ExecutionType.BACKGROUND ? "(BG)" : "(FG)")
- + " Type=" + type + " Index=" + getIndex() + " NbReq=" + getNbRequested()
+ String message = "CREATED "
+ + (getExecType() == ITmfDataRequest.ExecutionType.BACKGROUND ? "(BG)" : "(FG)")
+ + " Type=" + type + " Index=" + getIndex() + " NbReq=" + getNbRequested()
+ " Range=" + getRange()
+ " DataType=" + getDataType().getSimpleName();
Tracer.traceRequest(this, message);
}
private boolean overlaps(ITmfEventRequest<T> request) {
- ITmfTimestamp startTime = ((ITmfEventRequest<T>) request).getRange().getStartTime();
- ITmfTimestamp endTime = ((ITmfEventRequest<T>) request).getRange().getEndTime();
+ ITmfTimestamp startTime = request.getRange().getStartTime();
+ ITmfTimestamp endTime = request.getRange().getEndTime();
return (startTime.compareTo(endTime) <= 0) && (fRange.getStartTime().compareTo(fRange.getEndTime()) <= 0);
}
private void merge(ITmfEventRequest<T> request) {
- ITmfTimestamp startTime = ((ITmfEventRequest<T>) request).getRange().getStartTime();
- ITmfTimestamp endTime = ((ITmfEventRequest<T>) request).getRange().getEndTime();
+ ITmfTimestamp startTime = request.getRange().getStartTime();
+ ITmfTimestamp endTime = request.getRange().getEndTime();
if (!fRange.contains(startTime) && fRange.getStartTime().compareTo(startTime) > 0) {
fRange = new TmfTimeRange(startTime, fRange.getEndTime());
}
public TmfTimeRange getRange() {
return fRange;
}
-
+
@Override
public void setStartIndex(int index) {
setIndex(index);
}
-
+
// ------------------------------------------------------------------------
// Object
// ------------------------------------------------------------------------
@Override
@SuppressWarnings("nls")
public String toString() {
- return "[TmfCoalescedEventRequest(" + getRequestId() + "," + getDataType().getSimpleName()
+ return "[TmfCoalescedEventRequest(" + getRequestId() + "," + getDataType().getSimpleName()
+ "," + getRange() + "," + getIndex() + "," + getNbRequested() + "," + getBlockSize() + ")]";
}
/*******************************************************************************
* Copyright (c) 2009, 2010 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
/**
* A simple, straightforward request executor.
- *
+ *
* @version 1.0
* @author Francois Chouinard
*/
private final ExecutorService fExecutor;
private final String fExecutorName;
- private final PriorityBlockingQueue<TmfThread> fRequestQueue = new PriorityBlockingQueue<TmfThread>(100, new Comparator<TmfThread>() {
- @Override
- public int compare(TmfThread o1, TmfThread o2) {
- if (o1.getExecType() == o2.getExecType())
- return 0;
- if (o1.getExecType() == ExecutionType.BACKGROUND)
- return 1;
- return -1;
- }
- });
- private TmfThread fCurrentRequest;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- public TmfRequestExecutor() {
- this(Executors.newSingleThreadExecutor());
- }
+ private final PriorityBlockingQueue<TmfThread> fRequestQueue = new PriorityBlockingQueue<TmfThread>(
+ 100, new Comparator<TmfThread>() {
+ @Override
+ public int compare(TmfThread o1, TmfThread o2) {
+ if (o1.getExecType() == o2.getExecType()) {
+ return 0;
+ }
+ if (o1.getExecType() == ExecutionType.BACKGROUND) {
+ return 1;
+ }
+ return -1;
+ }
+ });
+ private TmfThread fCurrentRequest;
- public TmfRequestExecutor(ExecutorService executor) {
- fExecutor = executor;
- String canonicalName = fExecutor.getClass().getCanonicalName();
- fExecutorName = canonicalName.substring(canonicalName.lastIndexOf('.') + 1);
- if (Tracer.isComponentTraced()) Tracer.trace(fExecutor + " created"); //$NON-NLS-1$
- }
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Default constructor
+ */
+ public TmfRequestExecutor() {
+ this(Executors.newSingleThreadExecutor());
+ }
+
+ /**
+ * Standard constructor
+ *
+ * @param executor The executor service to use
+ */
+ public TmfRequestExecutor(ExecutorService executor) {
+ fExecutor = executor;
+ String canonicalName = fExecutor.getClass().getCanonicalName();
+ fExecutorName = canonicalName.substring(canonicalName.lastIndexOf('.') + 1);
+ if (Tracer.isComponentTraced())
+ {
+ Tracer.trace(fExecutor + " created"); //$NON-NLS-1$
+ }
+ }
/**
* @return the number of pending requests
public synchronized int getNbPendingRequests() {
return fRequestQueue.size();
}
-
+
/**
* @return the shutdown state (i.e. if it is accepting new requests)
*/
public synchronized boolean isShutdown() {
return fExecutor.isShutdown();
}
-
+
/**
* @return the termination state
*/
public synchronized boolean isTerminated() {
return fExecutor.isTerminated();
}
-
+
/**
* Stops the executor
*/
if (fCurrentRequest != null) {
fCurrentRequest.cancel();
}
-
+
while ((fCurrentRequest = fRequestQueue.poll()) != null) {
fCurrentRequest.cancel();
}
fExecutor.shutdown();
- if (Tracer.isComponentTraced()) Tracer.trace(fExecutor + " terminated"); //$NON-NLS-1$
+ if (Tracer.isComponentTraced())
+ {
+ Tracer.trace(fExecutor + " terminated"); //$NON-NLS-1$
+ }
}
-
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
-
+
/* (non-Javadoc)
* @see java.util.concurrent.Executor#execute(java.lang.Runnable)
*/
*/
protected synchronized void scheduleNext() {
if ((fCurrentRequest = fRequestQueue.poll()) != null) {
- if (!isShutdown())
- fExecutor.execute(fCurrentRequest);
+ if (!isShutdown()) {
+ fExecutor.execute(fCurrentRequest);
+ }
}
}
* The last trace refers to the trace from which the last event was "consumed"
* at the experiment level.
*/
-public class TmfExperimentContext extends TmfContext implements Cloneable {
+public class TmfExperimentContext extends TmfContext {
// ------------------------------------------------------------------------
// Constants
final ITmfLocation<?>[] locations = new ITmfLocation[fContexts.length];
setLocation(new TmfExperimentLocation(new TmfLocationArray(locations.clone())));
-
+
final long[] ranks = new long[fContexts.length];
long rank = 0;
- for (int i = 0; i < fContexts.length; i++)
+ for (int i = 0; i < fContexts.length; i++) {
if (contexts[i] != null) {
locations[i] = contexts[i].getLocation();
ranks[i] = contexts[i].getRank();
rank += contexts[i].getRank();
}
+ }
// setLocation(new TmfExperimentLocation(new TmfLocationArray(locations)));
setRank(rank);
public TmfExperimentContext(final TmfExperimentContext other) {
this(other.cloneContexts());
fEvents = other.fEvents;
- if (other.getLocation() != null)
+ if (other.getLocation() != null) {
setLocation(other.getLocation().clone());
+ }
setRank(other.getRank());
setLastTrace(other.fLastTraceRead);
}
private ITmfContext[] cloneContexts() {
final ITmfContext[] contexts = new ITmfContext[fContexts.length];
- for (int i = 0; i < fContexts.length; i++)
+ for (int i = 0; i < fContexts.length; i++) {
contexts[i] = (fContexts[i] != null) ? fContexts[i].clone() : null;
+ }
return contexts;
}
private ITmfEvent[] cloneEvents() {
final ITmfEvent[] events = new ITmfEvent[fEvents.length];
- for (int i = 0; i < fEvents.length; i++)
+ for (int i = 0; i < fEvents.length; i++) {
events[i] = (fEvents[i] != null) ? fEvents[i].clone() : null;
+ }
return events;
}
@Override
public boolean equals(final Object other) {
- if (this == other)
+ if (this == other) {
return true;
- if (!super.equals(other))
+ }
+ if (!super.equals(other)) {
return false;
- if (!(other instanceof TmfExperimentContext))
+ }
+ if (!(other instanceof TmfExperimentContext)) {
return false;
+ }
final TmfExperimentContext o = (TmfExperimentContext) other;
boolean isEqual = true;
int i = 0;
/*******************************************************************************
* Copyright (c) 2009, 2010, 2012 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
* Francois Chouinard - Updated as per TMF Trace Model 1.0
* <p>
* It is the responsibility of the user the individual trace locations are valid
* and that they are matched to the correct trace.
- *
+ *
* @version 1.0
* @author Francois Chouinard
- *
+ *
* @see TmfLocationArray
*/
-public class TmfExperimentLocation extends TmfLocation<TmfLocationArray> implements Cloneable {
+public class TmfExperimentLocation extends TmfLocation<TmfLocationArray> {
// ------------------------------------------------------------------------
// Constructors
/**
* The standard constructor
- *
+ *
* @param locations the set of trace locations
*/
public TmfExperimentLocation(TmfLocationArray locations) {
/**
* The copy constructor
- *
+ *
* @param location the other experiment location
*/
public TmfExperimentLocation(TmfExperimentLocation location) {
@Override
public TmfExperimentLocation clone() {
// super.clone(); // To keep FindBugs happy
- TmfLocationArray array = (TmfLocationArray) getLocation();
+ TmfLocationArray array = getLocation();
TmfLocationArray clones = array.clone();
return new TmfExperimentLocation(clones);
}
@SuppressWarnings("nls")
public String toString() {
StringBuilder result = new StringBuilder("[TmfExperimentLocation");
- ITmfLocation<? extends Comparable<?>>[] locations = ((TmfLocationArray) getLocation()).getLocations();
+ ITmfLocation<? extends Comparable<?>>[] locations = getLocation().getLocations();
for (ITmfLocation<?> location : locations) {
result.append("[" + location + "]");
}
/*******************************************************************************
* Copyright (c) 2011, 2012 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
- *
+ *
* Contributors:
* Patrick Tasse - Initial API and implementation
* Francois Chouinard - Put in shape for 1.0
/**
* A convenience class to store trace location arrays. The main purpose is to
* provide a Comparable implementation for TmfExperimentLocation.
- *
+ *
* @version 1.0
* @author Patrick Tasse
*/
// Attributes
// ------------------------------------------------------------------------
- private ITmfLocation<? extends Comparable<?>>[] fLocations;
+ private final ITmfLocation<? extends Comparable<?>>[] fLocations;
// ------------------------------------------------------------------------
// Constructors
/**
* The standard constructor
- *
+ *
* @param locations the locations
*/
public TmfLocationArray(ITmfLocation<? extends Comparable<?>>[] locations) {
/**
* The standard constructor
- *
+ *
* @param locations the locations
*/
public ITmfLocation<? extends Comparable<?>>[] getLocations() {
*/
@Override
public TmfLocationArray clone() {
- ITmfLocation<? extends Comparable<?>>[] clones = (ITmfLocation<? extends Comparable<?>>[]) new ITmfLocation<?>[fLocations.length];
+ ITmfLocation<? extends Comparable<?>>[] clones = new ITmfLocation<?>[fLocations.length];
for (int i = 0; i < fLocations.length; i++) {
ITmfLocation<?> location = fLocations[i];
clones[i] = (location != null) ? location.clone() : null;
/**
* The CTF adapter for the TMF timestamp
- *
+ *
* @version 1.0
* @author Matthew khouzam
*/
case SECONDS:{
return secondsToString();
}
+ default:
+ break;
}
return super.toString();
}
* sub-classes.
* @throws TmfTraceException
*/
- @SuppressWarnings({ "static-method" })
protected void buildStateSystem() throws TmfTraceException {
/*
* Nothing is done in the basic implementation, please specify
package org.eclipse.linuxtools.tmf.core.event;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
/**
* A basic implementation of ITmfEvent.
* event rank is set to TmfContext.UNKNOWN_RANK.
*/
public TmfEvent() {
- this(null, TmfContext.UNKNOWN_RANK, null, null, null, null, null);
+ this(null, ITmfContext.UNKNOWN_RANK, null, null, null, null, null);
}
/**
public TmfEvent(final ITmfTrace<? extends ITmfEvent> trace, final ITmfTimestamp timestamp, final String source,
final ITmfEventType type, final ITmfEventField content, final String reference)
{
- this(trace, TmfContext.UNKNOWN_RANK, timestamp, source, type, content, reference);
+ this(trace, ITmfContext.UNKNOWN_RANK, timestamp, source, type, content, reference);
}
/**
/*******************************************************************************
* Copyright (c) 2012 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
/**
* A simplified timestamp where scale and precision are set to 0.
- *
+ *
* @version 1.0
* @author Francois Chouinard
*/
-public class TmfSimpleTimestamp extends TmfTimestamp implements Cloneable {
+public class TmfSimpleTimestamp extends TmfTimestamp {
// ------------------------------------------------------------------------
// Constructors
/**
* Copy constructor
- *
+ *
* @param timestamp the timestamp to copy
*/
public TmfSimpleTimestamp(final ITmfTimestamp timestamp) {
/*******************************************************************************\r
* Copyright (c) 2010 Ericsson\r
- * \r
+ *\r
* All rights reserved. This program and the accompanying materials are\r
* made available under the terms of the Eclipse Public License v1.0 which\r
* accompanies this distribution, and is available at\r
* http://www.eclipse.org/legal/epl-v10.html\r
- * \r
+ *\r
* Contributors:\r
* Patrick Tasse - Initial API and implementation\r
*******************************************************************************/\r
\r
/**\r
* Filter node for the comparison operation\r
- * \r
+ *\r
* @version 1.0\r
* @author Patrick Tasse\r
*/\r
public static final String RESULT_ATTR = "result"; //$NON-NLS-1$\r
public static final String TYPE_ATTR = "type"; //$NON-NLS-1$\r
public static final String VALUE_ATTR = "value"; //$NON-NLS-1$\r
- \r
+\r
/**\r
* Supported comparison types\r
*/\r
ALPHA,\r
TIMESTAMP\r
}\r
- \r
+\r
private boolean fNot = false;\r
private String fField;\r
private int fResult;\r
private String fValue;\r
private Number fValueNumber;\r
private TmfTimestamp fValueTimestamp;\r
- \r
+\r
public TmfFilterCompareNode(ITmfFilterTreeNode parent) {\r
super(parent);\r
}\r
public boolean isNot() {\r
return fNot;\r
}\r
- \r
+\r
public void setNot(boolean not) {\r
this.fNot = not;\r
}\r
- \r
+\r
public String getField() {\r
return fField;\r
}\r
public int getResult() {\r
return fResult;\r
}\r
- \r
+\r
public void setResult(int result) {\r
this.fResult = result;\r
}\r
- \r
+\r
public Type getType() {\r
return fType;\r
}\r
public String getValue() {\r
return fValue;\r
}\r
- \r
+\r
public void setValue(String value) {\r
this.fValue = value;\r
fValueNumber = null;\r
}\r
}\r
}\r
- \r
+\r
@Override\r
public String getNodeName() {\r
return NODE_NAME;\r
if (value instanceof Number) {\r
Double valueDouble = ((Number) value).doubleValue();\r
return (valueDouble.compareTo(fValueNumber.doubleValue()) == fResult) ^ fNot;\r
- } else {\r
- try {\r
- Double valueDouble = NumberFormat.getInstance().parse(value.toString())\r
- .doubleValue();\r
- return (valueDouble.compareTo(fValueNumber.doubleValue()) == fResult)\r
- ^ fNot;\r
- } catch (ParseException e) {\r
- }\r
+ }\r
+ try {\r
+ Double valueDouble = NumberFormat.getInstance().parse(value.toString())\r
+ .doubleValue();\r
+ return (valueDouble.compareTo(fValueNumber.doubleValue()) == fResult)\r
+ ^ fNot;\r
+ } catch (ParseException e) {\r
}\r
}\r
} else if (fType == Type.ALPHA) {\r
String valueString = value.toString();\r
int comp = valueString.compareTo(fValue.toString());\r
- if (comp < -1) comp = -1;\r
- else if (comp > 1) comp = 1;\r
+ if (comp < -1) {\r
+ comp = -1;\r
+ } else if (comp > 1) {\r
+ comp = 1;\r
+ }\r
return (comp == fResult) ^ fNot;\r
} else if (fType == Type.TIMESTAMP) {\r
if (fValueTimestamp != null) {\r
if (value instanceof TmfTimestamp) {\r
TmfTimestamp valueTimestamp = (TmfTimestamp) value;\r
return (valueTimestamp.compareTo(fValueTimestamp, false) == fResult) ^ fNot;\r
- } else {\r
- try {\r
- TmfTimestamp valueTimestamp = new TmfTimestamp((long) (1E9 * NumberFormat\r
- .getInstance().parse(value.toString()).doubleValue()));\r
- return (valueTimestamp.compareTo(fValueTimestamp, false) == fResult) ^ fNot;\r
- } catch (ParseException e) {\r
- }\r
+ }\r
+ try {\r
+ TmfTimestamp valueTimestamp = new TmfTimestamp((long) (1E9 * NumberFormat\r
+ .getInstance().parse(value.toString()).doubleValue()));\r
+ return (valueTimestamp.compareTo(fValueTimestamp, false) == fResult) ^ fNot;\r
+ } catch (ParseException e) {\r
}\r
}\r
}\r
/*******************************************************************************\r
* Copyright (c) 2010 Ericsson\r
- * \r
+ *\r
* All rights reserved. This program and the accompanying materials are\r
* made available under the terms of the Eclipse Public License v1.0 which\r
* accompanies this distribution, and is available at\r
* http://www.eclipse.org/legal/epl-v10.html\r
- * \r
+ *\r
* Contributors:\r
* Patrick Tasse - Initial API and implementation\r
*******************************************************************************/\r
\r
/**\r
* Filter node for the 'contains' operation\r
- * \r
+ *\r
* @version 1.0\r
* @author Patrick Tasse\r
*/\r
public static final String FIELD_ATTR = "field"; //$NON-NLS-1$\r
public static final String VALUE_ATTR = "value"; //$NON-NLS-1$\r
public static final String IGNORECASE_ATTR = "ignorecase"; //$NON-NLS-1$\r
- \r
+\r
private boolean fNot = false;\r
private String fField;\r
private String fValue;\r
private String fValueUpperCase;\r
private boolean fIgnoreCase = false;\r
- \r
+\r
public TmfFilterContainsNode(ITmfFilterTreeNode parent) {\r
super(parent);\r
}\r
public boolean isNot() {\r
return fNot;\r
}\r
- \r
+\r
public void setNot(boolean not) {\r
this.fNot = not;\r
}\r
- \r
+\r
public String getField() {\r
return fField;\r
}\r
public boolean isIgnoreCase() {\r
return fIgnoreCase;\r
}\r
- \r
+\r
public void setIgnoreCase(boolean ignoreCase) {\r
this.fIgnoreCase = ignoreCase;\r
}\r
- \r
+\r
@Override\r
public String getNodeName() {\r
return NODE_NAME;\r
String valueString = value.toString();\r
if (fIgnoreCase) {\r
return valueString.toUpperCase().contains(fValueUpperCase) ^ fNot;\r
- } else {\r
- return valueString.contains(fValue) ^ fNot;\r
}\r
+ return valueString.contains(fValue) ^ fNot;\r
}\r
\r
@Override\r
/*******************************************************************************\r
* Copyright (c) 2010 Ericsson\r
- * \r
+ *\r
* All rights reserved. This program and the accompanying materials are\r
* made available under the terms of the Eclipse Public License v1.0 which\r
* accompanies this distribution, and is available at\r
* http://www.eclipse.org/legal/epl-v10.html\r
- * \r
+ *\r
* Contributors:\r
* Patrick Tasse - Initial API and implementation\r
*******************************************************************************/\r
\r
/**\r
* Filter node for the '==' operation\r
- * \r
+ *\r
* @version 1.0\r
* @author Patrick Tasse\r
*/\r
public static final String FIELD_ATTR = "field"; //$NON-NLS-1$\r
public static final String VALUE_ATTR = "value"; //$NON-NLS-1$\r
public static final String IGNORECASE_ATTR = "ignorecase"; //$NON-NLS-1$\r
- \r
+\r
private boolean fNot = false;\r
private String fField;\r
private String fValue;\r
private boolean fIgnoreCase = false;\r
- \r
+\r
public TmfFilterEqualsNode(ITmfFilterTreeNode parent) {\r
super(parent);\r
}\r
public boolean isNot() {\r
return fNot;\r
}\r
- \r
+\r
public void setNot(boolean not) {\r
this.fNot = not;\r
}\r
- \r
+\r
public String getField() {\r
return fField;\r
}\r
public boolean isIgnoreCase() {\r
return fIgnoreCase;\r
}\r
- \r
+\r
public void setIgnoreCase(boolean ignoreCase) {\r
this.fIgnoreCase = ignoreCase;\r
}\r
- \r
+\r
@Override\r
public String getNodeName() {\r
return NODE_NAME;\r
}\r
if (fIgnoreCase) {\r
return valueString.equalsIgnoreCase(fValue) ^ fNot;\r
- } else {\r
- return valueString.equals(fValue) ^ fNot;\r
}\r
+ return valueString.equals(fValue) ^ fNot;\r
}\r
\r
@Override\r
/*******************************************************************************\r
* Copyright (c) 2010 Ericsson\r
- * \r
+ *\r
* All rights reserved. This program and the accompanying materials are\r
* made available under the terms of the Eclipse Public License v1.0 which\r
* accompanies this distribution, and is available at\r
* http://www.eclipse.org/legal/epl-v10.html\r
- * \r
+ *\r
* Contributors:\r
* Patrick Tasse - Initial API and implementation\r
*******************************************************************************/\r
\r
/**\r
* Filter node for an event\r
- * \r
+ *\r
* @version 1.0\r
* @author Patrick Tasse\r
*/\r
public static final String NODE_NAME = "EVENTTYPE"; //$NON-NLS-1$\r
public static final String TYPE_ATTR = "type"; //$NON-NLS-1$\r
public static final String NAME_ATTR = "name"; //$NON-NLS-1$\r
- \r
+\r
private String fType;\r
private String fName;\r
- \r
+\r
public TmfFilterEventTypeNode(ITmfFilterTreeNode parent) {\r
super(parent);\r
}\r
public List<String> getValidChildren() {\r
if (getChildrenCount() == 0) {\r
return super.getValidChildren();\r
- } else {\r
- return new ArrayList<String>(0); // only one child allowed\r
}\r
+ return new ArrayList<String>(0); // only one child allowed\r
}\r
\r
@Override\r
/*******************************************************************************\r
* Copyright (c) 2010 Ericsson\r
- * \r
+ *\r
* All rights reserved. This program and the accompanying materials are\r
* made available under the terms of the Eclipse Public License v1.0 which\r
* accompanies this distribution, and is available at\r
* http://www.eclipse.org/legal/epl-v10.html\r
- * \r
+ *\r
* Contributors:\r
* Yuriy Vashchuk (yvashchuk@gmail.com) - Initial API and implementation\r
*******************************************************************************/\r
import javax.xml.parsers.SAXParserFactory;\r
\r
import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;\r
-\r
import org.xml.sax.SAXException;\r
import org.xml.sax.XMLReader;\r
\r
/**\r
* The SAX based XML parser\r
- * \r
+ *\r
* @version 1.0\r
* @author Yuriy Vashchuk\r
* @author Patrick Tasse\r
*/\r
public class TmfFilterXMLParser {\r
- \r
- private static ITmfFilterTreeNode fRoot = null;\r
- \r
- /**\r
- * The XMLParser constructor\r
- * \r
- * @param uri The XML file to parse\r
- */ \r
- public TmfFilterXMLParser(final String uri) throws SAXException, IOException {\r
- \r
- SAXParserFactory m_parserFactory = null;\r
- if (m_parserFactory == null) { \r
- m_parserFactory = SAXParserFactory.newInstance(); \r
- m_parserFactory.setNamespaceAware(true); \r
- } \r
\r
- XMLReader saxReader = null;\r
- try {\r
- \r
- saxReader = m_parserFactory.newSAXParser().getXMLReader();\r
- saxReader.setContentHandler(new TmfFilterContentHandler());\r
- saxReader.parse(uri);\r
- \r
- fRoot = ((TmfFilterContentHandler) saxReader.getContentHandler()).getTree();\r
- \r
- } catch (ParserConfigurationException e) {\r
- e.printStackTrace();\r
- }\r
- }\r
+ private static ITmfFilterTreeNode fRoot = null;\r
+\r
+ /**\r
+ * The XMLParser constructor\r
+ *\r
+ * @param uri\r
+ * The XML file to parse\r
+ */\r
+ public TmfFilterXMLParser(final String uri) throws SAXException,\r
+ IOException {\r
+\r
+ SAXParserFactory m_parserFactory = null;\r
+ m_parserFactory = SAXParserFactory.newInstance();\r
+ m_parserFactory.setNamespaceAware(true);\r
+\r
+ XMLReader saxReader = null;\r
+ try {\r
+\r
+ saxReader = m_parserFactory.newSAXParser().getXMLReader();\r
+ saxReader.setContentHandler(new TmfFilterContentHandler());\r
+ saxReader.parse(uri);\r
+\r
+ fRoot = ((TmfFilterContentHandler) saxReader.getContentHandler()).getTree();\r
+\r
+ } catch (ParserConfigurationException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
\r
- /**\r
- * Getter of tree\r
- * \r
- * @return The builded tree\r
- */ \r
- public ITmfFilterTreeNode getTree() {\r
- return fRoot;\r
- }\r
+ /**\r
+ * Getter of tree\r
+ *\r
+ * @return The builded tree\r
+ */\r
+ public ITmfFilterTreeNode getTree() {\r
+ return fRoot;\r
+ }\r
}\r
/*******************************************************************************\r
* Copyright (c) 2010 Ericsson\r
- * \r
+ *\r
* All rights reserved. This program and the accompanying materials are\r
* made available under the terms of the Eclipse Public License v1.0 which\r
* accompanies this distribution, and is available at\r
* http://www.eclipse.org/legal/epl-v10.html\r
- * \r
+ *\r
* Contributors:\r
* Yuriy Vashchuk (yvashchuk@gmail.com) - Initial API and implementation\r
*******************************************************************************/\r
package org.eclipse.linuxtools.tmf.core.filter.xml;\r
\r
import java.io.File;\r
-import java.io.IOException;\r
\r
import javax.xml.parsers.DocumentBuilder;\r
import javax.xml.parsers.DocumentBuilderFactory;\r
\r
/**\r
* The SAX based XML writer\r
- * \r
+ *\r
* @version 1.0\r
* @author Yuriy Vashchuk\r
* @author Patrick Tasse\r
*/\r
public class TmfFilterXMLWriter {\r
- \r
+\r
private Document document = null;\r
- \r
+\r
/**\r
* The XMLParser constructor\r
- * \r
+ *\r
* @param root The tree root\r
- * @throws ParserConfigurationException \r
- */ \r
- public TmfFilterXMLWriter(final ITmfFilterTreeNode root) throws IOException, ParserConfigurationException {\r
+ * @throws ParserConfigurationException\r
+ */\r
+ public TmfFilterXMLWriter(final ITmfFilterTreeNode root) throws ParserConfigurationException {\r
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();\r
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();\r
document = documentBuilder.newDocument();\r
- \r
+\r
Element rootElement = document.createElement(root.getNodeName());\r
document.appendChild(rootElement);\r
\r
\r
/**\r
* The Tree to XML parser\r
- * \r
+ *\r
* @param document The XML document\r
* @param treenode The node to write\r
* @param parentElement The XML element of the parent\r
- */ \r
+ */\r
public static void buildXMLTree(final Document document, final ITmfFilterTreeNode treenode, Element parentElement) {\r
Element element = document.createElement(treenode.getNodeName());\r
- \r
+\r
if (treenode instanceof TmfFilterNode) {\r
- \r
+\r
TmfFilterNode node = (TmfFilterNode) treenode;\r
element.setAttribute(TmfFilterNode.NAME_ATTR, node.getFilterName());\r
- \r
+\r
} else if (treenode instanceof TmfFilterEventTypeNode) {\r
- \r
+\r
TmfFilterEventTypeNode node = (TmfFilterEventTypeNode) treenode;\r
element.setAttribute(TmfFilterEventTypeNode.TYPE_ATTR, node.getEventType());\r
element.setAttribute(TmfFilterEventTypeNode.NAME_ATTR, node.getName());\r
- \r
+\r
} else if (treenode instanceof TmfFilterAndNode) {\r
- \r
+\r
TmfFilterAndNode node = (TmfFilterAndNode) treenode;\r
element.setAttribute(TmfFilterAndNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
- \r
+\r
} else if (treenode instanceof TmfFilterOrNode) {\r
- \r
+\r
TmfFilterOrNode node = (TmfFilterOrNode) treenode;\r
element.setAttribute(TmfFilterOrNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
- \r
+\r
} else if (treenode instanceof TmfFilterContainsNode) {\r
- \r
+\r
TmfFilterContainsNode node = (TmfFilterContainsNode) treenode;\r
element.setAttribute(TmfFilterContainsNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
element.setAttribute(TmfFilterContainsNode.FIELD_ATTR, node.getField());\r
element.setAttribute(TmfFilterContainsNode.VALUE_ATTR, node.getValue());\r
element.setAttribute(TmfFilterContainsNode.IGNORECASE_ATTR, Boolean.toString(node.isIgnoreCase()));\r
- \r
+\r
} else if (treenode instanceof TmfFilterEqualsNode) {\r
- \r
+\r
TmfFilterEqualsNode node = (TmfFilterEqualsNode) treenode;\r
element.setAttribute(TmfFilterEqualsNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
element.setAttribute(TmfFilterEqualsNode.FIELD_ATTR, node.getField());\r
element.setAttribute(TmfFilterEqualsNode.VALUE_ATTR, node.getValue());\r
element.setAttribute(TmfFilterEqualsNode.IGNORECASE_ATTR, Boolean.toString(node.isIgnoreCase()));\r
- \r
+\r
} else if (treenode instanceof TmfFilterMatchesNode) {\r
- \r
+\r
TmfFilterMatchesNode node = (TmfFilterMatchesNode) treenode;\r
element.setAttribute(TmfFilterMatchesNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
element.setAttribute(TmfFilterMatchesNode.FIELD_ATTR, node.getField());\r
element.setAttribute(TmfFilterMatchesNode.REGEX_ATTR, node.getRegex());\r
- \r
+\r
} else if (treenode instanceof TmfFilterCompareNode) {\r
- \r
+\r
TmfFilterCompareNode node = (TmfFilterCompareNode) treenode;\r
element.setAttribute(TmfFilterCompareNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
element.setAttribute(TmfFilterCompareNode.FIELD_ATTR, node.getField());\r
element.setAttribute(TmfFilterCompareNode.RESULT_ATTR, Integer.toString(node.getResult()));\r
element.setAttribute(TmfFilterCompareNode.TYPE_ATTR, node.getType().toString());\r
element.setAttribute(TmfFilterCompareNode.VALUE_ATTR, node.getValue());\r
- \r
+\r
}\r
- \r
+\r
parentElement.appendChild(element);\r
- \r
+\r
for (int i = 0; i < treenode.getChildrenCount(); i++) {\r
buildXMLTree(document, treenode.getChild(i), element);\r
}\r
}\r
- \r
+\r
/**\r
- * Save the tree \r
- * \r
+ * Save the tree\r
+ *\r
* @param uri The new Filter XML path\r
- */ \r
+ */\r
public void saveTree(final String uri) {\r
TransformerFactory transformerFactory = TransformerFactory.newInstance();\r
- \r
+\r
try {\r
Transformer transformer = transformerFactory.newTransformer();\r
DOMSource source = new DOMSource(document);\r
e.printStackTrace();\r
}\r
}\r
- \r
+\r
}\r
/*******************************************************************************\r
* Copyright (c) 2010 Ericsson\r
- * \r
+ *\r
* All rights reserved. This program and the accompanying materials are\r
* made available under the terms of the Eclipse Public License v1.0 which\r
* accompanies this distribution, and is available at\r
* http://www.eclipse.org/legal/epl-v10.html\r
- * \r
+ *\r
* Contributors:\r
* Patrick Tasse - Initial API and implementation, based on article by Nick Zhang\r
* (http://www.javaworld.com/javatips/jw-javatip26.html)\r
import java.nio.charset.Charset;\r
\r
/**\r
- * A class to mitigate the Java I/O inefficiency of RandomAccessFile. \r
- * \r
+ * A class to mitigate the Java I/O inefficiency of RandomAccessFile.\r
+ *\r
* @version 1.0\r
* @author Patrick Tasse\r
*/\r
\r
private static final int DEFAULT_BUF_SIZE = 8192;\r
private static final Charset CHARSET_UTF8 = Charset.forName("UTF-8"); //$NON-NLS-1$\r
- \r
+\r
final int BUF_SIZE;\r
byte buffer[];\r
int buf_end = 0;\r
int buf_pos = 0;\r
long real_pos = 0;\r
StringBuilder sb = new StringBuilder();\r
- \r
+\r
public BufferedRandomAccessFile(String name, String mode) throws IOException {\r
this(name, mode, DEFAULT_BUF_SIZE);\r
}\r
- \r
+\r
public BufferedRandomAccessFile(File file, String mode) throws IOException {\r
this(file, mode, DEFAULT_BUF_SIZE);\r
}\r
- \r
+\r
public BufferedRandomAccessFile(String name, String mode, int bufsize) throws IOException {\r
super(name, mode);\r
invalidate();\r
}\r
if (buf_end == 0) {\r
return -1;\r
- } else {\r
- return buffer[buf_pos++];\r
}\r
+ return buffer[buf_pos++];\r
}\r
- \r
+\r
@Override\r
public int read(byte b[], int off, int len) throws IOException {\r
int leftover = buf_end - buf_pos;\r
}\r
return len;\r
}\r
- \r
+\r
@Override\r
public long getFilePointer() throws IOException{\r
long l = real_pos;\r
buf_pos = lineend + 1;\r
return str;\r
}\r
- \r
+\r
private int fillBuffer() throws IOException {\r
int n = super.read(buffer, 0, BUF_SIZE);\r
if (n >= 0) {\r
}\r
return n;\r
}\r
- \r
+\r
private void invalidate() throws IOException {\r
buf_end = 0;\r
buf_pos = 0;\r
// Constants
// ------------------------------------------------------------------------
- public enum ExecutionType { BACKGROUND, FOREGROUND };
-
+ public enum ExecutionType { BACKGROUND, FOREGROUND }
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
/*******************************************************************************
* Copyright (c) 2012 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
/**
* The generic trace indexer in TMF with support for incremental indexing.
- *
+ *
* @version 1.0
* @author Francois Chouinard
*
* TmfTimeRange range = new TmfTimeRange(T1, T2);
* trace.getIndexer().buildIndex(100, range, false);
* </pre>
- *
+ *
* @param offset The offset of the first event to consider
* @param range The time range to consider
* @param waitForCompletion
*/
public void buildIndex(long offset, TmfTimeRange range, boolean waitForCompletion);
-
+
/**
* Indicates that the indexer is busy indexing the trace.
- * Will always return false if the indexing is done synchronously.
- *
+ * Will always return false if the indexing is done synchronously.
+ *
* @return the state of the indexer (indexing or not)
*/
public boolean isIndexing();
-
+
/**
- * Adds an entry to the trace index.
- *
+ * Adds an entry to the trace index.
+ *
* @param context
* @param timestamp
*/
public void updateIndex(ITmfContext context, ITmfTimestamp timestamp);
-
+
/**
* Returns the context of the checkpoint immediately preceding the requested
* timestamp (or at the timestamp if it coincides with a checkpoint).
- *
+ *
* @param timestamp the requested timestamp
* @return the checkpoint context
*/
/**
* Returns the context of the checkpoint immediately preceding the requested
* rank (or at rank if it coincides with a checkpoint).
- *
+ *
* @param rank the requested event rank
* @return the checkpoint context
*/
/*******************************************************************************
* Copyright (c) 2012 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
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentContext;
+import org.eclipse.linuxtools.tmf.core.component.TmfDataProvider;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
/**
* A simple indexer that manages the trace index as an array of trace
- * checkpoints. Checkpoints are stored at fixed intervals (event rank) in
+ * checkpoints. Checkpoints are stored at fixed intervals (event rank) in
* ascending timestamp order.
* <p>
* The goal being to access a random trace event reasonably fast from the user's
* <p>
* Locating a specific checkpoint is trivial for both rank (rank % interval) and
* timestamp (bsearch in the array).
- *
+ *
* @version 1.0
* @author Francois Chouinard
*
protected final List<ITmfCheckpoint> fTraceIndex;
/**
- * The indexing request
+ * The indexing request
*/
private ITmfEventRequest<ITmfEvent> fIndexingRequest = null;
-
+
// ------------------------------------------------------------------------
// Construction
// ------------------------------------------------------------------------
/**
* Basic constructor that uses the default trace block size as checkpoints
* intervals
- *
+ *
* @param trace the trace to index
*/
public TmfCheckpointIndexer(final ITmfTrace<ITmfEvent> trace) {
- this(trace, TmfTrace.DEFAULT_BLOCK_SIZE);
+ this(trace, TmfDataProvider.DEFAULT_BLOCK_SIZE);
}
/**
* Full trace indexer
- *
+ *
* @param trace the trace to index
* @param interval the checkpoints interval
*/
// ------------------------------------------------------------------------
/* (non-Javadoc)
- *
+ *
* The index is a list of contexts that point to events at regular interval
* (rank-wise) in the trace. After it is built, the index can be used to
* quickly access any event by rank or timestamp (using seekIndex()).
- *
+ *
* The index is built simply by reading the trace
*
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer#buildIndex(long, org.eclipse.linuxtools.tmf.core.event.TmfTimeRange, boolean)
@Override
public void buildIndex(final long offset, final TmfTimeRange range, final boolean waitForCompletion) {
- // Don't do anything if we are already indexing
+ // Don't do anything if we are already indexing
synchronized (fTraceIndex) {
if (fIsIndexing) {
return;
/**
* Notify the interested parties that the trace time range has changed
- *
+ *
* @param startTime the new start time
* @param endTime the new end time
*/
/**
* Position the trace at the given checkpoint
- *
+ *
* @param checkpoint the checkpoint index
* @return the corresponding context
*/
// Context conversion functions
// ------------------------------------------------------------------------
- private ITmfContext shrinkContext(ITmfContext context) {
+ private static ITmfContext shrinkContext(ITmfContext context) {
if (context instanceof TmfExperimentContext) {
return shrinkExpContext(context);
}
return ctx;
}
- private ITmfContext shrinkExpContext(ITmfContext context) {
+ private static ITmfContext shrinkExpContext(ITmfContext context) {
TmfExperimentContext expContext = (TmfExperimentContext) context;
int size = expContext.getContexts().length;
ITmfContext[] trcCtxts = new TmfContext[size];
* @param type
* @param id
* @param traces
- * @throws TmfTraceException
+ * @throws TmfTraceException
*/
public TmfExperiment(final Class<T> type, final String id, final ITmfTrace<T>[] traces) {
this(type, id, traces, DEFAULT_INDEX_PAGE_SIZE);
* @param id
* @param traces
* @param indexPageSize
- * @throws TmfTraceException
+ * @throws TmfTraceException
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public TmfExperiment(final Class<T> type, final String path, final ITmfTrace<T>[] traces, final int indexPageSize) {
}
if (fTraces != null) {
- for (final ITmfTrace trace : fTraces)
+ for (final ITmfTrace trace : fTraces) {
trace.dispose();
+ }
fTraces = null;
}
super.dispose();
/**
* Selects the current, framework-wide, experiment
- *
+ *
* @param experiment das experiment
*/
public static void setCurrentExperiment(final TmfExperiment<?> experiment) {
/**
* Get the list of traces. Handle with care...
- *
+ *
* @return the experiment traces
*/
public ITmfTrace<T>[] getTraces() {
/**
* Returns the timestamp of the event at the requested index. If none,
* returns null.
- *
+ *
* @param index the event index (rank)
* @return the corresponding event timestamp
*/
/**
* Set the file to be used for bookmarks on this experiment
- *
+ *
* @param file the bookmarks file
*/
public void setBookmarksFile(final IFile file) {
/**
* Get the file used for bookmarks on this experiment
- *
+ *
* @return the bookmarks file or null if none is set
*/
public IFile getBookmarksFile() {
*/
@Override
protected synchronized ITmfContext armRequest(final ITmfDataRequest<T> request) {
-
+
// Make sure we have something to read from
if (fTraces == null) {
return null;
}
-
+
if (request instanceof ITmfEventRequest<?>
&& !TmfTimestamp.BIG_BANG.equals(((ITmfEventRequest<T>) request).getRange().getStartTime())
&& request.getIndex() == 0)
/* (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.core.trace.TmfTrace#seekEvent(long)
- *
+ *
* TmfTrace.seekEvent(rank) will return a context that will position the
* trace to read the event at rank 'rank' in the trace. In the case of an
* experiment context, that event has to be actually read in the fEvents
* buffer and the corresponding trace context has to point to the next
* event (rank + 1) in the trace (the sum of the traces contexts ranks
* should equal [exp context rank + #traces] (corner cases not considered).
- *
+ *
* In the likely case that TmfTrace.seekEvent() computed the context
* by using a read loop (reading from the experiment), the 'lastTraceRead'
* field will be set to the actual trace that needs to be read to obtain
* event at rank 'rank'.
- *
+ *
* Therefore, if 'lastTraceRead' is set, we need to read that particular
* trace *and* then decrease the context rank (which has to correspond to
* the rank of the event to be returned next by TmfExperiemnt.getNext().
/* (non-Javadoc)
*
- * Returns a brand new context based on the location provided and
+ * Returns a brand new context based on the location provided and
* initializes the event queues
- *
+ *
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfLocation)
*/
@Override
// Instantiate the location
final TmfExperimentLocation expLocation = (location == null)
- ? new TmfExperimentLocation(new TmfLocationArray(new ITmfLocation<?>[fTraces.length]))
+ ? new TmfExperimentLocation(new TmfLocationArray(new ITmfLocation<?>[fTraces.length]))
: (TmfExperimentLocation) location.clone();
// Create and populate the context's traces contexts
context.setRank(ITmfContext.UNKNOWN_RANK);
fExperimentContext = context;
- return (ITmfContext) context;
+ return context;
}
// ------------------------------------------------------------------------
*/
@Override
@SuppressWarnings("nls")
- public String toString() {
+ public synchronized String toString() {
return "[TmfExperiment (" + getName() + ")]";
}
if (getStreamingInterval() == 0) {
final ITmfContext context = seekEvent(0);
final ITmfEvent event = getNext(context);
- if (event == null)
+ if (event == null) {
return;
+ }
final TmfTimeRange timeRange = new TmfTimeRange(event.getTimestamp().clone(), TmfTimestamp.BIG_CRUNCH);
final TmfExperimentRangeUpdatedSignal signal = new TmfExperimentRangeUpdatedSignal(this, this, timeRange);
ITmfTimestamp startTimestamp = TmfTimestamp.BIG_CRUNCH;
ITmfTimestamp endTimestamp = TmfTimestamp.BIG_BANG;
for (final ITmfTrace<T> trace : fTraces) {
- if (trace.getStartTime().compareTo(startTimestamp) < 0)
+ if (trace.getStartTime().compareTo(startTimestamp) < 0) {
startTimestamp = trace.getStartTime();
- if (trace.getStreamingInterval() != 0 && trace.getEndTime().compareTo(endTimestamp) > 0)
+ }
+ if (trace.getStreamingInterval() != 0 && trace.getEndTime().compareTo(endTimestamp) > 0) {
endTimestamp = trace.getEndTime();
+ }
}
- if (safeTimestamp != null && safeTimestamp.compareTo(getTimeRange().getEndTime(), false) > 0)
+ if (safeTimestamp != null && safeTimestamp.compareTo(getTimeRange().getEndTime(), false) > 0) {
timeRange = new TmfTimeRange(startTimestamp, safeTimestamp);
- else
+ } else {
timeRange = null;
+ }
safeTimestamp = endTimestamp;
if (timeRange != null) {
final TmfExperimentRangeUpdatedSignal signal =
@Override
public long getStreamingInterval() {
long interval = 0;
- for (final ITmfTrace<T> trace : fTraces)
+ for (final ITmfTrace<T> trace : fTraces) {
interval = Math.max(interval, trace.getStreamingInterval());
+ }
return interval;
}
/**
* Signal handler for the TmfExperimentSelectedSignal signal
- *
+ *
* @param signal
*/
@TmfSignalHandler
/**
* Signal handler for the TmfEndSynchSignal signal
- *
+ *
* @param signal
*/
@TmfSignalHandler
/**
* Signal handler for the TmfTraceUpdatedSignal signal
- *
+ *
* @param signal
*/
@TmfSignalHandler
/**
* Signal handler for the TmfExperimentRangeUpdatedSignal signal
- *
+ *
* @param signal
*/
@TmfSignalHandler
import java.io.File;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
String traceName = (resource != null) ? resource.getName() : null;
// If no resource was provided, extract the display name the trace path
if (traceName == null) {
- final int sep = path.lastIndexOf(Path.SEPARATOR);
+ final int sep = path.lastIndexOf(IPath.SEPARATOR);
traceName = (sep >= 0) ? path.substring(sep + 1) : path;
}
if (fParser == null) {
/*******************************************************************************
* Copyright (c) 2011, 2012 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
- *
+ *
* Contributors:
* Francois Godin (copelnug@gmail.com) - Initial design and implementation
* Mathieu Denis (mathieu.denis@polymtl.ca) - Correction and refactoring
/**
* <h4>Allow to create a List object that contain an already existing array.</h4>
- * <p>Works like {@link java.util.Arrays#asList} but offers more functions :
+ * <p>Works like {@link java.util.Arrays#asList} but offers more functions :
* <ul>
* <li>{@link #hashCode()}</li>
* <li>{@link #equals(Object)}</li>
* @param array Array to use. WILL NOT BE COPIED.
*/
public TmfFixedArray(final T... array) {
- fArray = array;
+ fArray = array;
}
/**
* Append a FixedArray to this FixedArray.
*/
public TmfFixedArray<T> append(final TmfFixedArray<T>... values) {
int newLength = 0;
- for(TmfFixedArray<T> value : values)
+ for(TmfFixedArray<T> value : values) {
newLength += value.size();
+ }
TmfFixedArray<T> result = new TmfFixedArray<T>(copyOf(fArray, fArray.length + newLength));
newLength = fArray.length;
for(TmfFixedArray<T> value : values)
*/
public TmfFixedArray<T> append(final T... values) {
TmfFixedArray<T> result = new TmfFixedArray<T>(copyOf(fArray, fArray.length + values.length));
- for(int i = 0; i < values.length; ++i)
+ for(int i = 0; i < values.length; ++i) {
result.set(fArray.length + i, values[i]);
+ }
return result;
}
/*
*/
@Override
public boolean equals(Object o) {
- if(o instanceof TmfFixedArray<?>)
+ if(o instanceof TmfFixedArray<?>) {
return Arrays.equals(fArray, ((TmfFixedArray<?>)o).fArray);
- if(!(o instanceof List))
+ }
+ if(!(o instanceof List)) {
return false;
- for(int i = 0; i < fArray.length; ++i)
- if(!fArray[i].equals((List<?>)o))
+ }
+ for(int i = 0; i < fArray.length; ++i) {
+ if(!fArray[i].equals(o)) {
return false;
+ }
+ }
return true;
}
/*
@SuppressWarnings("unchecked")
public <E> E[] toArray(E[] array)
{
- if(array.length < fArray.length)
+ if(array.length < fArray.length) {
return copyOf(fArray, fArray.length,(Class<? extends E[]>)array.getClass());
+ }
System.arraycopy(fArray, 0, array, 0, fArray.length);
- if(array.length > fArray.length)
+ if(array.length > fArray.length) {
array[fArray.length] = null;
+ }
return array;
}
/*
try {\r
TmfFilterXMLWriter writerXML = new TmfFilterXMLWriter(fRoot);\r
writerXML.saveTree(SAVED_FILTERS_PATH_NAME);\r
- } catch (IOException e) {\r
- Activator.getDefault().logError("Error saving filter xml file: " + SAVED_FILTERS_PATH_NAME, e); //$NON-NLS-1$\r
} catch (ParserConfigurationException e) {\r
Activator.getDefault().logError("Error saving filter xml file: " + SAVED_FILTERS_PATH_NAME, e); //$NON-NLS-1$\r
}\r
\r
} catch (ParserConfigurationException e) {\r
Activator.getDefault().logError("Error parsing filter xml file", e); //$NON-NLS-1$\r
- } catch (IOException e) {\r
- Activator.getDefault().logError("Error parsing filter xml file", e); //$NON-NLS-1$\r
}\r
}\r
}\r