Package org.apache.ambari.server.controller

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


   *    whose category is the parent and marked as a desired config.
   * @param properties  the properties on the request.
   */
  protected ConfigurationRequest getConfigurationRequest(String parentCategory, Map<String, Object> properties) {

    ConfigurationRequest config = null;

    // as a convenience, allow consumers to specify name/value overrides in this
    // call instead of forcing a cluster call to do that work
    for (Entry<String, Object> entry : properties.entrySet()) {
      String absCategory = PropertyHelper.getPropertyCategory(entry.getKey());
      String propName = PropertyHelper.getPropertyName(entry.getKey());

      if (absCategory.startsWith(parentCategory + "/desired_config")) {
        config = (null == config) ? new ConfigurationRequest() : config;

        if (propName.equals("type"))
          config.setType(entry.getValue().toString());
        else if (propName.equals("tag"))
          config.setVersionTag(entry.getValue().toString());
        else if (propName.equals("selected")) {
          config.setSelected(Boolean.parseBoolean(entry.getValue().toString()));
        }
        else if (absCategory.endsWith("/properties")) {
          config.getProperties().put(propName, entry.getValue().toString());
        }
      }
    }

    return config;
View Full Code Here


        (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

    Request request = PropertyHelper.getReadRequest(propertyIds);
    Set<Resource> resources = provider.getResources(request, predicate);

    Set<ConfigurationRequest> setRequest = configRequestCapture1.getValue();
    assertEquals(1, setRequest.size());
    ConfigurationRequest configRequest = setRequest.iterator().next();
    assertEquals("Cluster100", configRequest.getClusterName());
    assertNull(configRequest.getType());
    assertNull(configRequest.getVersionTag());

    Assert.assertEquals(3, resources.size());
    boolean containsResource1 = false;
    boolean containsResource2 = false;
    boolean containsResource3 = false;
View Full Code Here

    Assert.assertNotNull(clusters.getHost("h2"));
    clusters.getHost("h1").persist();
    clusters.getHost("h2").persist();

    // core-site
    ConfigurationRequest cr = new ConfigurationRequest();
    cr.setClusterName(clusterName);
    cr.setType("core-site");
    cr.setVersionTag("version1");
    cr.setProperties(new HashMap<String, String>() {{
      put("ipc.client.connect.max.retries", "30");
      put("fs.trash.interval", "30");
    }});

    final ClusterRequest clusterRequest1 =
      new ClusterRequest(cluster.getClusterId(), clusterName,
        cluster.getDesiredStackVersion().getStackVersion(), null);

    clusterRequest1.setDesiredConfig(cr);
    managementController.updateClusters(new HashSet<ClusterRequest>()
    {{ add(clusterRequest1); }}, null);

    // global
    cr.setType("global");
    cr.setVersionTag("version1");
    cr.setProperties(new HashMap<String, String>() {{
      put("dfs_namenode_name_dir", "/hadoop/hdfs/namenode");
      put("namenode_heapsize", "1024");
    }});

    final ClusterRequest clusterRequest2 =
View Full Code Here

        (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

   
    Object o = properties.get(HOST_MAINTENANCE_STATE_PROPERTY_ID);
    if (null != o)
      hostRequest.setMaintenanceState(o.toString());
   
    ConfigurationRequest cr = getConfigurationRequest("Hosts", properties);
   
    hostRequest.setDesiredConfig(cr);

    return hostRequest;
  }
View Full Code Here

      if (null != request.getClusterName() && null != request.getDesiredConfig()) {
        Cluster c = clusters.getCluster(request.getClusterName());

        if (clusters.getHostsForCluster(request.getClusterName()).containsKey(h.getHostName())) {

          ConfigurationRequest cr = request.getDesiredConfig();

          if (null != cr.getProperties() && cr.getProperties().size() > 0) {
            LOG.info(MessageFormat.format("Applying configuration with tag ''{0}'' to host ''{1}'' in cluster ''{2}''",
                cr.getVersionTag(),
                request.getHostname(),
                request.getClusterName()));

            cr.setClusterName(c.getClusterName());
            controller.createConfiguration(cr);
          }

          Config baseConfig = c.getConfig(cr.getType(), cr.getVersionTag());
          if (null != baseConfig) {
            String authName = controller.getAuthName();
            DesiredConfig oldConfig = h.getDesiredConfigs(c.getClusterId()).get(cr.getType());

            if (h.addDesiredConfig(c.getClusterId(), cr.isSelected(), authName,  baseConfig)) {
              Logger logger = LoggerFactory.getLogger("configchange");
              logger.info("cluster '" + c.getClusterName() + "', "
                  + "host '" + h.getHostName() + "' "
                  + "changed by: '" + authName + "'; "
                  + "type='" + baseConfig.getType() + "' "
View Full Code Here

      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

    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 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);
View Full Code Here

    ClusterRequest ucr2 = updateClusterRequest2.iterator().next();
    ClusterRequest ucr3 = updateClusterRequest3.iterator().next();
    assertEquals("c1", ucr1.getClusterName());
    assertEquals("c1", ucr2.getClusterName());
    assertEquals("c1", 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);
    mapConfigRequests.put(cr2.getType(), cr2);
    mapConfigRequests.put(cr3.getType(), cr3);
    assertEquals(3, mapConfigRequests.size());
    ConfigurationRequest globalConfigRequest = mapConfigRequests.get("global");
    assertEquals(4, globalConfigRequest.getProperties().size());
    assertEquals("hadoop", globalConfigRequest.getProperties().get("user_group"));
    assertEquals("ambari-qa", globalConfigRequest.getProperties().get("smokeuser"));
    assertEquals("default@REPLACEME.NOWHERE", globalConfigRequest.getProperties().get("nagios_contact"));
    assertEquals("admin", globalConfigRequest.getProperties().get("nagios_web_password"));
    ConfigurationRequest hdfsConfigRequest = mapConfigRequests.get("hdfs-site");
    assertEquals(1, hdfsConfigRequest.getProperties().size());
    assertEquals("value2", hdfsConfigRequest.getProperties().get("property2"));
    ConfigurationRequest coreConfigRequest = mapConfigRequests.get("core-site");
    assertEquals(2, coreConfigRequest.getProperties().size());
    assertEquals("value1", coreConfigRequest.getProperties().get("property1"));
    assertEquals("value3", coreConfigRequest.getProperties().get("property3"));
    assertNull(updateClusterPropertyMapCapture.getValue());
    assertNull(updateClusterPropertyMapCapture2.getValue());
    assertNull(updateClusterPropertyMapCapture3.getValue());

    Request serviceRequest = serviceRequestCapture.getValue();
View Full Code Here

TOP

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

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.