accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [1/2] accumulo git commit: ACCUMULO-3692 remove migrations for offline tables, added test
Date Mon, 23 Mar 2015 21:00:03 GMT
Repository: accumulo
Updated Branches:
  refs/heads/1.6 16a7bb437 -> 43e90022e


ACCUMULO-3692 remove migrations for offline tables, added test


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/4fe86be9
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/4fe86be9
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/4fe86be9

Branch: refs/heads/1.6
Commit: 4fe86be9387f88da55c060732a258b4da5d99471
Parents: 16a7bb4
Author: Eric C. Newton <eric.newton@gmail.com>
Authored: Mon Mar 23 16:47:21 2015 -0400
Committer: Eric C. Newton <eric.newton@gmail.com>
Committed: Mon Mar 23 16:47:21 2015 -0400

----------------------------------------------------------------------
 .../accumulo/master/TabletGroupWatcher.java     |  7 ++
 .../test/BalanceWithOfflineTableIT.java         | 90 ++++++++++++++++++++
 2 files changed, 97 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/4fe86be9/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java
b/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java
index 2194242..e86edf3 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java
@@ -46,6 +46,8 @@ import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.PartialKey;
 import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.master.state.tables.TableState;
+import org.apache.accumulo.core.master.thrift.MasterState;
 import org.apache.accumulo.core.master.thrift.TabletServerStatus;
 import org.apache.accumulo.core.metadata.MetadataTable;
 import org.apache.accumulo.core.metadata.RootTable;
@@ -254,6 +256,11 @@ class TabletGroupWatcher extends Daemon {
           } else {
             switch (state) {
               case UNASSIGNED:
+                TServerInstance dest = this.master.migrations.get(tls.extent);
+                TableState tableState = TableManager.getInstance().getTableState(tls.extent.getTableId().toString());
+                if (dest != null && tableState == TableState.OFFLINE) {
+                  this.master.migrations.remove(tls.extent);
+                }
                 break;
               case ASSIGNED_TO_DEAD_SERVER:
                 assignedToDeadServers.add(tls);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4fe86be9/test/src/test/java/org/apache/accumulo/test/BalanceWithOfflineTableIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/BalanceWithOfflineTableIT.java b/test/src/test/java/org/apache/accumulo/test/BalanceWithOfflineTableIT.java
new file mode 100644
index 0000000..86468c5
--- /dev/null
+++ b/test/src/test/java/org/apache/accumulo/test/BalanceWithOfflineTableIT.java
@@ -0,0 +1,90 @@
+/*
+ * 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.accumulo.test;
+
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.util.SimpleThreadPool;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
+import org.apache.accumulo.test.functional.ConfigurableMacIT;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.Text;
+import org.junit.Test;
+
+// ACCUMULO-3692
+public class BalanceWithOfflineTableIT extends ConfigurableMacIT {
+
+  @Override
+  protected int defaultTimeoutSeconds() {
+    return 30;
+  }
+
+  @Override
+  protected void configure(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
+  }
+
+  @Test
+  public void test() throws Exception {
+    final String tableNames[] = getUniqueNames(2);
+    final String tableName = tableNames[0];
+    // create a table with a bunch of splits
+
+    final Connector c = getConnector();
+    log.info("Creating table " + tableName);
+    c.tableOperations().create(tableName);;
+    final SortedSet<Text> splits = new TreeSet<>();
+    for (String split : "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(","))
{
+      splits.add(new Text(split));
+    }
+    log.info("Splitting table " + tableName);
+    c.tableOperations().addSplits(tableName, splits);
+    log.info("Balancing");
+    c.instanceOperations().waitForBalance();
+    log.info("Balanced");
+
+    // create a new table which will unbalance the cluster
+    final String table2 = tableNames[1];
+    log.info("Creating table " + table2);
+    c.tableOperations().create(table2);
+    log.info("Creating splits " + table2);
+    c.tableOperations().addSplits(table2, splits);
+
+    // offline the table, hopefully while there are some migrations going on
+    log.info("Offlining " + table2);
+    c.tableOperations().offline(table2, true);
+    log.info("Offlined " + table2);
+
+    log.info("Waiting for balance");
+
+    SimpleThreadPool pool = new SimpleThreadPool(1, "waitForBalance");
+    Future<Boolean> wait = pool.submit(new Callable<Boolean>() {
+      @Override
+      public Boolean call() throws Exception {
+        c.instanceOperations().waitForBalance();
+        return true;
+      }
+    });
+    wait.get(20, TimeUnit.SECONDS);
+    log.info("Balance succeeded with an offline table");
+  }
+
+}


Mime
View raw message