use of alluxio.hub.proto.AgentHeartbeatRequest in project alluxio by Alluxio.
the class AgentProcessContext method heartbeat.
private void heartbeat() {
try {
NodeStatus ps = new NodeStatus();
List<AlluxioProcessStatus> alluxioStatus = mProcs.keySet().stream().map(t -> {
try {
return ps.getProcessStatus(t);
} catch (IOException e) {
LogUtils.warnWithException(LOG, "Failed to get process status for {}", t, e);
return AlluxioProcessStatus.newBuilder().setNodeType(t).setState(ProcessState.UNKNOWN).setPid(-1).build();
}
}).collect(Collectors.toList());
AlluxioNodeStatus s = AlluxioNodeStatus.newBuilder().setHostname(NetworkAddressUtils.getConnectHost(NetworkAddressUtils.ServiceType.HUB_AGENT_RPC, mConf)).addAllProcess(alluxioStatus).build();
AgentHeartbeatRequest request = AgentHeartbeatRequest.newBuilder().setHubNode(getNodeAddress()).setAlluxioStatus(s).build();
mClient.get().agentHeartbeat(request);
} catch (Throwable t) {
LogUtils.warnWithException(LOG, "Failed to send agent heartbeat", t);
}
}
use of alluxio.hub.proto.AgentHeartbeatRequest in project alluxio by Alluxio.
the class ManagerAgentServiceTest method agentHeartbeatTest.
@Test
public void agentHeartbeatTest() {
AlluxioNodeStatus s = AlluxioNodeStatus.newBuilder().setHostname(UUID.randomUUID().toString()).addProcess(AlluxioProcessStatus.newBuilder().setState(ProcessState.RUNNING).setNodeType(AlluxioNodeType.MASTER).build()).build();
HubNodeAddress addr = HubNodeAddress.newBuilder().setHostname(UUID.randomUUID().toString()).setRpcPort(56565).build();
AgentHeartbeatRequest request = AgentHeartbeatRequest.newBuilder().setAlluxioStatus(s).setHubNode(addr).build();
AgentHeartbeatResponse resp = mClient.agentHeartbeat(request);
assertTrue(resp.hasOk());
assertTrue(resp.getOk());
assertEquals(1, mContext.getAlluxioCluster().size());
AlluxioCluster c = mContext.getAlluxioCluster().toProto();
AlluxioNodeStatus nodeStatus = c.getNode(0);
assertEquals(s.getHostname(), nodeStatus.getHostname());
assertEquals(AlluxioNodeType.MASTER, nodeStatus.getProcess(0).getNodeType());
assertEquals(ProcessState.RUNNING, nodeStatus.getProcess(0).getState());
}
Aggregations