Package net.sf.katta.protocol.metadata

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


      }
    };
    thread.start();
    deployFuture.disconnect();
    deployFuture.reconnect();
    _protocol.publishIndex(new IndexMetaData(indexName, "path", 1));
    thread.join();
  }
View Full Code Here


  public void testJoinIndexDeployment_DeleteIndex() throws Exception {
    String indexName = "indexA";
    IndexDeployFuture deployFuture = new IndexDeployFuture(_protocol, indexName);
    assertEquals(IndexState.DEPLOYING, deployFuture.joinDeployment(200));

    _protocol.publishIndex(new IndexMetaData(indexName, "path", 1));
    _protocol.unpublishIndex(indexName);
    assertEquals(IndexState.DEPLOYED, deployFuture.joinDeployment(200));
  }
View Full Code Here

  public synchronized IndexState getState() {
    if (!_registered) {
      return IndexState.DEPLOYED;
    }

    IndexMetaData indexMD = _protocol.getIndexMD(_indexName);
    if (indexMD == null) {
      return IndexState.DEPLOYING;
    } else if (indexMD.hasDeployError()) {
      return IndexState.ERROR;
    }
    if (_registered) {
      _registered = false;
      _protocol.unregisterComponent(this);
View Full Code Here

    deployClient.addIndex(TestResources.INDEX1.getName(), TestResources.INDEX1.getAbsolutePath(), 1);
  }

  @Test
  public void testIndexAcces() throws Exception {
    IndexMetaData indexMD = new IndexMetaData("index1", "indexPath", 1);
    IDeployClient deployClient = new DeployClient(_protocol);

    assertFalse(deployClient.existsIndex(indexMD.getName()));
    assertNull(deployClient.getIndexMetaData(indexMD.getName()));
    assertEquals(0, deployClient.getIndices().size());

    _protocol.publishIndex(indexMD);
    assertTrue(deployClient.existsIndex(indexMD.getName()));
    assertNotNull(deployClient.getIndexMetaData(indexMD.getName()));
    assertEquals(1, deployClient.getIndices().size());
  }
View Full Code Here

    assertEquals(1, deployClient.getIndices().size());
  }

  @Test
  public void testIndexRemove() throws Exception {
    IndexMetaData indexMD = new IndexMetaData("index1", "indexPath", 1);
    IDeployClient deployClient = new DeployClient(_protocol);

    try {
      deployClient.removeIndex(indexMD.getName());
      fail("should throw exception");
    } catch (Exception e) {
      // expected
    }

    _protocol.publishIndex(indexMD);
    deployClient.removeIndex(indexMD.getName());
    assertTrue(deployClient.existsIndex(indexMD.getName()));// undeploy
    // operation is send
    // to master
  }
View Full Code Here

        removeIndex(name);
      }

      @Override
      public void added(String name) {
        IndexMetaData indexMD = _protocol.getIndexMD(name);
        if (isIndexSearchable(indexMD)) {
          addIndexForSearching(indexMD);
        } else {
          addIndexForWatching(name);
        }
View Full Code Here

    }
  }

  protected void addOrWatchNewIndexes(List<String> indexes) {
    for (String index : indexes) {
      IndexMetaData indexMD = _protocol.getIndexMD(index);
      if (indexMD != null) {// could be undeployed in meantime
        if (isIndexSearchable(indexMD)) {
          addIndexForSearching(indexMD);
        } else {
          addIndexForWatching(index);
View Full Code Here

        // handled through IndexPathListener
      }

      @Override
      public void handleDataChange(String dataPath, Object data) throws Exception {
        IndexMetaData metaData = (IndexMetaData) data;
        if (isIndexSearchable(metaData)) {
          addIndexForSearching(metaData);
          _protocol.unregisterDataChanges(Client.this, dataPath);
        }
      }
View Full Code Here

  @Test
  public void testAddRemoveIndexForSearching() throws Exception {
    InteractionProtocol protocol = mock(InteractionProtocol.class);
    Client client = new Client(ISleepServer.class, new DefaultNodeSelectionPolicy(), protocol,
            new ClientConfiguration());
    IndexMetaData indexMD = new IndexMetaData("index1", "path", 1);
    indexMD.getShards().add(new Shard("shard1", "path"));
    indexMD.getShards().add(new Shard("shard2", "path"));
    client.addIndexForSearching(indexMD);
    verify(protocol, times(2)).registerChildListener(eq(client), eq(PathDef.SHARD_TO_NODES), anyString(),
            any(IAddRemoveListener.class));

    client.removeIndex(indexMD.getName());
    verify(protocol, times(2)).unregisterChildListener(eq(client), eq(PathDef.SHARD_TO_NODES), anyString());
  }
View Full Code Here

  @Test
  public void testAddRemoveIndexForWatching() throws Exception {
    InteractionProtocol protocol = mock(InteractionProtocol.class);
    Client client = new Client(ISleepServer.class, new DefaultNodeSelectionPolicy(), protocol,
            new ClientConfiguration());
    IndexMetaData indexMD = new IndexMetaData("index1", "path", 1);
    indexMD.getShards().add(new Shard("shard1", "path"));
    indexMD.getShards().add(new Shard("shard2", "path"));
    client.addIndexForWatching(indexMD.getName());
    verify(protocol, times(1)).registerDataListener(eq(client), eq(PathDef.INDICES_METADATA), anyString(),
            any(IZkDataListener.class));

    client.removeIndex(indexMD.getName());
    verify(protocol, times(1)).unregisterDataChanges(eq(client), eq(PathDef.INDICES_METADATA), anyString());
  }
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.