Example usage for org.apache.commons.configuration BaseConfiguration BaseConfiguration

List of usage examples for org.apache.commons.configuration BaseConfiguration BaseConfiguration

Introduction

In this page you can find the example usage for org.apache.commons.configuration BaseConfiguration BaseConfiguration.

Prototype

BaseConfiguration

Source Link

Usage

From source file:com.comcast.viper.flume2storm.IntegrationTest.java

/**
 * Integration test with the Dynamic Location Service and the KryoNet
 * Connection API/*from  w ww.  j  a  v  a 2 s.  co  m*/
 * 
 * @throws Exception
 *           If anything went wrong
 */
@Test
public void staticLocationService_KryoNet() throws Exception {
    //
    // Flume Configuration
    //

    // Base storm sink configuration
    BaseConfiguration sinkBaseConfig = new BaseConfiguration();
    sinkBaseConfig.addProperty(StormSinkConfiguration.LOCATION_SERVICE_FACTORY_CLASS,
            StaticLocationServiceFactory.class.getName());
    sinkBaseConfig.addProperty(StormSinkConfiguration.SERVICE_PROVIDER_SERIALIZATION_CLASS,
            KryoNetServiceProviderSerialization.class.getName());
    sinkBaseConfig.addProperty(StormSinkConfiguration.EVENT_SENDER_FACTORY_CLASS,
            KryoNetEventSenderFactory.class.getName());
    sinkBaseConfig.addProperty(StormSinkConfiguration.CONNECTION_PARAMETERS_FACTORY_CLASS,
            KryoNetConnectionParametersFactory.class.getName());

    // Location Service configuration
    BaseConfiguration flumeLocationServiceConfig = new BaseConfiguration();
    flumeLocationServiceConfig.addProperty(StaticLocationServiceConfiguration.CONFIGURATION_LOADER_CLASS,
            KryoNetServiceProvidersLoader.class.getName());

    // First storm sink configuration
    int sink1Port = TestUtils.getAvailablePort();
    BaseConfiguration sink1ConnectionParameters = new BaseConfiguration();
    sink1ConnectionParameters.addProperty(KryoNetConnectionParameters.ADDRESS,
            KryoNetConnectionParameters.ADDRESS_DEFAULT);
    sink1ConnectionParameters.addProperty(KryoNetConnectionParameters.PORT, sink1Port);
    CombinedConfiguration sink1Config = new CombinedConfiguration();
    sink1Config.addConfiguration(sinkBaseConfig);
    sink1Config.addConfiguration(sink1ConnectionParameters, "connectionParams",
            KryoNetConnectionParametersFactory.CONFIG_BASE_NAME);
    sink1Config.addConfiguration(flumeLocationServiceConfig, "Location Service Configuration",
            StaticLocationServiceFactory.CONFIG_BASE_NAME);
    config.addConfiguration(sink1Config, SINK1_CONFIG);

    // Second storm sink configuration
    int sink2Port = TestUtils.getAvailablePort();
    BaseConfiguration sink2ConnectionParameters = new BaseConfiguration();
    sink2ConnectionParameters.addProperty(KryoNetConnectionParameters.ADDRESS,
            KryoNetConnectionParameters.ADDRESS_DEFAULT);
    sink2ConnectionParameters.addProperty(KryoNetConnectionParameters.PORT, sink2Port);
    CombinedConfiguration sink2Config = new CombinedConfiguration();
    sink2Config.addConfiguration(sinkBaseConfig);
    sink2Config.addConfiguration(sink2ConnectionParameters, "connectionParams",
            KryoNetConnectionParametersFactory.CONFIG_BASE_NAME);
    sink2Config.addConfiguration(flumeLocationServiceConfig, "Location Service Configuration",
            StaticLocationServiceFactory.CONFIG_BASE_NAME);
    config.addConfiguration(sink2Config, SINK2_CONFIG);

    //
    // Storm Configuration
    //

    String sp1Id = "sp1Id";
    String sp2Id = "sp2Id";
    BaseConfiguration stormLocationServiceBaseConfig = new BaseConfiguration();
    stormLocationServiceBaseConfig.addProperty(StaticLocationServiceConfiguration.CONFIGURATION_LOADER_CLASS,
            KryoNetServiceProvidersLoader.class.getName());
    stormLocationServiceBaseConfig.addProperty(StaticLocationServiceConfiguration.SERVICE_PROVIDER_LIST,
            StringUtils.join(sp1Id, StaticLocationServiceConfiguration.SERVICE_PROVIDER_LIST_SEPARATOR, sp2Id));
    BaseConfiguration stormLocationServiceSink1Config = new BaseConfiguration();
    stormLocationServiceSink1Config.addProperty(KryoNetConnectionParameters.ADDRESS,
            KryoNetConnectionParameters.ADDRESS_DEFAULT);
    stormLocationServiceSink1Config.addProperty(KryoNetConnectionParameters.PORT, sink1Port);
    BaseConfiguration stormLocationServiceSink2Config = new BaseConfiguration();
    stormLocationServiceSink2Config.addProperty(KryoNetConnectionParameters.ADDRESS,
            KryoNetConnectionParameters.ADDRESS_DEFAULT);
    stormLocationServiceSink2Config.addProperty(KryoNetConnectionParameters.PORT, sink2Port);
    CombinedConfiguration stormLocationServiceConfig = new CombinedConfiguration();
    stormLocationServiceConfig.addConfiguration(stormLocationServiceBaseConfig);
    stormLocationServiceConfig.addConfiguration(stormLocationServiceSink1Config, "sink1",
            StringUtils.join(StaticLocationServiceConfiguration.SERVICE_PROVIDER_BASE_DEFAULT, ".", sp1Id));
    stormLocationServiceConfig.addConfiguration(stormLocationServiceSink2Config, "sink2",
            StringUtils.join(StaticLocationServiceConfiguration.SERVICE_PROVIDER_BASE_DEFAULT, ".", sp2Id));

    // Global KryoNet configuration
    MapConfiguration kryoConfig = new MapConfiguration(new HashMap<String, Object>());
    kryoConfig.addProperty(KryoNetParameters.CONNECTION_TIMEOUT, 500);
    kryoConfig.addProperty(KryoNetParameters.RECONNECTION_DELAY, 1000);
    kryoConfig.addProperty(KryoNetParameters.TERMINATION_TO, 2000);

    // Flume-spout base configuration
    CombinedConfiguration flumeSpoutBaseConfig = new CombinedConfiguration();
    flumeSpoutBaseConfig.addProperty(FlumeSpoutConfiguration.LOCATION_SERVICE_FACTORY_CLASS,
            StaticLocationServiceFactory.class.getName());
    flumeSpoutBaseConfig.addProperty(FlumeSpoutConfiguration.SERVICE_PROVIDER_SERIALIZATION_CLASS,
            KryoNetServiceProviderSerialization.class.getName());
    flumeSpoutBaseConfig.addProperty(FlumeSpoutConfiguration.EVENT_RECEPTOR_FACTORY_CLASS,
            KryoNetEventReceptorFactory.class.getName());

    // Final flume-spout configuration
    CombinedConfiguration flumeSpoutConfig = new CombinedConfiguration();
    flumeSpoutConfig.addConfiguration(flumeSpoutBaseConfig);
    flumeSpoutConfig.addConfiguration(kryoConfig, "Kryo Configuration", KryoNetParameters.CONFIG_BASE_NAME);
    flumeSpoutConfig.addConfiguration(stormLocationServiceConfig, "Location Service Configuration",
            StaticLocationServiceFactory.CONFIG_BASE_NAME);
    config.addConfiguration(flumeSpoutConfig, SPOUT_CONFIG);

    testAll();
}

