1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.giraph.comm.requests;
20
21 import org.apache.giraph.comm.ServerData;
22 import org.apache.giraph.comm.flow_control.CreditBasedFlowControl;
23 import org.apache.giraph.comm.flow_control.FlowControl;
24
25 import java.io.DataInput;
26 import java.io.DataOutput;
27 import java.io.IOException;
28
29 import static com.google.common.base.Preconditions.checkState;
30
31
32
33
34
35
36
37
38
39 public class SendResumeRequest extends WritableRequest
40 implements WorkerRequest {
41
42 private short credit;
43
44
45 public SendResumeRequest() { }
46
47
48
49
50
51
52 public SendResumeRequest(short credit) {
53 checkState(credit > 0);
54 this.credit = credit;
55 }
56
57 @Override
58 public void doRequest(ServerData serverData) {
59 FlowControl flowControl =
60 serverData.getServiceWorker().getWorkerClient().getFlowControl();
61 checkState(flowControl != null);
62 ((CreditBasedFlowControl) flowControl).processResumeSignal(getClientId(),
63 credit, getRequestId());
64 }
65
66 @Override
67 public RequestType getType() {
68 return RequestType.SEND_RESUME_REQUEST;
69 }
70
71 @Override
72 void readFieldsRequest(DataInput input) throws IOException {
73 credit = input.readShort();
74 }
75
76 @Override
77 void writeRequest(DataOutput output) throws IOException {
78 output.writeShort(credit);
79 }
80 }