public static WireCommand readFrom(DataInput in, int length) throws IOException { long requestId = in.readLong(); String target = in.readUTF(); String source = in.readUTF(); String delegationToken = in.readUTF(); return new MergeTableSegments(requestId, target, source, delegationToken); } }
/** * Verifies that the methods that are not yet implemented are not implemented by accident without unit tests. * This test should be removed once every method tested in it is implemented. */ @Test(timeout = 20000) public void testUnimplementedMethods() throws Exception { // Set up PravegaRequestProcessor instance to execute requests against String streamSegmentName = "test"; @Cleanup ServiceBuilder serviceBuilder = newInlineExecutionInMemoryBuilder(getBuilderConfig()); serviceBuilder.initialize(); StreamSegmentStore store = serviceBuilder.createStreamSegmentService(); TableStore tableStore = serviceBuilder.createTableStoreService(); ServerConnection connection = mock(ServerConnection.class); PravegaRequestProcessor processor = new PravegaRequestProcessor(store, tableStore, connection); assertThrows("seal() is implemented.", () -> processor.sealTableSegment(new WireCommands.SealTableSegment(1, streamSegmentName, "")), ex -> ex instanceof UnsupportedOperationException); assertThrows("merge() is implemented.", () -> processor.mergeTableSegments(new WireCommands.MergeTableSegments(1, streamSegmentName, streamSegmentName, "")), ex -> ex instanceof UnsupportedOperationException); }
@Test public void testMergeTableSegments() throws IOException { testCommand(new WireCommands.MergeTableSegments(l, testString1, testString2, "")); }
@Override public void mergeTableSegments(final MergeTableSegments mergeTableSegments) { final String operation = "mergeTableSegments"; if (!verifyToken(mergeTableSegments.getSource(), mergeTableSegments.getRequestId(), mergeTableSegments.getDelegationToken(), operation)) { return; } log.info(mergeTableSegments.getRequestId(), "Merging table segments {}.", mergeTableSegments); tableStore.merge(mergeTableSegments.getTarget(), mergeTableSegments.getSource(), TIMEOUT) .thenRun(() -> connection.send(new WireCommands.SegmentsMerged(mergeTableSegments.getRequestId(), mergeTableSegments.getTarget(), mergeTableSegments.getSource()))) .exceptionally(e -> handleException(mergeTableSegments.getRequestId(), mergeTableSegments.getSource(), operation, e)); }