You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by be...@apache.org on 2017/10/05 19:25:49 UTC

ambari git commit: AMBARI-14714. Fix compile errors (benyoka)

Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-14714-blueprint efc066ac3 -> 457b4080e


AMBARI-14714. Fix compile errors (benyoka)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/457b4080
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/457b4080
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/457b4080

Branch: refs/heads/branch-feature-AMBARI-14714-blueprint
Commit: 457b4080ef018907ab30f7d1225cbc44c8d5fabf
Parents: efc066a
Author: Balazs Bence Sari <be...@apache.org>
Authored: Thu Oct 5 21:25:36 2017 +0200
Committer: Balazs Bence Sari <be...@apache.org>
Committed: Thu Oct 5 21:25:36 2017 +0200

----------------------------------------------------------------------
 .../controller/ServiceComponentHostRequest.java | 11 +++++
 .../controller/ServiceComponentRequest.java     | 15 ++++++
 .../server/controller/ServiceRequest.java       | 15 ++++++
 .../ambari/server/mpack/MpackManager.java       | 34 +++++++------
 .../org/apache/ambari/server/state/Cluster.java |  8 ++++
 .../ambari/server/state/ServiceFactory.java     |  4 ++
 .../server/state/cluster/ClusterImpl.java       | 14 ++++++
 .../ambari/server/topology/Blueprint.java       |  8 ++--
 .../ambari/server/topology/BlueprintImpl.java   | 50 +++++++++++++-------
 .../ambari/server/topology/Component.java       | 12 +++++
 .../ambari/server/topology/HostGroup.java       | 10 ++--
 .../ambari/server/topology/HostGroupImpl.java   | 12 +++--
 .../apache/ambari/server/topology/Service.java  |  2 +-
 13 files changed, 154 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/457b4080/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java