From source file:co.turnus.analysis.buffers.MpcBoundedScheduling.java

public MpcBoundedScheduling(TraceProject traceProject) {
    // unload trace if loaded and not sensitive to token dependencies
    if (traceProject.isTraceLoaded()) {
        if (!traceProject.getTrace().isSensitive(Kind.TOKENS)) {
            traceProject.unloadTrace();/*  w w w  . j  a v a 2  s  .  c  o m*/
        }
    }

    if (!traceProject.isTraceLoaded()) {
        Configuration config = new BaseConfiguration();
        config.setProperty(SENS_FSM, false);
        config.setProperty(SENS_GUARD, false);
        config.setProperty(SENS_PORT, false);
        config.setProperty(SENS_STATEVAR, false);
        config.setProperty(SENS_TOKENS, true);
        traceProject.loadTrace(config);
    }

    this.traceProject = traceProject;
}

From source file:com.vmware.bdd.manager.TestClusteringJobs.java

@Test(groups = { "TestClusteringJobs" })
@Transactional(propagation = Propagation.NEVER)
public void testCreateCluster() throws Exception {
    ClusterCreate createSpec = new ClusterCreate();
    createSpec.setName(TEST_CLUSTER_NAME);
    createSpec.setAppManager("Default");
    createSpec.setType(ClusterType.HDFS_MAPRED);
    createSpec.setNetworkConfig(createNetConfig(TEST_DHCP_NETWORK_NAME, dhcpPortgroup));
    createSpec.setDistro("bigtop");
    createSpec.setDistroVendor(Constants.DEFAULT_VENDOR);
    long jobExecutionId = clusterMgr.createCluster(createSpec, new BaseConfiguration());
    ClusterRead cluster = clusterMgr.getClusterByName(TEST_CLUSTER_NAME, false);
    Assert.assertTrue(cluster.getStatus() == ClusterStatus.PROVISIONING,
            "Cluster status should be PROVISIONING, but got " + cluster.getStatus());
    waitTaskFinished(jobExecutionId);//from  www. j a v  a 2s. c om
    cluster = clusterEntityMgr.findClusterWithNodes(TEST_CLUSTER_NAME, true);
    Assert.assertTrue(cluster.getInstanceNum() == 5,
            "Cluster instance number should be 5, but got " + cluster.getInstanceNum());
    Assert.assertTrue(cluster.getStatus() == ClusterStatus.RUNNING,
            "Cluster status should be RUNNING, but got " + cluster.getStatus());
    //checkIpRange(cluster);
    checkVcFolders(TEST_CLUSTER_NAME);
    checkVcResourePools(cluster, ConfigInfo.getSerengetiUUID() + "-" + TEST_CLUSTER_NAME);
    checkDiskLayout(cluster);
}

