Package org.apache.whirr.state

Examples of org.apache.whirr.state.ClusterStateStore


    when(controller.getNodes((ClusterSpec) any())).thenReturn(
        (Set) Sets.newLinkedHashSet(Lists.newArrayList(node1, node2)));
    when(controller.getInstances((ClusterSpec)any(), (ClusterStateStore)any()))
        .thenCallRealMethod();

    ClusterStateStore memStore = new MemoryClusterStateStore();
    memStore.save(createTestCluster(
      new String[]{"id1", "id2"}, new String[]{"role1", "role2"}));

    ClusterStateStoreFactory stateStoreFactory = mock(ClusterStateStoreFactory.class);
    when(stateStoreFactory.create((ClusterSpec) any())).thenReturn(memStore);
View Full Code Here


  public void testRunScriptByRole() throws Exception {
    ClusterControllerFactory factory = mock(ClusterControllerFactory.class);
    ClusterController controller = mock(ClusterController.class);
    when(factory.create((String)any())).thenReturn(controller);

    ClusterStateStore memStore = new MemoryClusterStateStore();
    memStore.save(createTestCluster(
      new String[]{"reg/A", "reg/B"}, new String[]{"A", "B"}));

    ClusterStateStoreFactory stateStoreFactory = mock(ClusterStateStoreFactory.class);
    when(stateStoreFactory.create((ClusterSpec) any())).thenReturn(memStore);
View Full Code Here

   *                              or may not have been stopped.
   * @throws InterruptedException if the thread is interrupted.
   */
  public void destroyCluster(ClusterSpec clusterSpec)
    throws IOException, InterruptedException {
    ClusterStateStore stateStore = getClusterStateStore(clusterSpec);
    destroyCluster(clusterSpec, stateStore.tryLoadOrEmpty());
    stateStore.destroy();
  }
View Full Code Here

    /* Destroy the instance */
    ComputeService computeService = getCompute().apply(clusterSpec).getComputeService();
    computeService.destroyNode(instanceId);

    /* .. and update the cluster state storage */
    ClusterStateStore store = getClusterStateStore(clusterSpec);
    Cluster cluster = store.load();
    cluster.removeInstancesMatching(withIds(instanceId));
    store.save(cluster);

    LOG.info("Instance {} destroyed", instanceId);
  }
View Full Code Here

      return -1;
    }
  }

  public int run(InputStream in, PrintStream out, PrintStream err, ClusterSpec clusterSpec) throws Exception {
    ClusterStateStore stateStore = createClusterStateStore(clusterSpec);
    ClusterController controller = createClusterController(clusterSpec.getServiceName());

    for (Cluster.Instance instance : controller.getInstances(clusterSpec, stateStore)) {
      out.println(Joiner.on('\t').useForNull("-").join(
        instance.getId(),
View Full Code Here

      printUsage(parser, err);
      return -1;
    }
    try {
      ClusterSpec clusterSpec = getClusterSpec(optionSet);
      ClusterStateStore stateStore = createClusterStateStore(clusterSpec);
      ClusterController controller = createClusterController(clusterSpec.getServiceName());

      for (Cluster.Instance instance : controller.getInstances(clusterSpec, stateStore)) {
        out.println(Joiner.on('\t').useForNull("-").join(
            instance.getId(),
View Full Code Here

   *           if the thread is interrupted.
   */
  public void destroyCluster(ClusterSpec clusterSpec) throws IOException,
      InterruptedException {

    ClusterStateStore stateStore = getClusterStateStore(clusterSpec);
    Cluster cluster = stateStore.tryLoadOrEmpty();

    DestroyClusterAction destroyer = new DestroyClusterAction(getCompute(),
        HandlerMapFactory.create());
    destroyer.execute(clusterSpec, cluster);

    stateStore.destroy();
  }
View Full Code Here

    /* Destroy the instance */
    ComputeService computeService = getCompute().apply(clusterSpec).getComputeService();
    computeService.destroyNode(instanceId);

    /* .. and update the cluster state storage */
    ClusterStateStore store = getClusterStateStore(clusterSpec);
    Cluster cluster = store.load();
    cluster.removeInstancesMatching(withIds(instanceId));
    store.save(cluster);

    LOG.info("Instance {} destroyed", instanceId);
  }
View Full Code Here

    when(controller.getNodes((ClusterSpec) any())).thenReturn(
        (Set) Sets.newLinkedHashSet(Lists.newArrayList(node1, node2)));
    when(controller.getInstances((ClusterSpec)any(), (ClusterStateStore)any()))
        .thenCallRealMethod();

    ClusterStateStore memStore = new MemoryClusterStateStore();
    memStore.save(createTestCluster(
      new String[]{"id1", "id2"}, new String[]{"role1", "role2"}));

    ClusterStateStoreFactory stateStoreFactory = mock(ClusterStateStoreFactory.class);
    when(stateStoreFactory.create((ClusterSpec) any())).thenReturn(memStore);
View Full Code Here

  public void testRunScriptByRole() throws Exception {
    ClusterControllerFactory factory = mock(ClusterControllerFactory.class);
    ClusterController controller = mock(ClusterController.class);
    when(factory.create((String)any())).thenReturn(controller);

    ClusterStateStore memStore = new MemoryClusterStateStore();
    memStore.save(createTestCluster(
      new String[]{"reg/A", "reg/B"}, new String[]{"A", "B"}));

    ClusterStateStoreFactory stateStoreFactory = mock(ClusterStateStoreFactory.class);
    when(stateStoreFactory.create((ClusterSpec) any())).thenReturn(memStore);
View Full Code Here

TOP

Related Classes of org.apache.whirr.state.ClusterStateStore

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.