-ROOT- and
* .META..
@@ -181,9 +184,12 @@ public class CatalogTracker {
* ({@link Object#wait(long)} when passed a 0 waits for ever).
* @throws IOException
*/
- public CatalogTracker(final ZooKeeperWatcher zk, final Configuration conf,
- Abortable abortable, final int defaultTimeout)
- throws IOException {
+ @Inject
+ public CatalogTracker(@Assisted final ZooKeeperWatcher zk,
+ @Assisted final Configuration conf,
+ @Assisted Abortable abortable,
+ @Assisted final int defaultTimeout)
+ throws IOException {
this(zk, conf, HConnectionManager.getConnection(conf), abortable, defaultTimeout);
}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTrackerFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTrackerFactory.java
new file mode 100644
index 0000000..0403139
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTrackerFactory.java
@@ -0,0 +1,49 @@
+/**
+ * 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.hbase.catalog;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.Abortable;
+import org.apache.hadoop.hbase.catalog.CatalogTracker;
+import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+
+import java.io.IOException;
+
+/**
+ *
+ */
+public interface CatalogTrackerFactory {
+
+ /**
+ * Create a CatalogTracker
+ *
+ * @param zk TheZookeeperWatcher to use
+ * @param conf The Configuration for the server. This is passed in explicitly so that
+ * HConnectionManager will pool connections correctly.
+ * @param abortable Abortable to abort if there was an error.
+ * @param defaultTimeout Timeout to wait.
+ * @return
+ * @throws IOException
+ */
+ public CatalogTracker create(final ZooKeeperWatcher zk,
+ final Configuration conf,
+ Abortable abortable,
+ final int defaultTimeout) throws IOException;
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTrackerManager.java hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTrackerManager.java
new file mode 100644
index 0000000..fd7b5ff
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTrackerManager.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.catalog;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class CatalogTrackerManager extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(CatalogTracker.class, CatalogTracker.class)
+ .build(CatalogTrackerFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/executor/ExecutorService.java hbase-server/src/main/java/org/apache/hadoop/hbase/executor/ExecutorService.java
index d8f019a..e73a2de 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/executor/ExecutorService.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/executor/ExecutorService.java
@@ -33,6 +33,7 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -43,6 +44,8 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import javax.inject.Inject;
+
/**
* This is a generic executor service. This component abstracts a
* threadpool, a queue to which {@link EventHandler.EventType}s can be submitted,
@@ -110,7 +113,8 @@ public class ExecutorService {
* Default constructor.
* @param servername Name of the hosting server.
*/
- public ExecutorService(final String servername) {
+ @Inject
+ public ExecutorService(@Assisted final String servername) {
super();
this.servername = servername;
}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/executor/ExecutorServiceFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/executor/ExecutorServiceFactory.java
new file mode 100644
index 0000000..6dcf23e
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/executor/ExecutorServiceFactory.java
@@ -0,0 +1,10 @@
+package org.apache.hadoop.hbase.executor;
+
+/**
+ *
+ */
+public interface ExecutorServiceFactory {
+
+ public ExecutorService create(final String servername);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/executor/ExecutorServiceModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/executor/ExecutorServiceModule.java
new file mode 100644
index 0000000..e8552f7
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/executor/ExecutorServiceModule.java
@@ -0,0 +1,17 @@
+package org.apache.hadoop.hbase.executor;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class ExecutorServiceModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(ExecutorService.class, ExecutorService.class)
+ .build(ExecutorServiceFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerDefaultFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerDefaultFactory.java
new file mode 100644
index 0000000..347a065
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerDefaultFactory.java
@@ -0,0 +1,53 @@
+/**
+ * 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.hbase.ipc;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.ipc.HBaseRPC;
+import org.apache.hadoop.hbase.ipc.RpcServer;
+import org.apache.hadoop.hbase.ipc.RpcServerFactory;
+
+import java.io.IOException;
+
+/**
+ *
+ */
+public class RpcServerDefaultFactory implements RpcServerFactory {
+
+ @Override
+ public RpcServer create(Object instance,
+ Class>[] ifaces,
+ String bindAddress,
+ int port,
+ int numHandlers,
+ int metaHandlerCount,
+ boolean verbose,
+ Configuration conf,
+ int highPriorityLevel) throws IOException {
+ return HBaseRPC.getServer(instance,
+ ifaces,
+ bindAddress,
+ port,
+ numHandlers,
+ metaHandlerCount,
+ verbose,
+ conf,
+ highPriorityLevel);
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerFactory.java
new file mode 100644
index 0000000..2035840
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerFactory.java
@@ -0,0 +1,41 @@
+/**
+ * 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.hbase.ipc;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.ipc.RpcServer;
+
+import java.io.IOException;
+
+/**
+ *
+ */
+public interface RpcServerFactory {
+
+ public RpcServer create(final Object instance,
+ final Class>[] ifaces,
+ final String bindAddress,
+ final int port,
+ final int numHandlers,
+ int metaHandlerCount,
+ final boolean verbose,
+ Configuration conf,
+ int highPriorityLevel) throws IOException;
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerModule.java
new file mode 100644
index 0000000..4c0b8ba
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerModule.java
@@ -0,0 +1,32 @@
+/**
+ * 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.hbase.ipc;
+
+import com.google.inject.AbstractModule;
+
+/**
+ *
+ */
+public class RpcServerModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(RpcServerFactory.class).to(RpcServerDefaultFactory.class);
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java
index 84935d9..4af1a44 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java
@@ -22,6 +22,7 @@ package org.apache.hadoop.hbase.master;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -37,6 +38,8 @@ import org.apache.hadoop.hbase.zookeeper.ZooKeeperListener;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.apache.zookeeper.KeeperException;
+import javax.inject.Inject;
+
/**
* Handles everything on master-side related to master election.
*
@@ -51,7 +54,7 @@ import org.apache.zookeeper.KeeperException;
* the active master of the cluster.
*/
@InterfaceAudience.Private
-class ActiveMasterManager extends ZooKeeperListener {
+public class ActiveMasterManager extends ZooKeeperListener {
private static final Log LOG = LogFactory.getLog(ActiveMasterManager.class);
final AtomicBoolean clusterHasActiveMaster = new AtomicBoolean(false);
@@ -60,11 +63,14 @@ class ActiveMasterManager extends ZooKeeperListener {
private final Server master;
/**
- * @param watcher
- * @param sn ServerName
- * @param master In an instance of a Master.
+ * @param watcher The ZookeeperWatcher to use.
+ * @param sn ServerName
+ * @param master In an instance of a Master.
*/
- ActiveMasterManager(ZooKeeperWatcher watcher, ServerName sn, Server master) {
+ @Inject
+ ActiveMasterManager(@Assisted ZooKeeperWatcher watcher,
+ @Assisted ServerName sn,
+ @Assisted Server master) {
super(watcher);
this.sn = sn;
this.master = master;
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManagerFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManagerFactory.java
new file mode 100644
index 0000000..cf204c5
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManagerFactory.java
@@ -0,0 +1,37 @@
+/**
+ * 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.hbase.master;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.Server;
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+
+/**
+ * Interface of a Factory that can construct a ActiveMasterManager.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface ActiveMasterManagerFactory {
+
+ public ActiveMasterManager create(ZooKeeperWatcher watcher,
+ ServerName sn,
+ Server master);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManagerModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManagerModule.java
new file mode 100644
index 0000000..0f0c3b5
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManagerModule.java
@@ -0,0 +1,36 @@
+/**
+ * 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.hbase.master;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class ActiveMasterManagerModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(ActiveMasterManager.class, ActiveMasterManager.class)
+ .build(ActiveMasterManagerFactory.class));
+
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
index d6b41ec..f00f7de 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
@@ -38,6 +38,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -87,6 +88,8 @@ import org.apache.zookeeper.KeeperException.NoNodeException;
import org.apache.zookeeper.KeeperException.NodeExistsException;
import org.apache.zookeeper.data.Stat;
+import javax.inject.Inject;
+
/**
* Manages and performs region assignment.
*
@@ -186,9 +189,14 @@ public class AssignmentManager extends ZooKeeperListener {
* @throws KeeperException
* @throws IOException
*/
- public AssignmentManager(Server master, ServerManager serverManager,
- CatalogTracker catalogTracker, final LoadBalancer balancer,
- final ExecutorService service, MasterMetrics metrics) throws KeeperException, IOException {
+ @Inject
+ public AssignmentManager(@Assisted Server master,
+ @Assisted ServerManager serverManager,
+ @Assisted CatalogTracker catalogTracker,
+ @Assisted final LoadBalancer balancer,
+ @Assisted final ExecutorService service,
+ @Assisted MasterMetrics metrics)
+ throws KeeperException, IOException {
super(master.getZooKeeper());
this.master = master;
this.serverManager = serverManager;
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManagerFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManagerFactory.java
new file mode 100644
index 0000000..90326a1
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManagerFactory.java
@@ -0,0 +1,41 @@
+/**
+ * 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.hbase.master;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.Server;
+import org.apache.hadoop.hbase.catalog.CatalogTracker;
+import org.apache.hadoop.hbase.executor.ExecutorService;
+import org.apache.hadoop.hbase.master.metrics.MasterMetrics;
+
+/**
+ * Interface of a Factory that can construct a AssignmentManager.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface AssignmentManagerFactory {
+
+ public AssignmentManager create(Server master,
+ ServerManager serverManager,
+ CatalogTracker catalogTracker,
+ LoadBalancer balancer,
+ ExecutorService service,
+ MasterMetrics metrics);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManagerModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManagerModule.java
new file mode 100644
index 0000000..f8a47ad
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManagerModule.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.master;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class AssignmentManagerModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(AssignmentManager.class, AssignmentManager.class)
+ .build(AssignmentManagerFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java
index 0249d79..4bec2ba 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java
@@ -28,6 +28,7 @@ import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -52,22 +53,25 @@ import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.util.Writables;
+import javax.inject.Inject;
+
/**
* A janitor for the catalog tables. Scans the .META. catalog
* table on a period looking for unused regions to garbage collect.
*/
@InterfaceAudience.Private
-class CatalogJanitor extends Chore {
+public class CatalogJanitor extends Chore {
private static final Log LOG = LogFactory.getLog(CatalogJanitor.class.getName());
private final Server server;
private final MasterServices services;
private AtomicBoolean enabled = new AtomicBoolean(true);
private AtomicBoolean alreadyRunning = new AtomicBoolean(false);
- CatalogJanitor(final Server server, final MasterServices services) {
+ @Inject
+ CatalogJanitor(@Assisted final Server server, @Assisted final MasterServices services) {
super(server.getServerName() + "-CatalogJanitor",
- server.getConfiguration().getInt("hbase.catalogjanitor.interval", 300000),
- server);
+ server.getConfiguration().getInt("hbase.catalogjanitor.interval", 300000),
+ server);
this.server = server;
this.services = services;
}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitorFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitorFactory.java
new file mode 100644
index 0000000..1b838db
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitorFactory.java
@@ -0,0 +1,33 @@
+/**
+ * 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.hbase.master;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.Server;
+
+/**
+ * Interface of a Factory that can construct a CatalogJanitor.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface CatalogJanitorFactory {
+
+ public CatalogJanitor create( final Server server, final MasterServices services);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitorModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitorModule.java
new file mode 100644
index 0000000..ee74f25
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitorModule.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.master;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class CatalogJanitorModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(CatalogJanitor.class, CatalogJanitor.class)
+ .build(CatalogJanitorFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
index 31df068..6292cac 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
@@ -20,8 +20,6 @@
package org.apache.hadoop.hbase.master;
import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
@@ -39,17 +37,17 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
+import javax.inject.Inject;
import javax.management.ObjectName;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.Abortable;
import org.apache.hadoop.hbase.Chore;
import org.apache.hadoop.hbase.ClusterStatus;
-import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
import org.apache.hadoop.hbase.DeserializationException;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants;
@@ -79,15 +77,18 @@ import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
import org.apache.hadoop.hbase.executor.ExecutorService;
import org.apache.hadoop.hbase.executor.ExecutorService.ExecutorType;
-import org.apache.hadoop.hbase.ipc.HBaseRPC;
+import org.apache.hadoop.hbase.executor.ExecutorServiceFactory;
import org.apache.hadoop.hbase.ipc.HBaseServer;
+import org.apache.hadoop.hbase.master.balancer.LoadBalancerFactory;
+import org.apache.hadoop.hbase.master.balancer.LoadBalancerFactoryImpl;
import org.apache.hadoop.hbase.master.metrics.MXBeanImpl;
import org.apache.hadoop.hbase.metrics.MBeanSource;
+import org.apache.hadoop.hbase.ipc.RpcServerFactory;
+import org.apache.hadoop.hbase.master.metrics.MasterMetricsFactory;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.ResponseConverter;
import org.apache.hadoop.hbase.ipc.ProtocolSignature;
import org.apache.hadoop.hbase.ipc.RpcServer;
-import org.apache.hadoop.hbase.master.balancer.LoadBalancerFactory;
import org.apache.hadoop.hbase.master.cleaner.HFileCleaner;
import org.apache.hadoop.hbase.master.cleaner.LogCleaner;
import org.apache.hadoop.hbase.master.handler.CreateTableHandler;
@@ -105,6 +106,36 @@ import org.apache.hadoop.hbase.monitoring.MemoryBoundedLogMessageBuffer;
import org.apache.hadoop.hbase.monitoring.MonitoredTask;
import org.apache.hadoop.hbase.monitoring.TaskMonitor;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
+import org.apache.hadoop.hbase.replication.regionserver.Replication;
+import org.apache.hadoop.hbase.security.User;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.CompressionTest;
+import org.apache.hadoop.hbase.util.FSTableDescriptors;
+import org.apache.hadoop.hbase.util.FSTableDescriptorsFactory;
+import org.apache.hadoop.hbase.util.HFileArchiveUtil;
+import org.apache.hadoop.hbase.util.HasThread;
+import org.apache.hadoop.hbase.util.InfoServer;
+import org.apache.hadoop.hbase.util.Pair;
+import org.apache.hadoop.hbase.util.Sleeper;
+import org.apache.hadoop.hbase.util.SleeperFactory;
+import org.apache.hadoop.hbase.util.Strings;
+import org.apache.hadoop.hbase.util.Threads;
+import org.apache.hadoop.hbase.util.VersionInfo;
+import org.apache.hadoop.hbase.catalog.CatalogTrackerFactory;
+import org.apache.hadoop.hbase.zookeeper.ClusterStatusTrackerFactory;
+import org.apache.hadoop.hbase.zookeeper.DrainingServerTrackerFactory;
+import org.apache.hadoop.hbase.zookeeper.RegionServerTrackerFactory;
+import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
+import org.apache.hadoop.hbase.zookeeper.ClusterStatusTracker;
+import org.apache.hadoop.hbase.zookeeper.DrainingServerTracker;
+import org.apache.hadoop.hbase.zookeeper.RegionServerTracker;
+import org.apache.hadoop.hbase.zookeeper.ZKUtil;
+import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcherFactory;
+import org.apache.hadoop.metrics.util.MBeanUtil;
+import org.apache.hadoop.net.DNS;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.Watcher;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameStringPair;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType;
import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.AddColumnRequest;
@@ -159,29 +190,6 @@ import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.Regio
import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerStartupResponse;
import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.ReportRSFatalErrorRequest;
import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.ReportRSFatalErrorResponse;
-import org.apache.hadoop.hbase.replication.regionserver.Replication;
-import org.apache.hadoop.hbase.security.User;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.util.CompressionTest;
-import org.apache.hadoop.hbase.util.FSTableDescriptors;
-import org.apache.hadoop.hbase.util.HFileArchiveUtil;
-import org.apache.hadoop.hbase.util.HasThread;
-import org.apache.hadoop.hbase.util.InfoServer;
-import org.apache.hadoop.hbase.util.Pair;
-import org.apache.hadoop.hbase.util.Sleeper;
-import org.apache.hadoop.hbase.util.Strings;
-import org.apache.hadoop.hbase.util.Threads;
-import org.apache.hadoop.hbase.util.VersionInfo;
-import org.apache.hadoop.hbase.zookeeper.ClusterStatusTracker;
-import org.apache.hadoop.hbase.zookeeper.DrainingServerTracker;
-import org.apache.hadoop.hbase.zookeeper.RegionServerTracker;
-import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
-import org.apache.hadoop.hbase.zookeeper.ZKUtil;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
-import org.apache.hadoop.metrics.util.MBeanUtil;
-import org.apache.hadoop.net.DNS;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.Watcher;
import com.google.protobuf.RpcController;
import com.google.protobuf.ServiceException;
@@ -302,6 +310,20 @@ Server {
//should we check the compression codec type at master side, default true, HBASE-6370
private final boolean masterCheckCompression;
+ private final ClusterStatusTrackerFactory clusterStatusTrackerFactory;
+ private final ActiveMasterManagerFactory activeMasterManagerFactory;
+ private final CatalogTrackerFactory catalogTrackerFactory;
+ private final AssignmentManagerFactory assignmentManagerFactory;
+ private final RegionServerTrackerFactory regionServerTrackerFactory;
+ private final DrainingServerTrackerFactory drainingServerTrackerFactory;
+ private final LoadBalancerFactory loadBalancerFactory;
+ private final MasterFileSystemFactory masterFileSystemFactory;
+ private final FSTableDescriptorsFactory fsTableDescriptorsFactory;
+ private final ExecutorServiceFactory executorServiceFactory;
+ private final ServerManagerFactory serverManagerFactory;
+ private final MasterCoprocessorHostFactory masterCoprocessorHostFactory;
+ private final CatalogJanitorFactory catalogJanitorFactory;
+ private final MBeanSource mBeanSource;
/**
* Initializes the HMaster. The steps are as follows:
@@ -315,9 +337,45 @@ Server {
* run in their own thread rather than within the context of the constructor.
* @throws InterruptedException
*/
- public HMaster(final Configuration conf)
- throws IOException, KeeperException, InterruptedException {
+ @Inject
+ public HMaster(@Assisted final Configuration conf,
+ final RpcServerFactory rpcServerFactory,
+ final SleeperFactory sleeperFactory,
+ final ZooKeeperWatcherFactory zooKeeperWatcherFactory,
+ final MasterMetricsFactory masterMetricsFactory,
+ final ClusterStatusTrackerFactory clusterStatusTrackerFactory,
+ final ActiveMasterManagerFactory activeMasterManagerFactory,
+ final CatalogTrackerFactory catalogTrackerFactory,
+ final AssignmentManagerFactory assignmentManagerFactory,
+ final RegionServerTrackerFactory regionServerTrackerFactory,
+ final DrainingServerTrackerFactory drainingServerTrackerFactory,
+ final LoadBalancerFactory loadBalancerFactory,
+ final MasterFileSystemFactory masterFileSystemFactory,
+ final FSTableDescriptorsFactory fsTableDescriptorsFactory,
+ final ExecutorServiceFactory executorServiceFactory,
+ final ServerManagerFactory serverManagerFactory,
+ final MasterCoprocessorHostFactory masterCoprocessorHostFactory,
+ final CatalogJanitorFactory catalogJanitorFactory,
+ final MBeanSource mBeanSource)
+ throws IOException, KeeperException, InterruptedException {
+ //Store the factories that might be used later.
+ this.clusterStatusTrackerFactory = clusterStatusTrackerFactory;
+ this.activeMasterManagerFactory = activeMasterManagerFactory;
+ this.catalogTrackerFactory = catalogTrackerFactory;
+ this.assignmentManagerFactory = assignmentManagerFactory;
+ this.regionServerTrackerFactory = regionServerTrackerFactory;
+ this.drainingServerTrackerFactory = drainingServerTrackerFactory;
+ this.loadBalancerFactory = loadBalancerFactory;
+ this.masterFileSystemFactory = masterFileSystemFactory;
+ this.fsTableDescriptorsFactory = fsTableDescriptorsFactory;
+ this.executorServiceFactory = executorServiceFactory;
+ this.serverManagerFactory = serverManagerFactory;
+ this.masterCoprocessorHostFactory = masterCoprocessorHostFactory;
+ this.catalogJanitorFactory = catalogJanitorFactory;
+ this.mBeanSource = mBeanSource;
+
this.conf = new Configuration(conf);
+ this.stopSleeper = sleeperFactory.create(100, this);
// Disable the block cache on the master
this.conf.setFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, 0.0f);
// Set how many times to retry talking to another server over HConnection.
@@ -334,9 +392,10 @@ Server {
}
int numHandlers = conf.getInt("hbase.master.handler.count",
conf.getInt("hbase.regionserver.handler.count", 25));
- this.rpcServer = HBaseRPC.getServer(MasterMonitorProtocol.class, this,
- new Class>[]{MasterMonitorProtocol.class,
- MasterAdminProtocol.class, RegionServerStatusProtocol.class},
+
+ this.rpcServer = rpcServerFactory.create(this,
+ new Class>[]{MasterMonitorProtocol.class,
+ MasterAdminProtocol.class, RegionServerStatusProtocol.class},
initialIsa.getHostName(), // BindAddress is IP we got for this server.
initialIsa.getPort(),
numHandlers,
@@ -365,9 +424,9 @@ Server {
this.conf.set("mapred.task.id", "hb_m_" + this.serverName.toString());
}
- this.zooKeeper = new ZooKeeperWatcher(conf, MASTER + ":" + isa.getPort(), this, true);
+ this.zooKeeper = zooKeeperWatcherFactory.create(this.conf, MASTER + ":" + isa.getPort(), this, true);
this.rpcServer.startThreads();
- this.metrics = new MasterMetrics(getServerName().toString());
+ this.metrics = masterMetricsFactory.create(getServerName().toString());
// metrics interval: using the same property as region server.
this.msgInterval = conf.getInt("hbase.regionserver.msginterval", 3 * 1000);
@@ -483,15 +542,14 @@ Server {
throws InterruptedException {
// TODO: This is wrong!!!! Should have new servername if we restart ourselves,
// if we come back to life.
- this.activeMasterManager = new ActiveMasterManager(zooKeeper, this.serverName,
- this);
+ this.activeMasterManager = activeMasterManagerFactory.create(zooKeeper, this.serverName, this);
this.zooKeeper.registerListener(activeMasterManager);
stallIfBackupMaster(this.conf, this.activeMasterManager);
// The ClusterStatusTracker is setup before the other
// ZKBasedSystemTrackers because it's needed by the activeMasterManager
// to check if the cluster should be shutdown.
- this.clusterStatusTracker = new ClusterStatusTracker(getZooKeeper(), this);
+ this.clusterStatusTracker = clusterStatusTrackerFactory.create(getZooKeeper(), this);
this.clusterStatusTracker.start();
return this.activeMasterManager.blockUntilBecomingActiveMaster(startupStatus,
this.clusterStatusTracker);
@@ -504,20 +562,21 @@ Server {
*/
private void initializeZKBasedSystemTrackers() throws IOException,
InterruptedException, KeeperException {
- this.catalogTracker = createCatalogTracker(this.zooKeeper, this.conf,
+ this.catalogTracker = catalogTrackerFactory.create(this.zooKeeper, this.conf,
this, conf.getInt("hbase.master.catalog.timeout", Integer.MAX_VALUE));
this.catalogTracker.start();
- this.balancer = LoadBalancerFactory.getLoadBalancer(conf);
- this.assignmentManager = new AssignmentManager(this, serverManager,
- this.catalogTracker, this.balancer, this.executorService, this.metrics);
+ this.balancer = loadBalancerFactory.create();
+ this.assignmentManager = assignmentManagerFactory.create(this, serverManager,
+ this.catalogTracker, this.balancer, this.executorService, this.metrics);
+
zooKeeper.registerListenerFirst(assignmentManager);
- this.regionServerTracker = new RegionServerTracker(zooKeeper, this,
+ this.regionServerTracker = regionServerTrackerFactory.create(zooKeeper, this,
this.serverManager);
this.regionServerTracker.start();
- this.drainingServerTracker = new DrainingServerTracker(zooKeeper, this,
+ this.drainingServerTracker = drainingServerTrackerFactory.create(zooKeeper, this,
this.serverManager);
this.drainingServerTracker.start();
@@ -532,27 +591,8 @@ Server {
", cluster-up flag was=" + wasUp);
}
- /**
- * Create CatalogTracker.
- * In its own method so can intercept and mock it over in tests.
- * @param zk If zk is null, we'll create an instance (and shut it down
- * when {@link #stop()} is called) else we'll use what is passed.
- * @param conf
- * @param abortable If fatal exception we'll call abort on this. May be null.
- * If it is we'll use the Connection associated with the passed
- * {@link Configuration} as our {@link Abortable}.
- * @param defaultTimeout Timeout to use. Pass zero for no timeout
- * ({@link Object#wait(long)} when passed a 0 waits for ever).
- * @throws IOException
- */
- CatalogTracker createCatalogTracker(final ZooKeeperWatcher zk,
- final Configuration conf, Abortable abortable, final int defaultTimeout)
- throws IOException {
- return new CatalogTracker(zk, conf, abortable, defaultTimeout);
- }
-
// Check if we should stop every 100ms
- private Sleeper stopSleeper = new Sleeper(100, this);
+ private final Sleeper stopSleeper;
private void loop() {
long lastMsgTs = 0l;
@@ -613,20 +653,19 @@ Server {
status.setStatus("Initializing Master file system");
this.masterActiveTime = System.currentTimeMillis();
- // TODO: Do this using Dependency Injection, using PicoContainer, Guice or Spring.
- this.fileSystemManager = new MasterFileSystem(this, this, metrics, masterRecovery);
+ this.fileSystemManager = masterFileSystemFactory.create(this.conf, this, this, metrics, masterRecovery);
this.tableDescriptors =
- new FSTableDescriptors(this.fileSystemManager.getFileSystem(),
- this.fileSystemManager.getRootDir());
+ fsTableDescriptorsFactory.create(this.fileSystemManager.getFileSystem(),
+ this.fileSystemManager.getRootDir(), false /*ReadOnly = false*/);
// publish cluster ID
status.setStatus("Publishing Cluster ID in ZooKeeper");
ZKClusterId.setClusterId(this.zooKeeper, fileSystemManager.getClusterId());
if (!masterRecovery) {
- this.executorService = new ExecutorService(getServerName().toString());
- this.serverManager = createServerManager(this, this);
+ this.executorService = executorServiceFactory.create(getServerName().toString());
+ this.serverManager = serverManagerFactory.create(this, this, true /* connect */ );
}
status.setStatus("Initializing ZK system trackers");
@@ -635,7 +674,7 @@ Server {
if (!masterRecovery) {
// initialize master side coprocessors before we start handling requests
status.setStatus("Initializing master coprocessors");
- this.cpHost = new MasterCoprocessorHost(this, this.conf);
+ this.cpHost = masterCoprocessorHostFactory.create(this);
// start up all service threads.
status.setStatus("Initializing master service threads");
@@ -688,7 +727,7 @@ Server {
// been assigned.
status.setStatus("Starting balancer and catalog janitor");
this.balancerChore = getAndStartBalancerChore(this);
- this.catalogJanitorChore = new CatalogJanitor(this, this);
+ this.catalogJanitorChore = catalogJanitorFactory.create(this, this);
startCatalogJanitorChore();
registerMBean();
@@ -731,22 +770,6 @@ Server {
}
/**
- * Create a {@link ServerManager} instance.
- * @param master
- * @param services
- * @return An instance of {@link ServerManager}
- * @throws ZooKeeperConnectionException
- * @throws IOException
- */
- ServerManager createServerManager(final Server master,
- final MasterServices services)
- throws IOException {
- // We put this out here in a method so can do a Mockito.spy and stub it out
- // w/ a mocked up ServerManager.
- return new ServerManager(master, services);
- }
-
- /**
* If ServerShutdownHandler is disabled, we enable it and expire those dead
* but not expired servers.
* @throws IOException
@@ -1135,7 +1158,7 @@ Server {
*/
protected RegionServerStartupResponse.Builder createConfigurationSubset() {
RegionServerStartupResponse.Builder resp = addConfig(
- RegionServerStartupResponse.newBuilder(), HConstants.HBASE_DIR);
+ RegionServerStartupResponse.newBuilder(), HConstants.HBASE_DIR);
return addConfig(resp, "fs.default.name");
}
@@ -2222,31 +2245,6 @@ Server {
}
/**
- * Utility for constructing an instance of the passed HMaster class.
- * @param masterClass
- * @param conf
- * @return HMaster instance.
- */
- public static HMaster constructMaster(Class extends HMaster> masterClass,
- final Configuration conf) {
- try {
- Constructor extends HMaster> c =
- masterClass.getConstructor(Configuration.class);
- return c.newInstance(conf);
- } catch (InvocationTargetException ite) {
- Throwable target = ite.getTargetException() != null?
- ite.getTargetException(): ite;
- if (target.getCause() != null) target = target.getCause();
- throw new RuntimeException("Failed construction of Master: " +
- masterClass.toString(), target);
- } catch (Exception e) {
- throw new RuntimeException("Failed construction of Master: " +
- masterClass.toString() + ((e.getCause() != null)?
- e.getCause().getMessage(): ""), e);
- }
- }
-
- /**
* @see org.apache.hadoop.hbase.master.HMasterCommandLine
*/
public static void main(String [] args) throws Exception {
@@ -2259,8 +2257,7 @@ Server {
*/
void registerMBean() {
MXBeanImpl mxBeanInfo = MXBeanImpl.init(this);
- mxBean = CompatibilitySingletonFactory.getInstance(
- MBeanSource.class).register("hbase", "HMaster,sub=MXBean", mxBeanInfo);
+ mxBean = mBeanSource.register("hbase", "HMaster,sub=MXBean", mxBeanInfo);
LOG.info("Registered HMaster MXBean");
}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java
index 16a3cd8..6ce73b5 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java
@@ -23,6 +23,7 @@ import java.io.File;
import java.io.IOException;
import java.util.List;
+import com.google.inject.Injector;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.Options;
@@ -37,11 +38,11 @@ import org.apache.hadoop.hbase.LocalHBaseCluster;
import org.apache.hadoop.hbase.MasterNotRunningException;
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.hadoop.hbase.regionserver.HRegionServer;
+import org.apache.hadoop.hbase.HBaseGuice;
+import org.apache.hadoop.hbase.LocalHBaseClusterFactory;
import org.apache.hadoop.hbase.util.JVMClusterUtil;
import org.apache.hadoop.hbase.util.ServerCommandLine;
import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
-import org.apache.zookeeper.KeeperException;
@InterfaceAudience.Private
public class HMasterCommandLine extends ServerCommandLine {
@@ -143,13 +144,15 @@ public class HMasterCommandLine extends ServerCommandLine {
Integer.toString(clientPort));
// Need to have the zk cluster shutdown when master is shutdown.
// Run a subclass that does the zk cluster shutdown on its way out.
- LocalHBaseCluster cluster = new LocalHBaseCluster(conf, 1, 1,
- LocalHMaster.class, HRegionServer.class);
+ Injector injector = HBaseGuice.createLocalHBaseInjector();
+ LocalHBaseCluster cluster = injector.getInstance(LocalHBaseClusterFactory.class).create(conf, 1,1);
+
((LocalHMaster)cluster.getMaster(0)).setZKCluster(zooKeeperCluster);
cluster.startup();
waitOnMasterThreads(cluster);
} else {
- HMaster master = HMaster.constructMaster(masterClass, conf);
+ Injector injector = HBaseGuice.createInjector();
+ HMaster master = injector.getInstance(HMasterFactory.class).create(conf);
if (master.isStopped()) {
LOG.info("Won't bring the Master up as a shutdown is requested");
return -1;
@@ -209,32 +212,4 @@ public class HMasterCommandLine extends ServerCommandLine {
t.getRegionServer().stop("HMaster Aborted; Bringing down regions servers");
}
}
-
- /*
- * Version of master that will shutdown the passed zk cluster on its way out.
- */
- public static class LocalHMaster extends HMaster {
- private MiniZooKeeperCluster zkcluster = null;
-
- public LocalHMaster(Configuration conf)
- throws IOException, KeeperException, InterruptedException {
- super(conf);
- }
-
- @Override
- public void run() {
- super.run();
- if (this.zkcluster != null) {
- try {
- this.zkcluster.shutdown();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
- void setZKCluster(final MiniZooKeeperCluster zkcluster) {
- this.zkcluster = zkcluster;
- }
- }
}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterFactory.java
new file mode 100644
index 0000000..5be259b
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterFactory.java
@@ -0,0 +1,15 @@
+package org.apache.hadoop.hbase.master;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.conf.Configuration;
+
+/**
+ * Interface of a Factory that can construct a HMaster.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface HMasterFactory {
+
+ public HMaster create(Configuration conf);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterModule.java
new file mode 100644
index 0000000..8623b85
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterModule.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.master;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class HMasterModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(HMaster.class, HMaster.class)
+ .build(HMasterFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/LocalHMaster.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/LocalHMaster.java
new file mode 100644
index 0000000..c12efe0
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/LocalHMaster.java
@@ -0,0 +1,110 @@
+/**
+ * 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.hbase.master;
+
+import com.google.inject.assistedinject.Assisted;
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.catalog.CatalogTrackerFactory;
+import org.apache.hadoop.hbase.executor.ExecutorServiceFactory;
+import org.apache.hadoop.hbase.ipc.RpcServerFactory;
+import org.apache.hadoop.hbase.master.balancer.LoadBalancerFactory;
+import org.apache.hadoop.hbase.master.metrics.MasterMetricsFactory;
+import org.apache.hadoop.hbase.metrics.MBeanSource;
+import org.apache.hadoop.hbase.util.FSTableDescriptorsFactory;
+import org.apache.hadoop.hbase.util.SleeperFactory;
+import org.apache.hadoop.hbase.zookeeper.ClusterStatusTrackerFactory;
+import org.apache.hadoop.hbase.zookeeper.DrainingServerTrackerFactory;
+import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
+import org.apache.hadoop.hbase.zookeeper.RegionServerTrackerFactory;
+import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcherFactory;
+import org.apache.zookeeper.KeeperException;
+
+import javax.inject.Inject;
+import java.io.IOException;
+
+/**
+ *
+ */
+/*
+* Version of master that will shutdown the passed zk cluster on its way out.
+*/
+@InterfaceAudience.Private
+public class LocalHMaster extends HMaster {
+
+ private MiniZooKeeperCluster zkcluster = null;
+
+ @Inject
+ public LocalHMaster(final Configuration conf,
+ final RpcServerFactory rpcServerFactory,
+ final SleeperFactory sleeperFactory,
+ final ZooKeeperWatcherFactory zooKeeperWatcherFactory,
+ final MasterMetricsFactory masterMetricsFactory,
+ final ClusterStatusTrackerFactory clusterStatusTrackerFactory,
+ final ActiveMasterManagerFactory activeMasterManagerFactory,
+ final CatalogTrackerFactory catalogTrackerFactory,
+ final AssignmentManagerFactory assignmentManagerFactory,
+ final RegionServerTrackerFactory regionServerTrackerFactory,
+ final DrainingServerTrackerFactory drainingServerTrackerFactory,
+ final LoadBalancerFactory loadBalancerFactory,
+ final MasterFileSystemFactory masterFileSystemFactory,
+ final FSTableDescriptorsFactory fsTableDescriptorsFactory,
+ final ExecutorServiceFactory executorServiceFactory,
+ final ServerManagerFactory serverManagerFactory,
+ final MasterCoprocessorHostFactory masterCoprocessorHostFactory,
+ final CatalogJanitorFactory catalogJanitorFactory,
+ final MBeanSource mBeanSource)
+ throws IOException, KeeperException, InterruptedException {
+ super(conf,
+ rpcServerFactory,
+ sleeperFactory,
+ zooKeeperWatcherFactory,
+ masterMetricsFactory,
+ clusterStatusTrackerFactory,
+ activeMasterManagerFactory,
+ catalogTrackerFactory,
+ assignmentManagerFactory,
+ regionServerTrackerFactory,
+ drainingServerTrackerFactory,
+ loadBalancerFactory,
+ masterFileSystemFactory,
+ fsTableDescriptorsFactory,
+ executorServiceFactory,
+ serverManagerFactory,
+ masterCoprocessorHostFactory,
+ catalogJanitorFactory,
+ mBeanSource);
+ }
+
+ @Override
+ public void run() {
+ super.run();
+ if (this.zkcluster != null) {
+ try {
+ this.zkcluster.shutdown();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ void setZKCluster(final MiniZooKeeperCluster zkcluster) {
+ this.zkcluster = zkcluster;
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/LocalHMasterModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/LocalHMasterModule.java
new file mode 100644
index 0000000..15c83be
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/LocalHMasterModule.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.master;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class LocalHMasterModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(HMaster.class, LocalHMaster.class)
+ .build(HMasterFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
index 20f82e1..c38339c 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
@@ -20,6 +20,7 @@
package org.apache.hadoop.hbase.master;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -27,6 +28,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.*;
import org.apache.hadoop.hbase.coprocessor.*;
+import javax.inject.Inject;
import java.io.IOException;
/**
@@ -62,7 +64,9 @@ public class MasterCoprocessorHost
private MasterServices masterServices;
- MasterCoprocessorHost(final MasterServices services, final Configuration conf) {
+ @Inject
+ MasterCoprocessorHost(@Assisted final MasterServices services,
+ final Configuration conf) {
this.masterServices = services;
loadSystemCoprocessors(conf, MASTER_COPROCESSOR_CONF_KEY);
}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHostFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHostFactory.java
new file mode 100644
index 0000000..9e9eded
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHostFactory.java
@@ -0,0 +1,32 @@
+/**
+ * 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.hbase.master;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+/**
+ * Interface of a Factory that can construct a MasterCoprocessorHost.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface MasterCoprocessorHostFactory {
+
+ public MasterCoprocessorHost create(final MasterServices services);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHostModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHostModule.java
new file mode 100644
index 0000000..d2db185
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHostModule.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.master;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class MasterCoprocessorHostModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(MasterCoprocessorHost.class, MasterCoprocessorHost.class)
+ .build(MasterCoprocessorHostFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
index d9e0d01..00e03fc 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
@@ -27,6 +27,7 @@ import java.util.UUID;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -56,6 +57,8 @@ import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.FSTableDescriptors;
import org.apache.hadoop.hbase.util.FSUtils;
+import javax.inject.Inject;
+
/**
* This class abstracts a bunch of operations the HMaster needs to interact with
* the underlying file system, including splitting log files, checking file
@@ -86,10 +89,14 @@ public class MasterFileSystem {
final SplitLogManager splitLogManager;
private final MasterServices services;
- public MasterFileSystem(Server master, MasterServices services,
- MasterMetrics metrics, boolean masterRecovery)
- throws IOException {
- this.conf = master.getConfiguration();
+ @Inject
+ public MasterFileSystem(@Assisted Configuration conf,
+ @Assisted Server master,
+ @Assisted MasterServices services,
+ @Assisted MasterMetrics metrics,
+ @Assisted boolean masterRecovery)
+ throws IOException {
+ this.conf = conf;
this.master = master;
this.services = services;
this.metrics = metrics;
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystemFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystemFactory.java
new file mode 100644
index 0000000..e075f39
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystemFactory.java
@@ -0,0 +1,40 @@
+/**
+ * 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.hbase.master;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.Server;
+import org.apache.hadoop.hbase.master.metrics.MasterMetrics;
+
+/**
+ * Interface of a Factory that can construct a MasterFileSystem.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface MasterFileSystemFactory {
+
+ public MasterFileSystem create(
+ Configuration conf,
+ Server master,
+ MasterServices services,
+ MasterMetrics metrics,
+ boolean masterRecovery);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystemModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystemModule.java
new file mode 100644
index 0000000..65365a5
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystemModule.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.master;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class MasterFileSystemModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(MasterFileSystem.class, MasterFileSystem.class)
+ .build(MasterFileSystemFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
index 6939d8e..4d3393c 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
@@ -31,6 +31,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -60,6 +61,8 @@ import org.apache.hadoop.hbase.regionserver.RegionOpeningState;
import com.google.protobuf.ServiceException;
+import javax.inject.Inject;
+
/**
* The ServerManager class manages info about region servers.
*
@@ -126,8 +129,9 @@ public class ServerManager {
this(master, services, true);
}
- ServerManager(final Server master, final MasterServices services,
- final boolean connect) throws ZooKeeperConnectionException {
+ @Inject
+ ServerManager(@Assisted final Server master, @Assisted final MasterServices services,
+ @Assisted final boolean connect) throws ZooKeeperConnectionException {
this.master = master;
this.services = services;
Configuration c = master.getConfiguration();
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManagerFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManagerFactory.java
new file mode 100644
index 0000000..9c57433
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManagerFactory.java
@@ -0,0 +1,36 @@
+/**
+ * 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.hbase.master;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.Server;
+import org.apache.hadoop.hbase.ZooKeeperConnectionException;
+
+/**
+ * Interface of a Factory that can construct a ServerManager.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface ServerManagerFactory {
+
+ public ServerManager create(final Server master,
+ final MasterServices services,
+ final boolean connect) throws ZooKeeperConnectionException;
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManagerModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManagerModule.java
new file mode 100644
index 0000000..ef55c3f
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManagerModule.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.master;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class ServerManagerModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(ServerManager.class, ServerManager.class)
+ .build(ServerManagerFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/LoadBalancerFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/LoadBalancerFactory.java
index 68a0887..6de1b73 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/LoadBalancerFactory.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/LoadBalancerFactory.java
@@ -1,46 +1,14 @@
-/**
- * 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.hbase.master.balancer;
import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.master.LoadBalancer;
-import org.apache.hadoop.util.ReflectionUtils;
/**
- * The class that creates a load balancer from a conf.
+ * Interface of a Factory that can construct a ActiveMasterManager.
+ * This will be used by guice in DI.
*/
@InterfaceAudience.Private
-public class LoadBalancerFactory {
-
- /**
- * Create a loadblanacer from the given conf.
- * @param conf
- * @return A {@link LoadBalancer}
- */
- public static LoadBalancer getLoadBalancer(Configuration conf) {
-
- // Create the balancer
- Class extends LoadBalancer> balancerKlass =
- conf.getClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, DefaultLoadBalancer.class,
- LoadBalancer.class);
- return ReflectionUtils.newInstance(balancerKlass, conf);
+public interface LoadBalancerFactory {
- }
+ LoadBalancer create();
}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/LoadBalancerFactoryImpl.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/LoadBalancerFactoryImpl.java
new file mode 100644
index 0000000..63af771
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/LoadBalancerFactoryImpl.java
@@ -0,0 +1,57 @@
+/**
+ * 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.hbase.master.balancer;
+
+import com.google.inject.Injector;
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.master.LoadBalancer;
+
+import javax.inject.Inject;
+
+/** The class that creates a load balancer from a conf. */
+@InterfaceAudience.Private
+public class LoadBalancerFactoryImpl implements LoadBalancerFactory {
+
+ Injector injector;
+ Configuration conf;
+
+ @Inject
+ public LoadBalancerFactoryImpl(Configuration conf, Injector injector) {
+ this.conf = conf;
+ // Injecting the injector is hacky but it's the only way that I can see to still have classes
+ // loaded from the conf and use dependency injection. If we ever go to a fully plugin arch
+ // then we should re-look at this.
+ this.injector = injector;
+ }
+
+ /** Create a loadblanacer from the given conf. */
+ @Override
+ public LoadBalancer create() {
+
+ // Create the balancer
+ Class extends LoadBalancer> balancerKlass =
+ conf.getClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, DefaultLoadBalancer.class,
+ LoadBalancer.class);
+ LoadBalancer lb = injector.getInstance(balancerKlass);
+ lb.setConf(conf);
+ return lb;
+
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/LoadBalancerModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/LoadBalancerModule.java
new file mode 100644
index 0000000..7315217
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/LoadBalancerModule.java
@@ -0,0 +1,14 @@
+package org.apache.hadoop.hbase.master.balancer;
+
+import com.google.inject.AbstractModule;
+
+/**
+ *
+ */
+public class LoadBalancerModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(LoadBalancerFactory.class).to(LoadBalancerFactoryImpl.class);
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetrics.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetrics.java
index 8a575dc..ef05a62 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetrics.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetrics.java
@@ -21,7 +21,10 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
-import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
+
+import com.google.inject.assistedinject.Assisted;
+
+import javax.inject.Inject;
/**
* This class is for maintaining the various master statistics
@@ -36,8 +39,10 @@ public class MasterMetrics {
private final Log LOG = LogFactory.getLog(this.getClass());
private MasterMetricsSource masterMetricsSource;
- public MasterMetrics(final String name) {
- masterMetricsSource = CompatibilitySingletonFactory.getInstance(MasterMetricsSource.class);
+
+ @Inject
+ public MasterMetrics(MasterMetricsSource mms, @Assisted final String name) {
+ masterMetricsSource = mms;
}
// for unit-test usage
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetricsFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetricsFactory.java
new file mode 100644
index 0000000..64517c2
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetricsFactory.java
@@ -0,0 +1,32 @@
+/**
+ * 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.hbase.master.metrics;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+/**
+ * Interface of a Factory that can construct a MasterMetrics.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface MasterMetricsFactory {
+
+ public MasterMetrics create(String name);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetricsModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetricsModule.java
new file mode 100644
index 0000000..d8fa8a7
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetricsModule.java
@@ -0,0 +1,34 @@
+/**
+ * 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.hbase.master.metrics;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class MasterMetricsModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder().implement(MasterMetrics.class, MasterMetrics.class)
+ .build(MasterMetricsFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java
index 799a64a..039c444 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java
@@ -29,6 +29,7 @@ import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -37,6 +38,8 @@ import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest;
import com.google.common.base.Preconditions;
+import javax.inject.Inject;
+
/**
* Compact region on request and then run split if appropriate
*/
@@ -59,7 +62,8 @@ public class CompactSplitThread implements CompactionRequestor {
private int regionSplitLimit;
/** @param server */
- CompactSplitThread(HRegionServer server) {
+ @Inject
+ CompactSplitThread(@Assisted HRegionServer server) {
super();
this.server = server;
this.conf = server.getConfiguration();
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThreadFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThreadFactory.java
new file mode 100644
index 0000000..d2e78fd
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThreadFactory.java
@@ -0,0 +1,32 @@
+/**
+ * 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.hbase.regionserver;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+/**
+ * Interface of a Factory that can construct a CompactSplitThread.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface CompactSplitThreadFactory {
+
+ public CompactSplitThread create(HRegionServer server);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThreadModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThreadModule.java
new file mode 100644
index 0000000..a703c5d
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThreadModule.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.regionserver;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class CompactSplitThreadModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(CompactSplitThread.class, CompactSplitThread.class)
+ .build(CompactSplitThreadFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionChecker.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionChecker.java
new file mode 100644
index 0000000..a2de4ef
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionChecker.java
@@ -0,0 +1,87 @@
+/**
+ * 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.hbase.regionserver;
+
+import com.google.inject.assistedinject.Assisted;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.Chore;
+import org.apache.hadoop.hbase.Stoppable;
+import org.apache.hadoop.util.StringUtils;
+
+import javax.inject.Inject;
+import java.io.IOException;
+
+/**
+ *
+ */
+/*
+* Inner class that runs on a long period checking if regions need compaction.
+*/
+public class CompactionChecker extends Chore {
+
+ public static final Log LOG = LogFactory.getLog(CompactionChecker.class);
+
+ private final HRegionServer instance;
+ private final int majorCompactPriority;
+ private final static int DEFAULT_PRIORITY = Integer.MAX_VALUE;
+
+ @Inject
+ CompactionChecker(@Assisted final HRegionServer h, @Assisted final int sleepTime) {
+ super("CompactionChecker", sleepTime, h);
+ this.instance = h;
+ LOG.info("Runs every " + StringUtils.formatTime(sleepTime));
+
+ /* MajorCompactPriority is configurable.
+ * If not set, the compaction will use default priority.
+ */
+ this.majorCompactPriority = this.instance.conf.
+ getInt("hbase.regionserver.compactionChecker.majorCompactPriority",
+ DEFAULT_PRIORITY);
+ }
+
+ @Override
+ protected void chore() {
+ for (HRegion r : this.instance.onlineRegions.values()) {
+ if (r == null)
+ continue;
+ for (Store s : r.getStores().values()) {
+ try {
+ if (s.needsCompaction()) {
+ // Queue a compaction. Will recognize if major is needed.
+ this.instance.compactSplitThread.requestCompaction(r, s,
+ getName() + " requests compaction");
+ } else if (s.isMajorCompaction()) {
+ if (majorCompactPriority == DEFAULT_PRIORITY ||
+ majorCompactPriority > r.getCompactPriority()) {
+ this.instance.compactSplitThread.requestCompaction(r, s,
+ getName() + " requests major compaction; use default priority");
+ } else {
+ this.instance.compactSplitThread.requestCompaction(r, s,
+ getName() + " requests major compaction; use configured priority",
+ this.majorCompactPriority);
+ }
+ }
+ } catch (IOException e) {
+ LOG.warn("Failed major compaction check on " + r, e);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionCheckerFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionCheckerFactory.java
new file mode 100644
index 0000000..53dffc3
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionCheckerFactory.java
@@ -0,0 +1,32 @@
+/**
+ * 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.hbase.regionserver;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+/**
+ * Interface of a Factory that can construct a CompactionChecker.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface CompactionCheckerFactory {
+
+ public CompactionChecker create(final HRegionServer hrs, final int sleepTime);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionCheckerModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionCheckerModule.java
new file mode 100644
index 0000000..62d61c8
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionCheckerModule.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.regionserver;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class CompactionCheckerModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(CompactionChecker.class, CompactionChecker.class)
+ .build(CompactionCheckerFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index a708f3b..432a67e 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -51,8 +51,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import javax.inject.Inject;
import javax.management.ObjectName;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.lang.mutable.MutableDouble;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -104,6 +106,13 @@ import org.apache.hadoop.hbase.executor.ExecutorService.ExecutorType;
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
import org.apache.hadoop.hbase.filter.WritableByteArrayComparable;
import org.apache.hadoop.hbase.fs.HFileSystem;
+import org.apache.hadoop.hbase.catalog.CatalogTrackerFactory;
+import org.apache.hadoop.hbase.zookeeper.ClusterStatusTrackerFactory;
+import org.apache.hadoop.hbase.zookeeper.MasterAddressTrackerFactory;
+import org.apache.hadoop.hbase.replication.regionserver.ReplicationFactory;
+import org.apache.hadoop.hbase.ipc.RpcServerFactory;
+import org.apache.hadoop.hbase.util.SleeperFactory;
+import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcherFactory;
import org.apache.hadoop.hbase.io.hfile.BlockCache;
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
import org.apache.hadoop.hbase.io.hfile.CacheStats;
@@ -436,6 +445,19 @@ public class HRegionServer implements ClientProtocol,
*/
private final int scannerLeaseTimeoutPeriod;
+ /**
+ * Factories to be used later when initializing the HRegionServer.
+ */
+ private final ReplicationFactory replicationFactory;
+ private final ZooKeeperWatcherFactory zooKeeperWatcherFactory;
+ private final MasterAddressTrackerFactory masterAddressTrackerFactory;
+ private final ClusterStatusTrackerFactory clusterStatusTrackerFactory;
+ private final CatalogTrackerFactory catalogTrackerFactory;
+ private final MemStoreFlusherFactory memStoreFlusherFactory;
+ private final CompactSplitThreadFactory compactSplitThreadFactory;
+ private final CompactionCheckerFactory compactionCheckerFactory;
+ private final LeasesFactory leasesFactory;
+ private final HRegionThriftServerFactory hRegionThriftServerFactory;
/**
* Starts a HRegionServer at the default location
@@ -444,8 +466,32 @@ public class HRegionServer implements ClientProtocol,
* @throws IOException
* @throws InterruptedException
*/
- public HRegionServer(Configuration conf)
- throws IOException, InterruptedException {
+ @Inject
+ public HRegionServer(@Assisted Configuration conf,
+ SleeperFactory sleeperFactory,
+ RpcServerFactory rpcServerFactory,
+ ReplicationFactory replicationFactory,
+ RegionServerAccounting rsAccounting,
+ ZooKeeperWatcherFactory zooKeeperWatcherFactory,
+ MasterAddressTrackerFactory masterAddressTrackerFactory,
+ ClusterStatusTrackerFactory clusterStatusTrackerFactory,
+ CatalogTrackerFactory catalogTrackerFactory,
+ MemStoreFlusherFactory memStoreFlusherFactory,
+ CompactSplitThreadFactory compactSplitThreadFactory,
+ CompactionCheckerFactory compactionCheckerFactory,
+ LeasesFactory leasesFactory,
+ HRegionThriftServerFactory hRegionThriftServerFactory)
+ throws IOException, InterruptedException {
+ this.replicationFactory = replicationFactory;
+ this.zooKeeperWatcherFactory = zooKeeperWatcherFactory;
+ this.masterAddressTrackerFactory = masterAddressTrackerFactory;
+ this.clusterStatusTrackerFactory = clusterStatusTrackerFactory;
+ this.catalogTrackerFactory = catalogTrackerFactory;
+ this.memStoreFlusherFactory = memStoreFlusherFactory;
+ this.compactSplitThreadFactory = compactSplitThreadFactory;
+ this.compactionCheckerFactory = compactionCheckerFactory;
+ this.leasesFactory = leasesFactory;
+ this.hRegionThriftServerFactory = hRegionThriftServerFactory;
this.fsOk = true;
this.conf = conf;
// Set how many times to retry talking to another server over HConnection.
@@ -464,7 +510,7 @@ public class HRegionServer implements ClientProtocol,
10 * 1000);
this.msgInterval = conf.getInt("hbase.regionserver.msginterval", 3 * 1000);
- this.sleeper = new Sleeper(this.msgInterval, this);
+ this.sleeper = sleeperFactory.create(this.msgInterval, this);
this.maxScannerResultSize = conf.getLong(
HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY,
@@ -499,10 +545,12 @@ public class HRegionServer implements ClientProtocol,
throw new IllegalArgumentException("Failed resolve of " + initialIsa);
}
- this.rpcServer = HBaseRPC.getServer(AdminProtocol.class, this,
- new Class>[]{ClientProtocol.class,
- AdminProtocol.class, HBaseRPCErrorHandler.class,
- OnlineRegions.class},
+ this.rpcServer = rpcServerFactory.create(this,
+ new Class>[]{ ClientProtocol.class,
+ AdminProtocol.class,
+ HBaseRPCErrorHandler.class,
+ OnlineRegions.class},
+
initialIsa.getHostName(), // BindAddress is IP we got for this server.
initialIsa.getPort(),
conf.getInt("hbase.regionserver.handler.count", 10),
@@ -519,8 +567,8 @@ public class HRegionServer implements ClientProtocol,
// login the server principal (if using secure Hadoop)
User.login(this.conf, "hbase.regionserver.keytab.file",
"hbase.regionserver.kerberos.principal", this.isa.getHostName());
- regionServerAccounting = new RegionServerAccounting();
- cacheConfig = new CacheConfig(conf);
+ this.regionServerAccounting = rsAccounting;
+ this.cacheConfig = new CacheConfig(conf);
}
/**
@@ -667,25 +715,25 @@ public class HRegionServer implements ClientProtocol,
*/
private void initializeZooKeeper() throws IOException, InterruptedException {
// Open connection to zookeeper and set primary watcher
- this.zooKeeper = new ZooKeeperWatcher(conf, REGIONSERVER + ":" +
- this.isa.getPort(), this);
+ this.zooKeeper = zooKeeperWatcherFactory.create(this.conf, REGIONSERVER + ":" +
+ this.isa.getPort(), this, false);
// Create the master address manager, register with zk, and start it. Then
// block until a master is available. No point in starting up if no master
// running.
- this.masterAddressManager = new MasterAddressTracker(this.zooKeeper, this);
+ this.masterAddressManager = masterAddressTrackerFactory.create(this.zooKeeper, this);
this.masterAddressManager.start();
blockAndCheckIfStopped(this.masterAddressManager);
// Wait on cluster being up. Master will set this flag up in zookeeper
// when ready.
- this.clusterStatusTracker = new ClusterStatusTracker(this.zooKeeper, this);
+ this.clusterStatusTracker = clusterStatusTrackerFactory.create(this.zooKeeper, this);
this.clusterStatusTracker.start();
blockAndCheckIfStopped(this.clusterStatusTracker);
// Create the catalog tracker and start it;
- this.catalogTracker = new CatalogTracker(this.zooKeeper, this.conf,
- this, this.conf.getInt("hbase.regionserver.catalog.timeout", Integer.MAX_VALUE));
+ this.catalogTracker = catalogTrackerFactory.create(this.zooKeeper, this.conf,
+ this, this.conf.getInt("hbase.regionserver.catalog.timeout", Integer.MAX_VALUE));
catalogTracker.start();
}
@@ -714,23 +762,23 @@ public class HRegionServer implements ClientProtocol,
private void initializeThreads() throws IOException {
// Cache flushing thread.
- this.cacheFlusher = new MemStoreFlusher(conf, this);
+ this.cacheFlusher = memStoreFlusherFactory.create(this.conf, this);
// Compaction thread
- this.compactSplitThread = new CompactSplitThread(this);
+ this.compactSplitThread = compactSplitThreadFactory.create(this);
// Background thread to check for compactions; needed if region
// has not gotten updates in a while. Make it run at a lesser frequency.
int multiplier = this.conf.getInt(HConstants.THREAD_WAKE_FREQUENCY +
".multiplier", 1000);
- this.compactionChecker = new CompactionChecker(this,
- this.threadWakeFrequency * multiplier, this);
+ this.compactionChecker = compactionCheckerFactory.create(this,
+ this.threadWakeFrequency * multiplier);
- this.leases = new Leases(this.threadWakeFrequency);
+ this.leases = leasesFactory.create(this.threadWakeFrequency);
// Create the thread for the ThriftServer.
if (conf.getBoolean("hbase.regionserver.export.thrift", false)) {
- thriftServer = new HRegionThriftServer(this, conf);
+ thriftServer = hRegionThriftServerFactory.create(this.conf, this);
thriftServer.start();
LOG.info("Started Thrift API from Region Server.");
}
@@ -1201,57 +1249,6 @@ public class HRegionServer implements ClientProtocol,
return r != null ? createRegionLoad(r) : null;
}
- /*
- * Inner class that runs on a long period checking if regions need compaction.
- */
- private static class CompactionChecker extends Chore {
- private final HRegionServer instance;
- private final int majorCompactPriority;
- private final static int DEFAULT_PRIORITY = Integer.MAX_VALUE;
-
- CompactionChecker(final HRegionServer h, final int sleepTime,
- final Stoppable stopper) {
- super("CompactionChecker", sleepTime, h);
- this.instance = h;
- LOG.info("Runs every " + StringUtils.formatTime(sleepTime));
-
- /* MajorCompactPriority is configurable.
- * If not set, the compaction will use default priority.
- */
- this.majorCompactPriority = this.instance.conf.
- getInt("hbase.regionserver.compactionChecker.majorCompactPriority",
- DEFAULT_PRIORITY);
- }
-
- @Override
- protected void chore() {
- for (HRegion r : this.instance.onlineRegions.values()) {
- if (r == null)
- continue;
- for (Store s : r.getStores().values()) {
- try {
- if (s.needsCompaction()) {
- // Queue a compaction. Will recognize if major is needed.
- this.instance.compactSplitThread.requestCompaction(r, s,
- getName() + " requests compaction");
- } else if (s.isMajorCompaction()) {
- if (majorCompactPriority == DEFAULT_PRIORITY ||
- majorCompactPriority > r.getCompactPriority()) {
- this.instance.compactSplitThread.requestCompaction(r, s,
- getName() + " requests major compaction; use default priority");
- } else {
- this.instance.compactSplitThread.requestCompaction(r, s,
- getName() + " requests major compaction; use configured priority",
- this.majorCompactPriority);
- }
- }
- } catch (IOException e) {
- LOG.warn("Failed major compaction check on " + r, e);
- }
- }
- }
- }
- }
/**
* Report the status of the server. A server is online once all the startup is
@@ -1282,7 +1279,7 @@ public class HRegionServer implements ClientProtocol,
// Instantiate replication manager if replication enabled. Pass it the
// log directories.
- createNewReplicationInstance(conf, this, this.fs, logdir, oldLogDir);
+ createNewReplicationInstance(logdir, oldLogDir);
return instantiateHLog(logdir, oldLogDir);
}
@@ -2197,39 +2194,16 @@ public class HRegionServer implements ClientProtocol,
/**
* Load the replication service objects, if any
*/
- static private void createNewReplicationInstance(Configuration conf,
- HRegionServer server, FileSystem fs, Path logDir, Path oldLogDir) throws IOException{
+ private void createNewReplicationInstance( Path logDir, Path oldLogDir) throws IOException{
// If replication is not enabled, then return immediately.
if (!conf.getBoolean(HConstants.REPLICATION_ENABLE_KEY, false)) {
return;
}
- // read in the name of the source replication class from the config file.
- String sourceClassname = conf.get(HConstants.REPLICATION_SOURCE_SERVICE_CLASSNAME,
- HConstants.REPLICATION_SERVICE_CLASSNAME_DEFAULT);
+ this.replicationSinkHandler = this.replicationFactory.create(this, fs, logDir, oldLogDir);
+ this.replicationSourceHandler = (ReplicationSourceService) this.replicationSinkHandler;
- // read in the name of the sink replication class from the config file.
- String sinkClassname = conf.get(HConstants.REPLICATION_SINK_SERVICE_CLASSNAME,
- HConstants.REPLICATION_SERVICE_CLASSNAME_DEFAULT);
-
- // If both the sink and the source class names are the same, then instantiate
- // only one object.
- if (sourceClassname.equals(sinkClassname)) {
- server.replicationSourceHandler = (ReplicationSourceService)
- newReplicationInstance(sourceClassname,
- conf, server, fs, logDir, oldLogDir);
- server.replicationSinkHandler = (ReplicationSinkService)
- server.replicationSourceHandler;
- }
- else {
- server.replicationSourceHandler = (ReplicationSourceService)
- newReplicationInstance(sourceClassname,
- conf, server, fs, logDir, oldLogDir);
- server.replicationSinkHandler = (ReplicationSinkService)
- newReplicationInstance(sinkClassname,
- conf, server, fs, logDir, oldLogDir);
- }
}
static private ReplicationService newReplicationInstance(String classname,
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerCommandLine.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerCommandLine.java
index c0cdde5..6e08aeb 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerCommandLine.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerCommandLine.java
@@ -19,6 +19,7 @@
*/
package org.apache.hadoop.hbase.regionserver;
+import com.google.inject.Injector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -26,6 +27,7 @@ import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.LocalHBaseCluster;
+import org.apache.hadoop.hbase.HBaseGuice;
import org.apache.hadoop.hbase.util.ServerCommandLine;
/**
@@ -59,7 +61,8 @@ public class HRegionServerCommandLine extends ServerCommandLine {
+ HConstants.CLUSTER_DISTRIBUTED + " is false");
} else {
logJVMInfo();
- HRegionServer hrs = HRegionServer.constructRegionServer(regionServerClass, conf);
+ Injector injector = HBaseGuice.createInjector();
+ HRegionServer hrs = injector.getInstance(HRegionServerFactory.class).create(conf);
HRegionServer.startRegionServer(hrs);
}
return 0;
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerFactory.java
new file mode 100644
index 0000000..845154e
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerFactory.java
@@ -0,0 +1,33 @@
+/**
+ * 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.hbase.regionserver;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.conf.Configuration;
+
+/**
+ * Interface of a Factory that can construct a HRegionServer.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface HRegionServerFactory {
+
+ public HRegionServer create(Configuration conf);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerModule.java
new file mode 100644
index 0000000..e72ccf5
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerModule.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.regionserver;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class HRegionServerModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(HRegionServer.class, HRegionServer.class)
+ .build(HRegionServerFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java
index e33501e..de1cecf 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java
@@ -26,6 +26,7 @@ import java.nio.ByteBuffer;
import java.util.List;
import java.util.Map;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -42,6 +43,8 @@ import org.apache.hadoop.hbase.thrift.ThriftUtilities;
import org.apache.hadoop.hbase.thrift.generated.IOError;
import org.apache.hadoop.hbase.thrift.generated.TRowResult;
+import javax.inject.Inject;
+
/**
* HRegionThriftServer - this class starts up a Thrift server in the same
* JVM where the RegionServer is running. It inherits most of the
@@ -64,7 +67,8 @@ public class HRegionThriftServer extends Thread {
* Create an instance of the glue object that connects the
* RegionServer with the standard ThriftServer implementation
*/
- HRegionThriftServer(HRegionServer regionServer, Configuration conf)
+ @Inject
+ HRegionThriftServer(@Assisted Configuration conf, @Assisted HRegionServer regionServer )
throws IOException {
super("Region Thrift Server");
this.rs = regionServer;
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServerFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServerFactory.java
new file mode 100644
index 0000000..121ea38
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServerFactory.java
@@ -0,0 +1,33 @@
+/**
+ * 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.hbase.regionserver;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.conf.Configuration;
+
+/**
+ * Interface of a Factory that can construct a HRegionThriftServer.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface HRegionThriftServerFactory {
+
+ public HRegionThriftServer create(Configuration conf, HRegionServer regionServer);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServerModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServerModule.java
new file mode 100644
index 0000000..c11e56e
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServerModule.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.regionserver;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class HRegionThriftServerModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(HRegionThriftServer.class, HRegionThriftServer.class)
+ .build(HRegionThriftServerFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Leases.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Leases.java
index f2bd568..fa6d686 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Leases.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Leases.java
@@ -19,11 +19,13 @@
*/
package org.apache.hadoop.hbase.regionserver;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.hbase.util.HasThread;
+import javax.inject.Inject;
import java.util.ConcurrentModificationException;
import java.util.HashMap;
import java.util.Map;
@@ -66,7 +68,8 @@ public class Leases extends HasThread {
* @param leaseCheckFrequency - how often the lease should be checked
* (milliseconds)
*/
- public Leases(final int leaseCheckFrequency) {
+ @Inject
+ public Leases(@Assisted final int leaseCheckFrequency) {
this.leaseCheckFrequency = leaseCheckFrequency;
setDaemon(true);
}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/LeasesFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/LeasesFactory.java
new file mode 100644
index 0000000..0fcf771
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/LeasesFactory.java
@@ -0,0 +1,32 @@
+/**
+ * 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.hbase.regionserver;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+/**
+ * Interface of a Factory that can construct a Lease.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface LeasesFactory {
+
+ public Leases create(final int leaseCheckFrequency);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/LeasesModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/LeasesModule.java
new file mode 100644
index 0000000..370f815
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/LeasesModule.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.regionserver;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class LeasesModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(Leases.class, Leases.class)
+ .build(LeasesFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java
index cb6ed3c..51b431f 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java
@@ -35,6 +35,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -48,6 +49,8 @@ import org.apache.hadoop.util.StringUtils;
import com.google.common.base.Preconditions;
+import javax.inject.Inject;
+
/**
* Thread that flushes cache on request
*
@@ -58,7 +61,7 @@ import com.google.common.base.Preconditions;
* @see FlushRequester
*/
@InterfaceAudience.Private
-class MemStoreFlusher extends HasThread implements FlushRequester {
+public class MemStoreFlusher extends HasThread implements FlushRequester {
static final Log LOG = LogFactory.getLog(MemStoreFlusher.class);
// These two data members go together. Any entry in the one must have
// a corresponding entry in the other.
@@ -89,8 +92,9 @@ class MemStoreFlusher extends HasThread implements FlushRequester {
* @param conf
* @param server
*/
- public MemStoreFlusher(final Configuration conf,
- final HRegionServer server) {
+ @Inject
+ MemStoreFlusher(@Assisted final Configuration conf,
+ @Assisted final HRegionServer server) {
super();
this.server = server;
this.threadWakeFrequency =
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusherFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusherFactory.java
new file mode 100644
index 0000000..6b25831
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusherFactory.java
@@ -0,0 +1,33 @@
+/**
+ * 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.hbase.regionserver;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.conf.Configuration;
+
+/**
+ * Interface of a Factory that can construct a MemStoreFlusher.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface MemStoreFlusherFactory {
+
+ public MemStoreFlusher create(final Configuration conf, final HRegionServer server);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusherModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusherModule.java
new file mode 100644
index 0000000..0042122
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusherModule.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.regionserver;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class MemStoreFlusherModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(MemStoreFlusher.class, MemStoreFlusher.class)
+ .build(MemStoreFlusherFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeper.java hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeper.java
index 6eaa51f..555cebb 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeper.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeper.java
@@ -32,6 +32,7 @@ import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicBoolean;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -49,6 +50,8 @@ import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.ConnectionLossException;
import org.apache.zookeeper.KeeperException.SessionExpiredException;
+import javax.inject.Inject;
+
/**
* This class serves as a helper for all things related to zookeeper in
* replication.
@@ -139,7 +142,9 @@ public class ReplicationZookeeper implements Closeable{
* @throws IOException
* @throws KeeperException
*/
- public ReplicationZookeeper(final Server server, final AtomicBoolean replicating)
+ @Inject
+ public ReplicationZookeeper(@Assisted final Server server,
+ @Assisted final AtomicBoolean replicating)
throws IOException, KeeperException {
this.abortable = server;
this.zookeeper = server.getZooKeeper();
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeperFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeperFactory.java
new file mode 100644
index 0000000..ac4ce57
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeperFactory.java
@@ -0,0 +1,38 @@
+/**
+ * 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.hbase.replication;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.Server;
+import org.apache.hadoop.hbase.replication.ReplicationZookeeper;
+import org.apache.zookeeper.KeeperException;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Interface of a Factory that can construct a ReplicationZookeeper.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface ReplicationZookeeperFactory {
+
+ public ReplicationZookeeper create(final Server server, final AtomicBoolean replicating) throws
+ KeeperException;
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeperModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeperModule.java
new file mode 100644
index 0000000..396dbb6
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeperModule.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.replication;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class ReplicationZookeeperModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(ReplicationZookeeper.class, ReplicationZookeeper.class)
+ .build(ReplicationZookeeperFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java
index 250ea86..e6c1439 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java
@@ -24,6 +24,7 @@ import java.util.NavigableMap;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicBoolean;
+import com.google.inject.assistedinject.Assisted;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -32,6 +33,7 @@ import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.Server;
+import org.apache.hadoop.hbase.replication.ReplicationZookeeperFactory;
import org.apache.hadoop.hbase.regionserver.ReplicationSourceService;
import org.apache.hadoop.hbase.regionserver.ReplicationSinkService;
import org.apache.hadoop.hbase.regionserver.wal.HLog;
@@ -43,6 +45,8 @@ import org.apache.hadoop.hbase.replication.master.ReplicationLogCleaner;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.zookeeper.KeeperException;
+import javax.inject.Inject;
+
import static org.apache.hadoop.hbase.HConstants.HBASE_MASTER_LOGCLEANER_PLUGINS;
import static org.apache.hadoop.hbase.HConstants.REPLICATION_ENABLE_KEY;
import static org.apache.hadoop.hbase.HConstants.REPLICATION_SCOPE_LOCAL;
@@ -62,6 +66,11 @@ public class Replication implements WALActionsListener,
// Hosting server
private Server server;
+ //Factories for lazy init.
+ private ReplicationZookeeperFactory replicationZookeeperFactory;
+ private ReplicationSourceManagerFactory replicationSourceManagerFactory;
+ private ReplicationSinkFactory replicationSinkFactory;
+
/**
* Instantiate the replication management (if rep is enabled).
* @param server Hosting server
@@ -70,8 +79,17 @@ public class Replication implements WALActionsListener,
* @param oldLogDir directory where logs are archived
* @throws IOException
*/
- public Replication(final Server server, final FileSystem fs,
- final Path logDir, final Path oldLogDir) throws IOException{
+ @Inject
+ public Replication(@Assisted final Server server,
+ @Assisted final FileSystem fs,
+ @Assisted("logDir") final Path logDir,
+ @Assisted("oldLogDir") final Path oldLogDir,
+ ReplicationZookeeperFactory replicationZookeeperFactory,
+ ReplicationSourceManagerFactory replicationSourceManagerFactory,
+ ReplicationSinkFactory replicationSinkFactory) throws IOException{
+ this.replicationZookeeperFactory = replicationZookeeperFactory;
+ this.replicationSourceManagerFactory = replicationSourceManagerFactory;
+ this.replicationSinkFactory = replicationSinkFactory;
initialize(server, fs, logDir, oldLogDir);
}
@@ -88,12 +106,12 @@ public class Replication implements WALActionsListener,
this.replication = isReplication(this.conf);
if (replication) {
try {
- this.zkHelper = new ReplicationZookeeper(server, this.replicating);
+ this.zkHelper = replicationZookeeperFactory.create(server, this.replicating);
} catch (KeeperException ke) {
throw new IOException("Failed replication handler create " +
"(replicating=" + this.replicating, ke);
}
- this.replicationManager = new ReplicationSourceManager(zkHelper, conf,
+ this.replicationManager = replicationSourceManagerFactory.create(zkHelper,
this.server, fs, this.replicating, logDir, oldLogDir) ;
} else {
this.replicationManager = null;
@@ -150,7 +168,7 @@ public class Replication implements WALActionsListener,
public void startReplicationService() throws IOException {
if (this.replication) {
this.replicationManager.init();
- this.replicationSink = new ReplicationSink(this.conf, this.server);
+ this.replicationSink = replicationSinkFactory.create();
}
}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationFactory.java
new file mode 100644
index 0000000..80e78b3
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationFactory.java
@@ -0,0 +1,42 @@
+/**
+ * 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.hbase.replication.regionserver;
+
+import com.google.inject.assistedinject.Assisted;
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.Server;
+import org.apache.hadoop.hbase.replication.regionserver.Replication;
+
+import java.io.IOException;
+
+/**
+ * Interface of a Factory that can construct a ActiveMasterManager.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface ReplicationFactory {
+
+ public Replication create(@Assisted final Server server,
+ @Assisted final FileSystem fs,
+ @Assisted("logDir") final Path logDir,
+ @Assisted("oldLogDir") final Path oldLogDir) throws IOException;
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationModule.java
new file mode 100644
index 0000000..da6738e
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationModule.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.replication.regionserver;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class ReplicationModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(Replication.class, Replication.class)
+ .build(ReplicationFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSink.java hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSink.java
index a359f78..3a03535 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSink.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSink.java
@@ -35,6 +35,7 @@ import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
import org.apache.hadoop.hbase.replication.regionserver.metrics.ReplicationSinkMetrics;
import org.apache.hadoop.hbase.util.Bytes;
+import javax.inject.Inject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -74,12 +75,13 @@ public class ReplicationSink {
* @param stopper boolean to tell this thread to stop
* @throws IOException thrown when HDFS goes bad or bad file name
*/
- public ReplicationSink(Configuration conf, Stoppable stopper)
+ @Inject
+ public ReplicationSink(Configuration conf, ReplicationSinkMetrics metrics)
throws IOException {
this.conf = conf;
this.pool = new HTablePool(this.conf,
conf.getInt("replication.sink.htablepool.capacity", 10));
- this.metrics = new ReplicationSinkMetrics();
+ this.metrics = metrics;
}
/**
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSinkFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSinkFactory.java
new file mode 100644
index 0000000..ad37245
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSinkFactory.java
@@ -0,0 +1,31 @@
+/**
+ * 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.hbase.replication.regionserver;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+/**
+ * Interface of a Factory that can construct a ReplicationSink.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface ReplicationSinkFactory {
+
+ public ReplicationSink create();
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSinkModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSinkModule.java
new file mode 100644
index 0000000..7e6d748
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSinkModule.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hbase.replication.regionserver;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class ReplicationSinkModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(ReplicationSink.class, ReplicationSink.class)
+ .build(ReplicationSinkFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java
index ddca9d1..2e52181 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java
@@ -37,6 +37,7 @@ import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -57,12 +58,15 @@ import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
import org.apache.hadoop.hbase.replication.ReplicationZookeeper;
import org.apache.hadoop.hbase.replication.regionserver.metrics.ReplicationSourceMetrics;
+import org.apache.hadoop.hbase.replication.regionserver.metrics.ReplicationSourceMetricsFactory;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Threads;
import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
import org.apache.hadoop.ipc.RemoteException;
import org.apache.zookeeper.KeeperException;
+import javax.inject.Inject;
+
/**
* Class that handles the source of a replication stream.
* Currently does not handle more than 1 slave
@@ -141,24 +145,16 @@ public class ReplicationSource extends Thread
// Metrics for this source
private ReplicationSourceMetrics metrics;
- /**
- * Instantiation method used by region servers
- *
- * @param conf configuration to use
- * @param fs file system to use
- * @param manager replication manager to ping to
- * @param stopper the atomic boolean to use to stop the regionserver
- * @param replicating the atomic boolean that starts/stops replication
- * @param peerClusterZnode the name of our znode
- * @throws IOException
- */
- public void init(final Configuration conf,
- final FileSystem fs,
- final ReplicationSourceManager manager,
- final Stoppable stopper,
- final AtomicBoolean replicating,
- final String peerClusterZnode)
- throws IOException {
+ public ReplicationSource() { }
+
+ @Inject
+ public ReplicationSource(final Configuration conf,
+ final ReplicationSourceMetricsFactory replicationSourceMetricsFactory,
+ @Assisted final FileSystem fs,
+ @Assisted final ReplicationSourceManager manager,
+ @Assisted final Stoppable stopper,
+ @Assisted final AtomicBoolean replicating,
+ @Assisted final String peerClusterZnode) throws IOException {
this.stopper = stopper;
this.conf = conf;
this.replicationQueueSizeCapacity =
@@ -186,7 +182,7 @@ public class ReplicationSource extends Thread
this.sleepForRetries =
this.conf.getLong("replication.source.sleepforretries", 1000);
this.fs = fs;
- this.metrics = new ReplicationSourceMetrics(peerClusterZnode);
+ this.metrics = replicationSourceMetricsFactory.create(peerClusterZnode);
try {
this.clusterId = UUID.fromString(ZKClusterId.readClusterIdZNode(zkHelper
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceFactory.java
new file mode 100644
index 0000000..fb9949f
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceFactory.java
@@ -0,0 +1,43 @@
+/**
+ * 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.hbase.replication.regionserver;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.hbase.Stoppable;
+import org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceInterface;
+import org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceManager;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Interface of a Factory that can construct a ReplicationSourceInterface.
+ * This will be used by guice in DI.
+ */
+@InterfaceAudience.Private
+public interface ReplicationSourceFactory {
+
+ ReplicationSourceInterface create(
+ final FileSystem fs,
+ final ReplicationSourceManager manager,
+ final Stoppable stopper,
+ final AtomicBoolean replicating,
+ final String peerClusterZnode);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceInterface.java hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceInterface.java
index ccafe1f..f4a660c 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceInterface.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceInterface.java
@@ -35,23 +35,6 @@ import org.apache.hadoop.hbase.Stoppable;
public interface ReplicationSourceInterface {
/**
- * Initializer for the source
- * @param conf the configuration to use
- * @param fs the file system to use
- * @param manager the manager to use
- * @param stopper the stopper object for this region server
- * @param replicating the status of the replication on this cluster
- * @param peerClusterId the id of the peer cluster
- * @throws IOException
- */
- public void init(final Configuration conf,
- final FileSystem fs,
- final ReplicationSourceManager manager,
- final Stoppable stopper,
- final AtomicBoolean replicating,
- final String peerClusterId) throws IOException;
-
- /**
* Add a log to the list of logs to replicate
* @param log path to the log to replicate
*/
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
index 4a3ed90..de1ea29 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
@@ -35,6 +35,7 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -49,6 +50,8 @@ import org.apache.zookeeper.KeeperException;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import javax.inject.Inject;
+
/**
* This class is responsible to manage all the replication
* sources. There are two classes of sources:
@@ -90,6 +93,7 @@ public class ReplicationSourceManager {
private final long sleepBeforeFailover;
// Homemade executer service for replication
private final ThreadPoolExecutor executor;
+ private ReplicationSourceFactory replicationSourceFactory;
/**
* Creates a replication manager and sets the watch on all the other
@@ -102,13 +106,16 @@ public class ReplicationSourceManager {
* @param logDir the directory that contains all hlog directories of live RSs
* @param oldLogDir the directory where old logs are archived
*/
- public ReplicationSourceManager(final ReplicationZookeeper zkHelper,
+ @Inject
+ public ReplicationSourceManager(@Assisted final ReplicationZookeeper zkHelper,
final Configuration conf,
- final Stoppable stopper,
- final FileSystem fs,
- final AtomicBoolean replicating,
- final Path logDir,
- final Path oldLogDir) {
+ @Assisted final Stoppable stopper,
+ @Assisted final FileSystem fs,
+ @Assisted final AtomicBoolean replicating,
+ @Assisted("logDir") final Path logDir,
+ @Assisted("oldLogDir") final Path oldLogDir,
+ final ReplicationSourceFactory replicationSourceFactory) {
+ this.replicationSourceFactory = replicationSourceFactory;
this.sources = new ArrayList
@@ -60,7 +63,8 @@ public class MasterAddressTracker extends ZooKeeperNodeTracker {
* @param watcher zk reference and watcher
* @param abortable abortable in case of fatal error
*/
- public MasterAddressTracker(ZooKeeperWatcher watcher, Abortable abortable) {
+ @Inject
+ public MasterAddressTracker(@Assisted ZooKeeperWatcher watcher, @Assisted Abortable abortable) {
super(watcher, watcher.getMasterAddressZNode(), abortable);
}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTrackerFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTrackerFactory.java
new file mode 100644
index 0000000..db19c08
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTrackerFactory.java
@@ -0,0 +1,30 @@
+/*
+ * 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.hbase.zookeeper;
+
+import org.apache.hadoop.hbase.Abortable;
+
+/**
+ *
+ */
+public interface MasterAddressTrackerFactory {
+
+ public MasterAddressTracker create(ZooKeeperWatcher watcher, Abortable abortable);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTrackerModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTrackerModule.java
new file mode 100644
index 0000000..3b07214
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTrackerModule.java
@@ -0,0 +1,35 @@
+/*
+ * 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.hbase.zookeeper;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class MasterAddressTrackerModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(MasterAddressTracker.class, MasterAddressTracker.class)
+ .build(MasterAddressTrackerFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTracker.java hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTracker.java
index d95ff14..52b9146 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTracker.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTracker.java
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.NavigableSet;
import java.util.TreeSet;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -33,6 +34,8 @@ import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.master.ServerManager;
import org.apache.zookeeper.KeeperException;
+import javax.inject.Inject;
+
/**
* Tracks the online region servers via ZK.
*
@@ -50,8 +53,10 @@ public class RegionServerTracker extends ZooKeeperListener {
private ServerManager serverManager;
private Abortable abortable;
- public RegionServerTracker(ZooKeeperWatcher watcher,
- Abortable abortable, ServerManager serverManager) {
+ @Inject
+ public RegionServerTracker(@Assisted ZooKeeperWatcher watcher,
+ @Assisted Abortable abortable,
+ @Assisted ServerManager serverManager) {
super(watcher);
this.abortable = abortable;
this.serverManager = serverManager;
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTrackerFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTrackerFactory.java
new file mode 100644
index 0000000..d34e56d
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTrackerFactory.java
@@ -0,0 +1,33 @@
+/*
+ * 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.hbase.zookeeper;
+
+import org.apache.hadoop.hbase.Abortable;
+import org.apache.hadoop.hbase.master.ServerManager;
+
+/**
+ *
+ */
+public interface RegionServerTrackerFactory {
+
+ public RegionServerTracker create(ZooKeeperWatcher watcher,
+ Abortable abortable,
+ ServerManager serverManager);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTrackerModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTrackerModule.java
new file mode 100644
index 0000000..606fdf2
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTrackerModule.java
@@ -0,0 +1,35 @@
+/*
+ * 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.hbase.zookeeper;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class RegionServerTrackerModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(RegionServerTracker.class, RegionServerTracker.class)
+ .build(RegionServerTrackerFactory.class));
+ }
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
index 33bc1d0..5714b10 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
+import com.google.inject.assistedinject.Assisted;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -41,6 +42,8 @@ import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.data.ACL;
+import javax.inject.Inject;
+
/**
* Acts as the single ZooKeeper Watcher. One instance of this is instantiated
* for each Master, RegionServer, and client process.
@@ -132,8 +135,9 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
* @throws IOException
* @throws ZooKeeperConnectionException
*/
- public ZooKeeperWatcher(Configuration conf, String descriptor,
- Abortable abortable, boolean canCreateBaseZNode)
+ @Inject
+ public ZooKeeperWatcher(@Assisted Configuration conf, @Assisted String descriptor,
+ @Assisted Abortable abortable, @Assisted boolean canCreateBaseZNode)
throws IOException, ZooKeeperConnectionException {
this.conf = conf;
// Capture a stack trace now. Will print it out later if problem so we can
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcherFactory.java hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcherFactory.java
new file mode 100644
index 0000000..1689544
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcherFactory.java
@@ -0,0 +1,34 @@
+/*
+ * 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.hbase.zookeeper;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.Abortable;
+
+/**
+ *
+ */
+public interface ZooKeeperWatcherFactory {
+
+ public ZooKeeperWatcher create(Configuration conf,
+ String descriptor,
+ Abortable abortable,
+ boolean canCreateBaseZNode);
+
+}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcherModule.java hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcherModule.java
new file mode 100644
index 0000000..dd26490
--- /dev/null
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcherModule.java
@@ -0,0 +1,35 @@
+/*
+ * 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.hbase.zookeeper;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+
+/**
+ *
+ */
+public class ZooKeeperWatcherModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new FactoryModuleBuilder()
+ .implement(ZooKeeperWatcher.class, ZooKeeperWatcher.class)
+ .build(ZooKeeperWatcherFactory.class));
+ }
+}
diff --git hbase-server/src/main/resources/hbase-default.xml hbase-server/src/main/resources/hbase-default.xml
index a42d94b..af33909 100644
--- hbase-server/src/main/resources/hbase-default.xml
+++ hbase-server/src/main/resources/hbase-default.xml
@@ -895,4 +895,9 @@
default log cleaners in the list as they will be overwritten in hbase-site.xml.
+
+