You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2019/10/18 02:57:15 UTC

[GitHub] [incubator-iotdb] qiaojialin commented on a change in pull request #417: [IOTDB-234] Refactor TsFile storage on HDFS

qiaojialin commented on a change in pull request #417: [IOTDB-234] Refactor TsFile storage on HDFS
URL: https://github.com/apache/incubator-iotdb/pull/417#discussion_r336303498
 
 

 ##########
 File path: tsfile/src/main/java/org/apache/iotdb/tsfile/fileSystem/fsFactory/HDFSFactory.java
 ##########
 @@ -0,0 +1,190 @@
+/*
+ * 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.iotdb.tsfile.fileSystem.fsFactory;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URI;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HDFSFactory implements FSFactory {
+
+  private static final Logger logger = LoggerFactory.getLogger(HDFSFactory.class);
+  private static Constructor constructorWithPathname;
+  private static Constructor constructorWithParentStringAndChild;
+  private static Constructor constructorWithParentFileAndChild;
+  private static Constructor constructorWithUri;
+  private static Method getBufferedReader;
+  private static Method getBufferedWriter;
+  private static Method getBufferedInputStream;
+  private static Method getBufferedOutputStream;
+  private static Method listFilesBySuffix;
+  private static Method listFilesByPrefix;
+
+  static {
+    try {
+      Class<?> clazz = Class.forName("org.apache.iotdb.tsfile.fileSystem.HDFSFile");
+      constructorWithPathname = clazz.getConstructor(String.class);
+      constructorWithParentStringAndChild = clazz.getConstructor(String.class, String.class);
+      constructorWithParentFileAndChild = clazz.getConstructor(File.class, String.class);
+      constructorWithUri = clazz.getConstructor(URI.class);
+      getBufferedReader = clazz.getMethod("getBufferedReader", String.class);
+      getBufferedWriter = clazz.getMethod("getBufferedWriter", String.class, boolean.class);
+      getBufferedInputStream = clazz.getMethod("getBufferedInputStream", String.class);
+      getBufferedOutputStream = clazz.getMethod("getBufferedOutputStream", String.class);
+      listFilesBySuffix = clazz.getMethod("listFilesBySuffix", String.class, String.class);
+      listFilesByPrefix = clazz.getMethod("listFilesByPrefix", String.class, String.class);
+    } catch (ClassNotFoundException | NoSuchMethodException e) {
+      logger.error(
+          "Failed to get Hadoop file system. Please check your dependency of Hadoop module.", e);
 
 Review comment:
   So, even if we store data files on the local file system, the server will also print an error log? This should be avoided.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services