/*******************************************************************************
- * Copyright (c) 2009, 2010, 2012 Ericsson
+ * 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
*
* Contributors:
* Francois Chouinard - Initial API and implementation
- * Francois Chouinard - Replace background requests by pre-emptible requests
- * Francois Chouinard - Rebased on TmfCoalescedRequest:s
+ * Francois Chouinard - Replace background requests by pre-emptable requests
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.component;
import org.eclipse.linuxtools.internal.tmf.core.TmfCoreTracer;
import org.eclipse.linuxtools.internal.tmf.core.component.TmfEventThread;
import org.eclipse.linuxtools.internal.tmf.core.component.TmfProviderManager;
-import org.eclipse.linuxtools.internal.tmf.core.request.TmfCoalescedRequest;
+import org.eclipse.linuxtools.internal.tmf.core.request.TmfCoalescedDataRequest;
import org.eclipse.linuxtools.internal.tmf.core.request.TmfRequestExecutor;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfRequest;
-import org.eclipse.linuxtools.tmf.core.request.ITmfRequest.TmfRequestPriority;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
+import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.core.signal.TmfStartSynchSignal;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
/**
- * An abstract base class that implements ITmfEventProvider.
+ * An abstract base class that implements ITmfDataProvider.
* <p>
* This abstract class implements the housekeeping methods to register/
* de-register the event provider and to handle generically the event requests.
* @author Francois Chouinard
* @version 1.1
*/
-public abstract class TmfDataProvider extends TmfComponent implements ITmfEventProvider {
+public abstract class TmfDataProvider extends TmfComponent implements ITmfDataProvider {
// ------------------------------------------------------------------------
// Constants
private int fRequestPendingCounter = 0;
- /** List of coalesced requests */
- protected Vector<TmfCoalescedRequest> fPendingCoalescedRequests = new Vector<TmfCoalescedRequest>();
-
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
fSignalDepth = 0;
fLogData = TmfCoreTracer.isEventTraced();
+// fLogError = TmfCoreTracer.isErrorTraced();
TmfProviderManager.register(fType, this);
}
TmfProviderManager.deregister(fType, this);
fExecutor.stop();
super.dispose();
+ // if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "stopped");
}
// ------------------------------------------------------------------------
// ITmfRequestHandler
// ------------------------------------------------------------------------
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.core.component.ITmfEventProvider#sendRequest(org.eclipse.linuxtools.tmf.core.request.ITmfRequest)
- */
- /**
- * @since 2.0
- */
@Override
- public void sendRequest(final ITmfRequest request) {
+ public void sendRequest(final ITmfDataRequest request) {
synchronized (fLock) {
if (fSignalDepth > 0) {
coalesceDataRequest(request);
}
}
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.core.component.ITmfEventProvider#fireRequest()
- */
- /**
- * @since 2.0
- */
@Override
public void fireRequest() {
synchronized (fLock) {
return;
}
if (fPendingCoalescedRequests.size() > 0) {
- for (ITmfRequest request : fPendingCoalescedRequests) {
+ for (TmfDataRequest request : fPendingCoalescedRequests) {
dispatchRequest(request);
}
fPendingCoalescedRequests.clear();
// Coalescing (primitive test...)
// ------------------------------------------------------------------------
+ /** List of coalesced requests */
+ protected Vector<TmfCoalescedDataRequest> fPendingCoalescedRequests = new Vector<TmfCoalescedDataRequest>();
+
/**
* Create a new request from an existing one, and add it to the coalesced
* requests
*
- * @param request The request to copy
- * @since 2.0
+ * @param request
+ * The request to copy
*/
- protected void newCoalescedDataRequest(ITmfRequest request) {
+ protected void newCoalescedDataRequest(ITmfDataRequest request) {
synchronized (fLock) {
- TmfCoalescedRequest coalescedRequest = new TmfCoalescedRequest(request);
+ TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(request.getDataType(), request.getIndex(),
+ request.getNbRequested(), request.getBlockSize(), request.getExecType());
+ coalescedRequest.addRequest(request);
if (TmfCoreTracer.isRequestTraced()) {
TmfCoreTracer.traceRequest(request, "COALESCED with " + coalescedRequest.getRequestId()); //$NON-NLS-1$
TmfCoreTracer.traceRequest(coalescedRequest, "now contains " + coalescedRequest.getSubRequestIds()); //$NON-NLS-1$
/**
* Add an existing requests to the list of coalesced ones
*
- * @param request The request to add to the list
- * @since 2.0
+ * @param request
+ * The request to add to the list
*/
- protected void coalesceDataRequest(ITmfRequest request) {
+ protected void coalesceDataRequest(ITmfDataRequest request) {
synchronized (fLock) {
- for (TmfCoalescedRequest coalescedRequest : fPendingCoalescedRequests) {
+ for (TmfCoalescedDataRequest coalescedRequest : fPendingCoalescedRequests) {
if (coalescedRequest.isCompatible(request)) {
coalescedRequest.addRequest(request);
if (TmfCoreTracer.isRequestTraced()) {
// Request processing
// ------------------------------------------------------------------------
- private void dispatchRequest(final ITmfRequest request) {
- if (request.getRequestPriority() == TmfRequestPriority.HIGH) {
+ private void dispatchRequest(final ITmfDataRequest request) {
+ if (request.getExecType() == ExecutionType.FOREGROUND) {
queueRequest(request);
} else {
- queueBackgroundRequest(request, true);
+ queueBackgroundRequest(request, request.getBlockSize(), true);
}
}
/**
* Queue a request.
*
- * @param request The data request
- * @since 2.0
+ * @param request
+ * The data request
*/
- protected void queueRequest(final ITmfRequest request) {
+ protected void queueRequest(final ITmfDataRequest request) {
if (fExecutor.isShutdown()) {
request.cancel();
/**
* Queue a background request
*
- * @param request The request
- * @param indexing Should we index the chunks
-<<<<<<< Upstream, based on master
- *
-=======
->>>>>>> f5b88da Refactor TmfRequest
- * @since 2.0
+ * @param request
+ * The request
+ * @param blockSize
+ * The request should be split in chunks of this size
+ * @param indexing
+ * Should we index the chunks
*/
- protected void queueBackgroundRequest(final ITmfRequest request, final boolean indexing) {
+ protected void queueBackgroundRequest(final ITmfDataRequest request, final int blockSize, final boolean indexing) {
queueRequest(request);
}
* serviced
* @since 2.0
*/
- public abstract ITmfContext armRequest(ITmfRequest request);
+ public abstract ITmfContext armRequest(ITmfDataRequest request);
// /**
// * Return the next event based on the context supplied. The context
* Checks if the data meets the request completion criteria.
*
* @param request the request
- * @param event the event to check
+ * @param data the data to verify
* @param nbRead the number of events read so far
* @return true if completion criteria is met
-<<<<<<< Upstream, based on master
- *
-=======
->>>>>>> f5b88da Refactor TmfRequest
- * @since 2.0
*/
- public boolean isCompleted(ITmfRequest request, ITmfEvent event, int nbRead) {
- return request.isCompleted() ||
- nbRead >= request.getNbRequested() ||
- request.getTimeRange().getEndTime().compareTo(event.getTimestamp()) < 0;
+ public boolean isCompleted(ITmfDataRequest request, ITmfEvent data, int nbRead) {
+ return request.isCompleted() || nbRead >= request.getNbRequested();
}
// ------------------------------------------------------------------------