joshelser commented on a change in pull request #25: RATIS-588 LogStream
StateMachine export
URL: https://github.com/apache/incubator-ratis/pull/25#discussion_r304153325
##########
File path:
ratis-logservice/src/main/java/org/apache/ratis/logservice/client/LogServiceClient.java
##########
@@ -149,20 +186,62 @@ public void close() throws Exception {
* @param logInfo
* @return
*/
- private RaftClient getRaftClient(LogInfo logInfo) {
+ private RaftClient getRaftClient(LogInfo logInfo) throws IOException {
+
RaftProperties properties = new RaftProperties();
return
RaftClient.newBuilder().setRaftGroup(logInfo.getRaftGroup()).setProperties(properties).build();
}
+ private LogInfo getLogInfo(LogName logName) throws IOException {
+ RaftClientReply reply = client.sendReadOnly(
+ () ->
MetaServiceProtoUtil.toGetLogRequestProto(logName).toByteString());
+ GetLogReplyProto message =
GetLogReplyProto.parseFrom(reply.getMessage().getContent());
+ if (message.hasException()) {
+ throw
MetaServiceProtoUtil.toMetaServiceException(message.getException());
+ }
+ return MetaServiceProtoUtil.toLogInfo(message.getLog());
+ }
+
/**
- * Archives the given log out of the state machine and into a configurable
long-term storage. A log must be
- * in {@link State#CLOSED} to archive it.
+ * Archives the given log out of the state machine and into a configurable
long-term storage.
+ * A log must be in {@link State#CLOSED} to archive it.
+ * Archiving of the log will happen asynchronously from the client,
+ * The call will return immediately after adding a request for archiving
log
+ * to the respective quorum
*
- * @param name The name of the log to archive.
+ * Client can check the status of Archiving by calling getState() Method
+ *
+ * @param logName The name of the log to archive.
+ */
+ public void archiveLog(LogName logName) throws IOException {
+ exportLog(logName, null, 0);
+ }
+
+ /**
+ * Export the given log out of the state machine and into a provided
location on the configured storage
+ * A log must be in {@link State#CLOSED} to export it.
+ * exporting of the log will happen asynchronously from the client,
+ * The call will return immediately after adding a request for archiving
log
+ * to the respective quorum
+ *
+ * Client can check the status of export by calling getState() Method
+ *
+ * @param logName The name of the log to archive.
*/
- void archiveLog(LogName name) throws IOException {
- // TODO: write me
+ public void exportLog(LogName logName, String location, long recordId)
throws IOException {
Review comment:
Do we want `export` and `archive` to have different semantics? We could
leave the fact that we start at `recordId=0` as an implementation detail if we
don't have an obvious use-case for how a client would use this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services