hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1589538 - in /hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus: ./ ConsensusProvider.java ConsensusProviderFactory.java ZkConsensusProvider.java
Date Wed, 23 Apr 2014 22:58:52 GMT
Author: stack
Date: Wed Apr 23 22:58:51 2014
New Revision: 1589538

URL: http://svn.apache.org/r1589538
Log:
HBASE-11025 Infrastructure for pluggable consensus service (Mikhail Antonov)

Added:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus/
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus/ConsensusProvider.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus/ConsensusProviderFactory.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus/ZkConsensusProvider.java

Added: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus/ConsensusProvider.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus/ConsensusProvider.java?rev=1589538&view=auto
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus/ConsensusProvider.java
(added)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus/ConsensusProvider.java
Wed Apr 23 22:58:51 2014
@@ -0,0 +1,58 @@
+/**
+ * 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.consensus;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.Server;
+
+/**
+ * Implementations of this interface will keep and return to clients 
+ * implementations of classes providing API to execute
+ * coordinated operations.
+ *
+ * For each coarse-grained area of operations there will be a separate
+ * interface with implementation, providing API for relevant operations
+ * requiring coordination.
+ *
+ * Property hbase.consensus.provider.class in hbase-site.xml controls
+ * which provider to use.
+ */
+@InterfaceAudience.Private
+public interface ConsensusProvider {
+
+  /**
+   * Initialize consensus service.
+   * @param server server instance to run within.
+   */
+  void initialize(Server server);
+
+  /**
+   * Starts consensus service.
+   */
+  void start();
+
+  /**
+   * Stop consensus provider.
+   */
+  void stop();
+
+  /**
+   * @return instance of Server consensus runs within
+   */
+  Server getServer();
+}

Added: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus/ConsensusProviderFactory.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus/ConsensusProviderFactory.java?rev=1589538&view=auto
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus/ConsensusProviderFactory.java
(added)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus/ConsensusProviderFactory.java
Wed Apr 23 22:58:51 2014
@@ -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.consensus;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.util.ReflectionUtils;
+
+/**
+ * Creates instance of {@link org.apache.hadoop.hbase.consensus.ConsensusProvider}
+ * based on configuration.
+ */
+@InterfaceAudience.Private
+public class ConsensusProviderFactory {
+
+  /**
+   * Creates consensus provider from the given configuration.
+   * @param conf Configuration
+   * @return A {@link org.apache.hadoop.hbase.consensus.ConsensusProvider}
+   */
+  public static ConsensusProvider getConsensusProvider(Configuration conf) {
+    Class<? extends ConsensusProvider> consensusKlass =
+      conf.getClass(HConstants.HBASE_CONSENSUS_PROVIDER_CLASS, ZkConsensusProvider.class,
+        ConsensusProvider.class);
+    return ReflectionUtils.newInstance(consensusKlass, conf);
+  }
+}

Added: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus/ZkConsensusProvider.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus/ZkConsensusProvider.java?rev=1589538&view=auto
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus/ZkConsensusProvider.java
(added)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/consensus/ZkConsensusProvider.java
Wed Apr 23 22:58:51 2014
@@ -0,0 +1,50 @@
+/**
+ * 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.consensus;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.Server;
+import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+
+/**
+ * ZooKeeper-based implementation of {@link ConsensusProvider}.
+ */
+@InterfaceAudience.Private
+public class ZkConsensusProvider implements ConsensusProvider {
+  private Server server;
+  private ZooKeeperWatcher watcher;
+  
+  @Override
+  public void initialize(Server server) {
+    this.server = server;
+    this.watcher = server.getZooKeeper();
+  }
+
+  @Override
+  public void start() {
+  }
+
+  @Override
+  public void stop() {
+  }
+
+  @Override
+  public Server getServer() {
+    return server;
+  }
+}



Mime
View raw message