use of org.apache.flink.runtime.rpc.RpcGateway in project flink by apache.
the class AkkaRpcActorTest method resolvesRunningAkkaRpcActor.
@Test
public void resolvesRunningAkkaRpcActor() throws Exception {
final String endpointName = "foobar";
try (RpcEndpoint simpleRpcEndpoint1 = createRpcEndpointWithRandomNameSuffix(endpointName);
RpcEndpoint simpleRpcEndpoint2 = createRpcEndpointWithRandomNameSuffix(endpointName)) {
simpleRpcEndpoint1.closeAsync().join();
final String wildcardName = RpcServiceUtils.createWildcardName(endpointName);
final String wildcardAddress = AkkaRpcServiceUtils.getLocalRpcUrl(wildcardName);
final RpcGateway rpcGateway = akkaRpcService.connect(wildcardAddress, RpcGateway.class).join();
assertThat(rpcGateway.getAddress(), is(equalTo(simpleRpcEndpoint2.getAddress())));
}
}
use of org.apache.flink.runtime.rpc.RpcGateway in project flink by apache.
the class LeaderGatewayRetrieverTest method testGatewayRetrievalFailures.
/**
* Tests that the gateway retrieval is retried in case of a failure.
*/
@Test
public void testGatewayRetrievalFailures() throws Exception {
final String address = "localhost";
final UUID leaderId = UUID.randomUUID();
RpcGateway rpcGateway = mock(RpcGateway.class);
TestingLeaderGatewayRetriever leaderGatewayRetriever = new TestingLeaderGatewayRetriever(rpcGateway);
SettableLeaderRetrievalService settableLeaderRetrievalService = new SettableLeaderRetrievalService();
settableLeaderRetrievalService.start(leaderGatewayRetriever);
CompletableFuture<RpcGateway> gatewayFuture = leaderGatewayRetriever.getFuture();
// this triggers the first gateway retrieval attempt
settableLeaderRetrievalService.notifyListener(address, leaderId);
// check that the first future has been failed
try {
gatewayFuture.get();
fail("The first future should have been failed.");
} catch (ExecutionException ignored) {
// that's what we expect
}
// the second attempt should fail as well
assertFalse((leaderGatewayRetriever.getNow().isPresent()));
// the third attempt should succeed
assertEquals(rpcGateway, leaderGatewayRetriever.getNow().get());
}
Aggregations