use of alluxio.hub.proto.HubNodeAddress in project alluxio by Alluxio.
the class ManagerProcessContextTest method testListFiles.
@Test
public void testListFiles() {
AgentListFileResponse r = AgentListFileResponse.newBuilder().addFileInfo(AgentListFileInfo.newBuilder().setFileName("abc123").setProcessType(UploadProcessType.PRESTO).build()).build();
HubNodeAddress addr = HubTestUtils.generateNodeAddress();
Map<HubNodeAddress, Pair<AlluxioNodeType, AgentListFileResponse>> resp = new HashMap<>();
resp.put(addr, new Pair<>(AlluxioNodeType.MASTER, r));
doReturn(resp).when(mContext).execOnHub(any(), eq(AlluxioNodeType.MASTER), any());
doReturn(new HashMap<>()).when(mContext).execOnHub(any(), eq(AlluxioNodeType.WORKER), any());
List<ListFile> s = mContext.listFiles();
assertNotNull(s);
assertEquals(1, s.size());
assertTrue(s.get(0).hasLocation());
assertTrue(s.get(0).hasName());
assertTrue(s.get(0).hasProcessType());
assertEquals(AlluxioNodeType.MASTER, s.get(0).getLocation());
assertEquals("abc123", s.get(0).getName());
assertEquals(UploadProcessType.PRESTO, s.get(0).getProcessType());
}
use of alluxio.hub.proto.HubNodeAddress in project alluxio by Alluxio.
the class HubCluster method scanNodes.
/**
* Scans over the list of nodes in the cluster and marks them as lost if they haven't sent a
* heartbeat in the expected interval. Otherwise, if the node is in the
* {@link HubNodeState#LOST} and the time there exceeds a threshold, consider the node gone and
* remove it from the cluster.
*/
void scanNodes() {
long now = System.currentTimeMillis();
long deleteIfBefore = now - mDeleteThreshold;
long lostIfBefore = now - mLostThreshold;
Iterator<Map.Entry<HubNodeAddress, Long>> iter = mHeartbeats.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<HubNodeAddress, Long> entry = iter.next();
HubNodeAddress addr = entry.getKey();
long time = entry.getValue();
if (time < deleteIfBefore) {
if (!remove(addr)) {
LOG.debug("Failed to remove node {} from cluster", addr);
}
iter.remove();
mAlluxioCluster.remove(addr.getHostname());
} else if (time < lostIfBefore) {
mNodes.put(addr, HubNodeState.LOST);
} else {
mNodes.put(addr, HubNodeState.ALIVE);
}
}
}
use of alluxio.hub.proto.HubNodeAddress 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());
}
use of alluxio.hub.proto.HubNodeAddress in project alluxio by Alluxio.
the class HubClusterTest method testAddSame.
@Test
public void testAddSame() {
HubNodeAddress s = HubNodeAddress.newBuilder().setHostname("test-host").setRpcPort(1234).build();
mCluster.add(s);
assertEquals(1, mCluster.size());
HubNodeAddress s2 = HubNodeAddress.newBuilder().setHostname("test-host").setRpcPort(1234).build();
mCluster.add(s2);
assertEquals(1, mCluster.size());
}
use of alluxio.hub.proto.HubNodeAddress in project alluxio by Alluxio.
the class ManagerProcessContextTest method testRemoveFile.
@Test
public void testRemoveFile() {
AgentRemoveFileResponse r = AgentRemoveFileResponse.newBuilder().setSuccess(true).build();
HubNodeAddress addr = HubTestUtils.generateNodeAddress();
Map<HubNodeAddress, AgentRemoveFileResponse> resp = new HashMap<>();
resp.put(addr, r);
RemoveFile req = RemoveFile.newBuilder().setLocation(AlluxioNodeType.WORKER).setProcessType(UploadProcessType.PRESTO).setName("uptime").build();
doReturn(resp).when(mContext).execOnHub(any(), any(), any());
boolean addFileResp = mContext.removeFile(Collections.singletonList(req));
assertTrue(addFileResp);
resp.put(HubTestUtils.generateNodeAddress(), r.toBuilder().setSuccess(false).build());
assertFalse(mContext.removeFile(Collections.singletonList(req)));
}
Aggregations