Search in sources :

Example 1 with AgentHeartbeatRequest

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);
    }
}
Also used : Arrays(java.util.Arrays) ScheduledFuture(java.util.concurrent.ScheduledFuture) AlluxioConfigurationSet(alluxio.hub.proto.AlluxioConfigurationSet) AlluxioProcessStatus(alluxio.hub.proto.AlluxioProcessStatus) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) PropertyKey(alluxio.conf.PropertyKey) LogUtils(alluxio.util.LogUtils) AgentListFileInfo(alluxio.hub.proto.AgentListFileInfo) ByteArrayInputStream(java.io.ByteArrayInputStream) Duration(java.time.Duration) Map(java.util.Map) FileManager(alluxio.hub.agent.util.file.FileManager) Path(java.nio.file.Path) ProcessState(alluxio.hub.proto.ProcessState) UploadProcessType(alluxio.hub.proto.UploadProcessType) ConfigurationEditor(alluxio.hub.agent.util.conf.ConfigurationEditor) RpcClient(alluxio.hub.common.RpcClient) ManagerAgentServiceGrpc(alluxio.hub.proto.ManagerAgentServiceGrpc) Set(java.util.Set) AgentHeartbeatRequest(alluxio.hub.proto.AgentHeartbeatRequest) ExponentialTimeBoundedRetry(alluxio.retry.ExponentialTimeBoundedRetry) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) ThreadSafe(javax.annotation.concurrent.ThreadSafe) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) AlluxioNodeStatus(alluxio.hub.proto.AlluxioNodeStatus) ByteString(com.google.protobuf.ByteString) Objects(java.util.Objects) List(java.util.List) PrestoCatalogUtils.getProcessInfo(alluxio.hub.agent.util.file.PrestoCatalogUtils.getProcessInfo) ExponentialBackoffRetry(alluxio.retry.ExponentialBackoffRetry) HashMap(java.util.HashMap) NetworkAddressUtils(alluxio.util.network.NetworkAddressUtils) AlluxioNodeType(alluxio.hub.proto.AlluxioNodeType) PathUtils(alluxio.util.io.PathUtils) HubNodeAddress(alluxio.hub.proto.HubNodeAddress) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) NodeStatus(alluxio.hub.agent.util.process.NodeStatus) RetryPolicy(alluxio.retry.RetryPolicy) SimpleFileManager(alluxio.hub.agent.util.file.SimpleFileManager) RegisterAgentRequest(alluxio.hub.proto.RegisterAgentRequest) Logger(org.slf4j.Logger) Properties(java.util.Properties) Files(java.nio.file.Files) StringWriter(java.io.StringWriter) IOException(java.io.IOException) ThreadFactoryUtils(alluxio.util.ThreadFactoryUtils) Pair(alluxio.collections.Pair) ConfigurationUtils(alluxio.util.ConfigurationUtils) ProcessStateChange(alluxio.hub.proto.ProcessStateChange) TimeUnit(java.util.concurrent.TimeUnit) PrestoCatalogUtils(alluxio.hub.agent.util.file.PrestoCatalogUtils) ProcessLauncher(alluxio.hub.agent.util.process.ProcessLauncher) Paths(java.nio.file.Paths) Preconditions(com.google.common.base.Preconditions) Collections(java.util.Collections) AlluxioProcessStatus(alluxio.hub.proto.AlluxioProcessStatus) AgentHeartbeatRequest(alluxio.hub.proto.AgentHeartbeatRequest) AlluxioNodeStatus(alluxio.hub.proto.AlluxioNodeStatus) IOException(java.io.IOException) AlluxioNodeStatus(alluxio.hub.proto.AlluxioNodeStatus) NodeStatus(alluxio.hub.agent.util.process.NodeStatus)

Example 2 with AgentHeartbeatRequest

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());
}
Also used : HubNodeAddress(alluxio.hub.proto.HubNodeAddress) AlluxioCluster(alluxio.hub.proto.AlluxioCluster) AgentHeartbeatRequest(alluxio.hub.proto.AgentHeartbeatRequest) AlluxioNodeStatus(alluxio.hub.proto.AlluxioNodeStatus) AgentHeartbeatResponse(alluxio.hub.proto.AgentHeartbeatResponse) Test(org.junit.Test) BaseHubTest(alluxio.hub.test.BaseHubTest)

Aggregations

AgentHeartbeatRequest (alluxio.hub.proto.AgentHeartbeatRequest)2 AlluxioNodeStatus (alluxio.hub.proto.AlluxioNodeStatus)2 HubNodeAddress (alluxio.hub.proto.HubNodeAddress)2 Pair (alluxio.collections.Pair)1 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)1 PropertyKey (alluxio.conf.PropertyKey)1 ConfigurationEditor (alluxio.hub.agent.util.conf.ConfigurationEditor)1 FileManager (alluxio.hub.agent.util.file.FileManager)1 PrestoCatalogUtils (alluxio.hub.agent.util.file.PrestoCatalogUtils)1 PrestoCatalogUtils.getProcessInfo (alluxio.hub.agent.util.file.PrestoCatalogUtils.getProcessInfo)1 SimpleFileManager (alluxio.hub.agent.util.file.SimpleFileManager)1 NodeStatus (alluxio.hub.agent.util.process.NodeStatus)1 ProcessLauncher (alluxio.hub.agent.util.process.ProcessLauncher)1 RpcClient (alluxio.hub.common.RpcClient)1 AgentHeartbeatResponse (alluxio.hub.proto.AgentHeartbeatResponse)1 AgentListFileInfo (alluxio.hub.proto.AgentListFileInfo)1 AlluxioCluster (alluxio.hub.proto.AlluxioCluster)1 AlluxioConfigurationSet (alluxio.hub.proto.AlluxioConfigurationSet)1 AlluxioNodeType (alluxio.hub.proto.AlluxioNodeType)1 AlluxioProcessStatus (alluxio.hub.proto.AlluxioProcessStatus)1