Search in sources :

Example 1 with ManagerAgentServiceGrpc

use of alluxio.hub.proto.ManagerAgentServiceGrpc in project alluxio by Alluxio.

the class RpcClientTest method testClientClose.

@Test
public void testClientClose() throws Exception {
    GrpcChannel mockChannel = mock(GrpcChannel.class);
    RpcClient<ManagerAgentServiceGrpc.ManagerAgentServiceBlockingStub> client = new RpcClient<>(mAddr, ManagerAgentServiceGrpc::newBlockingStub, (addr) -> mockChannel);
    client.get();
    client.close();
    verify(mockChannel).shutdown();
}
Also used : ManagerAgentServiceGrpc(alluxio.hub.proto.ManagerAgentServiceGrpc) GrpcChannel(alluxio.grpc.GrpcChannel) Test(org.junit.Test) BaseHubTest(alluxio.hub.test.BaseHubTest)

Example 2 with ManagerAgentServiceGrpc

use of alluxio.hub.proto.ManagerAgentServiceGrpc in project alluxio by Alluxio.

the class RpcClientTest method testUnhealthyChannel.

@Test
public void testUnhealthyChannel() throws Exception {
    GrpcChannel mockChannel = mock(GrpcChannel.class);
    doReturn(false).when(mockChannel).isShutdown();
    doReturn(false).when(mockChannel).isHealthy();
    RpcClient<ManagerAgentServiceGrpc.ManagerAgentServiceBlockingStub> client = new RpcClient<>(mAddr, ManagerAgentServiceGrpc::newBlockingStub, (addr) -> mockChannel);
    client.get();
    client.get();
    verify(mockChannel).shutdown();
}
Also used : ManagerAgentServiceGrpc(alluxio.hub.proto.ManagerAgentServiceGrpc) GrpcChannel(alluxio.grpc.GrpcChannel) Test(org.junit.Test) BaseHubTest(alluxio.hub.test.BaseHubTest)

Example 3 with ManagerAgentServiceGrpc

use of alluxio.hub.proto.ManagerAgentServiceGrpc in project alluxio by Alluxio.

the class AgentProcessContextTest method before.

@Before
public void before() throws Exception {
    mContext = getTestManagerContext();
    mServerName = InProcessServerBuilder.generateName();
    mServer = InProcessServerBuilder.forName(mServerName).directExecutor().addService(new ManagerAgentService(mContext)).build();
    mServer.start();
    mChannel = InProcessChannelBuilder.forName(mServerName).directExecutor().build();
    mClient = new InProcessRpcClient<>(InetSocketAddress.createUnresolved(mServerName, 0), ManagerAgentServiceGrpc::newBlockingStub, (addr) -> InProcessChannelBuilder.forName(mServerName).directExecutor().build());
}
Also used : ManagedChannel(io.grpc.ManagedChannel) Assert.assertThrows(org.junit.Assert.assertThrows) NetworkAddressUtils(alluxio.util.network.NetworkAddressUtils) PropertyKey(alluxio.conf.PropertyKey) InProcessServerBuilder(io.grpc.inprocess.InProcessServerBuilder) WaitForOptions(alluxio.util.WaitForOptions) ManagerProcessContext(alluxio.hub.manager.process.ManagerProcessContext) After(org.junit.After) Server(io.grpc.Server) InProcessChannelBuilder(io.grpc.inprocess.InProcessChannelBuilder) AlluxioCluster(alluxio.hub.proto.AlluxioCluster) RetryPolicy(alluxio.retry.RetryPolicy) Before(org.junit.Before) RpcClient(alluxio.hub.common.RpcClient) ManagerAgentServiceGrpc(alluxio.hub.proto.ManagerAgentServiceGrpc) InProcessRpcClient(alluxio.hub.common.InProcessRpcClient) Test(org.junit.Test) HubNodeStatus(alluxio.hub.proto.HubNodeStatus) InetSocketAddress(java.net.InetSocketAddress) AlluxioNodeStatus(alluxio.hub.proto.AlluxioNodeStatus) BaseHubTest(alluxio.hub.test.BaseHubTest) TimeUnit(java.util.concurrent.TimeUnit) ManagerAgentService(alluxio.hub.manager.rpc.service.ManagerAgentService) Rule(org.junit.Rule) InstancedConfiguration(alluxio.conf.InstancedConfiguration) Assert.assertEquals(org.junit.Assert.assertEquals) ExponentialBackoffRetry(alluxio.retry.ExponentialBackoffRetry) CommonUtils(alluxio.util.CommonUtils) TemporaryFolder(org.junit.rules.TemporaryFolder) ManagerAgentService(alluxio.hub.manager.rpc.service.ManagerAgentService) Before(org.junit.Before)

Example 4 with ManagerAgentServiceGrpc

use of alluxio.hub.proto.ManagerAgentServiceGrpc in project alluxio by Alluxio.

the class RpcClientTest method testGrpcChannelBuilderThrowsException.

@Test
public void testGrpcChannelBuilderThrowsException() throws Exception {
    try (MockedStatic<GrpcChannelBuilder> builderMock = Mockito.mockStatic(GrpcChannelBuilder.class)) {
        builderMock.when(() -> GrpcChannelBuilder.newBuilder(any(), any())).thenReturn(mMockChannelBuilder);
        doThrow(AlluxioStatusException.from(Status.UNAVAILABLE)).when(mMockChannelBuilder).build();
        RpcClient<ManagerAgentServiceGrpc.ManagerAgentServiceBlockingStub> client = new RpcClient<>(mConf, mAddr, ManagerAgentServiceGrpc::newBlockingStub, () -> new CountingRetry(4));
        assertThrows(AlluxioStatusException.class, client::get);
        verify(mMockChannelBuilder, VerificationModeFactory.times(5)).build();
    }
}
Also used : CountingRetry(alluxio.retry.CountingRetry) ManagerAgentServiceGrpc(alluxio.hub.proto.ManagerAgentServiceGrpc) GrpcChannelBuilder(alluxio.grpc.GrpcChannelBuilder) Test(org.junit.Test) BaseHubTest(alluxio.hub.test.BaseHubTest)

Aggregations

ManagerAgentServiceGrpc (alluxio.hub.proto.ManagerAgentServiceGrpc)4 BaseHubTest (alluxio.hub.test.BaseHubTest)4 Test (org.junit.Test)4 GrpcChannel (alluxio.grpc.GrpcChannel)2 InstancedConfiguration (alluxio.conf.InstancedConfiguration)1 PropertyKey (alluxio.conf.PropertyKey)1 GrpcChannelBuilder (alluxio.grpc.GrpcChannelBuilder)1 InProcessRpcClient (alluxio.hub.common.InProcessRpcClient)1 RpcClient (alluxio.hub.common.RpcClient)1 ManagerProcessContext (alluxio.hub.manager.process.ManagerProcessContext)1 ManagerAgentService (alluxio.hub.manager.rpc.service.ManagerAgentService)1 AlluxioCluster (alluxio.hub.proto.AlluxioCluster)1 AlluxioNodeStatus (alluxio.hub.proto.AlluxioNodeStatus)1 HubNodeStatus (alluxio.hub.proto.HubNodeStatus)1 CountingRetry (alluxio.retry.CountingRetry)1 ExponentialBackoffRetry (alluxio.retry.ExponentialBackoffRetry)1 RetryPolicy (alluxio.retry.RetryPolicy)1 CommonUtils (alluxio.util.CommonUtils)1 WaitForOptions (alluxio.util.WaitForOptions)1 NetworkAddressUtils (alluxio.util.network.NetworkAddressUtils)1