1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.giraph.examples.utils;
20
21 import java.io.DataInput;
22 import java.io.DataOutput;
23 import java.io.IOException;
24
25 import org.apache.hadoop.io.Writable;
26
27
28
29
30 public class BrachaTouegDeadlockMessage implements Writable {
31
32
33
34
35 public static final long NOTIFY = 1;
36
37
38
39
40 public static final long GRANT = 1 << 1;
41
42
43
44
45 public static final long ACK = 1 << 2;
46
47
48
49
50 public static final long DONE = 1 << 3;
51
52 public static final long CTRL_IN_EDGE = 1 << 4;
53
54
55 private long senderId;
56
57 private long type;
58
59
60 public BrachaTouegDeadlockMessage() {
61
62
63
64
65
66 public BrachaTouegDeadlockMessage(long id, long type) {
67 this.senderId = id;
68 this.type = type;
69 }
70
71 @Override
72 public void readFields(DataInput input) throws IOException {
73 senderId = input.readLong();
74 this.type = input.readLong();
75 }
76
77 @Override
78 public void write(DataOutput output) throws IOException {
79 output.writeLong(senderId);
80 output.writeLong(this.type);
81 }
82
83
84
85
86 public long getSenderId() {
87 return senderId;
88 }
89
90
91
92
93 public long getType() {
94 return type;
95 }
96
97 @Override
98 public String toString() {
99 StringBuffer buffer = new StringBuffer();
100
101 buffer.append("Message ");
102 buffer.append("{ sender: " + this.senderId + "; type: ");
103 if (this.type == BrachaTouegDeadlockMessage.NOTIFY) {
104 buffer.append("notify");
105 } else if (this.type == BrachaTouegDeadlockMessage.GRANT) {
106 buffer.append("grant");
107 } else if (this.type == BrachaTouegDeadlockMessage.ACK) {
108 buffer.append("ack");
109 } else if (this.type == BrachaTouegDeadlockMessage.DONE) {
110 buffer.append("done");
111 } else if (this.type == BrachaTouegDeadlockMessage.CTRL_IN_EDGE) {
112 buffer.append("<ctrl>");
113 } else {
114 buffer.append("unknown");
115 }
116 buffer.append(" }");
117
118 return buffer.toString();
119 }
120 }