incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Fix for hadoop2, where the hdfs default and site files are not loaded by default.
Date Sun, 12 Apr 2015 00:54:20 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/master f8f81e007 -> c85f8c0cf


Fix for hadoop2, where the hdfs default and site files are not loaded by default.


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

Branch: refs/heads/master
Commit: c85f8c0cf9159abe9bee388eb3f08af73d1dc48e
Parents: f8f81e0
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sat Apr 11 20:54:18 2015 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sat Apr 11 20:54:18 2015 -0400

----------------------------------------------------------------------
 .../org/apache/blur/server/TableContext.java    |  3 +-
 .../blur/thrift/ThriftBlurControllerServer.java |  8 +++--
 .../blur/thrift/ThriftBlurShardServer.java      |  2 +-
 .../java/org/apache/blur/utils/BlurUtil.java    | 36 ++++++--------------
 4 files changed, 19 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/c85f8c0c/blur-core/src/main/java/org/apache/blur/server/TableContext.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/server/TableContext.java b/blur-core/src/main/java/org/apache/blur/server/TableContext.java
index 6fcf573..ed62b9b 100644
--- a/blur-core/src/main/java/org/apache/blur/server/TableContext.java
+++ b/blur-core/src/main/java/org/apache/blur/server/TableContext.java
@@ -63,6 +63,7 @@ import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.ScoreType;
 import org.apache.blur.thrift.generated.TableDescriptor;
 import org.apache.blur.utils.BlurConstants;
+import org.apache.blur.utils.BlurUtil;
 import org.apache.blur.utils.ShardUtil;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
@@ -349,7 +350,7 @@ public class TableContext implements Cloneable {
 
   public static synchronized Configuration getSystemConfiguration() {
     if (_systemConfiguration == null) {
-      _systemConfiguration = new Configuration();
+      _systemConfiguration = BlurUtil.newHadoopConfiguration();
     }
     return new Configuration(_systemConfiguration);
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/c85f8c0c/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurControllerServer.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurControllerServer.java
b/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurControllerServer.java
index 4c943b9..a122808 100644
--- a/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurControllerServer.java
+++ b/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurControllerServer.java
@@ -70,6 +70,7 @@ import org.apache.blur.server.ControllerServerEventHandler;
 import org.apache.blur.server.ServerSecurityFilter;
 import org.apache.blur.server.ServerSecurityFilterFactory;
 import org.apache.blur.server.ServerSecurityUtil;
+import org.apache.blur.server.TableContext;
 import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TJSONProtocol;
 import org.apache.blur.thirdparty.thrift_0_9_0.server.TServlet;
 import org.apache.blur.thirdparty.thrift_0_9_0.transport.TServerTransport;
@@ -110,6 +111,10 @@ public class ThriftBlurControllerServer extends ThriftServer {
   }
 
   public static ThriftServer createServer(int serverIndex, BlurConfiguration configuration)
throws Exception {
+    Configuration config = BlurUtil.newHadoopConfiguration();
+    TableContext.setSystemBlurConfiguration(configuration);
+    TableContext.setSystemConfiguration(config);
+    
     Thread.setDefaultUncaughtExceptionHandler(new SimpleUncaughtExceptionHandler());
     String bindAddress = configuration.get(BLUR_CONTROLLER_BIND_ADDRESS);
     int configBindPort = configuration.getInt(BLUR_CONTROLLER_BIND_PORT, -1);
@@ -134,8 +139,7 @@ public class ThriftBlurControllerServer extends ThriftServer {
 
     final ZooKeeper zooKeeper = ZkUtils.newZooKeeper(zkConnectionStr, sessionTimeout);
 
-    Configuration config = new Configuration();
-
+    
     BlurUtil.setupZookeeper(zooKeeper, null);
 
     final ZookeeperClusterStatus clusterStatus = new ZookeeperClusterStatus(zooKeeper, configuration,
config);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/c85f8c0c/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java b/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java
index f624119..c4c6c29 100644
--- a/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java
+++ b/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java
@@ -148,7 +148,7 @@ public class ThriftBlurShardServer extends ThriftServer {
   }
 
   public static ThriftServer createServer(int serverIndex, BlurConfiguration configuration)
throws Exception {
-    Configuration config = new Configuration();
+    Configuration config = BlurUtil.newHadoopConfiguration();
     TableContext.setSystemBlurConfiguration(configuration);
     TableContext.setSystemConfiguration(config);
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/c85f8c0c/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java b/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
index fc0be76..e4db03b 100644
--- a/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
+++ b/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
@@ -103,7 +103,6 @@ import org.apache.blur.trace.Tracer;
 import org.apache.blur.user.User;
 import org.apache.blur.user.UserContext;
 import org.apache.blur.zookeeper.ZookeeperPathConstants;
-import org.apache.hadoop.conf.Configurable;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
@@ -763,31 +762,6 @@ public class BlurUtil {
     return t;
   }
 
-  @SuppressWarnings("unchecked")
-  public static <T> T getInstance(String className, Class<T> c) {
-    Class<?> clazz;
-    try {
-      clazz = Class.forName(className);
-    } catch (ClassNotFoundException e) {
-      throw new RuntimeException(e);
-    }
-    try {
-      return (T) configure(clazz.newInstance());
-    } catch (InstantiationException e) {
-      throw new RuntimeException(e);
-    } catch (IllegalAccessException e) {
-      throw new RuntimeException(e);
-    }
-  }
-
-  public static <T> T configure(T t) {
-    if (t instanceof Configurable) {
-      Configurable configurable = (Configurable) t;
-      configurable.setConf(new Configuration());
-    }
-    return t;
-  }
-
   public static byte[] read(TBase<?, ?> base) {
     if (base == null) {
       return null;
@@ -1312,5 +1286,15 @@ public class BlurUtil {
       throw new RuntimeException(e);
     }
   }
+  
+  public static Configuration newHadoopConfiguration() {
+    return addHdfsConfig(new Configuration());
+  }
+
+  public static Configuration addHdfsConfig(Configuration configuration) {
+    configuration.addResource("hdfs-default.xml");
+    configuration.addResource("hdfs-site.xml");
+    return configuration;
+  }
 
 }


Mime
View raw message