Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model')
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/Config.java76
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/GraphScaledData.java246
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/IGraphDataModel.java41
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/IGraphModelListener.java31
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/LatencyController.java188
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/LatencyEventRequest.java92
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/LatencyGraphModel.java380
7 files changed, 0 insertions, 1054 deletions
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/Config.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/Config.java
deleted file mode 100644
index d9533b5097..0000000000
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/Config.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 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:
- * Philippe Sawicki (INF4990.A2010@gmail.com) - Initial API and implementation
- * Mathieu Denis (mathieu.denis55@gmail.com) - Refactor code
- * Bernd Hufmann - Added and updated constants
- *******************************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.latency.model;
-
-/**
- * <b><u>Config</u></b>
- * <p>
- * Configuration class, holds some application constants.
- *
- * @author Philippe Sawicki
- */
-public class Config {
-
- /**
- * Private constructor to defeat instantiation.
- */
- private Config() {
- }
-
- /**
- * Time scale for TMF events;
- */
- public static final byte TIME_SCALE = -9;
-
- /**
- * Size of the point buffer holding point values before sending them to the view.
- */
- public static final int POINT_BUFFER_SIZE = 10000;
-
- /**
- * Histogram bar width.
- */
- public static final int DEFAULT_HISTOGRAM_BAR_WIDTH = 2;
-
- /**
- * Histogram bar width increase step.
- */
- public static final int MIN_HISTOGRAM_BAR_WIDTH = 1;
-
- /**
- * Histogram bar width increase step.
- */
- public static final int MAX_HISTOGRAM_BAR_WIDTH = 16;
-
-
- /**
- * Diameter of a point drawn on the chart (in pixels).
- */
- public static final int GRAPH_POINT_DIAMETER = 1;
-
- /**
- * Graph padding.
- */
- public static final int GRAPH_PADDING = 10;
-
- /**
- * Default number of buckets used in data models
- */
- public static final int DEFAULT_NUMBER_OF_BUCKETS = 2 * 1000;
-
- /**
- * Invalid event time
- */
- public static final long INVALID_EVENT_TIME = -1;
-} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/GraphScaledData.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/GraphScaledData.java
deleted file mode 100644
index 010389afc1..0000000000
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/GraphScaledData.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.latency.model;
-
-/**
- * <b><u>GraphScaledData</u></b>
- * Convenience class for scaled distribution data.
- * <p>
- */
-import java.util.Arrays;
-
-import org.eclipse.linuxtools.tmf.ui.views.distribution.model.BaseDistributionData;
-
-public class GraphScaledData {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private int fWidth;
- private int fHeight;
- private int fBarWidth;
- private int[][] fData;
- private BaseDistributionData fHorDistributionData;
- private BaseDistributionData fVerDistributionData;
- private long fCurrentEventTime;
-
- // ------------------------------------------------------------------------
- // Constructor
- // ------------------------------------------------------------------------
-
- public GraphScaledData(int width, int height, int barWidth) {
- fWidth = width;
- fHeight = height;
- fBarWidth = barWidth;
- int horNbBuckets = (int)width/barWidth;
- int verNbBuckets = (int)height/barWidth;
- fData = new int[horNbBuckets][verNbBuckets];
- for (int[] row : fData) {
- Arrays.fill(row, 0);
- }
- fHorDistributionData = new BaseDistributionData(horNbBuckets);
- fHorDistributionData.clear();
-
- fVerDistributionData = new BaseDistributionData(verNbBuckets);
- fVerDistributionData.clear();
-
- fCurrentEventTime = Config.INVALID_EVENT_TIME;
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- public int getWidth() {
- return fWidth;
- }
-
- public int getHeight() {
- return fHeight;
- }
-
- public int getBarWidth() {
- return fBarWidth;
- }
-
- public int[][] getData() {
- return fData;
- }
-
- public int getHorNbBuckets() {
- return fHorDistributionData.getNbBuckets();
- }
-
- public int getVerNbBuckets() {
- return fVerDistributionData.getNbBuckets();
- }
-
- public long getHorFirstBucketTime() {
- return fHorDistributionData.getFirstBucketTime();
- }
-
- public long getVerFirstBucketTime() {
- return fVerDistributionData.getFirstBucketTime();
- }
-
- public long getHorLastBucketTime() {
- return fHorDistributionData.getLastBucketTime();
- }
-
- public long getVerLastBucketTime() {
- return fVerDistributionData.getLastBucketTime();
- }
-
- public long getHorFirstEventTime() {
- return fHorDistributionData.getFirstEventTime();
- }
-
- public long getVerFirstEventTime() {
- return fVerDistributionData.getFirstEventTime();
- }
-
- public long getHorLastEventTime() {
- return fHorDistributionData.getLastEventTime();
- }
-
- public long getVerLastEventTime() {
- return fVerDistributionData.getLastEventTime();
- }
-
- public long getHorBucketDuration() {
- return fHorDistributionData.getBucketDuration();
- }
-
- public long getVerBucketDuration() {
- return fVerDistributionData.getBucketDuration();
- }
-
- public int getHorLastBucket() {
- return fHorDistributionData.getLastBucket();
- }
-
- public int getVerLastBucket() {
- return fVerDistributionData.getLastBucket();
- }
-
- public long getHorBucketStartTime(int index) {
- return fHorDistributionData.getBucketStartTime(index);
- }
-
- public long getHorBucketEndTime(int index) {
- return fHorDistributionData.getBucketEndTime(index);
- }
-
- public long getVerBucketStartTime(int index) {
- return fVerDistributionData.getBucketStartTime(index);
- }
-
- public long getVerBucketEndTime(int index) {
- return fVerDistributionData.getBucketEndTime(index);
- }
-
- public int getEventCount(int horIndex, int verIndex) {
- return fData[horIndex][verIndex];
- }
-
- public long getCurrentEventTime() {
- return fCurrentEventTime;
- }
-
- public boolean isCurrentEventTimeValid() {
- if (fCurrentEventTime == Config.INVALID_EVENT_TIME || fCurrentEventTime < getHorFirstEventTime() || fCurrentEventTime > getHorLastEventTime()) {
- return false;
- }
- return true;
- }
-
- public int getHorBucketIndex(long time) {
- return fHorDistributionData.getIndex(time);
- }
-
- public int getVerBucketIndex(long time) {
- return fVerDistributionData.getIndex(time);
- }
-
- public boolean isHorIndexValid(int index) {
- return fHorDistributionData.isIndexValid(index);
- }
-
- public boolean isVerIndexValid(int index) {
- return fVerDistributionData.isIndexValid(index);
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- public void setWidth(int width) {
- fWidth = width;
- }
-
- public void setHeight(int height) {
- fHeight = height;
- }
-
- public void setBarWidth(int barWidth) {
- fBarWidth = barWidth;
- }
-
- public void setData(int[][] data) {
- fData = data;
- }
-
- public void setHorFirstBucketTime(long firstBucketTime) {
- fHorDistributionData.setFirstBucketTime(firstBucketTime);
- }
-
- public void setVerFirstBucketTime(long firstBucketTime) {
- fVerDistributionData.setFirstBucketTime(firstBucketTime);
- }
-
- public void setHorFirstEventTime(long firstEventTime) {
- fHorDistributionData.setFirstEventTime(firstEventTime);
- }
-
- public void setVerFirstEventTime(long firstEventTime) {
- fVerDistributionData.setFirstEventTime(firstEventTime);
- }
-
- public void setHorLastEventTime(long lastEventTime) {
- fHorDistributionData.setLastEventTime(lastEventTime);
- }
-
- public void setVerLastEventTime(long lastEventTime) {
- fVerDistributionData.setLastEventTime(lastEventTime);
- }
-
- public void setHorBucketDuration(long bucketDuration) {
- fHorDistributionData.setBucketDuration(bucketDuration);
- }
-
- public void setVerBucketDuration(long bucketDuration) {
- fVerDistributionData.setBucketDuration(bucketDuration);
- }
-
- public void setHorLastBucket(int lastBucket) {
- fHorDistributionData.setLastBucket(lastBucket);
- }
-
- public void setVerLastBucket(int lastBucket) {
- fVerDistributionData.setLastBucket(lastBucket);
- }
-
- public void setCurrentEventTime(long currentEventTime) {
- fCurrentEventTime = currentEventTime;
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/IGraphDataModel.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/IGraphDataModel.java
deleted file mode 100644
index f1a19c3bb3..0000000000
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/IGraphDataModel.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.latency.model;
-
-import org.eclipse.linuxtools.tmf.ui.views.distribution.model.IBaseDistributionModel;
-
-/**
- * <b><u>IGraphDataModel</u></b>
- * <p>
- */
-public interface IGraphDataModel extends IBaseDistributionModel {
-
- /**
- * Add event to the correct bucket, compacting the if needed.
- *
- * @param eventCount - the event count
- * @param timestamp - the timestamp (x-coordinate) of the event to count
- * @param time - the time (y-coordinate) of the event to count
- */
- public void countEvent(int eventCount, long timestamp, long time);
-
- /**
- * Scale the model data to the width and height requested.
- *
- * @param width - width of graph
- * @param height - height of graph
- * @param barWidth - width of bar
- * @return the result array of size [width] and where the highest value
- * doesn't exceed [height]
- */
- public GraphScaledData scaleTo(int width, int height, int barWidth);
-}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/IGraphModelListener.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/IGraphModelListener.java
deleted file mode 100644
index 086b56399d..0000000000
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/IGraphModelListener.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-
-package org.eclipse.linuxtools.internal.lttng.ui.views.latency.model;
-
-/**
- * <b><u>IGraphModelListener</u></b>
- * <p>
- */
-public interface IGraphModelListener {
-
- /**
- * Method to notify listeners about model updates
- */
- public void graphModelUpdated();
-
- /**
- * Method to inform listeners about current time updates
- */
- public void currentEventUpdated(long currentEventTime);
-
-}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/LatencyController.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/LatencyController.java
deleted file mode 100644
index 38f5bc9148..0000000000
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/LatencyController.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-
-package org.eclipse.linuxtools.internal.lttng.ui.views.latency.model;
-
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
-import org.eclipse.linuxtools.tmf.ui.views.distribution.model.IBaseDistributionModel;
-import org.eclipse.linuxtools.tmf.ui.views.histogram.IHistogramDataModel;
-
-/**
- * <b><u>LatencyController</u></b>
- * <p>
- */
-public class LatencyController {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private static LatencyController fInstance = null;
-
- private LatencyEventRequest fEventRequest;
-
- private TmfEventProvider fProvider;
-
- private final ListenerList fModels;
-
- // ------------------------------------------------------------------------
- // Constructor
- // ------------------------------------------------------------------------
-
- private LatencyController() {
- fModels = new ListenerList();
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- public static LatencyController getInstance() {
- if (fInstance == null) {
- fInstance = new LatencyController();
- }
- return fInstance;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /**
- * Refresh all registered models
- *
- * @param provider - TmfEventProvider to request data from
- * @param timeRange - time range of request
- */
- public void refreshModels(TmfEventProvider provider, TmfTimeRange timeRange) {
- // save provider
- fProvider = provider;
- if (fProvider != null) {
- if (fEventRequest != null && !fEventRequest.isCompleted()) {
- fEventRequest.cancel();
- }
- clear();
- fEventRequest = new LatencyEventRequest(this, timeRange, ExecutionType.FOREGROUND);
- fProvider.sendRequest((TmfDataRequest)fEventRequest);
- }
- }
-
- /**
- * Refreshes registered models by re-sending previous request to saved provider
- */
- public void refreshModels() {
- if (fProvider != null && fEventRequest != null) {
- refreshModels(fProvider, fEventRequest.getRange());
- }
- }
-
- /**
- * Clear all models
- */
- public void clear() {
- Object models[] = fModels.getListeners();
-
- for (int i = 0; i < models.length; i++) {
- ((IBaseDistributionModel)models[i]).clear();
- }
- }
-
- /**
- * Dispose of controller
- */
- public void dispose() {
- if (fEventRequest != null && !fEventRequest.isCompleted()) {
- fEventRequest.cancel();
- }
- fProvider = null;
- }
-
- /**
- * Register given model.
- * @param model - model to register
- */
- public void registerModel(IBaseDistributionModel model) {
- fModels.add(model);
- }
-
- /**
- * Deregister given model.
- *
- * @param model - model to deregister
- */
- public void deregisterModel(IBaseDistributionModel model) {
- fModels.remove(model);
- }
-
- /**
- * Handle data of event request and pass it information to the registered models
- *
- * @param eventCount - event count
- * @param timestamp - start timestamp of latency calculation
- * @param latency - latency value (startTimestamp - endTimestamp)
- */
- public void handleData(int eventCount, long timestamp, long latency) {
- Object[] models = fModels.getListeners();
- for (int i = 0; i < models.length; i++) {
- IBaseDistributionModel model = (IBaseDistributionModel)models[i];
- if (model instanceof IHistogramDataModel) {
- ((IHistogramDataModel)model).countEvent(eventCount, latency);
- } else if (model instanceof IGraphDataModel) {
- ((IGraphDataModel)model).countEvent(eventCount, timestamp, latency);
- }
- }
- }
-
- /**
- * Handle complete indication from request.
- */
- public void handleCompleted() {
- Object[] models = fModels.getListeners();
- for (int i = 0; i < models.length; i++) {
- ((IBaseDistributionModel)models[i]).complete();
- }
- }
-
- /**
- * Handle cancel indication from request.
- */
- public void handleCancel() {
- clear();
- }
-
- /**
- * Set event provider for refresh.
- *
- * @param provider
- */
- public void setEventProvider(TmfEventProvider provider) {
- fProvider = provider;
- }
-
- /**
- * Set current event time in model(s).
- *
- * @param timestamp
- */
- public void setCurrentEventTime(long timestamp) {
- Object[] models = fModels.getListeners();
- for (int i = 0; i < models.length; i++) {
- IBaseDistributionModel model = (IBaseDistributionModel)models[i];
- if (model instanceof LatencyGraphModel) {
- ((LatencyGraphModel)model).setCurrentEventNotifyListeners(timestamp);
- }
- }
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/LatencyEventRequest.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/LatencyEventRequest.java
deleted file mode 100644
index 7ecafab346..0000000000
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/LatencyEventRequest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-
-package org.eclipse.linuxtools.internal.lttng.ui.views.latency.model;
-
-import org.eclipse.linuxtools.internal.lttng.core.LttngConstants;
-import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
-import org.eclipse.linuxtools.internal.lttng.core.latency.analyzer.EventMatcher;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-
-/**
- * <b><u>LatencyEventRequest</u></b>
- * <p>
- */
-public class LatencyEventRequest extends TmfEventRequest {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- final private LatencyController fController;
-
- // ------------------------------------------------------------------------
- // Constructor
- // ------------------------------------------------------------------------
-
- public LatencyEventRequest(LatencyController controller, TmfTimeRange range, int rank, int nbEvents, ITmfDataRequest.ExecutionType execType) {
- super(LttngEvent.class, range, rank, nbEvents, LttngConstants.DEFAULT_BLOCK_SIZE, execType);
- fController = controller;
- EventMatcher.getInstance().clearStack();
- }
-
- public LatencyEventRequest(LatencyController controller, TmfTimeRange range, ITmfDataRequest.ExecutionType execType) {
- this(controller, range, 0, ALL_DATA, execType);
- }
-
- public LatencyEventRequest(LatencyController controller, TmfTimeRange range, int rank, ITmfDataRequest.ExecutionType execType) {
- this(controller, range, rank, ALL_DATA, execType);
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleData(org.eclipse.linuxtools.tmf.event.TmfData)
- */
- @Override
- public void handleData(ITmfEvent event) {
- super.handleData(event);
-
- LttngEvent startEvent = EventMatcher.getInstance().process(event);
-
- if (startEvent != null) {
- long latency = event.getTimestamp().getValue() - startEvent.getTimestamp().getValue();
- fController.handleData(getNbRead(), startEvent.getTimestamp().getValue(), latency);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleCompleted()
- */
- @Override
- public void handleCompleted() {
- fController.handleCompleted();
- super.handleCompleted();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleCancel()
- */
- @Override
- public void handleCancel() {
- EventMatcher.getInstance().clearStack();
- fController.handleCancel();
- super.handleCancel();
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/LatencyGraphModel.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/LatencyGraphModel.java
deleted file mode 100644
index fd5d2dc3aa..0000000000
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/latency/model/LatencyGraphModel.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-
-package org.eclipse.linuxtools.internal.lttng.ui.views.latency.model;
-
-import java.util.Arrays;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.linuxtools.internal.lttng.ui.views.distribution.model.DistributionData;
-import org.eclipse.linuxtools.internal.lttng.ui.views.distribution.model.HorDistributionData;
-import org.eclipse.linuxtools.internal.lttng.ui.views.distribution.model.VerDistributionData;
-
-/**
- * <b><u>LatencyGraphModel</u></b>
- * <p>
- */
-public class LatencyGraphModel implements IGraphDataModel {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- private final int fNbBuckets;
- private final int [][] fBuckets;
- private final DistributionData fHorDistributionData;
- private final DistributionData fVerDistributionData;
- private long fCurrentEventTime;
-
- // private listener lists
- private final ListenerList fModelListeners;
-
- private final ReentrantLock fLock;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- public LatencyGraphModel() {
- this(Config.DEFAULT_NUMBER_OF_BUCKETS);
- }
-
- public LatencyGraphModel(int nbBuckets) {
- fNbBuckets = nbBuckets;
- fBuckets = new int[nbBuckets][nbBuckets];
- fHorDistributionData = new HorDistributionData(nbBuckets, fBuckets);
- fVerDistributionData = new VerDistributionData(nbBuckets, fBuckets);
- fCurrentEventTime = Config.INVALID_EVENT_TIME;
-
- fModelListeners = new ListenerList();
- fLock = new ReentrantLock();
- clear();
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- public int getNbBuckets() {
- return fNbBuckets;
- }
-
- public long getHorBucketDuration() {
- fLock.lock();
- try {
- return fHorDistributionData.getBucketDuration();
- } finally {
- fLock.unlock();
- }
- }
-
- public long getVerBucketDuration() {
- fLock.lock();
- try {
- return fVerDistributionData.getBucketDuration();
- } finally {
- fLock.unlock();
- }
- }
-
- public long getHorFirstBucketTime() {
- fLock.lock();
- try {
- return fHorDistributionData.getFirstBucketTime();
- } finally {
- fLock.unlock();
- }
- }
-
- public long getVerFirstBucketTime() {
- fLock.lock();
- try {
- return fVerDistributionData.getFirstBucketTime();
- } finally {
- fLock.unlock();
- }
- }
-
- public long getHorFirstEventTime() {
- fLock.lock();
- try {
- return fHorDistributionData.getFirstEventTime();
- } finally {
- fLock.unlock();
- }
- }
-
- public long getVerFirstEventTime() {
- fLock.lock();
- try {
- return fVerDistributionData.getFirstEventTime();
- } finally {
- fLock.unlock();
- }
- }
-
- public long getHorLastEventTime() {
- fLock.lock();
- try {
- return fHorDistributionData.getLastEventTime();
- } finally {
- fLock.unlock();
- }
- }
-
- public long getVerLastEventTime() {
- fLock.lock();
- try {
- return fVerDistributionData.getLastEventTime();
- } finally {
- fLock.unlock();
- }
- }
-
- public long getHorTimeLimit() {
- fLock.lock();
- try {
- return fHorDistributionData.getTimeLimit();
- } finally {
- fLock.unlock();
- }
- }
-
- public long getVerTimeLimit() {
- fLock.lock();
- try {
- return fVerDistributionData.getTimeLimit();
- } finally {
- fLock.unlock();
- }
- }
-
- public int getHorLastBucket() {
- fLock.lock();
- try {
- return fHorDistributionData.getLastBucket();
- } finally {
- fLock.unlock();
- }
- }
-
- public int getVerLastBucket() {
- fLock.lock();
- try {
- return fVerDistributionData.getLastBucket();
- } finally {
- fLock.unlock();
- }
- }
-
- public long getCurrentEventTime() {
- fLock.lock();
- try {
- return fCurrentEventTime;
- } finally {
- fLock.unlock();
- }
- }
-
- // ------------------------------------------------------------------------
- // Listener interface
- // ------------------------------------------------------------------------
- public void addGraphModelListener(IGraphModelListener listener) {
- fModelListeners.add(listener);
- }
-
- public void removeGraphModelListener(IGraphModelListener listener) {
- fModelListeners.remove(listener);
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.distribution.model.IBaseDataModel#clear()
- */
- @Override
- public void clear() {
- fLock.lock();
- try {
- for (int[] row : fBuckets) {
- Arrays.fill(row, 0, fNbBuckets, 0);
- }
- fHorDistributionData.clear();
- fVerDistributionData.clear();
- } finally {
- fLock.unlock();
- }
- fireModelUpdateNotification();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.latency.model.IGraphDataModel#countEvent(int, long, long)
- */
- @Override
- public void countEvent(int eventCount, long timestamp, long time) {
- fLock.lock();
- try {
- int horIndex = fHorDistributionData.countEvent(timestamp);
- int verIndex = fVerDistributionData.countEvent(time);
-
- fBuckets[horIndex][verIndex]++;
- } finally {
- fLock.unlock();
- }
-
- fireModelUpdateNotification(eventCount);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.latency.model.IGraphDataModel#scaleTo(int, int, int)
- */
- @Override
- public GraphScaledData scaleTo(int width, int height, int barWidth) {
- GraphScaledData scaledData = new GraphScaledData(width, height, barWidth);
- fLock.lock();
- try {
- if (!fHorDistributionData.isFirst() && !fVerDistributionData.isFirst() ) {
-
- // Basic validation
- if (width <= 0 || height <= 0 || barWidth <= 0)
- throw new AssertionError("Invalid histogram dimensions (" + width + "x" + height + ", barWidth=" + barWidth + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
-
- // Scale horizontally
- int nbBars = width / barWidth;
- int bucketsPerBar = fHorDistributionData.getLastBucket() / nbBars + 1;
-
- int horData[][] = new int[nbBars][fNbBuckets];
- for (int y = 0; y < fNbBuckets; y++) {
- for (int i = 0; i < nbBars; i++) {
- int count = 0;
- for (int j = i * bucketsPerBar; j < (i + 1) * bucketsPerBar; j++) {
- if (fNbBuckets <= j)
- break;
- count += fBuckets[j][y];
- }
- horData[i][y] = count;
- }
- }
-
- // Scale vertically
- int nbVerBars = height / barWidth;
- int bucketsPerVerBar = fVerDistributionData.getLastBucket() / nbVerBars + 1;
-
- int verData[][] = new int[nbBars][nbVerBars];
- for (int x = 0; x < nbBars; x++) {
- for (int i = 0; i < nbVerBars; i++) {
- int count = 0;
- for (int j = i * bucketsPerVerBar; j < (i + 1) * bucketsPerVerBar; j++) {
- if (fNbBuckets <= j)
- break;
- count += horData[x][j];
- }
- verData[x][i] = count;
- }
- }
-
- scaledData.setData(verData);
- scaledData.setHorFirstBucketTime(fHorDistributionData.getFirstBucketTime());
- scaledData.setVerFirstBucketTime(fVerDistributionData.getFirstBucketTime());
- scaledData.setHorFirstEventTime(fHorDistributionData.getFirstEventTime());
- scaledData.setVerFirstEventTime(fVerDistributionData.getFirstEventTime());
- scaledData.setHorLastEventTime(fHorDistributionData.getLastEventTime());
- scaledData.setVerLastEventTime(fVerDistributionData.getLastEventTime());
- scaledData.setHorBucketDuration(bucketsPerBar * fHorDistributionData.getBucketDuration());
- scaledData.setVerBucketDuration(bucketsPerVerBar * fVerDistributionData.getBucketDuration());
- scaledData.setHorLastBucket(fHorDistributionData.getLastBucket() / bucketsPerBar);
- scaledData.setVerLastBucket(fVerDistributionData.getLastBucket() / bucketsPerVerBar);
- scaledData.setCurrentEventTime(fCurrentEventTime);
- }
- } finally {
- fLock.unlock();
- }
-
- return scaledData;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.distribution.model.IBaseDataModel#complete()
- */
- @Override
- public void complete() {
- fireModelUpdateNotification();
- }
-
- /**
- * Sets the current event time but don't notify listeners.
- *
- * @param timestamp
- */
- public void setCurrentEvent(long timestamp) {
- fLock.lock();
- try {
- fCurrentEventTime = timestamp;
- } finally {
- fLock.unlock();
- }
- }
-
- /**
- * Sets the current event time and notify listeners.
- *
- * @param timestamp
- */
- public void setCurrentEventNotifyListeners(long timestamp) {
- fLock.lock();
- try {
- fCurrentEventTime = timestamp;
- } finally {
- fLock.unlock();
- }
- fireCurrentEventUpdateNotification();
- }
-
- // ------------------------------------------------------------------------
- // Helper functions
- // ------------------------------------------------------------------------
-
- /*
- * Notify listeners immediately
- */
- private void fireModelUpdateNotification() {
- fireModelUpdateNotification(0);
- }
-
- /*
- * Notify listeners with certain refresh rate.
- */
- private void fireModelUpdateNotification(int count) {
- if (count % Config.POINT_BUFFER_SIZE == 0) {
- Object[] listeners = fModelListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- IGraphModelListener listener = (IGraphModelListener) listeners[i];
- listener.graphModelUpdated();
- }
- }
- }
-
- /*
- * Notify listeners immediately
- */
- private void fireCurrentEventUpdateNotification() {
- Object[] listeners = fModelListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- IGraphModelListener listener = (IGraphModelListener) listeners[i];
- listener.currentEventUpdated(fCurrentEventTime);
- }
- }
-}

Back to the top