From source file:com.vmware.bdd.rest.RestResource.java

/**
 * Expand the number of nodes in a node group
 * @param clusterName/*from  www .  j a va 2  s.  c  o m*/
 * @param groupName
 * @param instanceNum The target instance number after resize. It can be larger/smaller than existing instance number in this node group
 * @param request
 * @return Return a response with Accepted status and put task uri in the Location of header that can be used to monitor the progress
 */
@RequestMapping(value = "/cluster/{clusterName}/nodegroup/{groupName}/instancenum", method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.ACCEPTED)
public void resizeCluster(@PathVariable("clusterName") String clusterName,
        @PathVariable("groupName") String groupName, @RequestBody Integer instanceNum,
        @RequestParam(value = "force", required = false, defaultValue = "false") Boolean force,
        @RequestParam(value = "skiprefreshvc", required = false) boolean skipRefreshVC,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    verifyInitialized();

    if (CommonUtil.isBlank(clusterName) || !CommonUtil.validateClusterName(clusterName)) {
        throw BddException.INVALID_PARAMETER("cluster name", clusterName);
    }

    if (CommonUtil.isBlank(groupName) || !CommonUtil.validateNodeGroupName(groupName)) {
        throw BddException.INVALID_PARAMETER("node group name", groupName);
    }

    if (instanceNum <= 0) {
        throw BddException.INVALID_PARAMETER("node group instance number", String.valueOf(instanceNum));
    }
    BaseConfiguration params = new BaseConfiguration();
    params.addProperty(Constants.SKIP_REFRESH_VC, skipRefreshVC);

    Long taskId = clusterMgr.resizeCluster(clusterName, groupName, instanceNum, force, params);
    redirectRequest(taskId, request, response);
}

