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

 ##########
 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:
   Hi, thanks for  your checking.  I had solved this by avoiding constructing 
all filed in static field in `FSFactoryProducer`.

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


With regards,
Apache Git Services

Reply via email to