joshelser commented on a change in pull request #25: RATIS-588 LogStream 
StateMachine export
URL: https://github.com/apache/incubator-ratis/pull/25#discussion_r299658674
 
 

 ##########
 File path: 
ratis-logservice/src/main/java/org/apache/ratis/logservice/impl/ArchiveHdfsLogWriter.java
 ##########
 @@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ratis.logservice.impl;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.ratis.logservice.api.ArchiveLogWriter;
+import org.apache.ratis.logservice.api.LogName;
+import org.apache.ratis.logservice.util.LogServiceUtils;
+
+public class ArchiveHdfsLogWriter implements ArchiveLogWriter {
+  private FileSystem hdfs;
+  private FSDataOutputStream os;
+  private Path currentPath;
+  private long currentRecordId;
+  private long lastRollRecordId;
+
+  @Override
+  public void init(String location, LogName logName) throws IOException {
+    Configuration configuration = new Configuration();
+    hdfs = FileSystem.get(configuration);
+    Path loc = new Path(location);
+    if(!hdfs.exists(loc)){
+      hdfs.mkdirs(loc);
 
 Review comment:
   Thinking about the case where we switch writers of the file.
   
   * Leader1 writes a segment 0->100.
   * Leader1 starts writing the next segment 101->...
   * Leader1 pauses, Leader2 takes over
   * Leader1 sends archive request to Leader2
   
   A couple of concerns:
   1. Would Leader2 try to re-write segment 0->100? It looks like 
`LogStateMachine#processArchiveLog` alwasys starts from the beginning. Could we 
know that we don't need to rewrite segment(s)?
   2. If we just try to rewrite the segments from the start, do we need  to 
remove any of the old segments before starting again?

----------------------------------------------------------------
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

Reply via email to