Package org.springframework.yarn.am.grid

Examples of org.springframework.yarn.am.grid.GridProjection


    public TestGridProjectionFactory() {
    }

    @Override
    public GridProjection getGridProjection(ProjectionData projectionData) {
      GridProjection projection = null;
      if ("custom".equalsIgnoreCase(projectionData.getType())) {
        AnyGridProjection p = new AnyGridProjection();
        p.setPriority(projectionData.getPriority());
        projection = p;
      }
      if (projection != null) {
        projection.setProjectionData(projectionData);
      }
      return projection;
    }
View Full Code Here


    TestManagedContainerClusterAppmaster appmaster = createTestAppmaster(allocator, launcher);
    appmaster.setStateMachineFactory(stateMachineFactory);
    ProjectionData projectionData = new ProjectionData(1, null, null, "any", 0);

    // create and start
    GridProjection projection = appmaster.createContainerCluster("foo", projectionData).getGridProjection();
    appmaster.startContainerCluster("foo");
    assertDoTask(appmaster, 1, 0, 0, 0, "foo");

    // allocate container 1
    Container container1 = allocateContainer(appmaster, 1);
    assertThat(projection.getMembers().size(), is(1));
    appmaster.resetTestData();
    assertDoTask(appmaster, null, null, null, null, "foo");

    // release, should re-allocate
    releaseContainer(appmaster, container1);
    assertThat(projection.getMembers().size(), is(0));
    assertDoTask(appmaster, 1, 0, 0, 0, "foo");
  }
View Full Code Here

    hosts.put("host1", 2);
    hosts.put("host2", 2);
    ProjectionData projectionData = new ProjectionData(0, hosts, null, "hosts", 0);

    // create
    GridProjection projection = appmaster.createContainerCluster("foo", projectionData).getGridProjection();
    assertDoTask(appmaster, null, null, null, null, "foo");

    // start
    appmaster.startContainerCluster("foo");
    assertDoTask(appmaster, 0, 2, 0, 0, "foo");

    // allocate container 1
    allocateContainer(appmaster, 1, "host1");
    assertThat(projection.getMembers().size(), is(1));

    // allocate container 2
    allocateContainer(appmaster, 2, "host1");
    assertThat(projection.getMembers().size(), is(2));

    // allocate container 3
    allocateContainer(appmaster, 3, "host2");
    assertThat(projection.getMembers().size(), is(3));

    // allocate container 4
    allocateContainer(appmaster, 4, "host2");
    assertThat(projection.getMembers().size(), is(4));

    assertDoTask(appmaster, null, null, null, null, "foo");

    // modify - set only host1
    hosts.clear();
View Full Code Here

    appmaster.setStateMachineFactory(stateMachineFactory);
    Map<String, Integer> hosts = new HashMap<String, Integer>();
    hosts.put("host1", 1);
    ProjectionData projectionData = new ProjectionData(0, hosts, null, "hosts", 0);

    GridProjection projection = appmaster.createContainerCluster("foo", projectionData).getGridProjection();
    assertDoTask(appmaster, null, null, null, null, "foo");

    // we hook into statemachine to listen its events
    TestStateMachineListener sml = new TestStateMachineListener();
    StateMachine<State<ClusterState, ClusterEvent>, ClusterEvent> stateMachine = appmaster.getContainerClusters().get("foo").getStateMachine();
    stateMachine.addStateListener(sml);

    appmaster.startContainerCluster("foo");
    assertDoTask(appmaster, 0, 1, 0, 0, "foo");

    Container container1 = allocateContainer(appmaster, 1, "host2");
    assertThat(projection.getMembers().size(), is(0));
    assertThat(sml.states.size(), greaterThan(0));
    sml.states.clear();

    // when non of a clusters accept container,
    // check that we get events indicating that
    // clusters are requested to go into
    // an allocation mode.
    releaseContainer(appmaster, container1);
    assertThat(sml.states.size(), greaterThan(0));
    assertDoTask(appmaster, 0, 1, 0, 0, "foo");
    assertThat(appmaster.getContainerClusters().get("foo").getStateMachine().getState().getId(), is(ClusterState.RUNNING));

    allocateContainer(appmaster, 2, "host1");
    assertThat(projection.getMembers().size(), is(1));
    assertThat(sml.states.size(), greaterThan(0));
  }
