1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.giraph.comm.netty; |
20 | |
|
21 | |
import java.net.InetSocketAddress; |
22 | |
|
23 | |
import org.apache.giraph.bsp.CentralizedServiceMaster; |
24 | |
import org.apache.giraph.comm.MasterServer; |
25 | |
import org.apache.giraph.comm.flow_control.FlowControl; |
26 | |
import org.apache.giraph.comm.netty.handler.MasterRequestServerHandler; |
27 | |
import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration; |
28 | |
import org.apache.hadoop.util.Progressable; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
public class NettyMasterServer implements MasterServer { |
34 | |
|
35 | |
private final NettyServer nettyServer; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
public NettyMasterServer(ImmutableClassesGiraphConfiguration conf, |
46 | |
CentralizedServiceMaster<?, ?, ?> service, |
47 | |
Progressable progressable, |
48 | 0 | Thread.UncaughtExceptionHandler exceptionHandler) { |
49 | 0 | nettyServer = new NettyServer(conf, |
50 | 0 | new MasterRequestServerHandler.Factory(service.getGlobalCommHandler()), |
51 | 0 | service.getMasterInfo(), progressable, exceptionHandler); |
52 | 0 | nettyServer.start(); |
53 | 0 | } |
54 | |
|
55 | |
@Override |
56 | |
public InetSocketAddress getMyAddress() { |
57 | 0 | return nettyServer.getMyAddress(); |
58 | |
} |
59 | |
|
60 | |
@Override |
61 | |
public String getLocalHostOrIp() { |
62 | 0 | return nettyServer.getLocalHostOrIp(); |
63 | |
} |
64 | |
|
65 | |
@Override |
66 | |
public void close() { |
67 | 0 | nettyServer.stop(); |
68 | 0 | } |
69 | |
|
70 | |
@Override |
71 | |
public void setFlowControl(FlowControl flowControl) { |
72 | 0 | nettyServer.setFlowControl(flowControl); |
73 | 0 | } |
74 | |
} |