7a9c9cb3ac4f996352b6beac4ffed677d840f0ce
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / synchronization / SynchronizationAlgorithm.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
3 *
4 * All rights reserved. This program and the accompanying materials are made
5 * available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Geneviève Bastien - Initial implementation and API
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.tmf.core.synchronization;
14
15 import java.io.Serializable;
16 import java.util.Map;
17
18 import org.eclipse.tracecompass.tmf.core.event.matching.TmfEventDependency;
19 import org.eclipse.tracecompass.tmf.core.event.matching.TmfEventMatches;
20 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
21
22 /**
23 * Abstract class for synchronization algorithm
24 *
25 * @author Geneviève Bastien
26 */
27 public abstract class SynchronizationAlgorithm extends TmfEventMatches implements Serializable {
28
29 private static final long serialVersionUID = -3083906749528872196L;
30
31 /**
32 * Quality of the result obtained by the synchronization algorithm
33 */
34 public enum SyncQuality {
35 /**
36 * Algorithm returned a result satisfying all hypothesis for the
37 * algorithm
38 */
39 ACCURATE,
40 /**
41 * Best effort of the algorithm
42 */
43 APPROXIMATE,
44 /**
45 * There is communication only in one direction
46 */
47 INCOMPLETE,
48 /**
49 * No communication between two traces
50 */
51 ABSENT,
52 /**
53 * Hypothesis of the algorithm are not satisfied for some reason
54 */
55 FAIL
56 }
57
58 @Override
59 public void addMatch(TmfEventDependency match) {
60 super.addMatch(match);
61 processMatch(match);
62 }
63
64 /**
65 * Function for synchronization algorithm to do something with the received
66 * match
67 *
68 * @param match
69 * The match of events
70 */
71 protected abstract void processMatch(TmfEventDependency match);
72
73 /**
74 * Returns a map of staticstics relating to this algorithm. Those stats
75 * could be used to be displayed in a view for example.
76 *
77 * @return A map of statistics for this algorithm
78 */
79 public abstract Map<String, Map<String, Object>> getStats();
80
81 /**
82 * Returns a timestamp transformation algorithm
83 *
84 * @param trace
85 * The trace to get the transform for
86 * @return The timestamp transformation formula
87 */
88 public abstract ITmfTimestampTransform getTimestampTransform(ITmfTrace trace);
89
90 /**
91 * Returns a timestamp transformation algorithm
92 *
93 * @param hostId
94 * The host ID of the trace to get the transform for
95 * @return The timestamp transformation formula
96 */
97 public abstract ITmfTimestampTransform getTimestampTransform(String hostId);
98
99 /**
100 * Gets the quality of the synchronization between two given traces
101 *
102 * @param trace1
103 * First trace
104 * @param trace2
105 * Second trace
106 * @return The synchronization quality
107 */
108 public abstract SyncQuality getSynchronizationQuality(ITmfTrace trace1, ITmfTrace trace2);
109
110 /**
111 * Returns whether a given trace has a synchronization formula that is not
112 * identity. This function returns true if the synchronization algorithm has
113 * failed for some reason
114 *
115 * @param hostId
116 * The host ID of the trace
117 * @return true if trace has formula
118 */
119 public abstract boolean isTraceSynced(String hostId);
120
121 }
This page took 0.035076 seconds and 4 git commands to generate.