Package net.sf.katta.protocol

Examples of net.sf.katta.protocol.InteractionProtocol


    super(2);
  }

  @Test(timeout = 20000)
  public void testDeployAndUndeployIndex() throws Exception {
    final InteractionProtocol protocol = _miniCluster.getProtocol();

    IndexDeployOperation deployOperation = new IndexDeployOperation(INDEX_NAME, "file://"
            + INDEX_FILE.getAbsolutePath(), getNodeCount());
    protocol.addMasterOperation(deployOperation);

    TestUtil.waitUntilIndexDeployed(protocol, INDEX_NAME);
    assertEquals(1, protocol.getIndices().size());
    IndexMetaData indexMD = protocol.getIndexMD(INDEX_NAME);
    assertEquals(null, indexMD.getDeployError());
    assertEquals(SHARD_COUNT, indexMD.getShards().size());

    Set<Shard> shards = indexMD.getShards();
    for (Shard shard : shards) {
      assertEquals(getNodeCount(), protocol.getShardNodes(shard.getName()).size());
      assertEquals(1, shard.getMetaDataMap().size());
    }

    // undeploy
    IndexUndeployOperation undeployOperation = new IndexUndeployOperation(INDEX_NAME);
    protocol.addMasterOperation(undeployOperation);
    TestUtil.waitUntilShardsUndeployed(protocol, indexMD);

    assertEquals(0, protocol.getIndices().size());
    assertEquals(null, protocol.getIndexMD(INDEX_NAME));
    for (Shard shard : shards) {
      assertEquals(0, protocol.getShardNodes(shard.getName()).size());
    }
    assertEquals(0, protocol.getZkClient().getChildren(getZkConfiguration().getZkPath(PathDef.SHARD_TO_NODES)).size());
  }
View Full Code Here


    assertEquals(0, protocol.getZkClient().getChildren(getZkConfiguration().getZkPath(PathDef.SHARD_TO_NODES)).size());
  }

  @Test(timeout = 20000)
  public void testDeployError() throws Exception {
    final InteractionProtocol protocol = _miniCluster.getProtocol();

    final File indexFile = TestResources.INVALID_INDEX;
    IndexDeployOperation deployOperation = new IndexDeployOperation(INDEX_NAME,
            "file://" + indexFile.getAbsolutePath(), getNodeCount());
    protocol.addMasterOperation(deployOperation);
    TestUtil.waitUntilIndexDeployed(protocol, INDEX_NAME);
    assertEquals(1, protocol.getIndices().size());
    IndexMetaData indexMD = protocol.getIndexMD(INDEX_NAME);
    assertNotNull(indexMD.getDeployError());
    assertEquals(ErrorType.SHARDS_NOT_DEPLOYABLE, indexMD.getDeployError().getErrorType());
  }
View Full Code Here

  @Test(timeout = 20000)
  public void testRebalanceIndexAfterNodeCrash() throws Exception {
    int replicationCount = getNodeCount() - 1;
    deployTestIndices(1, replicationCount);
    final InteractionProtocol protocol = _miniCluster.getProtocol();
    assertEquals(1, protocol.getIndices().size());

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

    _miniCluster.shutdownNode(0);
View Full Code Here

  }

  @Test(timeout = 20000)
  public void testIndexPickupAfterMasterRestart() throws Exception {
    deployTestIndices(1, getNodeCount());
    final InteractionProtocol protocol = _miniCluster.getProtocol();
    assertEquals(1, protocol.getIndices().size());

    _miniCluster.restartMaster();
    assertEquals(1, protocol.getIndices().size());
    assertTrue(protocol.getReplicationReport(protocol.getIndexMD(INDEX_NAME)).isDeployed());
  }
View Full Code Here

  @Test
  public void testReplicateUnderreplicatedIndexesAfterNodeAdding() throws Exception {
    int replicationCount = getNodeCount() + 1;
    deployTestIndices(1, replicationCount);
    final InteractionProtocol protocol = _miniCluster.getProtocol();
    assertEquals(1, protocol.getIndices().size());

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

    Node node = _miniCluster.startAdditionalNode();
View Full Code Here

    }

    @Override
    public final void execute(ZkConfiguration zkConf) throws Exception {
      ZkClient zkClient = new ZkClient(zkConf.getZKServers());
      InteractionProtocol protocol = new InteractionProtocol(zkClient, zkConf);
      execute(zkConf, protocol);
      protocol.disconnect();
    }
View Full Code Here

    super(indexMD.getName(), indexMD.getPath(), indexMD.getReplicationLevel());
  }

  @Override
  public List<OperationId> execute(MasterContext context, List<MasterOperation> runningOperations) throws Exception {
    InteractionProtocol protocol = context.getProtocol();
    try {
      _indexMD.getShards().addAll(readShardsFromFs(_indexMD.getName(), _indexMD.getPath()));
      protocol.updateIndexMD(_indexMD);
    } catch (Exception e) {
      ExceptionUtil.rethrowInterruptedException(e);
      handleMasterDeployException(protocol, _indexMD, e);
    }
    return null;
View Full Code Here

  }

  @Test
  public void testDeployShardAfterRestart() throws Exception {
    deployTestIndices(1, getNodeCount());
    final InteractionProtocol protocol = _miniCluster.getProtocol();
    assertEquals(1, protocol.getIndices().size());

    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

    _indexName = indexName;
  }

  @Override
  public List<OperationId> execute(MasterContext context, List<MasterOperation> runningOperations) throws Exception {
    InteractionProtocol protocol = context.getProtocol();
    _indexMD = protocol.getIndexMD(_indexName);

    Map<String, List<String>> shard2NodesMap = protocol.getShard2NodesMap(Shard.getShardNames(_indexMD.getShards()));
    Map<String, List<String>> node2ShardsMap = CollectionUtil.invertListMap(shard2NodesMap);
    Set<String> nodes = node2ShardsMap.keySet();
    List<OperationId> nodeOperationIds = new ArrayList<OperationId>(nodes.size());
    for (String node : nodes) {
      List<String> nodeShards = node2ShardsMap.get(node);
      OperationId operationId = protocol.addNodeOperation(node, new ShardUndeployOperation(nodeShards));
      nodeOperationIds.add(operationId);
    }
    protocol.unpublishIndex(_indexName);
    return nodeOperationIds;
  }
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

TOP

Related Classes of net.sf.katta.protocol.InteractionProtocol

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.