You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2013/12/17 21:56:00 UTC

[1/2] git commit: ACCUMULO-2037 quick test to verify locality, location state management

Updated Branches:
  refs/heads/1.6.0-SNAPSHOT 46585ab59 -> b54b13049


ACCUMULO-2037 quick test to verify locality, location state management


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 741c83ca1a87dac227ddc783e94dab1924716658
Parents: 46585ab
Author: Eric Newton <er...@gmail.com>
Authored: Tue Dec 17 15:05:33 2013 -0500
Committer: Eric Newton <er...@gmail.com>
Committed: Tue Dec 17 15:05:33 2013 -0500

----------------------------------------------------------------------
 .../test/functional/MasterAssignmentIT.java     | 88 ++++++++++++++++++++
 1 file changed, 88 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/741c83ca/test/src/test/java/org/apache/accumulo/test/functional/MasterAssignmentIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/MasterAssignmentIT.java b/test/src/test/java/org/apache/accumulo/test/functional/MasterAssignmentIT.java
new file mode 100644
index 0000000..01bbd73
--- /dev/null
+++ b/test/src/test/java/org/apache/accumulo/test/functional/MasterAssignmentIT.java
@@ -0,0 +1,88 @@
+/*
+ * 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.functional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.accumulo.core.data.KeyExtent;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.security.Credentials;
+import org.apache.accumulo.fate.util.UtilWaitThread;
+import org.apache.accumulo.server.master.state.MetaDataTableScanner;
+import org.apache.accumulo.server.master.state.TabletLocationState;
+import org.apache.hadoop.io.Text;
+import org.junit.Test;
+
+public class MasterAssignmentIT extends SimpleMacIT {
+  
+  @Test(timeout=2*60*1000)
+  public void test() throws Exception {
+    Connector c = getConnector();
+    String tableName = super.getTableNames(1)[0];
+    c.tableOperations().create(tableName);
+    String tableId = c.tableOperations().tableIdMap().get(tableName);
+    // wait for the table to be online
+    TabletLocationState newTablet;
+    do {
+      UtilWaitThread.sleep(250);
+      newTablet = getTabletLocationState(c, tableId);
+    } while (newTablet.current == null);
+    assertNull(newTablet.last);
+    assertNull(newTablet.future);
+    
+    // put something in it
+    BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
+    Mutation m = new Mutation("a");
+    m.put("b", "c", "d");
+    bw.addMutation(m);
+    bw.close();
+    // give it a last location
+    c.tableOperations().flush(tableName, null, null, true);
+    
+    TabletLocationState flushed = getTabletLocationState(c, tableId);
+    assertEquals(newTablet.current, flushed.current);
+    assertEquals(flushed.current, flushed.last);
+    assertNull(newTablet.future);
+    
+    // take the tablet offline
+    c.tableOperations().offline(tableName, true);
+    TabletLocationState offline = getTabletLocationState(c, tableId);
+    assertNull(offline.future);
+    assertNull(offline.current);
+    assertEquals(flushed.current, offline.last);
+    
+    // put it back online
+    c.tableOperations().online(tableName, true);
+    TabletLocationState online = getTabletLocationState(c, tableId);
+    assertNull(online.future);
+    assertNotNull(online.current);
+    assertEquals(online.current, online.last);
+  }
+
+  private TabletLocationState getTabletLocationState(Connector c, String tableId) {
+    Credentials creds = new Credentials("root", new PasswordToken(ROOT_PASSWORD));
+    MetaDataTableScanner s = new MetaDataTableScanner(c.getInstance(), creds, new Range(KeyExtent.getMetadataEntry(new Text(tableId), null)));
+    return s.next();
+  }
+}


[2/2] git commit: ACCUMULO-2037 use the last location information

Posted by ec...@apache.org.
ACCUMULO-2037 use the last location information


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: b54b130491100b100caca72f1075a9dc91be5f5d
Parents: 741c83c
Author: Eric Newton <er...@gmail.com>
Authored: Tue Dec 17 15:55:31 2013 -0500
Committer: Eric Newton <er...@gmail.com>
Committed: Tue Dec 17 15:55:31 2013 -0500

----------------------------------------------------------------------
 .../balancer/DefaultLoadBalancerTest.java       | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/b54b1304/server/base/src/test/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java
index a471a84..9f99b1c 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java
@@ -41,6 +41,7 @@ import org.apache.accumulo.server.master.state.TServerInstance;
 import org.apache.accumulo.server.master.state.TabletMigration;
 import org.apache.hadoop.io.Text;
 import org.apache.thrift.TException;
+import org.junit.Before;
 import org.junit.Test;
 
 import com.google.common.net.HostAndPort;
@@ -68,6 +69,7 @@ public class DefaultLoadBalancerTest {
   }
   
   Map<TServerInstance,FakeTServer> servers = new HashMap<TServerInstance,FakeTServer>();
+  Map<KeyExtent, TServerInstance> last = new HashMap<KeyExtent, TServerInstance>();
   
   class TestDefaultLoadBalancer extends DefaultLoadBalancer {
     
@@ -83,12 +85,17 @@ public class DefaultLoadBalancerTest {
     }
   }
   
+  @Before
+  public void setUp() {
+    last.clear();
+    servers.clear();
+  }
+  
   @Test
   public void testAssignMigrations() {
-    servers.clear();
     servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.1", 1234), "a"), new FakeTServer());
-    servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.1", 1235), "b"), new FakeTServer());
-    servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.1", 1236), "c"), new FakeTServer());
+    servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.2", 1234), "b"), new FakeTServer());
+    servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.3", 1234), "c"), new FakeTServer());
     List<KeyExtent> metadataTable = new ArrayList<KeyExtent>();
     String table = "t1";
     metadataTable.add(makeExtent(table, null, null));
@@ -143,10 +150,11 @@ public class DefaultLoadBalancerTest {
       TestDefaultLoadBalancer balancer) {
     // Assign tablets
     for (KeyExtent extent : metadataTable) {
-      TServerInstance assignment = balancer.getAssignment(status, extent, null);
+      TServerInstance assignment = balancer.getAssignment(status, extent, last.get(extent));
       assertNotNull(assignment);
       assertFalse(servers.get(assignment).extents.contains(extent));
       servers.get(assignment).extents.add(extent);
+      last.put(extent, assignment);
     }
   }
   
@@ -160,7 +168,6 @@ public class DefaultLoadBalancerTest {
   
   @Test
   public void testUnevenAssignment() {
-    servers.clear();
     for (char c : "abcdefghijklmnopqrstuvwxyz".toCharArray()) {
       String cString = Character.toString(c);
       HostAndPort fakeAddress = HostAndPort.fromParts("127.0.0.1", (int) c);
@@ -201,7 +208,6 @@ public class DefaultLoadBalancerTest {
   
   @Test
   public void testUnevenAssignment2() {
-    servers.clear();
     // make 26 servers
     for (char c : "abcdefghijklmnopqrstuvwxyz".toCharArray()) {
       String cString = Character.toString(c);
@@ -237,7 +243,9 @@ public class DefaultLoadBalancerTest {
       for (TabletMigration migration : migrationsOut) {
         if (servers.get(migration.oldServer).extents.remove(migration.tablet))
           moved++;
+        last.remove(migration.tablet);
         servers.get(migration.newServer).extents.add(migration.tablet);
+        last.put(migration.tablet, migration.newServer);
       }
     }
     // average is 58, with 2 at 59: we need 48 more moved to the short server