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.master.MasterGlobalCommHandler;
22 import org.apache.giraph.io.InputType;
23
24 import java.io.DataInput;
25 import java.io.DataOutput;
26 import java.io.IOException;
27
28
29
30
31 public class AskForInputSplitRequest extends WritableRequest
32 implements MasterRequest {
33
34 private InputType splitType;
35
36 private int workerTaskId;
37
38
39
40
41 private boolean isFirstSplit;
42
43
44
45
46
47
48
49
50
51 public AskForInputSplitRequest(InputType splitType, int workerTaskId,
52 boolean isFirstSplit) {
53 this.splitType = splitType;
54 this.workerTaskId = workerTaskId;
55 this.isFirstSplit = isFirstSplit;
56 }
57
58
59
60
61 public AskForInputSplitRequest() {
62 }
63
64 @Override
65 public void doRequest(MasterGlobalCommHandler commHandler) {
66 commHandler.getInputSplitsHandler().sendSplitTo(
67 splitType, workerTaskId, isFirstSplit);
68 }
69
70 @Override
71 void readFieldsRequest(DataInput in) throws IOException {
72 splitType = InputType.values()[in.readInt()];
73 workerTaskId = in.readInt();
74 isFirstSplit = in.readBoolean();
75 }
76
77 @Override
78 void writeRequest(DataOutput out) throws IOException {
79 out.writeInt(splitType.ordinal());
80 out.writeInt(workerTaskId);
81 out.writeBoolean(isFirstSplit);
82 }
83
84 @Override
85 public RequestType getType() {
86 return RequestType.ASK_FOR_INPUT_SPLIT_REQUEST;
87 }
88 }