From source file:com.linkedin.pinot.routing.RoutingTableTest.java

@Test
public void testCombinedKafkaRouting() throws Exception {
    HelixExternalViewBasedRouting routingTable = new HelixExternalViewBasedRouting(null, NO_LLC_ROUTING, null,
            new BaseConfiguration());

    final long now = System.currentTimeMillis();
    final String tableName = "table";
    final String resourceName = tableName + "_REALTIME";
    final String group1 = resourceName + "_" + Long.toString(now) + "_0";
    final String group2 = resourceName + "_" + Long.toString(now) + "_1";
    final String online = "ONLINE";
    final String consuming = "CONSUMING";
    final int partitionId = 1;
    final String partitionRange = "JUNK";
    final int segId1 = 1;
    final int segId2 = 2;
    final int port1 = 1;
    final int port2 = 2;
    final String host = "host";
    final ServerInstance serverInstance1 = new ServerInstance(host, port1);
    final ServerInstance serverInstance2 = new ServerInstance(host, port2);
    final String helixInstance1 = CommonConstants.Helix.PREFIX_OF_SERVER_INSTANCE + serverInstance1;
    final String helixInstance2 = CommonConstants.Helix.PREFIX_OF_SERVER_INSTANCE + serverInstance2;
    final HLCSegmentName s1HlcSegment1 = new HLCSegmentName(group1, partitionRange, Integer.toString(segId1));
    final HLCSegmentName s1HlcSegment2 = new HLCSegmentName(group1, partitionRange, Integer.toString(segId2));
    final HLCSegmentName s2HlcSegment1 = new HLCSegmentName(group2, partitionRange, Integer.toString(segId1));
    final HLCSegmentName s2HlcSegment2 = new HLCSegmentName(group2, partitionRange, Integer.toString(segId2));
    final LLCSegmentName llcSegment1 = new LLCSegmentName(tableName, partitionId, segId1, now);
    final LLCSegmentName llcSegment2 = new LLCSegmentName(tableName, partitionId, segId2, now);

    final List<InstanceConfig> instanceConfigs = new ArrayList<>(2);
    instanceConfigs.add(new InstanceConfig(helixInstance1));
    instanceConfigs.add(new InstanceConfig(helixInstance2));
    ExternalView ev = new ExternalView(resourceName);
    ev.setState(s1HlcSegment1.getSegmentName(), helixInstance1, online);
    ev.setState(s1HlcSegment2.getSegmentName(), helixInstance1, online);
    ev.setState(llcSegment1.getSegmentName(), helixInstance2, online);
    ev.setState(llcSegment2.getSegmentName(), helixInstance2, consuming);
    routingTable.markDataResourceOnline(resourceName, ev, instanceConfigs);

    RoutingTableLookupRequest request = new RoutingTableLookupRequest(resourceName,
            Collections.<String>emptyList());
    for (int i = 0; i < 100; i++) {
        Map<ServerInstance, SegmentIdSet> routingMap = routingTable.findServers(request);
        Assert.assertEquals(routingMap.size(), 1);
        List<String> segments = routingMap.get(serverInstance1).getSegmentsNameList();
        Assert.assertEquals(segments.size(), 2);
        Assert.assertTrue(segments.contains(s1HlcSegment1.getSegmentName()));
        Assert.assertTrue(segments.contains(s1HlcSegment2.getSegmentName()));
    }//  w w  w  .  j av a 2  s  . c o m

    // Now change the percent value in the routing table selector to be 100, and we should get only LLC segments.
    Configuration configuration = new PropertiesConfiguration();
    configuration.addProperty("class", PercentageBasedRoutingTableSelector.class.getName());
    configuration.addProperty("table." + resourceName, new Integer(100));
    RoutingTableSelector selector = RoutingTableSelectorFactory.getRoutingTableSelector(configuration, null);
    selector.init(configuration, null);
    Field selectorField = HelixExternalViewBasedRouting.class.getDeclaredField("_routingTableSelector");
    selectorField.setAccessible(true);
    selectorField.set(routingTable, selector);

    // And we should find only LLC segments.
    for (int i = 0; i < 100; i++) {
        Map<ServerInstance, SegmentIdSet> routingMap = routingTable.findServers(request);
        Assert.assertEquals(routingMap.size(), 1);
        List<String> segments = routingMap.get(serverInstance2).getSegmentsNameList();
        Assert.assertEquals(segments.size(), 2);
        Assert.assertTrue(segments.contains(llcSegment1.getSegmentName()));
        Assert.assertTrue(segments.contains(llcSegment2.getSegmentName()));
    }

    // Now change it to 50, and we should find both (at least 10 times each).
    configuration = new PropertiesConfiguration();
    configuration.addProperty("table." + resourceName, new Integer(50));
    selector = new PercentageBasedRoutingTableSelector();
    selector.init(configuration, null);
    selectorField.set(routingTable, selector);

    int hlc = 0;
    int llc = 0;
    for (int i = 0; i < 100; i++) {
        Map<ServerInstance, SegmentIdSet> routingMap = routingTable.findServers(request);
        Assert.assertEquals(routingMap.size(), 1);
        if (routingMap.containsKey(serverInstance2)) {
            List<String> segments = routingMap.get(serverInstance2).getSegmentsNameList();
            Assert.assertEquals(segments.size(), 2);
            Assert.assertTrue(segments.contains(llcSegment1.getSegmentName()));
            Assert.assertTrue(segments.contains(llcSegment2.getSegmentName()));
            llc++;
        } else {
            List<String> segments = routingMap.get(serverInstance1).getSegmentsNameList();
            Assert.assertEquals(segments.size(), 2);
            Assert.assertTrue(segments.contains(s1HlcSegment1.getSegmentName()));
            Assert.assertTrue(segments.contains(s1HlcSegment2.getSegmentName()));
            hlc++;
        }
    }

    // If we do the above iteration 100 times, we should get at least 10 of each type of routing.
    // If this test fails
    Assert.assertTrue(hlc >= 10, "Got low values hlc=" + hlc + ",llc=" + llc);
    Assert.assertTrue(llc >= 10, "Got low values hlc=" + hlc + ",llc=" + llc);

    // Check that force HLC works
    request = new RoutingTableLookupRequest(resourceName, Collections.singletonList("FORCE_HLC"));
    hlc = 0;
    llc = 0;
    for (int i = 0; i < 100; i++) {
        Map<ServerInstance, SegmentIdSet> routingMap = routingTable.findServers(request);
        Assert.assertEquals(routingMap.size(), 1);
        if (routingMap.containsKey(serverInstance2)) {
            List<String> segments = routingMap.get(serverInstance2).getSegmentsNameList();
            Assert.assertEquals(segments.size(), 2);
            Assert.assertTrue(segments.contains(llcSegment1.getSegmentName()));
            Assert.assertTrue(segments.contains(llcSegment2.getSegmentName()));
            llc++;
        } else {
            List<String> segments = routingMap.get(serverInstance1).getSegmentsNameList();
            Assert.assertEquals(segments.size(), 2);
            Assert.assertTrue(segments.contains(s1HlcSegment1.getSegmentName()));
            Assert.assertTrue(segments.contains(s1HlcSegment2.getSegmentName()));
            hlc++;
        }
    }

    Assert.assertEquals(hlc, 100);
    Assert.assertEquals(llc, 0);

    // Check that force LLC works
    request = new RoutingTableLookupRequest(resourceName, Collections.singletonList("FORCE_LLC"));
    hlc = 0;
    llc = 0;
    for (int i = 0; i < 100; i++) {
        Map<ServerInstance, SegmentIdSet> routingMap = routingTable.findServers(request);
        Assert.assertEquals(routingMap.size(), 1);
        if (routingMap.containsKey(serverInstance2)) {
            List<String> segments = routingMap.get(serverInstance2).getSegmentsNameList();
            Assert.assertEquals(segments.size(), 2);
            Assert.assertTrue(segments.contains(llcSegment1.getSegmentName()));
            Assert.assertTrue(segments.contains(llcSegment2.getSegmentName()));
            llc++;
        } else {
            List<String> segments = routingMap.get(serverInstance1).getSegmentsNameList();
            Assert.assertEquals(segments.size(), 2);
            Assert.assertTrue(segments.contains(s1HlcSegment1.getSegmentName()));
            Assert.assertTrue(segments.contains(s1HlcSegment2.getSegmentName()));
            hlc++;
        }
    }

    Assert.assertEquals(hlc, 0);
    Assert.assertEquals(llc, 100);
}

