use of io.pravega.shared.protocol.netty.WireCommands.CreateTableSegment in project pravega by pravega.
the class PravegaRequestProcessor method createTableSegment.
@Override
public void createTableSegment(final CreateTableSegment createTableSegment) {
final String operation = "createTableSegment";
if (!verifyToken(createTableSegment.getSegment(), createTableSegment.getRequestId(), createTableSegment.getDelegationToken(), operation)) {
return;
}
log.info(createTableSegment.getRequestId(), "Creating table segment {}.", createTableSegment);
val timer = new Timer();
val typeBuilder = SegmentType.builder().tableSegment();
val configBuilder = TableSegmentConfig.builder();
if (createTableSegment.getKeyLength() > 0) {
typeBuilder.fixedKeyLengthTableSegment();
configBuilder.keyLength(createTableSegment.getKeyLength());
}
if (createTableSegment.getRolloverSizeBytes() < 0) {
log.warn("Table segment rollover size bytes cannot be less than 0, actual is {}, fall back to default value", createTableSegment.getRolloverSizeBytes());
}
final long rolloverSizeByes = createTableSegment.getRolloverSizeBytes() < 0 ? 0 : createTableSegment.getRolloverSizeBytes();
configBuilder.rolloverSizeBytes(rolloverSizeByes);
tableStore.createSegment(createTableSegment.getSegment(), typeBuilder.build(), configBuilder.build(), TIMEOUT).thenAccept(v -> {
connection.send(new SegmentCreated(createTableSegment.getRequestId(), createTableSegment.getSegment()));
this.tableStatsRecorder.createTableSegment(createTableSegment.getSegment(), timer.getElapsed());
}).exceptionally(e -> handleException(createTableSegment.getRequestId(), createTableSegment.getSegment(), operation, e));
}
use of io.pravega.shared.protocol.netty.WireCommands.CreateTableSegment in project pravega by pravega.
the class FailingRequestProcessorTest method testEverythingThrows.
@Test
public void testEverythingThrows() {
assertThrows(IllegalStateException.class, () -> rp.hello(new Hello(0, 0)));
assertThrows(IllegalStateException.class, () -> rp.setupAppend(new SetupAppend(0, null, "", "")));
assertThrows(IllegalStateException.class, () -> rp.append(new Append("", null, 0, EMPTY_EVENT, 0)));
assertThrows(IllegalStateException.class, () -> rp.readSegment(new ReadSegment("", 0, 0, "", 0)));
assertThrows(IllegalStateException.class, () -> rp.updateSegmentAttribute(new UpdateSegmentAttribute(0, "", null, 0, 0, "")));
assertThrows(IllegalStateException.class, () -> rp.getSegmentAttribute(new GetSegmentAttribute(0, "", null, "")));
assertThrows(IllegalStateException.class, () -> rp.getStreamSegmentInfo(new WireCommands.GetStreamSegmentInfo(0, "", "")));
assertThrows(IllegalStateException.class, () -> rp.createSegment(new CreateSegment(0, "", (byte) 0, 0, "", 0)));
assertThrows(IllegalStateException.class, () -> rp.updateSegmentPolicy(new UpdateSegmentPolicy(0, "", (byte) 0, 0, "")));
assertThrows(IllegalStateException.class, () -> rp.createTableSegment(new CreateTableSegment(0, "", false, 0, "", 0)));
assertThrows(IllegalStateException.class, () -> rp.deleteTableSegment(new DeleteTableSegment(0, "", false, "")));
assertThrows(IllegalStateException.class, () -> rp.updateTableEntries(new UpdateTableEntries(0, "", "", null, 0)));
assertThrows(IllegalStateException.class, () -> rp.removeTableKeys(new RemoveTableKeys(0, "", "", null, 0)));
assertThrows(IllegalStateException.class, () -> rp.readTable(new ReadTable(0, "", "", null)));
assertThrows(IllegalStateException.class, () -> rp.readTableKeys(new ReadTableKeys(0, "", "", 0, null)));
assertThrows(IllegalStateException.class, () -> rp.readTableEntries(new ReadTableEntries(0, "", "", 0, null)));
assertThrows(IllegalStateException.class, () -> rp.mergeSegments(new MergeSegments(0, "", "", "")));
assertThrows(IllegalStateException.class, () -> rp.sealSegment(new SealSegment(0, "", "")));
assertThrows(IllegalStateException.class, () -> rp.truncateSegment(new TruncateSegment(0, "", 0, "")));
assertThrows(IllegalStateException.class, () -> rp.deleteSegment(new DeleteSegment(0, "", "")));
assertThrows(IllegalStateException.class, () -> rp.readTableEntries(new ReadTableEntries(0, "", "", 0, null)));
assertThrows(IllegalStateException.class, () -> rp.createTableSegment(new CreateTableSegment(0, "", false, 0, "", 0)));
assertThrows(IllegalStateException.class, () -> rp.readTableEntriesDelta(new ReadTableEntriesDelta(0, "", "", 0, 0)));
assertThrows(IllegalStateException.class, () -> rp.createTransientSegment(new CreateTransientSegment(0, new UUID(0, 0), "", "")));
assertThrows(IllegalStateException.class, () -> rp.connectionDropped());
}
Aggregations