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


        if (propertyCategory != null && propertyCategory.equals("properties") && null != entry.getValue()) {
          configMap.put(PropertyHelper.getPropertyName(entry.getKey()), entry.getValue().toString());
        }
      }

      final ConfigurationRequest configRequest = new ConfigurationRequest(cluster, type, tag, configMap);

      createResources(new Command<Void>() {
        @Override
        public Void invoke() throws AmbariException {
          getManagementController().createConfiguration(configRequest);
View Full Code Here

      }
      return resources;
     
    } else {
      // TODO : handle multiple requests
      final ConfigurationRequest configRequest = getRequest(map);
     
      Set<ConfigurationResponse> responses = getResources(new Command<Set<ConfigurationResponse>>() {
        @Override
        public Set<ConfigurationResponse> invoke() throws AmbariException {
          return getManagementController().getConfigurations(Collections.singleton(configRequest));
View Full Code Here

   */
  private ConfigurationRequest getRequest(Map<String, Object> properties) {
    String type = (String) properties.get(CONFIGURATION_CONFIG_TYPE_PROPERTY_ID);
    String tag  = (String) properties.get(CONFIGURATION_CONFIG_TAG_PROPERTY_ID);

    return new ConfigurationRequest(
        (String) properties.get(CONFIGURATION_CLUSTER_NAME_PROPERTY_ID),
        type, tag, 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 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> 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")
View Full Code Here

    Assert.assertEquals("8088", providerModule.getPort("c1", "RESOURCEMANAGER"));

    Map<String, String> yarnConfigs = new HashMap<String, String>();
    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);
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

              mergeProperties(oldConfig.getProperties(), properties, updateIfExists);

            LOG.info("Applying configuration with tag '%s' to " +
              "cluster '%s'", newTag, cluster.getClusterName());

            ConfigurationRequest cr = new ConfigurationRequest();
            cr.setClusterName(cluster.getClusterName());
            cr.setVersionTag(newTag);
            cr.setType(configType);
            cr.setProperties(mergedProperties);
            controller.createConfiguration(cr);

            Config baseConfig = cluster.getConfig(cr.getType(), cr.getVersionTag());
            if (baseConfig != null) {
              String authName = "ambari-upgrade";

              if (cluster.addDesiredConfig(authName, baseConfig)) {
                LOG.info("cluster '" + cluster.getClusterName() + "' "
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.