Package net.sf.katta.node

Examples of net.sf.katta.node.Node$NodeOperationProcessor


    assertEquals(1, protocol.getIndices().size());

    int optimumShardDeployCount = SHARD_COUNT * replicationCount;
    assertTrue(optimumShardDeployCount > countShardDeployments(protocol, INDEX_NAME));

    Node node = _miniCluster.startAdditionalNode();
    TestUtil.waitUntilNodeServesShards(protocol, node.getName(), SHARD_COUNT);
    assertTrue(optimumShardDeployCount == countShardDeployments(protocol, INDEX_NAME));
  }
View Full Code Here


    Collection<String> deployedShards = protocol.getNodeShards(_miniCluster.getNode(0).getName());
    assertFalse(deployedShards.isEmpty());

    // restart node
    Node node = _miniCluster.restartNode(0);
    assertEquals(deployedShards, protocol.getNodeShards(node.getName()));
  }
View Full Code Here

  @Test
  public void testUndeployShard() throws Exception {
    deployTestIndices(1, getNodeCount());
    final InteractionProtocol protocol = _miniCluster.getProtocol();
    assertEquals(1, protocol.getIndices().size());
    Node node = _miniCluster.getNode(0);
    TestUtil.waitUntilNodeServesShards(protocol, node.getName(), SHARD_COUNT);

    // we should have 4 folders in our working folder now.
    File shardsFolder = node.getContext().getShardManager().getShardsFolder();
    assertEquals(SHARD_COUNT, shardsFolder.list().length);

    ShardUndeployOperation undeployOperation = new ShardUndeployOperation(Arrays.asList(protocol.getNodeShards(
            node.getName()).iterator().next()));
    protocol.addNodeOperation(node.getName(), undeployOperation);
    TestUtil.waitUntilNodeServesShards(protocol, node.getName(), 3);
    // Thread.sleep(2000);
    assertEquals(3, shardsFolder.list().length);
  }
View Full Code Here

    // kill 2nd of 3 nodes
    _miniCluster.shutdownNode(0);
    assertEquals(4, client.count(query, new String[] { INDEX_NAME }));

    // add a 4th node
    Node node4 = _miniCluster.startAdditionalNode();
    TestUtil.waitUntilNodeServesShards(_protocol, node4.getName(), SHARD_COUNT);
    assertEquals(4, client.count(query, new String[] { INDEX_NAME }));

    // kill 3rd node
    Thread.sleep(5000);
    _miniCluster.shutdownNode(0);
View Full Code Here

    CheckIndicesOperation checkOperation = new CheckIndicesOperation();
    checkOperation.execute(_context, EMPTY_LIST);
    assertEquals(0, masterQueue.size());

    // add node and then balance again
    Node node3 = Mocks.mockNode();
    Mocks.publisNode(_protocol, node3);
    checkOperation.execute(_context, EMPTY_LIST);
    assertEquals(1, masterQueue.size());
  }
View Full Code Here

    gateway.stop();
  }

  @Test(timeout = 7000)
  public void testNodeQueue() throws Exception {
    Node node = mock(Node.class);
    String nodeName = "node1";
    when(node.getName()).thenReturn(nodeName);

    InteractionProtocol protocol = _zk.getInteractionProtocol();
    NodeQueue nodeQueue = protocol.publishNode(node, new NodeMetaData());

    NodeOperation nodeOperation1 = mock(NodeOperation.class, withSettings().serializable().name("a"));
View Full Code Here

    assertNotNull(_protocol.getMasterMD());
  }

  @Test(timeout = 7000)
  public void testPublishNode() throws Exception {
    Node node = Mocks.mockNode();
    assertNull(_protocol.getNodeMD(node.getName()));
    NodeQueue queue = _protocol.publishNode(node, new NodeMetaData(node.getName()));
    assertNotNull(queue);
    assertNotNull(_protocol.getNodeMD(node.getName()));

    // test operation
    NodeOperation operation = mock(NodeOperation.class);
    OperationId operationId = _protocol.addNodeOperation(node.getName(), operation);
    assertEquals(1, queue.size());
    assertNotNull(queue.peek());
    assertEquals(node.getName(), operationId.getNodeName());
  }
View Full Code Here

  @Test(timeout = 70000)
  public void testIndexManagement() throws Exception {
    IndexMetaData indexMD = new IndexMetaData("index1", "indexPath", 2);
    indexMD.getShards().add(new Shard(AbstractIndexOperation.createShardName(indexMD.getName(), "path1"), "path1"));
    Node node = Mocks.mockNode();

    assertNull(_protocol.getIndexMD("index1"));
    assertEquals(0, _protocol.getIndices().size());

    // publish index
View Full Code Here

    }
  }

  @Test(timeout = 7000)
  public void testShardManagement() throws Exception {
    Node node1 = Mocks.mockNode();
    Node node2 = Mocks.mockNode();
    Map<String, String> shardMD = new HashMap<String, String>();
    shardMD.put("a", "1");

    assertEquals(0, _protocol.getShardNodes("shard1").size());

    // publish shard
    _protocol.publishShard(node1, "shard1");
    assertEquals(1, _protocol.getShardNodes("shard1").size());
    assertEquals(1, _protocol.getNodeShards(node1.getName()).size());
    assertEquals(0, _protocol.getNodeShards(node2.getName()).size());

    // publish shard on 2nd node
    _protocol.publishShard(node2, "shard1");
    assertEquals(2, _protocol.getShardNodes("shard1").size());
    assertEquals(1, _protocol.getNodeShards(node1.getName()).size());
    assertEquals(1, _protocol.getNodeShards(node2.getName()).size());

    // remove shard on first node
    _protocol.unpublishShard(node1, "shard1");
    assertEquals(1, _protocol.getShardNodes("shard1").size());
    assertEquals(0, _protocol.getNodeShards(node1.getName()).size());
    assertEquals(1, _protocol.getNodeShards(node2.getName()).size());

    // publish 2nd shard
    _protocol.publishShard(node1, "shard2");
    assertEquals(1, _protocol.getShardNodes("shard1").size());
    assertEquals(1, _protocol.getShardNodes("shard2").size());
    assertEquals(1, _protocol.getNodeShards(node1.getName()).size());
    assertEquals(1, _protocol.getNodeShards(node2.getName()).size());

    // remove one shard completely
    _protocol.unpublishShard(node1, "shard2");

    Map<String, List<String>> shard2NodesMap = _protocol.getShard2NodesMap(Arrays.asList("shard1"));
View Full Code Here

      int numberOfRunningNode = _miniCluster.getRunningNodeCount();
      int nodesToStop = numberOfRunningNode - _nodeCount;
      int nodesToStart = _nodeCount - numberOfRunningNode;
      if (nodesToStop > 0) {
        for (int i = 0; i < nodesToStop; i++) {
          Node node = _miniCluster.shutdownNode(i);
          LOG.info("stopped " + node.getName());
        }
      } else if (nodesToStart > 0) {
        for (int i = 0; i < nodesToStart; i++) {
          Node node = _miniCluster.startAdditionalNode();
          LOG.info("started " + node.getName());
        }
      }
      TestUtil.waitUntilNumberOfLiveNode(_protocol, _nodeCount);
      // remove all indices
      if (_undeployIndicesAfterEachTest) {
View Full Code Here

TOP

Related Classes of net.sf.katta.node.Node$NodeOperationProcessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.