You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by sz...@apache.org on 2012/03/10 02:58:29 UTC

svn commit: r1299144 - /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/RollingLogs.java

Author: szetszwo
Date: Sat Mar 10 01:58:29 2012
New Revision: 1299144

URL: http://svn.apache.org/viewvc?rev=1299144&view=rev
Log:
HDFS-3056: add the new file for the previous commit.

Added:
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/RollingLogs.java

Added: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/RollingLogs.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/RollingLogs.java?rev=1299144&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/RollingLogs.java (added)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/RollingLogs.java Sat Mar 10 01:58:29 2012
@@ -0,0 +1,68 @@
+/**
+ * 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.hadoop.hdfs.server.datanode;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.Iterator;
+
+/**
+ * Rolling logs consist of a current log and a previous log.
+ * When the roll operation is invoked, current is rolled to previous
+ * and previous is deleted.
+ * The implementation should support a single appender and multiple readers.
+ */
+public interface RollingLogs {
+  /**
+   * To iterate the lines of the logs.
+   */
+  public interface LineIterator extends Iterator<String>, Closeable {
+    /** Is the iterator iterating the previous? */
+    public boolean isPrevious();
+  }
+
+  /**
+   * To append text to the logs.
+   */
+  public interface Appender extends Appendable, Closeable {
+  }
+
+  /**
+   * Create an iterator to iterate the lines in the logs.
+   * 
+   * @param skipPrevious Should it skip reading the previous log? 
+   * @return a new iterator.
+   */
+  public LineIterator iterator(boolean skipPrevious) throws IOException;
+
+  /**
+   * @return the only appender to append text to the logs.
+   *   The same object is returned if it is invoked multiple times.
+   */
+  public Appender appender();
+
+  /**
+   * Roll current to previous and delete the previous.
+   *
+   * @return true if the rolling succeeded.
+   *   When it returns false, it is not equivalent to an error. 
+   *   It means that the rolling cannot be performed at the moment,
+   *   e.g. the logs are being read.
+   */
+  public boolean roll() throws IOException;
+}
\ No newline at end of file