connection.send(new SegmentAlreadyExists(requestId, segment, clientReplyStackTrace)); } else if (u instanceof StreamSegmentNotExistsException) { log.warn("Segment '{}' does not exist and {} cannot perform operation '{}'.", segment, writerId, doingWhat);
log.info(requestId, "Segment '{}' already exists and cannot perform operation '{}'.", segment, operation); invokeSafely(connection::send, new SegmentAlreadyExists(requestId, segment, clientReplyStackTrace), failureHandler);
@Test public void testCreateTableSegment() { MockConnectionFactory factory = new MockConnectionFactory(); // On receiving SegmentAlreadyExists true should be returned. CompletableFuture<Boolean> result = helper.createTableSegment("", "", new MockHostControllerStore(), factory, "", Long.MIN_VALUE); factory.rp.segmentAlreadyExists(new WireCommands.SegmentAlreadyExists(0, getQualifiedStreamSegmentName("", "", 0L), "")); assertTrue(result.join()); // On Receiving SegmentCreated true should be returned. result = helper.createTableSegment("", "", new MockHostControllerStore(), factory, "", Long.MIN_VALUE); factory.rp.segmentCreated(new WireCommands.SegmentCreated(0, getQualifiedStreamSegmentName("", "", 0L))); assertTrue(result.join()); // Validate failure conditions. Supplier<CompletableFuture<?>> futureSupplier = () -> helper.createTableSegment("", "", new MockHostControllerStore(), factory, "", Long.MIN_VALUE); validateAuthTokenCheckFailed(factory, futureSupplier); validateWrongHost(factory, futureSupplier); validateConnectionDropped(factory, futureSupplier); validateProcessingFailure(factory, futureSupplier); }
@Test(timeout = 20000) public void testCreateTableSegment() throws Exception { // Set up PravegaRequestProcessor instance to execute requests against String streamSegmentName = "testCreateTableSegment"; @Cleanup ServiceBuilder serviceBuilder = newInlineExecutionInMemoryBuilder(getBuilderConfig()); serviceBuilder.initialize(); StreamSegmentStore store = serviceBuilder.createStreamSegmentService(); TableStore tableStore = serviceBuilder.createTableStoreService(); ServerConnection connection = mock(ServerConnection.class); InOrder order = inOrder(connection); PravegaRequestProcessor processor = new PravegaRequestProcessor(store, tableStore, connection); // Execute and Verify createTableSegment calling stack is executed as design. processor.createTableSegment(new WireCommands.CreateTableSegment(1, streamSegmentName, "")); order.verify(connection).send(new WireCommands.SegmentCreated(1, streamSegmentName)); processor.createTableSegment(new WireCommands.CreateTableSegment(2, streamSegmentName, "")); order.verify(connection).send(new WireCommands.SegmentAlreadyExists(2, streamSegmentName, "")); }
@Test public void testSegmentAlreadyExists() throws IOException { testCommand(new WireCommands.SegmentAlreadyExists(l, testString1, "SomeException")); }
@Test public void testCompatibilitySegmentAlreadyExistsV5() throws IOException { // Test that we are able to decode a message with a previous version ByteArrayOutputStream bout = new ByteArrayOutputStream(); SegmentAlreadyExistsV5 commandV5 = new SegmentAlreadyExistsV5(l, "segment"); commandV5.writeFields(new DataOutputStream(bout)); testCommandFromByteArray(bout.toByteArray(), new WireCommands.SegmentAlreadyExists(l, "segment", "")); }
public static WireCommand readFrom(ByteBufInputStream in, int length) throws IOException { long requestId = in.readLong(); String segment = in.readUTF(); String serverStackTrace = (in.available() > 0) ? in.readUTF() : EMPTY_STACK_TRACE; return new SegmentAlreadyExists(requestId, segment, serverStackTrace); }