From source file:com.vmware.bdd.manager.TestClusteringJobs.java

@Test(groups = { "TestClusteringJobs" }, dependsOnMethods = { "testCreateCluster" })
@Transactional(propagation = Propagation.NEVER)
public void testCreateClusterFailed() throws Exception {
    ClusterCreate createSpec = ClusterSpecFactory.createDefaultSpec(ClusterType.HDFS_MAPRED,
            Constants.DEFAULT_VENDOR, null, null);
    createSpec.setAppManager("Default");
    createSpec.setName(TEST_DHCP_CLUSTER_NAME);
    createSpec.setNetworkConfig(createNetConfig(TEST_DHCP_NETWORK_NAME, dhcpPortgroup));
    createSpec.setDistro("bigtop");
    NodeGroupCreate worker = createSpec.getNodeGroup("worker");
    worker.setInstanceNum(1);//w  w  w.  j  a  v  a 2 s  .c o m
    long jobExecutionId = clusterMgr.createCluster(createSpec, new BaseConfiguration());
    ClusterRead cluster = clusterMgr.getClusterByName(TEST_DHCP_CLUSTER_NAME, false);
    Assert.assertTrue(cluster.getStatus() == ClusterStatus.PROVISIONING,
            "Cluster status should be PROVISIONING, but got " + cluster.getStatus());
    stopVmAfterStarted(
            vcRP + "/" + ConfigInfo.getSerengetiUUID() + "-" + TEST_DHCP_CLUSTER_NAME + "/" + "worker",
            TEST_DHCP_CLUSTER_NAME + "-worker-0", jobExecutionId);
    waitTaskFinished(jobExecutionId);
    cluster = clusterMgr.getClusterByName(TEST_DHCP_CLUSTER_NAME, false);
    Assert.assertTrue(cluster.getInstanceNum() == 3,
            "Cluster instance number should be 3, but got " + cluster.getInstanceNum());
    Assert.assertTrue(cluster.getStatus() == ClusterStatus.PROVISION_ERROR,
            "Cluster status should be PROVISION_ERROR, but got " + cluster.getStatus());
}

