use of org.apache.ratis.shaded.com.google.protobuf.ByteString in project incubator-ratis by apache.
the class TestRaftId method testClientId.
@Test
public void testClientId() {
final ClientId id = ClientId.randomId();
final ByteString bytes = id.toByteString();
Assert.assertEquals(bytes, id.toByteString());
Assert.assertEquals(id, ClientId.valueOf(bytes));
}
use of org.apache.ratis.shaded.com.google.protobuf.ByteString in project incubator-ratis by apache.
the class TestRaftId method testRaftGroupId.
@Test
public void testRaftGroupId() {
final RaftGroupId id = RaftGroupId.randomId();
final ByteString bytes = id.toByteString();
Assert.assertEquals(bytes, id.toByteString());
Assert.assertEquals(id, RaftGroupId.valueOf(bytes));
}
use of org.apache.ratis.shaded.com.google.protobuf.ByteString in project incubator-ratis by apache.
the class TestRaftId method testRaftPeerId.
@Test
public void testRaftPeerId() {
final RaftPeerId id = RaftPeerId.valueOf("abc");
final ByteString bytes = id.toByteString();
Assert.assertEquals(bytes, id.toByteString());
Assert.assertEquals(id, RaftPeerId.valueOf(bytes));
}
use of org.apache.ratis.shaded.com.google.protobuf.ByteString in project incubator-ratis by apache.
the class FileStoreClient method write.
public long write(String path, long offset, boolean close, ByteBuffer buffer) throws IOException {
final int chunkSize = FileStoreCommon.getChunkSize(buffer.remaining());
buffer.limit(chunkSize);
final ByteString reply = writeImpl(this::send, path, offset, close, buffer);
return WriteReplyProto.parseFrom(reply).getLength();
}
use of org.apache.ratis.shaded.com.google.protobuf.ByteString in project incubator-ratis by apache.
the class FileStoreStateMachine method writeStateMachineData.
@Override
public CompletableFuture<Integer> writeStateMachineData(LogEntryProto entry) {
final SMLogEntryProto smLog = entry.getSmLogEntry();
final ByteString data = smLog.getData();
final FileStoreRequestProto proto;
try {
proto = FileStoreRequestProto.parseFrom(data);
} catch (InvalidProtocolBufferException e) {
return FileStoreCommon.completeExceptionally(entry.getIndex(), "Failed to parse data, entry=" + entry, e);
}
if (proto.getRequestCase() != FileStoreRequestProto.RequestCase.WRITEHEADER) {
return null;
}
final WriteRequestHeaderProto h = proto.getWriteHeader();
final CompletableFuture<Integer> f = files.write(entry.getIndex(), h.getPath().toStringUtf8(), h.getClose(), h.getOffset(), smLog.getStateMachineData());
// sync only if closing the file
return h.getClose() ? f : null;
}
Aggregations