lttng: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / analysis / os / linux / core / model / HostThread.java
CommitLineData
4a74f111
MG
1/*******************************************************************************
2 * Copyright (c) 2014 École Polytechnique de Montréal
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made 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 API and implementation
11 *******************************************************************************/
12
a6145763 13package org.eclipse.tracecompass.analysis.os.linux.core.model;
4a74f111
MG
14
15import org.eclipse.jdt.annotation.Nullable;
16import org.eclipse.tracecompass.common.core.NonNullUtils;
17
18import com.google.common.hash.HashFunction;
19import com.google.common.hash.Hashing;
20
21/**
22 * This class represents a thread from a specific host. Many machines in an
23 * experiment can have the same thread IDs. This class differentiates the
24 * threads by adding the host ID it belongs to.
25 *
26 * @author Geneviève Bastien
dbc7991d 27 * @since 1.0
4a74f111
MG
28 */
29public class HostThread {
30
31 private static final HashFunction HF = NonNullUtils.checkNotNull(Hashing.goodFastHash(32));
32
33 private final String fHost;
34 private final Integer fTid;
35
36 /**
37 * Constructor
38 *
39 * @param host
40 * The host this thread belongs to
41 * @param tid
42 * The thread ID of this thread
43 */
44 public HostThread(String host, Integer tid) {
45 fHost = host;
46 fTid = tid;
47 }
48
49 @Override
50 public int hashCode() {
51 return HF.newHasher()
52 .putUnencodedChars(fHost)
53 .putInt(fTid).hash().asInt();
54 }
55
56 @Override
57 public boolean equals(@Nullable Object o) {
58 if (o instanceof HostThread) {
59 HostThread hostTid = (HostThread) o;
60 if (fTid.equals(hostTid.fTid) &&
61 fHost.equals(hostTid.fHost)) {
62 return true;
63 }
64 }
65 return false;
66 }
67
68 @Override
69 public String toString() {
70 return "HostTid: [" + fHost + ',' + fTid + ']'; //$NON-NLS-1$
71 }
72
73 /**
74 * Get the thread ID of this thread
75 *
76 * @return The thread ID of this thread
77 */
78 public Integer getTid() {
79 return fTid;
80 }
81
82 /**
83 * Get the host ID of the machine this thread belongs to
84 *
85 * @return The host ID this thread belongs to
86 */
87 public String getHost() {
88 return fHost;
89 }
90
91}
This page took 0.035821 seconds and 5 git commands to generate.