Package net.sf.katta.protocol.metadata

Examples of net.sf.katta.protocol.metadata.IndexMetaData


            + 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());
    }
View Full Code Here


    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

  }

  @Override
  public List<OperationId> execute(MasterContext context, List<MasterOperation> runningOperations) throws Exception {
    InteractionProtocol protocol = context.getProtocol();
    IndexMetaData indexMD = protocol.getIndexMD(_indexName);
    if (indexMD == null) {// could be undeployed in meantime
      LOG.info("skip balancing for index '" + _indexName + "' cause it is already undeployed");
      return null;
    }
    if (!canAndShouldRegulateReplication(protocol, indexMD)) {
      LOG.info("skip balancing for index '" + _indexName + "' cause there is no possible optimization");
      return null;
    }
    try {
      FileSystem fileSystem = context.getFileSystem(indexMD);
      Path path = new Path(indexMD.getPath());
      if (!fileSystem.exists(path)) {
        LOG.warn("skip balancing for index '" + _indexName + "' cause source '" + path + "' does not exists anymore");
        return null;
      }
    } catch (Exception e) {
      LOG.error("skip balancing of index '" + _indexName + "' cause failed to access source '" + indexMD.getPath()
              + "'", e);
      return null;
    }

    LOG.info("balancing shards for index '" + _indexName + "'");
View Full Code Here

  }

  @Override
  public void nodeOperationsComplete(MasterContext context, List<OperationResult> results) throws Exception {
    LOG.info("balancing of index " + _indexName + " complete");
    IndexMetaData indexMD = context.getProtocol().getIndexMD(_indexName);
    if (indexMD != null) {// could be undeployed in meantime
      handleDeploymentComplete(context, results, indexMD, false);
    }
  }
View Full Code Here

  protected IndexMetaData _indexMD;
  private final String _indexName;
  private final String _indexPath;

  public IndexDeployOperation(String indexName, String indexPath, int replicationLevel) {
    _indexMD = new IndexMetaData(indexName, indexPath, replicationLevel);
    _indexName = indexName;
    _indexPath = indexPath;
  }
View Full Code Here

    InteractionProtocol protocol = context.getProtocol();
    List<String> liveNodes = protocol.getLiveNodes();
    List<String> indices = protocol.getIndices();

    for (String indexName : indices) {
      IndexMetaData indexMD = protocol.getIndexMD(indexName);
      if (indexMD != null) { // can be removed already
        if ((indexMD.hasDeployError() && isRecoverable(indexMD.getDeployError(), liveNodes.size()))
                || canAndShouldRegulateReplication(protocol, indexMD)) {
          protocol.addMasterOperation(new BalanceIndexOperation(indexName));
        }
      }
    }
View Full Code Here

          List<MasterOperation> runningOperations) {
    List<String> obsoletShards = new ArrayList<String>();
    for (String shardName : nodeShards) {
      try {
        String indexName = AbstractIndexOperation.getIndexNameFromShardName(shardName);
        IndexMetaData indexMD = protocol.getIndexMD(indexName);
        if (indexMD == null && !containsDeployOperation(runningOperations, indexName)) {
          // index has been removed
          obsoletShards.add(shardName);
        }
      } catch (IllegalArgumentException e) {
View Full Code Here

    INodeProxyManager proxyCreatorSpy = spy(proxyCreator);
    PauseAnswer<Void> pauseAnswer = new PauseAnswer<Void>(null);
    doAnswer(new ChainedAnswer(pauseAnswer, new CallsRealMethods())).when(proxyCreatorSpy).getProxy(anyString(),
            eq(true));
    client.setProxyCreator(proxyCreatorSpy);
    IndexMetaData indexMD = deployIndex(INDEX_NAME, INDEX_FILE, getNodeCount());
    pauseAnswer.joinExecutionBegin();
    assertThat(client.getSelectionPolicy().getShardNodes(indexMD.getShards().iterator().next().getName())).isEmpty();
    assertThat(client.getIndices()).isEmpty();
    pauseAnswer.resumeExecution(true);
    while (client.getSelectionPolicy().getShardNodes(indexMD.getShards().iterator().next().getName()).isEmpty()) {
      Thread.sleep(200);
    }
    assertThat(client.getSelectionPolicy().getShardNodes(indexMD.getShards().iterator().next().getName())).isNotEmpty();
    assertThat(client.getIndices()).isNotEmpty();
  }
View Full Code Here

    String oldIndicesPath = getOldIndicesPath(zkConf);
    List<String> indices = zkClient.getChildren(oldIndicesPath);
    LOG.info("found " + indices.size() + " old indices");
    for (String indexName : indices) {
      net.sf.katta.index.IndexMetaData oldIndexMD = zkClientForWriables.readData(oldIndicesPath + "/" + indexName);
      IndexMetaData newIndexMD = new IndexMetaData(indexName, oldIndexMD.getPath(), oldIndexMD.getReplicationLevel());
      IndexReinitializeOperation deployOperation = new IndexReinitializeOperation(newIndexMD);
      protocol.addMasterOperation(deployOperation);
      protocol.publishIndex(newIndexMD);
    }
    zkClientForWriables.close();
View Full Code Here

  public void publishIndex(IndexMetaData indexMD) {
    _zkClient.createPersistent(_zkConf.getZkPath(PathDef.INDICES_METADATA, indexMD.getName()), indexMD);
  }

  public void unpublishIndex(String indexName) {
    IndexMetaData indexMD = getIndexMD(indexName);
    _zkClient.delete(_zkConf.getZkPath(PathDef.INDICES_METADATA, indexName));
    for (Shard shard : indexMD.getShards()) {
      _zkClient.deleteRecursive(_zkConf.getZkPath(PathDef.SHARD_TO_NODES, shard.getName()));
    }
  }
View Full Code Here

TOP

Related Classes of net.sf.katta.protocol.metadata.IndexMetaData

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.