log.warn("Wrong host. Segment '{}' (Container {}) is not owned and {} cannot perform operation '{}'.", segment, containerId, writerId, doingWhat); connection.send(new WrongHost(requestId, segment, "", clientReplyStackTrace)); } else if (u instanceof BadAttributeUpdateException) { log.warn("Bad attribute update by {} on segment {}.", writerId, segment, u);
log.warn(requestId, "Wrong host. Segment = '{}' (Container {}) is not owned. Operation = '{}').", segment, containerId, operation); invokeSafely(connection::send, new WrongHost(requestId, segment, "", clientReplyStackTrace), failureHandler); } else if (u instanceof ReadCancellationException) { log.info(requestId, "Closing connection {} while reading segment {} due to CancellationException.",
@Test(timeout = 10000) public void testConnectWithMultipleFailures() throws Exception { UUID cid = UUID.randomUUID(); PravegaNodeUri uri = new PravegaNodeUri("endpoint", SERVICE_PORT); MockConnectionFactoryImpl cf = new MockConnectionFactoryImpl(); ScheduledExecutorService executor = mock(ScheduledExecutorService.class); implementAsDirectExecutor(executor); // Ensure task submitted to executor is run inline. cf.setExecutor(executor); MockController controller = new MockController(uri.getEndpoint(), uri.getPort(), cf); ClientConnection connection = mock(ClientConnection.class); cf.provideConnection(uri, connection); @Cleanup SegmentOutputStreamImpl output = new SegmentOutputStreamImpl(SEGMENT, controller, cf, cid, segmentSealedCallback, RETRY_SCHEDULE, ""); output.reconnect(); verify(connection).send(new SetupAppend(1, cid, SEGMENT, "")); //simulate a processing Failure and ensure SetupAppend is executed. cf.getProcessor(uri).processingFailure(new IOException()); verify(connection).send(new SetupAppend(2, cid, SEGMENT, "")); cf.getProcessor(uri).connectionDropped(); verify(connection).send(new SetupAppend(3, cid, SEGMENT, "")); cf.getProcessor(uri).wrongHost(new WireCommands.WrongHost(3, SEGMENT, "newHost", "SomeException")); verify(connection).send(new SetupAppend(4, cid, SEGMENT, "")); }
@Test public void testWrongHost() throws IOException { testCommand(new WireCommands.WrongHost(l, "Foo", testString1, "SomeException")); }
@Override public void wrongHost(WrongHost wrongHost) { failConnection(new ConnectionFailedException(wrongHost.toString())); }
public static WireCommand readFrom(ByteBufInputStream in, int length) throws IOException { long requestId = in.readLong(); String segment = in.readUTF(); String correctHost = in.readUTF(); String serverStackTrace = (in.available() > 0) ? in.readUTF() : EMPTY_STACK_TRACE; return new WrongHost(requestId, segment, correctHost, serverStackTrace); }
private void validateWrongHost(MockConnectionFactory factory, Supplier<CompletableFuture<?>> futureSupplier) { CompletableFuture<?> future = futureSupplier.get(); factory.rp.wrongHost(new WireCommands.WrongHost(0, "segment", "correctHost", "SomeException")); AssertExtensions.assertThrows("", future::join, ex -> ex instanceof WireCommandFailedException && (((WireCommandFailedException) ex).getReason() == WireCommandFailedException.Reason.UnknownHost)); }
@Override public void wrongHost(WireCommands.WrongHost wrongHost) { closeConnection(new ConnectionFailedException(wrongHost.toString())); }
@Test public void testCompatibilityWrongHostV5() throws IOException { // Test that we are able to decode a message with a previous version ByteArrayOutputStream bout = new ByteArrayOutputStream(); WrongHostV5 commandV5 = new WrongHostV5(l, "", ""); commandV5.writeFields(new DataOutputStream(bout)); testCommandFromByteArray(bout.toByteArray(), new WireCommands.WrongHost(l, "", "", "")); }