From source file:com.vmware.bdd.manager.TestClusteringJobs.java

@Test(groups = { "TestClusteringJobs" }, dependsOnMethods = { "testCreateClusterFailed" })
@Transactional(propagation = Propagation.NEVER)
public void testClusterResume() throws Exception {
    long jobExecutionId = clusterMgr.resumeClusterCreation(TEST_DHCP_CLUSTER_NAME, new BaseConfiguration());
    ClusterRead cluster = clusterMgr.getClusterByName(TEST_DHCP_CLUSTER_NAME, false);
    Assert.assertTrue(cluster.getStatus() == ClusterStatus.PROVISIONING,
            "Cluster status should be PROVISIONING, but got " + cluster.getStatus());
    waitTaskFinished(jobExecutionId);//from  w  w  w .j a  v a2s. c  o m
    cluster = clusterMgr.getClusterByName(TEST_DHCP_CLUSTER_NAME, false);
    Assert.assertTrue(cluster.getInstanceNum() == 3,
            "Cluster instance number should be 3, but got " + cluster.getInstanceNum());
    Assert.assertTrue(cluster.getStatus() == ClusterStatus.RUNNING,
            "Cluster status should be RUNNING, but got " + cluster.getStatus());
}

From source file:com.vmware.bdd.manager.TestClusteringJobs.java

