Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 7a9c9cb3ac4f996352b6beac4ffed677d840f0ce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*******************************************************************************
 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
 *
 * 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:
 *   Geneviève Bastien - Initial implementation and API
 *******************************************************************************/

package org.eclipse.tracecompass.tmf.core.synchronization;

import java.io.Serializable;
import java.util.Map;

import org.eclipse.tracecompass.tmf.core.event.matching.TmfEventDependency;
import org.eclipse.tracecompass.tmf.core.event.matching.TmfEventMatches;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;

/**
 * Abstract class for synchronization algorithm
 *
 * @author Geneviève Bastien
 */
public abstract class SynchronizationAlgorithm extends TmfEventMatches implements Serializable {

    private static final long serialVersionUID = -3083906749528872196L;

    /**
     * Quality of the result obtained by the synchronization algorithm
     */
    public enum SyncQuality {
        /**
         * Algorithm returned a result satisfying all hypothesis for the
         * algorithm
         */
        ACCURATE,
        /**
         * Best effort of the algorithm
         */
        APPROXIMATE,
        /**
         * There is communication only in one direction
         */
        INCOMPLETE,
        /**
         * No communication between two traces
         */
        ABSENT,
        /**
         * Hypothesis of the algorithm are not satisfied for some reason
         */
        FAIL
    }

    @Override
    public void addMatch(TmfEventDependency match) {
        super.addMatch(match);
        processMatch(match);
    }

    /**
     * Function for synchronization algorithm to do something with the received
     * match
     *
     * @param match
     *            The match of events
     */
    protected abstract void processMatch(TmfEventDependency match);

    /**
     * Returns a map of staticstics relating to this algorithm. Those stats
     * could be used to be displayed in a view for example.
     *
     * @return A map of statistics for this algorithm
     */
    public abstract Map<String, Map<String, Object>> getStats();

    /**
     * Returns a timestamp transformation algorithm
     *
     * @param trace
     *            The trace to get the transform for
     * @return The timestamp transformation formula
     */
    public abstract ITmfTimestampTransform getTimestampTransform(ITmfTrace trace);

    /**
     * Returns a timestamp transformation algorithm
     *
     * @param hostId
     *            The host ID of the trace to get the transform for
     * @return The timestamp transformation formula
     */
    public abstract ITmfTimestampTransform getTimestampTransform(String hostId);

    /**
     * Gets the quality of the synchronization between two given traces
     *
     * @param trace1
     *            First trace
     * @param trace2
     *            Second trace
     * @return The synchronization quality
     */
    public abstract SyncQuality getSynchronizationQuality(ITmfTrace trace1, ITmfTrace trace2);

    /**
     * Returns whether a given trace has a synchronization formula that is not
     * identity. This function returns true if the synchronization algorithm has
     * failed for some reason
     *
     * @param hostId
     *            The host ID of the trace
     * @return true if trace has formula
     */
    public abstract boolean isTraceSynced(String hostId);

}

Back to the top