Package org.apache.ambari.server.controller

Examples of org.apache.ambari.server.controller.ClusterRequest


  @Override
  public RequestStatus deleteResources(Predicate predicate)
      throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {

    for (Map<String, Object> propertyMap : getPropertyMaps(predicate)) {
      final ClusterRequest clusterRequest = getRequest(propertyMap);
      modifyResources(new Command<Void>() {
        @Override
        public Void invoke() throws AmbariException {
          getManagementController().deleteCluster(clusterRequest);
          return null;
View Full Code Here


   * @param properties  the predicate
   *
   * @return the cluster request object
   */
  private ClusterRequest getRequest(Map<String, Object> properties) {
    return new ClusterRequest(
        (Long) properties.get(CLUSTER_ID_PROPERTY_ID),
        (String) properties.get(CLUSTER_NAME_PROPERTY_ID),
        (String) properties.get(CLUSTER_VERSION_PROPERTY_ID),
        null);
  }
View Full Code Here

    controller.createHostComponents(requests);
  }

  private void createHDFSServiceConfigs(boolean version1) throws AmbariException {
    String clusterName = "c1";
    ClusterRequest r = new ClusterRequest(null, clusterName, "HDP-0.1", null);
    controller.createCluster(r);
    clusters.getCluster(clusterName).setDesiredStackVersion(new StackId("HDP-0.1"));
    String serviceName = "HDFS";
    createService(clusterName, serviceName, null);
    String componentName1 = "NAMENODE";
    String componentName2 = "DATANODE";
    String componentName3 = "HDFS_CLIENT";

    Map<String, String> mapRequestProps = new HashMap<String, String>();
    mapRequestProps.put("context", "Called from a test");

    createServiceComponent(clusterName, serviceName, componentName1,
      State.INIT);
    createServiceComponent(clusterName, serviceName, componentName2,
      State.INIT);
    createServiceComponent(clusterName, serviceName, componentName3,
      State.INIT);

    String host1 = "h1";
    clusters.addHost(host1)
    Map<String, String> hostAttributes = new HashMap<String, String>();
    hostAttributes.put("os_family", "redhat");
    hostAttributes.put("os_release_version", "5.9");
    clusters.getHost("h1").setHostAttributes(hostAttributes);
    clusters.getHost("h1").persist();
    String host2 = "h2";
    clusters.addHost(host2);
    hostAttributes = new HashMap<String, String>();
    hostAttributes.put("os_family", "redhat");
    hostAttributes.put("os_release_version", "6.3");
    clusters.getHost("h2").setHostAttributes(hostAttributes);
    clusters.getHost("h2").persist();
    clusters.mapHostToCluster(host1, clusterName);
    clusters.mapHostToCluster(host2, clusterName);

    createServiceComponentHost(clusterName, null, componentName1,
      host1, null);
    createServiceComponentHost(clusterName, serviceName, componentName2,
      host1, null);
    createServiceComponentHost(clusterName, serviceName, componentName2,
      host2, null);
    createServiceComponentHost(clusterName, serviceName, componentName3,
      host1, null);
    createServiceComponentHost(clusterName, serviceName, componentName3,
      host2, null);
   
    // Create configs
    if (version1) {
      Map<String, String> configs = new HashMap<String, String>();
      configs.put(NAMENODE_PORT_V1, "localhost:${ambari.dfs.datanode.http.port}");
      configs.put(DATANODE_PORT, "localhost:70075");
      configs.put("ambari.dfs.datanode.http.port", "70070");
     
      ConfigurationRequest cr = new ConfigurationRequest(clusterName,
        "hdfs-site", "version1", configs);
      ClusterRequest crequest = new ClusterRequest(null, clusterName, null, null);
      crequest.setDesiredConfig(cr);
      controller.updateClusters(Collections.singleton(crequest), new HashMap<String,String>());
     
    } else {
      Map<String, String> configs = new HashMap<String, String>();
      configs.put(NAMENODE_PORT_V2, "localhost:70071");
      configs.put(DATANODE_PORT, "localhost:70075");

      ConfigurationRequest cr = new ConfigurationRequest(clusterName,
        "hdfs-site", "version2", configs);
     
      ClusterRequest crequest = new ClusterRequest(null, clusterName, null, null);
      crequest.setDesiredConfig(cr);
      controller.updateClusters(Collections.singleton(crequest), new HashMap<String,String>());
    }
  }
View Full Code Here

    }
  }

  private void createConfigs() throws AmbariException {
    String clusterName = "c1";
    ClusterRequest r = new ClusterRequest(null, clusterName, "HDP-2.0.6", null);
    controller.createCluster(r);
    clusters.getCluster(clusterName).setDesiredStackVersion(new StackId("HDP-2.0.6"));
    String serviceName = "HDFS";
    String serviceName2 = "YARN";
    createService(clusterName, serviceName, null);
    createService(clusterName, serviceName2, null);
    String componentName1 = "NAMENODE";
    String componentName2 = "DATANODE";
    String componentName3 = "HDFS_CLIENT";
    String componentName4 = "RESOURCEMANAGER";

    createServiceComponent(clusterName, serviceName, componentName1,
      State.INIT);
    createServiceComponent(clusterName, serviceName, componentName2,
      State.INIT);
    createServiceComponent(clusterName, serviceName, componentName3,
      State.INIT);
    createServiceComponent(clusterName, serviceName2, componentName4,
      State.INIT);

    String host1 = "h1";
    clusters.addHost(host1);
    Map<String, String> hostAttributes = new HashMap<String, String>();
    hostAttributes.put("os_family", "redhat");
    hostAttributes.put("os_release_version", "5.9");
    clusters.getHost("h1").setHostAttributes(hostAttributes);
    clusters.getHost("h1").persist();
    String host2 = "h2";
    clusters.addHost(host2);
    hostAttributes = new HashMap<String, String>();
    hostAttributes.put("os_family", "redhat");
    hostAttributes.put("os_release_version", "6.3");
    clusters.getHost("h2").setHostAttributes(hostAttributes);
    clusters.getHost("h2").persist();
    clusters.mapHostToCluster(host1, clusterName);
    clusters.mapHostToCluster(host2, clusterName);

    createServiceComponentHost(clusterName, null, componentName1,
      host1, null);
    createServiceComponentHost(clusterName, serviceName, componentName2,
      host1, null);
    createServiceComponentHost(clusterName, serviceName, componentName2,
      host2, null);
    createServiceComponentHost(clusterName, serviceName, componentName3,
      host1, null);
    createServiceComponentHost(clusterName, serviceName, componentName3,
      host2, null);
    createServiceComponentHost(clusterName, serviceName2, componentName4,
      host2, null);

    // Create configs
    Map<String, String> configs = new HashMap<String, String>();
    configs.put(NAMENODE_PORT_V1, "localhost:${ambari.dfs.datanode.http.port}");
    configs.put(DATANODE_PORT, "localhost:70075");
    configs.put("ambari.dfs.datanode.http.port", "70070");

    Map<String, String> yarnConfigs = new HashMap<String, String>();
    yarnConfigs.put(RESOURCEMANAGER_PORT, "8088");
    yarnConfigs.put(NODEMANAGER_PORT, "8042");

    ConfigurationRequest cr1 = new ConfigurationRequest(clusterName,
      "hdfs-site", "versionN", configs);

    ClusterRequest crReq = new ClusterRequest(null, clusterName, null, null);
    crReq.setDesiredConfig(cr1);
    controller.updateClusters(Collections.singleton(crReq), null);
    Cluster cluster = clusters.getCluster(clusterName);
    Assert.assertEquals("versionN", cluster.getDesiredConfigByType("hdfs-site")
      .getVersionTag());

    ConfigurationRequest cr2 = new ConfigurationRequest(clusterName,
      "yarn-site", "versionN", yarnConfigs);
    crReq.setDesiredConfig(cr2);
    controller.updateClusters(Collections.singleton(crReq), null);

    Assert.assertEquals("versionN", cluster.getDesiredConfigByType("yarn-site")
      .getVersionTag());
    Assert.assertEquals("localhost:${ambari.dfs.datanode.http.port}", cluster.getDesiredConfigByType
View Full Code Here

    yarnConfigs.put(RESOURCEMANAGER_PORT, "localhost:50030");
    yarnConfigs.put(NODEMANAGER_PORT, "localhost:11111");
    ConfigurationRequest cr2 = new ConfigurationRequest("c1",
      "yarn-site", "versionN+1", yarnConfigs);

    ClusterRequest crReq = new ClusterRequest(null, "c1", null, null);
    crReq.setDesiredConfig(cr2);
    controller.updateClusters(Collections.singleton(crReq), null);
    Assert.assertEquals("50030", providerModule.getPort("c1", "RESOURCEMANAGER"));
    Assert.assertEquals("11111", providerModule.getPort("c1", "NODEMANAGER"));

    //Unrelated ports
View Full Code Here

  }

  @Test
  public void testUpdateConfigurationProperties() throws Exception {
    AmbariManagementController controller = injector.getInstance(AmbariManagementController.class);
    ClusterRequest r = new ClusterRequest(null, "c1", "HDP-0.1", null);
    controller.createCluster(r);
    Clusters clusters = injector.getInstance(Clusters.class);
    Cluster cluster = clusters.getCluster("c1");

    Assert.assertNotNull(cluster);

    Map<String, String> properties = new HashMap<String, String>() {{
      put("a", "b");
    }};

    final ClusterRequest cl = new ClusterRequest(
      cluster.getClusterId(),
      cluster.getClusterName(),
      cluster.getDesiredStackVersion().getStackVersion(),
      null
    );

    ConfigurationRequest cr = new ConfigurationRequest();
    cr.setClusterName(cluster.getClusterName());
    cr.setType("global");
    cr.setVersionTag("version1");
    cr.setProperties(properties);

    cl.setDesiredConfig(cr);

    controller.updateClusters(new HashSet<ClusterRequest>() {{ add(cl); }}, null);

    Config config = cluster.getConfig("global", "version1");
View Full Code Here

    assertEquals("test", configReq2.getStackName());
    assertTrue(configReq1.getServiceName().equals("service1") || configReq1.getServiceName().equals("service2"));
    assertTrue(configReq2.getServiceName().equals("service1") || configReq2.getServiceName().equals("service2") &&
        ! configReq2.getServiceName().equals(configReq1.getServiceName()));

    ClusterRequest clusterRequest = createClusterRequestCapture.getValue();
    assertEquals(clusterName, clusterRequest.getClusterName());
    assertEquals("test-1.23", clusterRequest.getStackVersion());

    Set<ClusterRequest> updateClusterRequest1 = updateClusterRequestCapture.getValue();
    Set<ClusterRequest> updateClusterRequest2 = updateClusterRequestCapture2.getValue();
    Set<ClusterRequest> updateClusterRequest3 = updateClusterRequestCapture3.getValue();
    assertEquals(1, updateClusterRequest1.size());
    assertEquals(1, updateClusterRequest2.size());
    assertEquals(1, updateClusterRequest3.size());
    ClusterRequest ucr1 = updateClusterRequest1.iterator().next();
    ClusterRequest ucr2 = updateClusterRequest2.iterator().next();
    ClusterRequest ucr3 = updateClusterRequest3.iterator().next();
    assertEquals(clusterName, ucr1.getClusterName());
    assertEquals(clusterName, ucr2.getClusterName());
    assertEquals(clusterName, ucr3.getClusterName());
    ConfigurationRequest cr1 = ucr1.getDesiredConfig();
    ConfigurationRequest cr2 = ucr2.getDesiredConfig();
    ConfigurationRequest cr3 = ucr3.getDesiredConfig();
    assertEquals("1", cr1.getVersionTag());
    assertEquals("1", cr2.getVersionTag());
    assertEquals("1", cr3.getVersionTag());
    Map<String, ConfigurationRequest> mapConfigRequests = new HashMap<String, ConfigurationRequest>();
    mapConfigRequests.put(cr1.getType(), cr1);
View Full Code Here

    assertEquals("test", configReq2.getStackName());
    assertTrue(configReq1.getServiceName().equals("service1") || configReq1.getServiceName().equals("service2"));
    assertTrue(configReq2.getServiceName().equals("service1") || configReq2.getServiceName().equals("service2") &&
        ! configReq2.getServiceName().equals(configReq1.getServiceName()));

    ClusterRequest clusterRequest = createClusterRequestCapture.getValue();
    assertEquals(clusterName, clusterRequest.getClusterName());
    assertEquals("test-1.23", clusterRequest.getStackVersion());

    Set<ClusterRequest> updateClusterRequest1 = updateClusterRequestCapture.getValue();
    Set<ClusterRequest> updateClusterRequest2 = updateClusterRequestCapture2.getValue();
    Set<ClusterRequest> updateClusterRequest3 = updateClusterRequestCapture3.getValue();
    assertEquals(1, updateClusterRequest1.size());
    assertEquals(1, updateClusterRequest2.size());
    assertEquals(1, updateClusterRequest3.size());
    ClusterRequest ucr1 = updateClusterRequest1.iterator().next();
    ClusterRequest ucr2 = updateClusterRequest2.iterator().next();
    ClusterRequest ucr3 = updateClusterRequest3.iterator().next();
    assertEquals(clusterName, ucr1.getClusterName());
    assertEquals(clusterName, ucr2.getClusterName());
    assertEquals(clusterName, ucr3.getClusterName());
    ConfigurationRequest cr1 = ucr1.getDesiredConfig();
    ConfigurationRequest cr2 = ucr2.getDesiredConfig();
    ConfigurationRequest cr3 = ucr3.getDesiredConfig();
    assertEquals("1", cr1.getVersionTag());
    assertEquals("1", cr2.getVersionTag());
    assertEquals("1", cr3.getVersionTag());
    Map<String, ConfigurationRequest> mapConfigRequests = new HashMap<String, ConfigurationRequest>();
    mapConfigRequests.put(cr1.getType(), cr1);
View Full Code Here

  @Override
  public RequestStatus deleteResources(Predicate predicate)
      throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {

    for (Map<String, Object> propertyMap : getPropertyMaps(predicate)) {
      final ClusterRequest clusterRequest = getRequest(propertyMap);
      modifyResources(new Command<Void>() {
        @Override
        public Void invoke() throws AmbariException {
          getManagementController().deleteCluster(clusterRequest);
          return null;
View Full Code Here

   * @param properties  the predicate
   *
   * @return the cluster request object
   */
  private ClusterRequest getRequest(Map<String, Object> properties) {
    ClusterRequest cr = new ClusterRequest(
        (Long) properties.get(CLUSTER_ID_PROPERTY_ID),
        (String) properties.get(CLUSTER_NAME_PROPERTY_ID),
        (String) properties.get(CLUSTER_VERSION_PROPERTY_ID),
        null);


    ConfigurationRequest configRequest = getConfigurationRequest("Clusters", properties);

    if (null != configRequest)
      cr.setDesiredConfig(configRequest);

    return cr;
  }
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.controller.ClusterRequest

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.