incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Fixed BLUR-88.
Date Sat, 18 May 2013 18:34:09 GMT
Updated Branches:
  refs/heads/0.1.5 53d224fd0 -> 49ef3aa7a


Fixed BLUR-88.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/49ef3aa7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/49ef3aa7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/49ef3aa7

Branch: refs/heads/0.1.5
Commit: 49ef3aa7abfe1d0f8b91bc5ec6b38da1885a33c2
Parents: 53d224f
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sat May 18 14:33:47 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sat May 18 14:33:47 2013 -0400

----------------------------------------------------------------------
 .../src/test/java/org/apache/blur/MiniCluster.java |   26 +++++++++++++++
 .../org/apache/blur/thrift/BlurClusterTest.java    |   21 ++++++++++++
 2 files changed, 47 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/49ef3aa7/src/blur-core/src/test/java/org/apache/blur/MiniCluster.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/test/java/org/apache/blur/MiniCluster.java b/src/blur-core/src/test/java/org/apache/blur/MiniCluster.java
index c2ffc9d..f827e2f 100644
--- a/src/blur-core/src/test/java/org/apache/blur/MiniCluster.java
+++ b/src/blur-core/src/test/java/org/apache/blur/MiniCluster.java
@@ -23,6 +23,7 @@ import static org.apache.blur.utils.BlurConstants.BLUR_GUI_SHARD_PORT;
 import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_BIND_PORT;
 import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_BLOCKCACHE_DIRECT_MEMORY_ALLOCATION;
 import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_BLOCKCACHE_SLAB_COUNT;
+import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_HOSTNAME;
 import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_SAFEMODEDELAY;
 import static org.apache.blur.utils.BlurConstants.BLUR_ZOOKEEPER_CONNECTION;
 
@@ -42,6 +43,7 @@ import java.util.concurrent.ThreadPoolExecutor;
 
 import org.apache.blur.log.Log;
 import org.apache.blur.log.LogFactory;
+import org.apache.blur.manager.clusterstatus.ZookeeperPathConstants;
 import org.apache.blur.store.buffer.BufferStore;
 import org.apache.blur.thrift.BlurClient;
 import org.apache.blur.thrift.BlurClientManager;
@@ -61,6 +63,7 @@ import org.apache.blur.thrift.generated.Row;
 import org.apache.blur.thrift.generated.RowMutation;
 import org.apache.blur.thrift.generated.TableDescriptor;
 import org.apache.blur.utils.BlurUtil;
+import org.apache.blur.zookeeper.ZooKeeperClient;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
@@ -280,6 +283,29 @@ public abstract class MiniCluster {
     }
   }
 
+  public static void killShardServer(int shardServer) throws IOException, InterruptedException,
KeeperException {
+    killShardServer(getBlurConfiguration(), shardServer);
+  }
+
+  public static void killShardServer(final BlurConfiguration configuration, int shardServer)
throws IOException,
+      InterruptedException, KeeperException {
+    final BlurConfiguration localConf = getBlurConfiguration(configuration);
+    int shardPort = localConf.getInt(BLUR_SHARD_BIND_PORT, 40020);
+    String nodeNameHostname = ThriftServer.getNodeName(configuration, BLUR_SHARD_HOSTNAME);
+    String nodeName = nodeNameHostname + ":" + (shardPort + shardServer);
+    ZooKeeper zk = new ZooKeeperClient(getZkConnectionString(), 30000, new Watcher() {
+      @Override
+      public void process(WatchedEvent event) {
+
+      }
+    });
+    String onlineShardsPath = ZookeeperPathConstants
+        .getOnlineShardsPath(org.apache.blur.utils.BlurConstants.BLUR_CLUSTER);
+    String path = onlineShardsPath + "/" + nodeName;
+    zk.delete(path, -1);
+    zk.close();
+  }
+
   private static void startServer(final ThriftServer server, Connection connection) {
     new Thread(new Runnable() {
       @Override

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/49ef3aa7/src/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java b/src/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
index 39a44b5..6aaa236 100644
--- a/src/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
+++ b/src/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
@@ -45,6 +45,7 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsAction;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.thrift.TException;
+import org.apache.zookeeper.KeeperException;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -120,6 +121,26 @@ public class BlurClusterTest {
     BlurResults results = client.query("test", blurQuery);
     assertEquals(length, results.getTotalResults());
   }
+  
+  @Test
+  public void testTestShardFailover() throws BlurException, TException, InterruptedException,
IOException, KeeperException {
+    Iface client = getClient();
+    int length = 100;
+    BlurQuery blurQuery = new BlurQuery();
+    blurQuery.setUseCacheIfPresent(false);
+    SimpleQuery simpleQuery = new SimpleQuery();
+    simpleQuery.setQueryStr("test.test:value");
+    blurQuery.setSimpleQuery(simpleQuery);
+    BlurResults results1 = client.query("test", blurQuery);
+    assertEquals(length, results1.getTotalResults());
+    
+    MiniCluster.killShardServer(1);
+    
+    client.shardServerLayout("test");
+    
+    assertEquals(length, client.query("test", blurQuery).getTotalResults());
+    
+  }
 
   @Test
   public void testCreateDisableAndRemoveTable() throws IOException, BlurException, TException
{


Mime
View raw message