index 7c4c9ab..806e9d3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java
@@ -35,6 +35,17 @@ public class ServiceComponentHostRequest {
   private String adminState; // GET - predicate
   private String maintenanceState; // UPDATE
 
+
+  // TODO: BP3.0
+  @Deprecated
+  public ServiceComponentHostRequest(String clusterName,
+                                     String serviceName,
+                                     String componentName,
+                                     String hostname,
+                                     String desiredState) {
+    throw new UnsupportedOperationException("Not supported with 3.0 Blueprints.");
+  }
+
   public ServiceComponentHostRequest(String clusterName,
                                      String serviceGroupName,
                                      String serviceDisplayName,

http://git-wip-us.apache.org/repos/asf/ambari/blob/457b4080/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java
index 1556b70..11aaf0b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java
@@ -29,6 +29,21 @@ public class ServiceComponentRequest {
   private String componentCategory;
   private String recoveryEnabled; // CREATE/UPDATE
 
+  // TODO: BP3.0
+  @Deprecated
+  public ServiceComponentRequest(String clusterName,
+                                 String componentName, String desiredState) {
+    throw new UnsupportedOperationException("Not supported with 3.0 Blueprints.");
+  }
+
+  // TODO: BP3.0
+  @Deprecated
+  public ServiceComponentRequest(String clusterName, String componentName,
+                                 String desiredState, String recoveryEnabled) {
+    throw new UnsupportedOperationException("Not supported with 3.0 Blueprints.");
+  }
+
+
   public ServiceComponentRequest(String clusterName, String serviceGroupName, String serviceDisplayName,
                                  String componentName, String desiredState) {
     this(clusterName, serviceGroupName, serviceDisplayName, componentName, desiredState, null, null);

http://git-wip-us.apache.org/repos/asf/ambari/blob/457b4080/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
index b084582..8efcfba 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
@@ -38,6 +38,21 @@ public class ServiceRequest {
    */
   private RepositoryVersionEntity resolvedRepository;
 
+  // TODO: BP3.0
+  @Deprecated
+  public ServiceRequest(String clusterName, String serviceName,
+                        Long desiredRepositoryVersionId, String desiredState) {
+    throw new UnsupportedOperationException("Not supported with 3.0 Blueprints.");
+  }
+
+  // TODO: BP3.0
+  @Deprecated
+  public ServiceRequest(String clusterName, String serviceName,
+                        Long desiredRepositoryVersionId, String desiredState, String credentialStoreEnabled) {
+    throw new UnsupportedOperationException("Not supported with 3.0 Blueprints.");
+  }
+
+
   public ServiceRequest(String clusterName, String serviceGroupName, String serviceName,
       Long desiredRepositoryVersionId, String desiredState) {
     this(clusterName, serviceGroupName, serviceName, serviceName, desiredRepositoryVersionId, desiredState, null);

http://git-wip-us.apache.org/repos/asf/ambari/blob/457b4080/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManager.java b/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManager.java
index 12070fa..a450d39 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManager.java
@@ -17,9 +17,21 @@
  */
 package org.apache.ambari.server.mpack;
 
-import com.google.gson.Gson;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.assistedinject.AssistedInject;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
 import org.apache.ambari.server.controller.MpackRequest;
 import org.apache.ambari.server.controller.MpackResponse;
 import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
@@ -37,15 +49,9 @@ import org.apache.commons.io.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.*;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
+import com.google.gson.Gson;
+import com.google.inject.assistedinject.Assisted;
+import com.google.inject.assistedinject.AssistedInject;
 
 /**
  * Manages all mpack related behavior including parsing of stacks and providing access to
@@ -78,7 +84,7 @@ public class MpackManager {
    * Parses mpackdirectories during boostrap/ambari-server restart
    * Reads from /var/lib/ambari-server/mpacks-v2/
    *
-   * @throws IOException
+   * @throws java.io.IOException
    */
   private void parseMpackDirectories() {
 
@@ -118,7 +124,7 @@ public class MpackManager {
    *
    * @param mpackRequest
    * @return MpackResponse
-   * @throws IOException
+   * @throws java.io.IOException
    * @throws IllegalArgumentException
    * @throws ResourceAlreadyExistsException
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/457b4080/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java b/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
index 0c1059b..fd83be4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
@@ -72,6 +72,14 @@ public interface Cluster {
   Service addService(ServiceGroup serviceGroup, String serviceName, String serviceDisplayName,
                      RepositoryVersionEntity repositoryVersion) throws AmbariException;
 
+  // TODO: BP3.0
+  @Deprecated
+  Service addService(String serviceName);
+
+  // TODO: BP3.0
+  @Deprecated
+  Service addService(String serviceName, RepositoryVersionEntity repositoryVersion);
+
   /**
    * Add service group to the cluster
    *

http://git-wip-us.apache.org/repos/asf/ambari/blob/457b4080/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceFactory.java
index 883fa2d..e798e58 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceFactory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceFactory.java
@@ -45,6 +45,10 @@ public interface ServiceFactory {
                     @Assisted("serviceDisplayName") String serviceDisplayName,
                     RepositoryVersionEntity desiredRepositoryVersion);
 
+  // TODO BP3.0
+  @Deprecated
+  Service createNew(Cluster cluster, String serviceName, RepositoryVersionEntity desiredRepositoryVersion);
+
   /**
    * Creates an in-memory representation of a service from an existing database
    * object.

http://git-wip-us.apache.org/repos/asf/ambari/blob/457b4080/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index 6b32d4c..a085348 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -882,6 +882,20 @@ public class ClusterImpl implements Cluster {
     return service;
   }
 
+  // TODO BP3.0
+  @Deprecated
+  @Override
+  public Service addService(String serviceName) {
+    throw (new UnsupportedOperationException("Not supported with 3.0 Blueprints"));
+  }
+
+  // TODO BP3.0
+  @Deprecated
+  @Override
+  public Service addService(String serviceName, RepositoryVersionEntity repositoryVersion) {
+    throw (new UnsupportedOperationException("Not supported with 3.0 Blueprints"));
+  }
+
   @Override
   public void addServiceGroup(ServiceGroup serviceGroup) {
     if (LOG.isDebugEnabled()) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/457b4080/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java
index 7063c93..38e78dc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java
@@ -18,13 +18,13 @@
 
 package org.apache.ambari.server.topology;
 
-import org.apache.ambari.server.controller.internal.Stack;
-import org.apache.ambari.server.orm.entities.BlueprintEntity;
-
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.ambari.server.controller.internal.Stack;
+import org.apache.ambari.server.orm.entities.BlueprintEntity;
+
 /**
  * Blueprint representation.
  */
@@ -124,6 +124,8 @@ public interface Blueprint {
    *
    * @return associated stack
    */
+  @Deprecated
+  // TODO remove for BP3.0
   Stack getStack();
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/457b4080/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
index 9623871..9504e8e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
@@ -19,17 +19,28 @@
 
 package org.apache.ambari.server.topology;
 
-import com.google.gson.Gson;
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.StackAccessException;
-import org.apache.ambari.server.controller.AmbariServer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.ambari.server.controller.internal.Stack;
-import org.apache.ambari.server.orm.entities.*;
+import org.apache.ambari.server.orm.entities.BlueprintConfigEntity;
+import org.apache.ambari.server.orm.entities.BlueprintConfiguration;
+import org.apache.ambari.server.orm.entities.BlueprintEntity;
+import org.apache.ambari.server.orm.entities.BlueprintSettingEntity;
+import org.apache.ambari.server.orm.entities.HostGroupComponentEntity;
+import org.apache.ambari.server.orm.entities.HostGroupConfigEntity;
+import org.apache.ambari.server.orm.entities.HostGroupEntity;
+import org.apache.ambari.server.orm.entities.StackEntity;
 import org.apache.ambari.server.stack.NoSuchStackException;
 import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.commons.lang.StringUtils;
 
-import java.util.*;
+import com.google.gson.Gson;
 
 /**
  * Blueprint implementation.
@@ -60,7 +71,8 @@ public class BlueprintImpl implements Blueprint {
     // create config first because it is set as a parent on all host-group configs
     processConfiguration(entity.getConfigurations());
     parseBlueprintHostGroups(entity);
-    configuration.setParentConfiguration(stack.getConfiguration(getServices()));
+    // TODO BP3.0
+    // configuration.setParentConfiguration(stack.getConfiguration(getServices()));
     validator = new BlueprintValidatorImpl(this);
     processSetting(entity.getSettings());
     processRepoSettings();
@@ -274,8 +286,10 @@ public class BlueprintImpl implements Blueprint {
   }
 
   @Override
+  @Deprecated
+  // TODO BP3.0
   public Stack getStack() {
-    return stack;
+    throw new UnsupportedOperationException("Not supported with 3.0 Blueprints.");
   }
 
   /**
@@ -353,20 +367,22 @@ public class BlueprintImpl implements Blueprint {
   }
 
   private void parseStack(StackEntity stackEntity) throws NoSuchStackException {
-    try {
+//    try {
       //todo: don't pass in controller
-      stack = new Stack(stackEntity.getStackName(), stackEntity.getStackVersion(), AmbariServer.getController());
-    } catch (StackAccessException e) {
-      throw new NoSuchStackException(stackEntity.getStackName(), stackEntity.getStackVersion());
-    } catch (AmbariException e) {
-      //todo:
-      throw new RuntimeException("An error occurred parsing the stack information.", e);
-    }
+      // TODO BP3.0
+      // stack = new Stack(stackEntity.getStackName(), stackEntity.getStackVersion(), AmbariServer.getController());
+//    } catch (StackAccessException e) {
+//      throw new NoSuchStackException(stackEntity.getStackName(), stackEntity.getStackVersion());
+//    } catch (AmbariException e) {
+//      //todo:
+//      throw new RuntimeException("An error occurred parsing the stack information.", e);
+//    }
   }
 
   private Map<String, HostGroup> parseBlueprintHostGroups(BlueprintEntity entity) {
     for (HostGroupEntity hostGroupEntity : entity.getHostGroups()) {
-      HostGroupImpl hostGroup = new HostGroupImpl(hostGroupEntity, getName(), stack);
+      // TODO BP3.0
+      HostGroupImpl hostGroup = new HostGroupImpl(hostGroupEntity, getName(), null /* TODO */);
       // set the bp configuration as the host group config parent
       hostGroup.getConfiguration().setParentConfiguration(configuration);
       hostGroups.put(hostGroupEntity.getName(), hostGroup);

http://git-wip-us.apache.org/repos/asf/ambari/blob/457b4080/ambari-server/src/main/java/org/apache/ambari/server/topology/Component.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Component.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Component.java
index 4cdf2de..4e43e46 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Component.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Component.java
@@ -31,6 +31,18 @@ public class Component {
 
   private final Configuration configuration;
 
+  // TODO: remove for BP3.0
+  @Deprecated
+  public Component(String name) {
+    throw new UnsupportedOperationException("Not supported with 3.0 Blueprints.");
+  }
+
+  // TODO: remove for BP3.0
+  @Deprecated
+  public Component(String name,  ProvisionAction provisionAction) {
+    throw new UnsupportedOperationException("Not supported with 3.0 Blueprints.");
+  }
+
   public Component(String name, Service service) {
     this(name, service, null, null);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/457b4080/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroup.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroup.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroup.java
index 0590e1f..de7fad4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroup.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroup.java
@@ -18,12 +18,12 @@
 
 package org.apache.ambari.server.topology;
 
-import org.apache.ambari.server.controller.internal.ProvisionAction;
-import org.apache.ambari.server.controller.internal.Stack;
-
 import java.util.Collection;
 import java.util.regex.Pattern;
 
+import org.apache.ambari.server.controller.internal.ProvisionAction;
+import org.apache.ambari.server.controller.internal.Stack;
+
 /**
  * Host Group representation.
  */
@@ -99,6 +99,10 @@ public interface HostGroup {
    */
   boolean addComponent(String component, Service service);
 
+  // TODO: remove BP3.0
+  @Deprecated
+  boolean addComponent(String component);
+
   /**
    * Add a component to the host group, with the specified name
    *   and provision action.

http://git-wip-us.apache.org/repos/asf/ambari/blob/457b4080/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupImpl.java
index 2234475..b5d3952 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupImpl.java
@@ -159,6 +159,12 @@ public class HostGroupImpl implements HostGroup {
     return this.addComponent(component, service);
   }
 
+  @Override
+  // TODO BP3.0
+  public boolean addComponent(String component) {
+    throw new UnsupportedOperationException("Not supported with 3.0 blueprints.");
+  }
+
   /**
    * Add a component with the specified provision action to the
    *   host group.
@@ -180,14 +186,14 @@ public class HostGroupImpl implements HostGroup {
     if (stack.isMasterComponent(component)) {
       containsMasterComponent = true;
     }
+    // TODO review for BP3.0
     if (added) {
-      String service = stack.getServiceForComponent(component);
       if (service != null) {
         // an example of a component without a service in the stack is AMBARI_SERVER
-        Set<String> serviceComponents = componentsForService.get(service);
+        Set<String> serviceComponents = componentsForService.get(service.getName());
         if (serviceComponents == null) {
           serviceComponents = new HashSet<>();
-          componentsForService.put(service, serviceComponents);
+          componentsForService.put(service.getName(), serviceComponents);
         }
         serviceComponents.add(component);
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/457b4080/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
index 66c0dc3..bb8656f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
@@ -18,10 +18,10 @@
 
 package org.apache.ambari.server.topology;
 
+import java.util.Set;
 
 import org.apache.ambari.server.controller.internal.Stack;
 
-import java.util.Set;
 
 public class Service {