org.apache.flink.runtime.rpc.exceptions.FencingTokenException Java Examples
The following examples show how to use
org.apache.flink.runtime.rpc.exceptions.FencingTokenException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsyncCallsTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Tests that async callables are not executed if the fencing token changes. */ @Test public void testCallAsyncWithFencing() throws Exception { final UUID newFencingToken = UUID.randomUUID(); CompletableFuture<Boolean> resultFuture = testRunAsync( endpoint -> endpoint.callAsync(() -> true, timeout), newFencingToken); try { resultFuture.get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS); fail("The async call operation should fail due to the changed fencing token."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.stripExecutionException(e) instanceof FencingTokenException); } }
Example #2
Source File: ResourceManagerJobMasterTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Test receive registration with unmatched leadershipId from job master. */ @Test public void testRegisterJobMasterWithUnmatchedLeaderSessionId1() throws Exception { final ResourceManagerGateway wronglyFencedGateway = rpcService.connect(resourceManager.getAddress(), ResourceManagerId.generate(), ResourceManagerGateway.class) .get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS); // test throw exception when receive a registration from job master which takes unmatched leaderSessionId CompletableFuture<RegistrationResponse> unMatchedLeaderFuture = wronglyFencedGateway.registerJobManager( jobMasterGateway.getFencingToken(), jobMasterResourceId, jobMasterGateway.getAddress(), jobId, TIMEOUT); try { unMatchedLeaderFuture.get(5L, TimeUnit.SECONDS); fail("Should fail because we are using the wrong fencing token."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.stripExecutionException(e) instanceof FencingTokenException); } }
Example #3
Source File: AsyncCallsTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that async callables are not executed if the fencing token changes. */ @Test public void testCallAsyncWithFencing() throws Exception { final UUID newFencingToken = UUID.randomUUID(); CompletableFuture<Boolean> resultFuture = testRunAsync( endpoint -> endpoint.callAsync(() -> true, timeout), newFencingToken); try { resultFuture.get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS); fail("The async call operation should fail due to the changed fencing token."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.stripExecutionException(e) instanceof FencingTokenException); } }
Example #4
Source File: ResourceManagerJobMasterTest.java From flink with Apache License 2.0 | 6 votes |
/** * Test receive registration with unmatched leadershipId from job master. */ @Test public void testRegisterJobMasterWithUnmatchedLeaderSessionId1() throws Exception { final ResourceManagerGateway wronglyFencedGateway = rpcService.connect(resourceManager.getAddress(), ResourceManagerId.generate(), ResourceManagerGateway.class) .get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS); // test throw exception when receive a registration from job master which takes unmatched leaderSessionId CompletableFuture<RegistrationResponse> unMatchedLeaderFuture = wronglyFencedGateway.registerJobManager( jobMasterGateway.getFencingToken(), jobMasterResourceId, jobMasterGateway.getAddress(), jobId, TIMEOUT); try { unMatchedLeaderFuture.get(5L, TimeUnit.SECONDS); fail("Should fail because we are using the wrong fencing token."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.stripExecutionException(e) instanceof FencingTokenException); } }
Example #5
Source File: AsyncCallsTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that async callables are not executed if the fencing token changes. */ @Test public void testCallAsyncWithFencing() throws Exception { final UUID newFencingToken = UUID.randomUUID(); CompletableFuture<Boolean> resultFuture = testRunAsync( endpoint -> endpoint.callAsync(() -> true, timeout), newFencingToken); try { resultFuture.get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS); fail("The async call operation should fail due to the changed fencing token."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.stripExecutionException(e) instanceof FencingTokenException); } }
Example #6
Source File: ResourceManagerJobMasterTest.java From flink with Apache License 2.0 | 6 votes |
/** * Test receive registration with unmatched leadershipId from job master. */ @Test public void testRegisterJobMasterWithUnmatchedLeaderSessionId1() throws Exception { final ResourceManagerGateway wronglyFencedGateway = rpcService.connect(resourceManager.getAddress(), ResourceManagerId.generate(), ResourceManagerGateway.class) .get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS); // test throw exception when receive a registration from job master which takes unmatched leaderSessionId CompletableFuture<RegistrationResponse> unMatchedLeaderFuture = wronglyFencedGateway.registerJobManager( jobMasterGateway.getFencingToken(), jobMasterResourceId, jobMasterGateway.getAddress(), jobId, TIMEOUT); try { unMatchedLeaderFuture.get(5L, TimeUnit.SECONDS); fail("Should fail because we are using the wrong fencing token."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.stripExecutionException(e) instanceof FencingTokenException); } }
Example #7
Source File: ResourceManagerTaskExecutorTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Test receive registration with unmatched leadershipId from task executor. */ @Test public void testRegisterTaskExecutorWithUnmatchedLeaderSessionId() throws Exception { // test throw exception when receive a registration from taskExecutor which takes unmatched leaderSessionId CompletableFuture<RegistrationResponse> unMatchedLeaderFuture = registerTaskExecutor(wronglyFencedGateway, taskExecutorGateway.getAddress()); try { unMatchedLeaderFuture.get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS); fail("Should have failed because we are using a wrongly fenced ResourceManagerGateway."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.stripExecutionException(e) instanceof FencingTokenException); } }
Example #8
Source File: ResourceManagerTaskExecutorTest.java From flink with Apache License 2.0 | 5 votes |
/** * Test receive registration with unmatched leadershipId from task executor. */ @Test public void testRegisterTaskExecutorWithUnmatchedLeaderSessionId() throws Exception { // test throw exception when receive a registration from taskExecutor which takes unmatched leaderSessionId CompletableFuture<RegistrationResponse> unMatchedLeaderFuture = registerTaskExecutor(wronglyFencedGateway, taskExecutorGateway.getAddress()); try { unMatchedLeaderFuture.get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS); fail("Should have failed because we are using a wrongly fenced ResourceManagerGateway."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.stripExecutionException(e) instanceof FencingTokenException); } }
Example #9
Source File: ResourceManagerTaskExecutorTest.java From flink with Apache License 2.0 | 5 votes |
/** * Test receive registration with unmatched leadershipId from task executor. */ @Test public void testRegisterTaskExecutorWithUnmatchedLeaderSessionId() throws Exception { // test throw exception when receive a registration from taskExecutor which takes unmatched leaderSessionId CompletableFuture<RegistrationResponse> unMatchedLeaderFuture = registerTaskExecutor(wronglyFencedGateway, taskExecutorGateway.getAddress()); try { unMatchedLeaderFuture.get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS); fail("Should have failed because we are using a wrongly fenced ResourceManagerGateway."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.stripExecutionException(e) instanceof FencingTokenException); } }
Example #10
Source File: FencedAkkaRpcActor.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override protected void handleRpcMessage(Object message) { if (message instanceof FencedMessage) { final F expectedFencingToken = rpcEndpoint.getFencingToken(); if (expectedFencingToken == null) { if (log.isDebugEnabled()) { log.debug("Fencing token not set: Ignoring message {} because the fencing token is null.", message); } sendErrorIfSender( new FencingTokenException( String.format( "Fencing token not set: Ignoring message %s sent to %s because the fencing token is null.", message, rpcEndpoint.getAddress()))); } else { @SuppressWarnings("unchecked") FencedMessage<F, ?> fencedMessage = ((FencedMessage<F, ?>) message); F fencingToken = fencedMessage.getFencingToken(); if (Objects.equals(expectedFencingToken, fencingToken)) { super.handleRpcMessage(fencedMessage.getPayload()); } else { if (log.isDebugEnabled()) { log.debug("Fencing token mismatch: Ignoring message {} because the fencing token {} did " + "not match the expected fencing token {}.", message, fencingToken, expectedFencingToken); } sendErrorIfSender( new FencingTokenException("Fencing token mismatch: Ignoring message " + message + " because the fencing token " + fencingToken + " did not match the expected fencing token " + expectedFencingToken + '.')); } } } else if (message instanceof UnfencedMessage) { super.handleRpcMessage(((UnfencedMessage<?>) message).getPayload()); } else { if (log.isDebugEnabled()) { log.debug("Unknown message type: Ignoring message {} because it is neither of type {} nor {}.", message, FencedMessage.class.getSimpleName(), UnfencedMessage.class.getSimpleName()); } sendErrorIfSender(new AkkaUnknownMessageException("Unknown message type: Ignoring message " + message + " of type " + message.getClass().getSimpleName() + " because it is neither of type " + FencedMessage.class.getSimpleName() + " nor " + UnfencedMessage.class.getSimpleName() + '.')); } }
Example #11
Source File: FencedRpcEndpointTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Tests that the self gateway always uses the current fencing token whereas the remote * gateway has a fixed fencing token. */ @Test public void testRemoteAndSelfGateways() throws Exception { final UUID initialFencingToken = UUID.randomUUID(); final UUID newFencingToken = UUID.randomUUID(); final String value = "foobar"; final FencedTestingEndpoint fencedTestingEndpoint = new FencedTestingEndpoint(rpcService, value, initialFencingToken); try { fencedTestingEndpoint.start(); FencedTestingGateway selfGateway = fencedTestingEndpoint.getSelfGateway(FencedTestingGateway.class); FencedTestingGateway remoteGateway = rpcService.connect(fencedTestingEndpoint.getAddress(), initialFencingToken, FencedTestingGateway.class) .get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS); assertEquals(initialFencingToken, selfGateway.getFencingToken()); assertEquals(initialFencingToken, remoteGateway.getFencingToken()); assertEquals(value, selfGateway.foobar(timeout).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS)); assertEquals(value, remoteGateway.foobar(timeout).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS)); CompletableFuture<Acknowledge> newFencingTokenFuture = fencedTestingEndpoint.setFencingTokenInMainThread(newFencingToken, timeout); // wait for the new fencing token to be set newFencingTokenFuture.get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS); assertEquals(newFencingToken, selfGateway.getFencingToken()); assertNotEquals(newFencingToken, remoteGateway.getFencingToken()); assertEquals(value, selfGateway.foobar(timeout).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS)); try { remoteGateway.foobar(timeout).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS); fail("This should have failed because we don't have the right fencing token."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.stripExecutionException(e) instanceof FencingTokenException); } } finally { RpcUtils.terminateRpcEndpoint(fencedTestingEndpoint, timeout); } }
Example #12
Source File: FencedAkkaRpcActor.java From flink with Apache License 2.0 | 4 votes |
@Override protected void handleRpcMessage(Object message) { if (message instanceof FencedMessage) { final F expectedFencingToken = rpcEndpoint.getFencingToken(); if (expectedFencingToken == null) { if (log.isDebugEnabled()) { log.debug("Fencing token not set: Ignoring message {} because the fencing token is null.", message); } sendErrorIfSender( new FencingTokenException( String.format( "Fencing token not set: Ignoring message %s sent to %s because the fencing token is null.", message, rpcEndpoint.getAddress()))); } else { @SuppressWarnings("unchecked") FencedMessage<F, ?> fencedMessage = ((FencedMessage<F, ?>) message); F fencingToken = fencedMessage.getFencingToken(); if (Objects.equals(expectedFencingToken, fencingToken)) { super.handleRpcMessage(fencedMessage.getPayload()); } else { if (log.isDebugEnabled()) { log.debug("Fencing token mismatch: Ignoring message {} because the fencing token {} did " + "not match the expected fencing token {}.", message, fencingToken, expectedFencingToken); } sendErrorIfSender( new FencingTokenException("Fencing token mismatch: Ignoring message " + message + " because the fencing token " + fencingToken + " did not match the expected fencing token " + expectedFencingToken + '.')); } } } else if (message instanceof UnfencedMessage) { super.handleRpcMessage(((UnfencedMessage<?>) message).getPayload()); } else { if (log.isDebugEnabled()) { log.debug("Unknown message type: Ignoring message {} because it is neither of type {} nor {}.", message, FencedMessage.class.getSimpleName(), UnfencedMessage.class.getSimpleName()); } sendErrorIfSender(new AkkaUnknownMessageException("Unknown message type: Ignoring message " + message + " of type " + message.getClass().getSimpleName() + " because it is neither of type " + FencedMessage.class.getSimpleName() + " nor " + UnfencedMessage.class.getSimpleName() + '.')); } }
Example #13
Source File: FencedRpcEndpointTest.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that the self gateway always uses the current fencing token whereas the remote * gateway has a fixed fencing token. */ @Test public void testRemoteAndSelfGateways() throws Exception { final UUID initialFencingToken = UUID.randomUUID(); final UUID newFencingToken = UUID.randomUUID(); final String value = "foobar"; final FencedTestingEndpoint fencedTestingEndpoint = new FencedTestingEndpoint(rpcService, value, initialFencingToken); try { fencedTestingEndpoint.start(); FencedTestingGateway selfGateway = fencedTestingEndpoint.getSelfGateway(FencedTestingGateway.class); FencedTestingGateway remoteGateway = rpcService.connect(fencedTestingEndpoint.getAddress(), initialFencingToken, FencedTestingGateway.class) .get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS); assertEquals(initialFencingToken, selfGateway.getFencingToken()); assertEquals(initialFencingToken, remoteGateway.getFencingToken()); assertEquals(value, selfGateway.foobar(timeout).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS)); assertEquals(value, remoteGateway.foobar(timeout).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS)); CompletableFuture<Acknowledge> newFencingTokenFuture = fencedTestingEndpoint.setFencingTokenInMainThread(newFencingToken, timeout); // wait for the new fencing token to be set newFencingTokenFuture.get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS); assertEquals(newFencingToken, selfGateway.getFencingToken()); assertNotEquals(newFencingToken, remoteGateway.getFencingToken()); assertEquals(value, selfGateway.foobar(timeout).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS)); try { remoteGateway.foobar(timeout).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS); fail("This should have failed because we don't have the right fencing token."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.stripExecutionException(e) instanceof FencingTokenException); } } finally { RpcUtils.terminateRpcEndpoint(fencedTestingEndpoint, timeout); } }
Example #14
Source File: FencedAkkaRpcActor.java From flink with Apache License 2.0 | 4 votes |
@Override protected void handleRpcMessage(Object message) { if (message instanceof FencedMessage) { final F expectedFencingToken = rpcEndpoint.getFencingToken(); if (expectedFencingToken == null) { if (log.isDebugEnabled()) { log.debug("Fencing token not set: Ignoring message {} because the fencing token is null.", message); } sendErrorIfSender( new FencingTokenException( String.format( "Fencing token not set: Ignoring message %s sent to %s because the fencing token is null.", message, rpcEndpoint.getAddress()))); } else { @SuppressWarnings("unchecked") FencedMessage<F, ?> fencedMessage = ((FencedMessage<F, ?>) message); F fencingToken = fencedMessage.getFencingToken(); if (Objects.equals(expectedFencingToken, fencingToken)) { super.handleRpcMessage(fencedMessage.getPayload()); } else { if (log.isDebugEnabled()) { log.debug("Fencing token mismatch: Ignoring message {} because the fencing token {} did " + "not match the expected fencing token {}.", message, fencingToken, expectedFencingToken); } sendErrorIfSender( new FencingTokenException("Fencing token mismatch: Ignoring message " + message + " because the fencing token " + fencingToken + " did not match the expected fencing token " + expectedFencingToken + '.')); } } } else if (message instanceof UnfencedMessage) { super.handleRpcMessage(((UnfencedMessage<?>) message).getPayload()); } else { if (log.isDebugEnabled()) { log.debug("Unknown message type: Ignoring message {} because it is neither of type {} nor {}.", message, FencedMessage.class.getSimpleName(), UnfencedMessage.class.getSimpleName()); } sendErrorIfSender(new AkkaUnknownMessageException("Unknown message type: Ignoring message " + message + " of type " + message.getClass().getSimpleName() + " because it is neither of type " + FencedMessage.class.getSimpleName() + " nor " + UnfencedMessage.class.getSimpleName() + '.')); } }
Example #15
Source File: FencedRpcEndpointTest.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that the self gateway always uses the current fencing token whereas the remote * gateway has a fixed fencing token. */ @Test public void testRemoteAndSelfGateways() throws Exception { final UUID initialFencingToken = UUID.randomUUID(); final UUID newFencingToken = UUID.randomUUID(); final String value = "foobar"; final FencedTestingEndpoint fencedTestingEndpoint = new FencedTestingEndpoint(rpcService, value, initialFencingToken); try { fencedTestingEndpoint.start(); FencedTestingGateway selfGateway = fencedTestingEndpoint.getSelfGateway(FencedTestingGateway.class); FencedTestingGateway remoteGateway = rpcService.connect(fencedTestingEndpoint.getAddress(), initialFencingToken, FencedTestingGateway.class) .get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS); assertEquals(initialFencingToken, selfGateway.getFencingToken()); assertEquals(initialFencingToken, remoteGateway.getFencingToken()); assertEquals(value, selfGateway.foobar(timeout).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS)); assertEquals(value, remoteGateway.foobar(timeout).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS)); CompletableFuture<Acknowledge> newFencingTokenFuture = fencedTestingEndpoint.setFencingTokenInMainThread(newFencingToken, timeout); // wait for the new fencing token to be set newFencingTokenFuture.get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS); assertEquals(newFencingToken, selfGateway.getFencingToken()); assertNotEquals(newFencingToken, remoteGateway.getFencingToken()); assertEquals(value, selfGateway.foobar(timeout).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS)); try { remoteGateway.foobar(timeout).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS); fail("This should have failed because we don't have the right fencing token."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.stripExecutionException(e) instanceof FencingTokenException); } } finally { RpcUtils.terminateRpcEndpoint(fencedTestingEndpoint, timeout); } }