IndexDeployFuture implements IIndexDeployFuture, IZkDataListener, ConnectedComponent { public synchronized IndexState joinDeployment() throws InterruptedException { while (isDeploymentRunning()) { wait(3000); } return getState(); } IndexDeployFuture(InteractionProtocol protocol, String indexName); synchronized IndexState getState(); synchronized IndexState joinDeployment(); synchronized IndexState joinDeployment(long maxTime); @Override synchronized void handleDataChange(String dataPath, Object data); synchronized void handleDataDeleted(String dataPath); @Override void reconnect(); @Override void disconnect();  }
@Test public void testJoinIndexDeployment() throws Exception { String indexName = "indexA"; IndexDeployFuture deployFuture = new IndexDeployFuture(_protocol, indexName); assertEquals(IndexState.DEPLOYING, deployFuture.joinDeployment(200)); _protocol.publishIndex(new IndexMetaData(indexName, "path", 1)); assertEquals(IndexState.DEPLOYED, deployFuture.joinDeployment(200)); }
@Test public void testJoinIndexErrorDeployment() throws Exception { String indexName = "indexA"; IndexDeployFuture deployFuture = new IndexDeployFuture(_protocol, indexName); assertEquals(IndexState.DEPLOYING, deployFuture.joinDeployment(200)); IndexMetaData indexMD = new IndexMetaData(indexName, "path", 1); indexMD.setDeployError(new IndexDeployError(indexName, ErrorType.NO_NODES_AVAILIBLE)); _protocol.publishIndex(indexMD); assertEquals(IndexState.ERROR, deployFuture.joinDeployment(200)); }
@Test 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)); }