@Test(groups = { "TestClusteringJobs" }, dependsOnMethods = { "testClusterResume" })
@Transactional(propagation = Propagation.NEVER)
public void testClusterResizeFailed() throws Exception {
    long jobExecutionId = clusterMgr.resizeCluster(TEST_DHCP_CLUSTER_NAME, "worker", 2, false,
            new BaseConfiguration());
    ClusterRead cluster = clusterMgr.getClusterByName(TEST_DHCP_CLUSTER_NAME, false);
    Assert.assertTrue(cluster.getStatus() == ClusterStatus.UPDATING,
            "Cluster status should be UPDATING, but got " + cluster.getStatus());
    stopVmAfterStarted(/*from w ww .j a v a 2s.co  m*/
            vcRP + "/" + ConfigInfo.getSerengetiUUID() + "-" + TEST_DHCP_CLUSTER_NAME + "/" + "worker",
            TEST_DHCP_CLUSTER_NAME + "-worker-1", jobExecutionId);
    waitTaskFinished(jobExecutionId);
    assertTaskFailed(jobExecutionId);
    assertDefinedInstanceNum(TEST_DHCP_CLUSTER_NAME, "worker", 1);

    cluster = clusterMgr.getClusterByName(TEST_DHCP_CLUSTER_NAME, false);
    Assert.assertTrue(cluster.getStatus() == ClusterStatus.RUNNING,
            "Cluster status should be RUNNING, but got " + cluster.getStatus());
    assertTaskFailed(jobExecutionId);
}

From source file:com.vmware.bdd.manager.TestClusteringJobs.java

@Test(groups = { "TestClusteringJobs" }, dependsOnMethods = { "testClusterResizeFailed" })
@Transactional(propagation = Propagation.NEVER)
public void testClusterResizeSuccess() throws Exception {
    stopVcVm(vcRP + "/" + ConfigInfo.getSerengetiUUID() + "-" + TEST_DHCP_CLUSTER_NAME + "/" + "worker",
            TEST_DHCP_CLUSTER_NAME + "-worker-0");
    long jobExecutionId = clusterMgr.resizeCluster(TEST_DHCP_CLUSTER_NAME, "worker", 2, false,
            new BaseConfiguration());
    ClusterRead cluster = clusterMgr.getClusterByName(TEST_DHCP_CLUSTER_NAME, false);
    Assert.assertTrue(cluster.getStatus() == ClusterStatus.UPDATING,
            "Cluster status should be UPDATING, but got " + cluster.getStatus());
    waitTaskFinished(jobExecutionId);/* ww w  . j a  va  2 s  .  c o m*/
    assertTaskSuccess(jobExecutionId);
    assertDefinedInstanceNum(TEST_DHCP_CLUSTER_NAME, "worker", 2);
    NodeEntity node = clusterEntityMgr.findByName(TEST_DHCP_CLUSTER_NAME, "worker",
            TEST_DHCP_CLUSTER_NAME + "-worker-0");
    Assert.assertTrue(node.getStatus() == NodeStatus.POWERED_OFF, "Stopped vm " + TEST_DHCP_CLUSTER_NAME
            + "-worker-0" + " status should be Powered Off, but got " + node.getStatus());
    cluster = clusterMgr.getClusterByName(TEST_DHCP_CLUSTER_NAME, false);
    Assert.assertTrue(cluster.getStatus() == ClusterStatus.RUNNING,
            "Cluster status should be RUNNING, but got " + cluster.getStatus());
}

From source file:com.vmware.bdd.manager.TestClusteringJobs.java

@Test(groups = { "TestClusteringJobs" }, dependsOnMethods = { "testLimitCluster" })
@Transactional(propagation = Propagation.NEVER)
public void testDupCreateCluster() throws Exception {
    ClusterCreate createSpec = new ClusterCreate();
    createSpec.setName(TEST_CLUSTER_NAME);
    createSpec.setType(ClusterType.HDFS_MAPRED);
    try {/*from w  w w .  jav  a2s .c  om*/
        clusterMgr.createCluster(createSpec, new BaseConfiguration());
        Assert.assertTrue(false, "Cluster creation should throw exception.");
    } catch (Exception e) {
        e.printStackTrace();
        Assert.assertTrue(true, "got expected exception.");
    }
}