View Full Code Here

    TestUtils.setField("initCalled", new RackResolver(), false);
  }

  @Test
  public void testDefaults() {
    GridProjection projection = new RacksGridProjection();
    SatisfyStateData satisfyState = projection.getSatisfyState();
    assertThat(satisfyState, notNullValue());
    assertThat(satisfyState.getAllocateData(), notNullValue());
    assertThat(satisfyState.getAllocateData().getAny(), is(0));
    assertThat(satisfyState.getAllocateData().getHosts().size(), is(0));
    assertThat(satisfyState.getAllocateData().getRacks().size(), is(0));
View Full Code Here

    TestManagedContainerClusterAppmaster appmaster = createTestAppmaster(allocator, launcher);
    appmaster.setStateMachineFactory(stateMachineFactory);

    // cluster1
    ProjectionData projectionData1 = new ProjectionData(1, null, null, "any", 0);
    GridProjection projection1 = appmaster.createContainerCluster("cluster1", projectionData1).getGridProjection();

    // cluster2
    ProjectionData projectionData2 = new ProjectionData(1, null, null, "any", 0);
    GridProjection projection2 = appmaster.createContainerCluster("cluster2", projectionData2).getGridProjection();

    appmaster.startContainerCluster("cluster1");
    assertDoTask(appmaster, 1, 0, 0, 0, "cluster1");
    assertDoTask(appmaster, null, null, null, null, "cluster2");

    appmaster.startContainerCluster("cluster2");
    assertDoTask(appmaster, 1, 0, 0, 0, "cluster2");
    assertDoTask(appmaster, null, null, null, null, "cluster1");

    // allocate container 1
    allocateContainer(appmaster, 1);
    assertThat(projection1.getMembers().size() + projection2.getMembers().size(), is(1));
//    assertDoTask(appmaster, null, null, null, null, "cluster1");

    allocateContainer(appmaster, 2);
    assertThat(projection1.getMembers().size() + projection2.getMembers().size(), is(2));
//    assertDoTask(appmaster, null, null, null, null, "cluster1");

    allocateContainer(appmaster, 3);
    assertThat(projection1.getMembers().size(), is(1));
    assertThat(projection2.getMembers().size(), is(1));

    // modify - ramp up to 2
    appmaster.modifyContainerCluster("cluster1", new ProjectionData(2));
    assertDoTask(appmaster, 1, 0, 0, 0, "cluster1");
View Full Code Here

//    projection1.setProjectionData(projectionData1);
    ProjectionData projectionData1 = new ProjectionData(0, hosts1, null, "hosts", 0);


//    HostsGridProjection projection1 = new HostsGridProjection(hosts1);
    GridProjection projection1 = appmaster.createContainerCluster("cluster1", projectionData1).getGridProjection();

    // cluster2
    Map<String, Integer> hosts2 = new HashMap<String, Integer>();
    hosts2.put("host20", 1);
//    ProjectionData projectionData2 = new ProjectionData(0, hosts2, null);
//    HostsGridProjection projection2 = new HostsGridProjection();
//    projection2.setProjectionData(projectionData2);
//    HostsGridProjection projection2 = new HostsGridProjection(hosts2);
    ProjectionData projectionData2 = new ProjectionData(0, hosts2, null, "hosts", 0);
    GridProjection projection2 = appmaster.createContainerCluster("cluster2", projectionData2).getGridProjection();

    appmaster.startContainerCluster("cluster1");
    assertDoTask(appmaster, 0, 1, 0, 0, "cluster1");
    assertDoTask(appmaster, null, null, null, null, "cluster2");

    appmaster.startContainerCluster("cluster2");
    assertDoTask(appmaster, 0, 1, 0, 0, "cluster2");
    assertDoTask(appmaster, null, null, null, null, "cluster1");

    // allocate container 1
    allocateContainer(appmaster, 1, "host10");
    assertThat(projection1.getMembers().size() + projection2.getMembers().size(), is(1));
//    assertDoTask(appmaster, null, null, null, null, "cluster1");

    allocateContainer(appmaster, 2, "host20");
    assertThat(projection1.getMembers().size() + projection2.getMembers().size(), is(2));
//    assertDoTask(appmaster, null, null, null, null, "cluster1");

    allocateContainer(appmaster, 3, "hostX1");
    assertThat(projection1.getMembers().size(), is(1));
    assertThat(projection2.getMembers().size(), is(1));

    // modify - ramp up to 2
//    appmaster.modifyContainerCluster("cluster1", new ProjectionData(2));
//    assertDoTask(appmaster, 1, 0, 0, 0, "cluster1");
View Full Code Here

public class AnyGridProjectionTests {

  @Test
  public void testDefaults() {
    GridProjection projection = new AnyGridProjection();
    SatisfyStateData satisfyState = projection.getSatisfyState();
    assertThat(satisfyState, notNullValue());
    assertThat(satisfyState.getAllocateData(), notNullValue());
    assertThat(satisfyState.getAllocateData().getAny(), is(0));
    assertThat(satisfyState.getAllocateData().getHosts().size(), is(0));
    assertThat(satisfyState.getAllocateData().getRacks().size(), is(0));
View Full Code Here

    assertThat(satisfyState.getRemoveData().size(), is(0));
  }

  @Test
  public void testAddOne() {
    GridProjection projection = new AnyGridProjection();
    projection.setProjectionData(new ProjectionData(1));
    SatisfyStateData satisfyState = projection.getSatisfyState();
    assertThat(satisfyState, notNullValue());
    assertThat(satisfyState.getAllocateData(), notNullValue());
    assertThat(satisfyState.getAllocateData().getAny(), is(1));
    assertThat(satisfyState.getAllocateData().getHosts().size(), is(0));
    assertThat(satisfyState.getAllocateData().getRacks().size(), is(0));
View Full Code Here

*/
public class HostsGridProjectionTests {

  @Test
  public void testDefaults() {
    GridProjection projection = new HostsGridProjection();
    SatisfyStateData satisfyState = projection.getSatisfyState();
    assertThat(satisfyState, notNullValue());
    assertThat(satisfyState.getAllocateData(), notNullValue());
    assertThat(satisfyState.getAllocateData().getAny(), is(0));
    assertThat(satisfyState.getAllocateData().getHosts().size(), is(0));
    assertThat(satisfyState.getAllocateData().getRacks().size(), is(0));
View Full Code Here

TOP

Related Classes of org.springframework.yarn.am.grid.GridProjection

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.