You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2011/03/01 05:04:12 UTC

svn commit: r1075644 - /hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/handler/SplitRegionHandler.java

Author: stack
Date: Tue Mar  1 04:04:12 2011
New Revision: 1075644

URL: http://svn.apache.org/viewvc?rev=1075644&view=rev
Log:
HBASE-3559  Move report of split to master OFF the heartbeat channel -- forgot to add file

Added:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/handler/SplitRegionHandler.java

Added: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/handler/SplitRegionHandler.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/handler/SplitRegionHandler.java?rev=1075644&view=auto
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/handler/SplitRegionHandler.java (added)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/handler/SplitRegionHandler.java Tue Mar  1 04:04:12 2011
@@ -0,0 +1,89 @@
+/**
+ * Copyright 2011 The Apache Software Foundation
+ *
+ * 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.handler;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.HServerInfo;
+import org.apache.hadoop.hbase.Server;
+import org.apache.hadoop.hbase.executor.EventHandler;
+import org.apache.hadoop.hbase.master.AssignmentManager;
+import org.apache.hadoop.hbase.zookeeper.ZKAssign;
+import org.apache.zookeeper.KeeperException;
+
+/**
+ * Handles SPLIT region event on Master.
+ */
+public class SplitRegionHandler extends EventHandler implements TotesHRegionInfo {
+  private static final Log LOG = LogFactory.getLog(SplitRegionHandler.class);
+  private final AssignmentManager assignmentManager;
+  private final HRegionInfo parent;
+  private final HServerInfo serverInfo;
+  private final List<HRegionInfo> daughters;
+  /**
+   * For testing only!  Set to true to skip handling of split.
+   */
+  public static boolean TEST_SKIP = false;
+
+  public SplitRegionHandler(Server server,
+      AssignmentManager assignmentManager, HRegionInfo regionInfo,
+      HServerInfo serverInfo, final List<HRegionInfo> daughters) {
+    super(server, EventType.RS_ZK_REGION_SPLIT);
+    this.assignmentManager = assignmentManager;
+    this.parent = regionInfo;
+    this.serverInfo = serverInfo;
+    this.daughters = daughters;
+  }
+
+  @Override
+  public HRegionInfo getHRegionInfo() {
+    return this.parent;
+  }
+
+  @Override
+  public void process() {
+    LOG.debug("Handling SPLIT event for " + this.parent.getEncodedName() +
+      "; deleting node");
+    // The below is for testing ONLY!  We can't do fault injection easily, so
+    // resort to this kinda uglyness -- St.Ack 02/25/2011.
+    if (TEST_SKIP) {
+      LOG.warn("Skipping split message, TEST_SKIP is set");
+      return;
+    }
+    this.assignmentManager.handleSplitReport(this.serverInfo, this.parent,
+      this.daughters.get(0), this.daughters.get(1));
+    // Remove region from ZK
+    try {
+      ZKAssign.deleteNode(this.server.getZooKeeper(),
+        this.parent.getEncodedName(),
+        EventHandler.EventType.RS_ZK_REGION_SPLIT);
+    } catch (KeeperException e) {
+      server.abort("Error deleting SPLIT node in ZK for transition ZK node (" +
+        parent.getEncodedName() + ")", e);
+    }
+    LOG.info("Handled SPLIT report); parent=" +
+      this.parent.getRegionNameAsString() +
+      " daughter a=" + this.daughters.get(0).getRegionNameAsString() +
+      "daughter b=" + this.daughters.get(1).getRegionNameAsString());
+  }
+}
\ No newline at end of file