You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by af...@apache.org on 2015/11/12 20:08:58 UTC

incubator-reef git commit: [REEF-901] Add GetFileInfo/GetFileStatus API to IFileSystem

Repository: incubator-reef
Updated Branches:
  refs/heads/master 0b42c728d -> 1e21ecafa


[REEF-901] Add GetFileInfo/GetFileStatus API to IFileSystem

This addressed the issue by
 * Creating the new API
 * Adding trivial implementation to LocalFileSystem

JIRA:
 [REEF-901](https://issues.apache.org/jira/browse/REEF-901)

Pull Request:
  Closes #628


Project: http://git-wip-us.apache.org/repos/asf/incubator-reef/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-reef/commit/1e21ecaf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-reef/tree/1e21ecaf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-reef/diff/1e21ecaf

Branch: refs/heads/master
Commit: 1e21ecafa594364e90a1453e814728466230c115
Parents: 0b42c72
Author: Anupam <an...@gmail.com>
Authored: Tue Nov 10 17:57:43 2015 -0800
Committer: Andrew Chung <af...@gmail.com>
Committed: Thu Nov 12 11:07:09 2015 -0800

----------------------------------------------------------------------
 .../Org.Apache.REEF.IO/FileSystem/FileStatus.cs | 48 ++++++++++++++++++++
 .../FileSystem/Hadoop/HadoopFileSystem.cs       | 10 ++++
 .../FileSystem/IFileSystem.cs                   |  8 ++++
 .../FileSystem/Local/LocalFileSystem.cs         | 17 +++++++
 .../Org.Apache.REEF.IO.csproj                   |  1 +
 5 files changed, 84 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/1e21ecaf/lang/cs/Org.Apache.REEF.IO/FileSystem/FileStatus.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.IO/FileSystem/FileStatus.cs b/lang/cs/Org.Apache.REEF.IO/FileSystem/FileStatus.cs
new file mode 100644
index 0000000..5c1f999
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.IO/FileSystem/FileStatus.cs
@@ -0,0 +1,48 @@
+// 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.
+
+using System;
+
+namespace Org.Apache.REEF.IO.FileSystem
+{
+    /// <summary>
+    /// Represents metadata about a file.
+    /// </summary>
+    public sealed class FileStatus
+    {
+        /// <summary>
+        /// Creates filestatus object.
+        /// </summary>
+        /// <param name="modificationTime">Last modification time of the file</param>
+        /// <param name="lengthBytes">Size of the file in bytes</param>
+        public FileStatus(DateTime modificationTime, long lengthBytes)
+        {
+            ModificationTime = modificationTime;
+            LengthBytes = lengthBytes;
+        }
+
+        /// <summary>
+        /// Last modification time of the file
+        /// </summary>
+        public DateTime ModificationTime { get; private set; }
+
+        /// <summary>
+        /// Size of the file in bytes.
+        /// </summary>
+        public long LengthBytes { get; private set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/1e21ecaf/lang/cs/Org.Apache.REEF.IO/FileSystem/Hadoop/HadoopFileSystem.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.IO/FileSystem/Hadoop/HadoopFileSystem.cs b/lang/cs/Org.Apache.REEF.IO/FileSystem/Hadoop/HadoopFileSystem.cs
index 9d3b2c4..7be9db6 100644
--- a/lang/cs/Org.Apache.REEF.IO/FileSystem/Hadoop/HadoopFileSystem.cs
+++ b/lang/cs/Org.Apache.REEF.IO/FileSystem/Hadoop/HadoopFileSystem.cs
@@ -85,6 +85,16 @@ namespace Org.Apache.REEF.IO.FileSystem.Hadoop
         /// <summary>
         /// Not implemented by this IFileSystem.
         /// </summary>
+        /// <param name="remoteFileUri"></param>
+        /// <returns></returns>
+        public FileStatus GetFileStatus(Uri remoteFileUri)
+        {
+            throw new NotImplementedException("GetFileStatus() is not implemented for HadoopFileSystem");
+        }
+
+        /// <summary>
+        /// Not implemented by this IFileSystem.
+        /// </summary>
         /// <param name="fileUri"></param>
         /// <returns></returns>
         public Stream Open(Uri fileUri)

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/1e21ecaf/lang/cs/Org.Apache.REEF.IO/FileSystem/IFileSystem.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.IO/FileSystem/IFileSystem.cs b/lang/cs/Org.Apache.REEF.IO/FileSystem/IFileSystem.cs
index af0ade1..41e12cd 100644
--- a/lang/cs/Org.Apache.REEF.IO/FileSystem/IFileSystem.cs
+++ b/lang/cs/Org.Apache.REEF.IO/FileSystem/IFileSystem.cs
@@ -113,5 +113,13 @@ namespace Org.Apache.REEF.IO.FileSystem
         /// <param name="path"></param>
         /// <returns></returns>
         Uri CreateUriForPath(string path);
+
+        /// <summary>
+        /// Gets the FileStatus for remote file.
+        /// </summary>
+        /// <param name="remoteFileUri"></param>
+        /// <exception cref="ArgumentNullException">If remote file URI is null</exception>
+        /// <returns>FileStatus</returns>
+        FileStatus GetFileStatus(Uri remoteFileUri);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/1e21ecaf/lang/cs/Org.Apache.REEF.IO/FileSystem/Local/LocalFileSystem.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.IO/FileSystem/Local/LocalFileSystem.cs b/lang/cs/Org.Apache.REEF.IO/FileSystem/Local/LocalFileSystem.cs
index 76ea828..69a33ad 100644
--- a/lang/cs/Org.Apache.REEF.IO/FileSystem/Local/LocalFileSystem.cs
+++ b/lang/cs/Org.Apache.REEF.IO/FileSystem/Local/LocalFileSystem.cs
@@ -48,6 +48,23 @@ namespace Org.Apache.REEF.IO.FileSystem.Local
             return new Uri(path);
         }
 
+        /// <summary>
+        /// Gets the FileStatus for given file.
+        /// </summary>
+        /// <param name="remoteFileUri"></param>
+        /// <exception cref="ArgumentNullException">If file URI is null</exception>
+        /// <returns>FileStatus</returns>
+        public FileStatus GetFileStatus(Uri remoteFileUri)
+        {
+            if (remoteFileUri == null)
+            {
+                throw new ArgumentNullException("remoteFileUri");
+            }
+
+            FileInfo fileInfo = new FileInfo(remoteFileUri.LocalPath);
+            return new FileStatus(fileInfo.LastWriteTime, fileInfo.Length);
+        }
+
         public Stream Open(Uri fileUri)
         {
             return File.Open(fileUri.LocalPath, FileMode.Open);

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/1e21ecaf/lang/cs/Org.Apache.REEF.IO/Org.Apache.REEF.IO.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.IO/Org.Apache.REEF.IO.csproj b/lang/cs/Org.Apache.REEF.IO/Org.Apache.REEF.IO.csproj
index 9af9d24..7ed8e77 100644
--- a/lang/cs/Org.Apache.REEF.IO/Org.Apache.REEF.IO.csproj
+++ b/lang/cs/Org.Apache.REEF.IO/Org.Apache.REEF.IO.csproj
@@ -41,6 +41,7 @@ under the License.
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="FileSystem\FileStatus.cs" />
     <Compile Include="FileSystem\Hadoop\CommandResult.cs" />
     <Compile Include="FileSystem\Hadoop\HDFSConfigurationWithoutDriverBinding.cs" />
     <Compile Include="FileSystem\Hadoop\HadoopFileSystemConfiguration.cs" />