This is an automated email from the ASF dual-hosted git repository.

mradhakrishnan pushed a commit to branch branch-feature-AMBARI-14714
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-feature-AMBARI-14714 by 
this push:
     new aedcb74  [AMBARI-22904] Revised mpack APIs (#252)
aedcb74 is described below

commit aedcb74030e25fa9a0a1784b37c642022c0dd437
Author: mradha25 <[email protected]>
AuthorDate: Tue Feb 6 11:20:52 2018 -0800

    [AMBARI-22904] Revised mpack APIs (#252)
    
    * [AMBARI-22904] Revised mpack APIs
    
    * [AMBARI-22904] Revised mpack APIs
    
    * [AMBARI-22904] Revised mpack APIs
    
    * [AMBARI-22904] Revised mpack APIs
    
    * [AMBARI-22904] Revised mpack APIs
    
    * [AMBARI-22904] Revised mpack APIs
    
    *  [AMBARI-22904] Revised mpack APIs
---
 .../ambari/server/api/services/AmbariMetaInfo.java |  33 ++-
 .../controller/AmbariManagementController.java     |  21 +-
 .../controller/AmbariManagementControllerImpl.java |  29 ++-
 .../ambari/server/controller/MpackResponse.java    |  12 +
 .../controller/internal/MpackResourceProvider.java |  68 +++---
 .../controller/internal/StackDefinition.java       |  18 ++
 .../apache/ambari/server/mpack/MpackGenerator.java |  58 +++--
 .../apache/ambari/server/mpack/MpackManager.java   | 189 ++++++++-------
 .../apache/ambari/server/stack/StackDirectory.java |  12 +-
 .../org/apache/ambari/server/state/Module.java     | 163 +++++++++++++
 .../ambari/server/state/ModuleComponent.java       | 109 +++++++++
 .../ambari/server/state/ModuleDependency.java      |  88 +++++++
 .../java/org/apache/ambari/server/state/Mpack.java | 253 +++++++++------------
 .../org/apache/ambari/server/state/Packlet.java    | 167 --------------
 .../AmbariManagementControllerImplTest.java        |  19 +-
 .../server/controller/MpackResponseTest.java       |   4 +-
 .../internal/MpackResourceProviderTest.java        |  37 +--
 .../org/apache/ambari/server/state/MpackTest.java  | 103 ++++++---
 18 files changed, 849 insertions(+), 534 deletions(-)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
index f5abc6c..4109035 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
@@ -74,8 +74,9 @@ import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.DependencyInfo;
 import org.apache.ambari.server.state.ExtensionInfo;
+import org.apache.ambari.server.state.Module;
+import org.apache.ambari.server.state.Mpack;
 import org.apache.ambari.server.state.OperatingSystemInfo;
-import org.apache.ambari.server.state.Packlet;
 import org.apache.ambari.server.state.PropertyInfo;
 import org.apache.ambari.server.state.RepositoryInfo;
 import org.apache.ambari.server.state.Service;
@@ -694,12 +695,12 @@ public class AmbariMetaInfo {
   }
 
   /**
-   * Gets the packlet information for given mpack.
+   * Gets the module information for given mpack.
    * @param mpackId
-   * @return List of Packlets.
+   * @return List of Modules.
    */
-  public List<Packlet> getPacklets(Long mpackId) {
-    return mpackManager.getPacklets(mpackId);
+  public List<Module> getModules(Long mpackId) {
+    return mpackManager.getModules(mpackId);
   }
 
 
@@ -1655,4 +1656,26 @@ public class AmbariMetaInfo {
   public File getCommonWidgetsDescriptorFile() {
     return commonWidgetsDescriptorFile;
   }
+
+  /***
+   * Fetch all mpacks from mpackMap
+   * @return all mpacks from mpackMap - in memory data structure
+   */
+  public Collection<Mpack> getMpacks() {
+    if (mpackManager.getMpackMap() != null) {
+      return mpackManager.getMpackMap().values();
+    }
+    return Collections.emptySet();
+  }
+
+  /***
+   * Fetch a particular mpack based on mpackid
+   * @return a single mpack
+   */
+  public Mpack getMpack(Long mpackId) {
+    if (mpackManager.getMpackMap() != null && 
mpackManager.getMpackMap().containsKey(mpackId)) {
+      return mpackManager.getMpackMap().get(mpackId);
+    }
+    return null;
+  }
 }
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
index 2064c0e..9a1bb92 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
@@ -57,8 +57,8 @@ import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.HostState;
 import org.apache.ambari.server.state.MaintenanceState;
+import org.apache.ambari.server.state.Module;
 import org.apache.ambari.server.state.OsSpecific;
-import org.apache.ambari.server.state.Packlet;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.ServiceComponentFactory;
@@ -942,12 +942,12 @@ public interface AmbariManagementController {
   void saveConfigGroupUpdate(ConfigGroupRequest configGroupRequest, 
ConfigGroupResponse configGroupResponse);
 
   /**
-   * Fetch the packlet info for a given mpack.
+   * Fetch the module info for a given mpack.
    *
    * @param mpackId
-   * @return List of packlets
+   * @return List of modules
    */
-  List<Packlet> getPacklets(Long mpackId);
+  List<Module> getModules(Long mpackId);
 
   /**
    * Get the software registries identified by the given request objects.
@@ -992,5 +992,18 @@ public interface AmbariManagementController {
    * @throws AuthorizationException
    */
   Set<ServiceConfigVersionResponse> 
createServiceConfigVersion(Set<ServiceConfigVersionRequest> requests) throws 
AmbariException, AuthorizationException;
+
+  /***
+   * Fetch all mpacks
+   * @return
+   */
+  Set<MpackResponse> getMpacks();
+
+  /***
+   * Fetch an mpack based on id
+   * @param mpackId
+   * @return
+   */
+  MpackResponse getMpack(Long mpackId);
 }
 
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 7989fe7..51bacae 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -172,9 +172,10 @@ import org.apache.ambari.server.state.ExtensionInfo;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.HostState;
 import org.apache.ambari.server.state.MaintenanceState;
+import org.apache.ambari.server.state.Module;
+import org.apache.ambari.server.state.Mpack;
 import org.apache.ambari.server.state.OperatingSystemInfo;
 import org.apache.ambari.server.state.OsSpecific;
-import org.apache.ambari.server.state.Packlet;
 import org.apache.ambari.server.state.PropertyDependencyInfo;
 import org.apache.ambari.server.state.PropertyInfo;
 import org.apache.ambari.server.state.PropertyInfo.PropertyType;
@@ -577,16 +578,34 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
   @Override
   public MpackResponse registerMpack(MpackRequest request)
     throws IOException, AuthorizationException, ResourceAlreadyExistsException{
-
-
     MpackResponse mpackResponse = ambariMetaInfo.registerMpack(request);
     updateStacks();
     return mpackResponse;
   }
 
   @Override
-  public List<Packlet> getPacklets(Long mpackId) {
-    return ambariMetaInfo.getPacklets(mpackId);
+  public Set<MpackResponse> getMpacks(){
+    Collection<Mpack> mpacks = ambariMetaInfo.getMpacks();
+    Set<MpackResponse> responseSet = new HashSet<>();
+    for (Mpack mpack : mpacks){
+      responseSet.add(new MpackResponse(mpack));
+    }
+    return responseSet;
+  }
+
+  @Override
+  public MpackResponse getMpack(Long mpackId) {
+    Mpack mpack = ambariMetaInfo.getMpack(mpackId);
+    if (mpack != null) {
+      return new MpackResponse(mpack);
+    }else{
+      return null;
+    }
+  }
+
+  @Override
+  public List<Module> getModules(Long mpackId) {
+    return ambariMetaInfo.getModules(mpackId);
   }
 
   @Override
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/MpackResponse.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/MpackResponse.java
index ff42fde..ce70f8a 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/MpackResponse.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/MpackResponse.java
@@ -33,6 +33,7 @@ public class MpackResponse {
   private String mpackUri;
   private Long registryId;
   private String stackId;
+  private String description;
 
   public MpackResponse(Mpack mpack) {
     this.mpackId = mpack.getMpackId();
@@ -41,6 +42,7 @@ public class MpackResponse {
     this.mpackName = mpack.getName();
     this.registryId = mpack.getRegistryId();
     this.stackId = mpack.getStackId();
+    this.description = mpack.getDescription();
   }
 
   public String getMpackVersion() {
@@ -91,6 +93,16 @@ public class MpackResponse {
     this.mpackId = mpackId;
   }
 
+
+  public String getDescription() {
+    return description;
+  }
+
+  public void setDescription(String description) {
+    this.description = description;
+  }
+
+
   @Override
   public int hashCode() {
     int result = 1;
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java
index 0a9ca52..2ed6f3d 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java
@@ -55,7 +55,7 @@ import org.apache.ambari.server.orm.entities.StackEntity;
 import org.apache.ambari.server.registry.Registry;
 import org.apache.ambari.server.registry.RegistryMpack;
 import org.apache.ambari.server.registry.RegistryMpackVersion;
-import org.apache.ambari.server.state.Packlet;
+import org.apache.ambari.server.state.Module;
 import org.apache.ambari.server.state.StackId;
 import org.apache.commons.lang.Validate;
 
@@ -74,7 +74,8 @@ public class MpackResourceProvider extends 
AbstractControllerResourceProvider {
   public static final String MPACK_NAME = RESPONSE_KEY + 
PropertyHelper.EXTERNAL_PATH_SEP + "mpack_name";
   public static final String MPACK_VERSION = RESPONSE_KEY + 
PropertyHelper.EXTERNAL_PATH_SEP + "mpack_version";
   public static final String MPACK_URI = RESPONSE_KEY + 
PropertyHelper.EXTERNAL_PATH_SEP + "mpack_uri";
-  public static final String PACKLETS = RESPONSE_KEY + 
PropertyHelper.EXTERNAL_PATH_SEP + "packlets";
+  public static final String MODULES = RESPONSE_KEY + 
PropertyHelper.EXTERNAL_PATH_SEP + "modules";
+  public static final String MPACK_DESC = RESPONSE_KEY + 
PropertyHelper.EXTERNAL_PATH_SEP + "description";
   public static final String STACK_NAME_PROPERTY_ID = RESPONSE_KEY + 
PropertyHelper.EXTERNAL_PATH_SEP + "stack_name";
   public static final String STACK_VERSION_PROPERTY_ID =
     RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "stack_version";
@@ -108,7 +109,8 @@ public class MpackResourceProvider extends 
AbstractControllerResourceProvider {
     PROPERTY_IDS.add(MPACK_NAME);
     PROPERTY_IDS.add(MPACK_VERSION);
     PROPERTY_IDS.add(MPACK_URI);
-    PROPERTY_IDS.add(PACKLETS);
+    PROPERTY_IDS.add(MPACK_DESC);
+    PROPERTY_IDS.add(MODULES);
     PROPERTY_IDS.add(STACK_NAME_PROPERTY_ID);
     PROPERTY_IDS.add(STACK_VERSION_PROPERTY_ID);
 
@@ -146,10 +148,11 @@ public class MpackResourceProvider extends 
AbstractControllerResourceProvider {
         notifyCreate(Resource.Type.Mpack, request);
         Resource resource = new ResourceImpl(Resource.Type.Mpack);
         resource.setProperty(MPACK_ID, response.getMpackId());
-        resource.setProperty(REGISTRY_ID, response.getRegistryId());
         resource.setProperty(MPACK_NAME, response.getMpackName());
         resource.setProperty(MPACK_VERSION, response.getMpackVersion());
         resource.setProperty(MPACK_URI, response.getMpackUri());
+        resource.setProperty(MPACK_DESC, response.getDescription());
+        resource.setProperty(REGISTRY_ID, response.getRegistryId());
         associatedResources.add(resource);
         return getRequestStatus(null, associatedResources);
       }
@@ -240,17 +243,18 @@ public class MpackResourceProvider extends 
AbstractControllerResourceProvider {
     Long mpackId = null;
     if (predicate == null) {
       // Fetch all mpacks
-      List<MpackEntity> entities = mpackDAO.findAll();
-      if (null == entities) {
-        entities = Collections.emptyList();
+      Set<MpackResponse> responses = 
(HashSet)getManagementController().getMpacks();
+      if (null == responses) {
+        responses = Collections.emptySet();
       }
-      for (MpackEntity entity : entities) {
+      for (MpackResponse response : responses){
         Resource resource = new ResourceImpl(Resource.Type.Mpack);
-        resource.setProperty(MPACK_ID, entity.getMpackId());
-        resource.setProperty(MPACK_NAME, entity.getMpackName());
-        resource.setProperty(MPACK_VERSION, entity.getMpackVersion());
-        resource.setProperty(MPACK_URI, entity.getMpackUri());
-        resource.setProperty(REGISTRY_ID, entity.getRegistryId());
+        resource.setProperty(MPACK_ID, response.getMpackId());
+        resource.setProperty(MPACK_NAME, response.getMpackName());
+        resource.setProperty(MPACK_VERSION, response.getMpackVersion());
+        resource.setProperty(MPACK_URI, response.getMpackUri());
+        resource.setProperty(MPACK_DESC, response.getDescription());
+        resource.setProperty(REGISTRY_ID, response.getRegistryId());
         results.add(resource);
       }
     } else {
@@ -262,12 +266,15 @@ public class MpackResourceProvider extends 
AbstractControllerResourceProvider {
         StackEntity stackEntity = stackDAO.find(stackName, stackVersion);
         mpackId = stackEntity.getCurrentMpackId();
         if (mpackId != null) {
-          MpackEntity entity = mpackDAO.findById(mpackId);
+          MpackResponse response = getManagementController().getMpack(mpackId);
           Resource resource = new ResourceImpl(Resource.Type.Mpack);
-          if (null != entity) {
-            resource.setProperty(MPACK_ID, entity.getMpackId());
-            resource.setProperty(MPACK_NAME, entity.getMpackName());
-            resource.setProperty(MPACK_VERSION, entity.getMpackVersion());
+          if (null != response) {
+            resource.setProperty(MPACK_ID, response.getMpackId());
+            resource.setProperty(MPACK_NAME, response.getMpackName());
+            resource.setProperty(MPACK_VERSION, response.getMpackVersion());
+            resource.setProperty(MPACK_URI, response.getMpackUri());
+            resource.setProperty(MPACK_DESC, response.getDescription());
+            resource.setProperty(REGISTRY_ID, response.getRegistryId());
             resource.setProperty(STACK_NAME_PROPERTY_ID, stackName);
             resource.setProperty(STACK_VERSION_PROPERTY_ID, stackVersion);
             results.add(resource);
@@ -281,18 +288,19 @@ public class MpackResourceProvider extends 
AbstractControllerResourceProvider {
         if (objMpackId != null)
           mpackId = Long.valueOf((String) objMpackId);
 
-        MpackEntity entity = mpackDAO.findById(mpackId);
-        Resource resource = new ResourceImpl(Resource.Type.Mpack);
-        if (null != entity) {
-          resource.setProperty(MPACK_ID, entity.getMpackId());
-          resource.setProperty(MPACK_NAME, entity.getMpackName());
-          resource.setProperty(MPACK_VERSION, entity.getMpackVersion());
-          resource.setProperty(MPACK_URI, entity.getMpackUri());
-          resource.setProperty(REGISTRY_ID, entity.getRegistryId());
-          List<Packlet> packlets = 
getManagementController().getPacklets(entity.getMpackId());
-          resource.setProperty(PACKLETS, packlets);
-          results.add(resource);
-        }
+          MpackResponse response = getManagementController().getMpack(mpackId);
+          Resource resource = new ResourceImpl(Resource.Type.Mpack);
+          if (null != response) {
+            resource.setProperty(MPACK_ID, response.getMpackId());
+            resource.setProperty(MPACK_NAME, response.getMpackName());
+            resource.setProperty(MPACK_VERSION, response.getMpackVersion());
+            resource.setProperty(MPACK_URI, response.getMpackUri());
+            resource.setProperty(MPACK_DESC, response.getDescription());
+            resource.setProperty(REGISTRY_ID, response.getRegistryId());
+            List<Module> modules = 
getManagementController().getModules(response.getMpackId());
+            resource.setProperty(MODULES, modules);
+            results.add(resource);
+          }
       }
       if (results.isEmpty()) {
         throw new NoSuchResourceException(
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinition.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinition.java
index 25c4ede..82aaa69 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinition.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinition.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.ambari.server.controller.internal;
 
 import java.util.Collection;
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackGenerator.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackGenerator.java
index 491d7dc..6795aef 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackGenerator.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackGenerator.java
@@ -42,8 +42,8 @@ import javax.xml.bind.Marshaller;
 import org.apache.ambari.server.stack.ServiceDirectory;
 import org.apache.ambari.server.stack.StackDirectory;
 import org.apache.ambari.server.stack.StackManager;
+import org.apache.ambari.server.state.Module;
 import org.apache.ambari.server.state.Mpack;
-import org.apache.ambari.server.state.Packlet;
 import org.apache.ambari.server.state.PropertyInfo;
 import org.apache.ambari.server.state.QuickLinksConfigurationInfo;
 import org.apache.ambari.server.state.ServiceInfo;
@@ -243,7 +243,6 @@ public class MpackGenerator {
     Mpack mpack = new Mpack();
     mpack.setName(dstStackName);
     mpack.setVersion(vdf.release.version);
-    mpack.setBuildNumber(vdf.release.getFullVersion());
     mpack.setStackId(dstStackId.getStackId());
     mpack.setDescription(dstStackName + " Ambari Management Pack");
     Map<String, String> prereqs = new HashMap<>();
@@ -251,8 +250,8 @@ public class MpackGenerator {
     prereqs.put("min-jdk", srcStackInfo.getMinJdk());
     prereqs.put("max-jdk", srcStackInfo.getMaxJdk());
     mpack.setPrerequisites(prereqs);
-    List<Packlet> packlets = new ArrayList<>();
-    mpack.setPacklets(packlets);
+    List<Module> modules = new ArrayList<>();
+    mpack.setModules(modules);
 
     for (ManifestServiceInfo manifestServiceInfo : 
vdf.getStackServices(srcStackInfo, true /* skipMissingServices = true */)) {
       ServiceInfo serviceInfo = 
srcStackInfo.getService(manifestServiceInfo.getName());
@@ -270,20 +269,19 @@ public class MpackGenerator {
 
       System.out.println("Processing service=" + serviceInfo.getName() + ", 
version=" + serviceVersion);
       System.out.println("Service Parent : " + serviceInfo.getParent());
-      String packletDirName = serviceName + "-packlet-" + serviceVersion;
-      String packletTarName = packletDirName + ".tar.gz";
-      File packletDir = new File(
-        mpackPackletsDir.getAbsolutePath() + File.separator + packletDirName);
-      if (!packletDir.exists()) {
-        packletDir.mkdir();
+      String moduleDirName = serviceName + "-packlet-" + serviceVersion;
+      String moduleTarName = moduleDirName + ".tar.gz";
+      File moduleDir = new File(
+        mpackPackletsDir.getAbsolutePath() + File.separator + moduleDirName);
+      if (!moduleDir.exists()) {
+        moduleDir.mkdir();
       }
-      Packlet packlet = new Packlet();
-      packlet.setType(Packlet.PackletType.SERVICE_PACKLET);
-      packlet.setName(serviceName);
-      packlet.setVersion(serviceVersion);
-      packlet.setServiceId(serviceVersion);
-      packlet.setSourceLocation("packlets" + File.separator + packletTarName);
-      packlets.add(packlet);
+      Module module = new Module();
+      module.setCategory(Module.Category.SERVER);
+      module.setName(serviceName);
+      module.setVersion(serviceVersion);
+      module.setDefinition(moduleTarName);
+      modules.add(module);
 
       // Export service metainfo.xml
       ServiceMetainfoXml serviceMetainfoXml = new ServiceMetainfoXml();
@@ -294,26 +292,26 @@ public class MpackGenerator {
       marshaller = ctx.createMarshaller();
       marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
       FileOutputStream serviceMetainfoFileStream = new FileOutputStream(
-        packletDir.getAbsolutePath() + File.separator + "metainfo.xml");
+              moduleDir.getAbsolutePath() + File.separator + "metainfo.xml");
       marshaller.marshal(serviceMetainfoXml, serviceMetainfoFileStream);
       serviceMetainfoFileStream.flush();
       serviceMetainfoFileStream.close();
 
       // Export mertrics.json
       File srcMetricsFile = serviceInfo.getMetricsFile();
-      exportFile(srcMetricsFile, packletDir);
+      exportFile(srcMetricsFile, moduleDir);
 
       // Export widgets.json
       File srcWidgetsFile = serviceInfo.getWidgetsDescriptorFile();
-      exportFile(srcWidgetsFile, packletDir);
+      exportFile(srcWidgetsFile, moduleDir);
 
       // Export alerts.json
       File srcAlertsFile = serviceInfo.getAlertsFile();
-      exportFile(srcAlertsFile, packletDir);
+      exportFile(srcAlertsFile, moduleDir);
 
       // Export kerberos.json
       File srcKerberosFile = serviceInfo.getKerberosDescriptorFile();
-      exportFile(srcKerberosFile, packletDir);
+      exportFile(srcKerberosFile, moduleDir);
 
       // Export quicklinks
       for (Map.Entry<String, QuickLinksConfigurationInfo> entry : 
serviceInfo.getQuickLinksConfigurationsMap()
@@ -323,7 +321,7 @@ public class MpackGenerator {
         for (Map.Entry<String, QuickLinks> quickLinksEntry : 
quickLinksConfigurationInfo
           .getQuickLinksConfigurationMap().entrySet()) {
           File quickLinksDir = new File(
-            packletDir.getAbsolutePath() + File.separator + serviceInfo
+                  moduleDir.getAbsolutePath() + File.separator + serviceInfo
               .getQuickLinksConfigurationsDir());
           if (!quickLinksDir.exists()) {
             quickLinksDir.mkdir();
@@ -341,7 +339,7 @@ public class MpackGenerator {
         String themeFileName = themeInfo.getFileName();
         for (Map.Entry<String, Theme> themeEntry : 
themeInfo.getThemeMap().entrySet()) {
           File themesDir = new File(
-            packletDir.getAbsolutePath() + File.separator + 
serviceInfo.getThemesDir());
+                  moduleDir.getAbsolutePath() + File.separator + 
serviceInfo.getThemesDir());
           if (!themesDir.exists()) {
             themesDir.mkdir();
           }
@@ -362,19 +360,19 @@ public class MpackGenerator {
       File srcPackageFile = new File(srcPackageFolder);
       if (srcPackageFile != null && srcPackageFile.exists()) {
         File destPackageFile = new File(
-          packletDir.getAbsolutePath() + File.separator
+                moduleDir.getAbsolutePath() + File.separator
             + ServiceDirectory.PACKAGE_FOLDER_NAME);
         FileUtils.copyDirectory(srcPackageFile, destPackageFile);
       }
 
       // Export merged configs
       File configDir = new File(
-        packletDir.getAbsolutePath() + File.separator + 
serviceInfo.getConfigDir());
+              moduleDir.getAbsolutePath() + File.separator + 
serviceInfo.getConfigDir());
       exportConfigs(serviceInfo.getProperties(), configDir);
 
       // Copy service advisor
       File srcServiceAdvisor = serviceInfo.getAdvisorFile();
-      File destServiceAdvisor = new File(packletDir.getAbsolutePath() + 
File.separator + "service_advisor.py");
+      File destServiceAdvisor = new File(moduleDir.getAbsolutePath() + 
File.separator + "service_advisor.py");
       if(srcServiceAdvisor != null && srcServiceAdvisor.exists()) {
         FileUtils.copyFile(srcServiceAdvisor, destServiceAdvisor);
       }
@@ -382,9 +380,9 @@ public class MpackGenerator {
       // TODO: Export upgrade packs
 
       // Create packlet tarball
-      createTarGzip(packletDir.getAbsolutePath());
-      if(packletDir.exists()) {
-        FileUtils.deleteDirectory(packletDir);
+      createTarGzip(moduleDir.getAbsolutePath());
+      if(moduleDir.exists()) {
+        FileUtils.deleteDirectory(moduleDir);
       }
     }
 
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 5ad0d9e..300c22e 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
@@ -21,6 +21,7 @@ import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.FileReader;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.net.URL;
@@ -43,8 +44,9 @@ import org.apache.ambari.server.orm.dao.MpackDAO;
 import org.apache.ambari.server.orm.dao.StackDAO;
 import org.apache.ambari.server.orm.entities.MpackEntity;
 import org.apache.ambari.server.orm.entities.StackEntity;
+import org.apache.ambari.server.state.Module;
 import org.apache.ambari.server.state.Mpack;
-import org.apache.ambari.server.state.Packlet;
+import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.stack.StackMetainfoXml;
 import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
 import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
@@ -66,8 +68,7 @@ public class MpackManager {
   private static final String MPACK_METADATA = "mpack.json";
   private static final String METAINFO_FILE_NAME = "metainfo.xml";
   private static final String MPACK_TAR_LOCATION = "staging";
-  private static final String SERVICES_DIRECTORY = "services";
-  private static final String PACKLETS_DIRECTORY = "packlets";
+  private static final String MODULES_DIRECTORY = "services";
   private static final String MIN_JDK_PROPERTY = "min-jdk";
   private static final String MAX_JDK_PROPERTY = "max-jdk";
   private static final String DEFAULT_JDK_VALUE = "1.8";
@@ -105,7 +106,7 @@ public class MpackManager {
       for (final File dirEntry : mpacksStaging.listFiles()) {
         if (dirEntry.isDirectory()) {
           String mpackName = dirEntry.getName();
-
+          LOG.info("Reading mpack :" + mpackName);
           if (!mpackName.equals(MPACK_TAR_LOCATION)) {
             for (final File file : dirEntry.listFiles()) {
               if (file.isDirectory()) {
@@ -119,6 +120,8 @@ public class MpackManager {
                     "UTF-8");
                   Gson gson = new Gson();
                   Mpack existingMpack = gson.fromJson(mpackJsonContents, 
Mpack.class);
+                  existingMpack.setMpackId(mpackEntity.getMpackId());
+                  existingMpack.setMpackUri(mpackEntity.getMpackUri());
                   mpackMap.put(mpackEntity.getMpackId(), existingMpack);
                 }
               }
@@ -131,6 +134,16 @@ public class MpackManager {
     }
   }
 
+
+  public Map<Long, Mpack> getMpackMap() {
+    return mpackMap;
+  }
+
+  public void setMpackMap(Map<Long, Mpack> mpackMap) {
+    this.mpackMap = mpackMap;
+  }
+
+
   /**
    * Parses mpack.json to fetch mpack and associated packlet information and
    * stores the mpack to the database and mpackMap
@@ -158,24 +171,31 @@ public class MpackManager {
       mpackVersion = mpackRequest.getMpackVersion();
       mpack.setRegistryId(mpackRequest.getRegistryId());
 
-      mpackTarPath = downloadMpack(mpackRequest.getMpackUri());
+      LOG.info("Mpack Registration via Registry :" + mpackName);
 
-      if (createMpackDirectory(mpack, mpackTarPath)) {
-        isValidMetadata = validateMpackInfo(mpackName, mpackVersion, 
mpack.getName(), mpack.getVersion());
-        if (isValidMetadata) {
-          mpackDirectory = mpacksStaging + File.separator + mpack.getName() + 
File.separator + mpack.getVersion();
-        } else {
+      mpack = downloadMpackMetadata(mpackRequest.getMpackUri());
+      isValidMetadata = validateMpackInfo(mpackName, mpackVersion, 
mpack.getName(), mpack.getVersion());
+
+      if (isValidMetadata) {
+        mpackTarPath = downloadMpack(mpackRequest.getMpackUri(), 
mpack.getDefinition());
+        createMpackDirectory(mpack);
+        mpackDirectory = mpacksStaging + File.separator + mpack.getName() + 
File.separator + mpack.getVersion();
+      }
+      else {
           String message =
             "Incorrect information : Mismatch in - (" + mpackName + "," + 
mpack.getName() + ") or (" + mpackVersion
               + "," + mpack.getVersion() + ")";
           throw new IllegalArgumentException(message); //Mismatch in 
information
         }
-
       }
-    } else {    //Mpack registration using direct download
-      mpackTarPath = downloadMpack(mpackRequest.getMpackUri());
+    //Mpack registration using direct download
+    else {
+      mpack = downloadMpackMetadata(mpackRequest.getMpackUri());
+      mpackTarPath = downloadMpack(mpackRequest.getMpackUri(), 
mpack.getDefinition());
+
+      LOG.info("Custom Mpack Registration :" + mpackRequest.getMpackUri());
 
-      if (createMpackDirectory(mpack, mpackTarPath)) {
+      if (createMpackDirectory(mpack)) {
         mpackDirectory = mpacksStaging + File.separator + mpack.getName() + 
File.separator + mpack.getVersion();
       }
     }
@@ -196,6 +216,31 @@ public class MpackManager {
   }
 
   /***
+   * Download the mpack.json as a primary step towards providing
+   * meta information about mpack and associated services
+   * @param mpackURI
+   * @return
+   * @throws IOException
+   */
+  private Mpack downloadMpackMetadata(String mpackURI) throws IOException  {
+    URL url = new URL(mpackURI);
+    File stagingDir = new File(mpacksStaging.toString() + File.separator + 
MPACK_TAR_LOCATION);
+    Path targetPath = new File(stagingDir.getPath() + File.separator + 
MPACK_METADATA).toPath();
+
+    LOG.debug("Download mpack.json and store in :" + targetPath);
+
+    if (!stagingDir.exists()) {
+      stagingDir.mkdir();
+    }
+
+    Files.copy(url.openStream(), targetPath, 
StandardCopyOption.REPLACE_EXISTING);
+    //Read the mpack.json file into Mpack Object for further use.
+    Gson gson = new Gson();
+    Mpack mpack = gson.fromJson(new FileReader(targetPath.toString()), 
Mpack.class);
+    return mpack;
+  }
+
+  /***
    * A generic method to extract tar files.
    *
    * @param tarPath
@@ -207,6 +252,8 @@ public class MpackManager {
     TarArchiveEntry entry = null;
     File outputFile = null;
 
+    LOG.debug("Extracting tar file :" + tarFile);
+
     //Create a loop to read every single entry in TAR file
     while ((entry = tarFile.getNextTarEntry()) != null) {
       outputFile = new File(untarDirectory, entry.getName());
@@ -253,6 +300,8 @@ public class MpackManager {
           .substring(mpackTarDirectory.lastIndexOf('/') + 1, 
mpackTarDirectory.indexOf(".tar")) + File.separator),
         Paths.get(mpackDirectory), StandardCopyOption.REPLACE_EXISTING);
 
+    LOG.debug("Extracting Mpack definitions into :" + extractedMpackDirectory);
+
     createServicesDirectory(extractedMpackDirectory, mpack);
 
     File metainfoFile = new File(extractedMpackDirectory + File.separator + 
METAINFO_FILE_NAME);
@@ -317,64 +366,35 @@ public class MpackManager {
    * @throws IOException
    */
   private void createServicesDirectory(Path extractedMpackDirectory, Mpack 
mpack) throws IOException {
-    File servicesDir = new File(extractedMpackDirectory.toAbsolutePath() + 
File.separator + SERVICES_DIRECTORY);
+    File servicesDir = new File(extractedMpackDirectory.toAbsolutePath() + 
File.separator + MODULES_DIRECTORY);
     if (!servicesDir.exists()) {
       servicesDir.mkdir();
     }
-    List<Packlet> packlets = mpack.getPacklets();
-
-    for (Packlet packlet : packlets) {
-      if (packlet.getType() == Packlet.PackletType.SERVICE_PACKLET) {
-        String packletSourceLocation = packlet.getSourceLocation();
-        File serviceTargetDir = new File(servicesDir + File.separator + 
packlet.getName());
-        extractTar(Paths.get(extractedMpackDirectory + File.separator + 
packlet.getSourceLocation()), servicesDir);
-        Path extractedServiceDirectory = Files.move(Paths.get(servicesDir + 
File.separator + packletSourceLocation
-            .substring(packletSourceLocation.indexOf("/") + 1, 
packletSourceLocation.indexOf(".tar.gz"))),
+    List<Module> modules = mpack.getModules();
+
+    LOG.info("Creating services directory for mpack :" + mpack.getName());
+
+    for (Module module : modules) {
+      //if (module.getType() == Packlet.PackletType.SERVICE_PACKLET) { //Add 
back if there is going to be a view packlet
+        String moduleDefinitionLocation = module.getDefinition();
+        File serviceTargetDir = new File(servicesDir + File.separator + 
module.getName());
+        extractTar(Paths.get(extractedMpackDirectory + File.separator + 
"modules" + File.separator + moduleDefinitionLocation), servicesDir);
+        Path extractedServiceDirectory = Files.move(Paths.get(servicesDir + 
File.separator + moduleDefinitionLocation
+            .substring(moduleDefinitionLocation.indexOf("/") + 1, 
moduleDefinitionLocation.indexOf(".tar.gz"))),
           serviceTargetDir.toPath(), StandardCopyOption.REPLACE_EXISTING);
-      }
+
     }
   }
 
   /**
-   * Reads the mpack.json file within the {mpack-name}.tar.gz file and 
populates Mpack object.
-   * Extract the mpack-name and mpack-version from mpack.json to create the 
new mpack directory to hold the mpack files.
+   * Create the new mpack directory to hold the mpack files.
    *
    * @param mpack        Mpack to process
-   * @param mpackTarPath Path to mpack tarball
    * @return boolean
    * @throws IOException
    */
-  private Boolean createMpackDirectory(Mpack mpack, Path mpackTarPath)
+  private Boolean createMpackDirectory(Mpack mpack)
     throws IOException, ResourceAlreadyExistsException {
-
-    TarArchiveInputStream mpackTarFile = new TarArchiveInputStream(
-      new GzipCompressorInputStream(new BufferedInputStream(new 
FileInputStream(new File(mpackTarPath.toString())))));
-    TarArchiveEntry entry = null;
-    String individualFiles;
-    int offset;
-
-    // Create a loop to read every single entry in TAR file
-    while ((entry = mpackTarFile.getNextTarEntry()) != null) {
-      // Get the name of the file
-      individualFiles = entry.getName();
-      String[] dirFile = individualFiles.split(File.separator);
-
-      //Search for mpack.json
-      String fileName = dirFile[dirFile.length - 1];
-      if (fileName.contains("mpack") && fileName.contains(".json")) {
-        byte[] content = new byte[(int) entry.getSize()];
-        offset = 0;
-        LOG.debug("Size of the File is: " + entry.getSize());
-        mpackTarFile.read(content, offset, content.length - offset);
-
-        //Read the mpack.json file into Mpack Object for further use.
-        String mpackJsonContents = new String(content, "UTF-8");
-        Gson gson = new Gson();
-        Mpack tempMpack = gson.fromJson(mpackJsonContents, Mpack.class);
-        mpack.copyFrom(tempMpack);
-
-        mpackTarFile.close();
-
         //Check if the mpack already exists
         List<MpackEntity> mpackEntities = 
mpackDAO.findByNameVersion(mpack.getName(), mpack.getVersion());
         if (mpackEntities.size() == 0) {
@@ -389,10 +409,6 @@ public class MpackManager {
             "Mpack: " + mpack.getName() + " version: " + mpack.getVersion() + 
" already exists in server";
           throw new ResourceAlreadyExistsException(message);
         }
-      }
-    }
-
-    return false;
   }
 
   /***
@@ -405,9 +421,16 @@ public class MpackManager {
   private void createSymLinks(Mpack mpack) throws IOException {
 
     String stackId = mpack.getStackId();
-    String[] stackMetaData = stackId.split("-");
-    String stackName = stackMetaData[0];
-    String stackVersion = stackMetaData[1];
+    String stackName = "";
+    String stackVersion = "";
+    if (stackId == null) {
+      stackName = mpack.getName();
+      stackVersion = mpack.getVersion();
+    } else {
+      StackId id = new StackId(stackId);
+      stackName = id.getStackName();
+      stackVersion = id.getStackVersion();
+    }
     File stack = new File(stackRoot + "/" + stackName);
     Path stackPath = Paths.get(stackRoot + "/" + stackName + "/" + 
stackVersion);
     Path mpackPath = Paths.get(mpacksStaging + "/" + mpack.getName() + "/" + 
mpack.getVersion());
@@ -425,14 +448,15 @@ public class MpackManager {
    * Download the mpack from the given uri
    *
    * @param mpackURI
+   * @param mpackDefinitionLocation
    * @return
    */
-  public Path downloadMpack(String mpackURI) throws IOException {
+  public Path downloadMpack(String mpackURI, String mpackDefinitionLocation) 
throws IOException {
 
-    URL url = new URL(mpackURI);
-    String mpackTarFile = mpackURI.substring(mpackURI.lastIndexOf('/') + 1, 
mpackURI.length());
     File stagingDir = new File(mpacksStaging.toString() + File.separator + 
MPACK_TAR_LOCATION);
-    Path targetPath = new File(stagingDir.getPath() + File.separator + 
mpackTarFile).toPath();
+    Path targetPath = new File(stagingDir.getPath() + File.separator + 
mpackDefinitionLocation).toPath();
+    String mpackTarURI = mpackURI.substring(0, mpackURI.lastIndexOf('/')) + 
File.separator + mpackDefinitionLocation;
+    URL url = new URL(mpackTarURI);
 
     if (!stagingDir.exists()) {
       stagingDir.mkdir();
@@ -506,9 +530,16 @@ public class MpackManager {
   protected void populateStackDB(Mpack mpack) throws IOException {
 
     String stackId = mpack.getStackId();
-    String[] stackMetaData = stackId.split("-");
-    String stackName = stackMetaData[0];
-    String stackVersion = stackMetaData[1];
+    String stackName = "";
+    String stackVersion = "";
+    if (stackId == null) {
+      stackName = mpack.getName();
+      stackVersion = mpack.getVersion();
+    } else {
+      StackId id = new StackId(stackId);
+      stackName = id.getStackName();
+      stackVersion = id.getStackVersion();
+    }
 
     StackEntity stackEntity = stackDAO.find(stackName, stackVersion);
     if (stackEntity == null) {
@@ -528,18 +559,14 @@ public class MpackManager {
   }
 
   /**
-   * Fetches the packlet info stored in the memory for mpacks/{mpack_id} call.
+   * Fetches the mpack info stored in the memory for mpacks/{mpack_id} call.
    *
    * @param mpackId
-   * @return list of {@link Packlet}
+   * @return list of {@link Module}
    */
-  public List<Packlet> getPacklets(Long mpackId) {
-
+  public List<Module> getModules(Long mpackId) {
     Mpack mpack = mpackMap.get(mpackId);
-    if (mpack.getPacklets() != null) {
-      return mpack.getPacklets();
-    }
-    return null;
+    return mpack.getModules();
   }
 
   /***
@@ -557,6 +584,8 @@ public class MpackManager {
     String mpackName = mpackEntity.getMpackName() + "-" + 
mpackEntity.getMpackVersion() + ".tar.gz";
     Path mpackTarFile = Paths.get(mpacksStaging + File.separator + 
MPACK_TAR_LOCATION + File.separator + mpackName);
 
+    LOG.info("Removing mpack :" + mpackName);
+
     mpackMap.remove(mpackEntity.getMpackId());
     FileUtils.deleteDirectory(mpackDirToDelete);
 
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/stack/StackDirectory.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/stack/StackDirectory.java
index daf8e7c..baaf8f0 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/stack/StackDirectory.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/stack/StackDirectory.java
@@ -389,15 +389,19 @@ public class StackDirectory extends 
StackDefinitionDirectory {
         for (File upgradeFile : f.listFiles(XML_FILENAME_FILTER)) {
           if 
(upgradeFile.getName().toLowerCase().startsWith(CONFIG_UPGRADE_XML_FILENAME_PREFIX))
 {
             if (configUpgradePack == null) {
-              configUpgradePack = parseConfigUpgradePack(upgradeFile);
+              if(upgradeFile.length() != 0) {
+                configUpgradePack = parseConfigUpgradePack(upgradeFile);
+              }
             } else { // If user messed things up with lower/upper case 
filenames
               throw new AmbariException(String.format("There are multiple 
files with name like %s" + upgradeFile.getAbsolutePath()));
             }
           } else {
             String upgradePackName = 
FilenameUtils.removeExtension(upgradeFile.getName());
-            UpgradePack pack = parseUpgradePack(upgradePackName, upgradeFile);
-            pack.setName(upgradePackName);
-            upgradeMap.put(upgradePackName, pack);
+            if(upgradeFile.length() != 0) {
+              UpgradePack pack = parseUpgradePack(upgradePackName, 
upgradeFile);
+              pack.setName(upgradePackName);
+              upgradeMap.put(upgradePackName, pack);
+            }
           }
         }
       }
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/Module.java 
b/ambari-server/src/main/java/org/apache/ambari/server/state/Module.java
new file mode 100644
index 0000000..800a9e0
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Module.java
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.state;
+
+import java.util.List;
+import java.util.Objects;
+
+import com.google.gson.annotations.SerializedName;
+
+public class Module {
+  public enum Category {
+    @SerializedName("SERVER")
+    SERVER,
+    @SerializedName("CLIENT")
+    CLIENT,
+    @SerializedName("LIBRARY")
+    LIBRARY
+  }
+
+  @SerializedName("id")
+  private String id;
+  @SerializedName("displayName")
+  private String displayName;
+  @SerializedName("description")
+  private String description;
+  @SerializedName("category")
+  private Category category;
+  @SerializedName("name")
+  private String name;
+  @SerializedName("version")
+  private String version;
+  @SerializedName("definition")
+  private String definition;
+  @SerializedName("dependencies")
+  private List<ModuleDependency> dependencies;
+  @SerializedName("components")
+  private List<ModuleComponent> components;
+
+  public Category getCategory() {
+    return category;
+  }
+
+  public void setType(Category category) {
+    this.category = category;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getVersion() {
+    return version;
+  }
+
+  public void setVersion(String version) {
+    this.version = version;
+  }
+
+  public String getDefinition() {
+    return definition;
+  }
+
+  public void setDefinition(String definition) {
+    this.definition = definition;
+  }
+
+  public String getId() {
+    return id;
+  }
+
+  public void setId(String id) {
+    this.id = id;
+  }
+
+  public String getDisplayName() {
+    return displayName;
+  }
+
+  public void setDisplayName(String displayName) {
+    this.displayName = displayName;
+  }
+
+  public String getDescription() {
+    return description;
+  }
+
+  public void setDescription(String description) {
+    this.description = description;
+  }
+
+  public void setCategory(Category category) {
+    this.category = category;
+  }
+
+  public List<ModuleDependency> getDependencies() {
+    return dependencies;
+  }
+
+  public void setDependencies(List<ModuleDependency> dependencies) {
+    this.dependencies = dependencies;
+  }
+
+  public List<ModuleComponent> getComponents() {
+    return components;
+  }
+
+  public void setComponents(List<ModuleComponent> components) {
+    this.components = components;
+  }
+
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    Module module = (Module) o;
+
+    return Objects.equals(id, module.id) && Objects.equals(displayName, 
module.displayName) &&
+            Objects.equals(description, module.description) && 
Objects.equals(category, module.category) &&
+            Objects.equals(name, module.name) && Objects.equals(version, 
module.version) && Objects.equals(definition, module.definition)
+            && Objects.equals(dependencies, module.dependencies) && 
Objects.equals(components, module.components);
+  }
+
+  @Override
+  public int hashCode() {
+    return Objects.hash(id, displayName, description, category, name, version, 
definition, dependencies, components);
+  }
+
+  @Override
+  public String toString() {
+    return "Module{" +
+            "id='" + id + '\'' +
+            ", displayName='" + displayName + '\'' +
+            ", description='" + description + '\'' +
+            ", category=" + category +
+            ", name='" + name + '\'' +
+            ", version='" + version + '\'' +
+            ", definition='" + definition + '\'' +
+            ", dependencies=" + dependencies +
+            ", components=" + components +
+            '}';
+  }
+}
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/ModuleComponent.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/state/ModuleComponent.java
new file mode 100644
index 0000000..56c82af
--- /dev/null
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/ModuleComponent.java
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.state;
+
+import com.google.gson.annotations.SerializedName;
+
+public class ModuleComponent {
+
+  @SerializedName("id")
+  private String id;
+  @SerializedName("name")
+  private String name;
+  @SerializedName("category")
+  private String category;
+  @SerializedName("isExternal")
+  private Boolean isExternal;
+  @SerializedName("version")
+  private String version;
+
+  public String getId() {
+    return id;
+  }
+
+  public void setId(String id) {
+    this.id = id;
+  }
+
+  public String getCategory() {
+    return category;
+  }
+
+  public void setCategory(String category) {
+    this.category = category;
+  }
+
+
+  public String getVersion() {
+    return version;
+  }
+
+  public void setVersion(String version) {
+    this.version = version;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+  public Boolean getIsExternal() {
+    return isExternal;
+  }
+
+  public void setIsExternal(Boolean isExternal) {
+    this.isExternal = isExternal;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    ModuleComponent that = (ModuleComponent) o;
+
+    if (id != null ? !id.equals(that.id) : that.id != null) return false;
+    if (name != null ? !name.equals(that.name) : that.name != null) return 
false;
+    if (category != null ? !category.equals(that.category) : that.category != 
null) return false;
+    if (isExternal != null ? !isExternal.equals(that.isExternal) : 
that.isExternal != null) return false;
+    return version != null ? version.equals(that.version) : that.version == 
null;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = id != null ? id.hashCode() : 0;
+    result = 31 * result + (name != null ? name.hashCode() : 0);
+    result = 31 * result + (category != null ? category.hashCode() : 0);
+    result = 31 * result + (isExternal != null ? isExternal.hashCode() : 0);
+    result = 31 * result + (version != null ? version.hashCode() : 0);
+    return result;
+  }
+
+  @Override
+  public String toString() {
+    return "ModuleComponent{" +
+            "id='" + id + '\'' +
+            ", name='" + name + '\'' +
+            ", category='" + category + '\'' +
+            ", isExternal=" + isExternal +
+            ", version='" + version + '\'' +
+            '}';
+  }
+}
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/ModuleDependency.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/state/ModuleDependency.java
new file mode 100644
index 0000000..bdce407
--- /dev/null
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/ModuleDependency.java
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.state;
+
+import com.google.gson.annotations.SerializedName;
+
+public class ModuleDependency {
+  @SerializedName("id")
+  private String id;
+  @SerializedName("name")
+  private String name;
+  public enum DependencyType {
+    @SerializedName("RUNTIME")
+    RUNTIME,
+    @SerializedName("INSTALL")
+    INSTALL
+  }
+  @SerializedName("dependencyType")
+  private DependencyType dependencyType;
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getId() {
+    return id;
+  }
+
+  public void setId(String id) {
+    this.id = id;
+  }
+
+  public DependencyType getDependencyType() {
+    return dependencyType;
+  }
+
+  public void setDependencyType(DependencyType dependencyType) {
+    this.dependencyType = dependencyType;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    ModuleDependency that = (ModuleDependency) o;
+
+    if (id != null ? !id.equals(that.id) : that.id != null) return false;
+    if (name != null ? !name.equals(that.name) : that.name != null) return 
false;
+    return dependencyType != null ? dependencyType.equals(that.dependencyType) 
: that.dependencyType == null;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = id != null ? id.hashCode() : 0;
+    result = 31 * result + (name != null ? name.hashCode() : 0);
+    result = 31 * result + (dependencyType != null ? dependencyType.hashCode() 
: 0);
+    return result;
+  }
+
+  @Override
+  public String toString() {
+    return "ModuleDependency{" +
+            "id='" + id + '\'' +
+            ", name='" + name + '\'' +
+            ", dependencyType='" + dependencyType + '\'' +
+            '}';
+  }
+}
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/Mpack.java 
b/ambari-server/src/main/java/org/apache/ambari/server/state/Mpack.java
index ea094d3..62904f9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/Mpack.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Mpack.java
@@ -37,21 +37,30 @@ public class Mpack {
   @SerializedName("version")
   private String version;
 
-  @SerializedName("buildNumber")
-  private String buildNumber;
-
-  @SerializedName("description")
-  private String description;
+  @SerializedName("artifacts-path")
+  private String artifactsPath;
 
   @SerializedName("prerequisites")
   private Map<String, String> prerequisites;
 
-  @SerializedName("packlets")
-  private List<Packlet> packlets;
+  @SerializedName("modules")
+  private List<Module> modules;
+
+  @SerializedName("modules-path")
+  private String modulesPath;
+
+  @SerializedName("mpack-path")
+  private String mpackPath;
 
   @SerializedName("stack-id")
   private String stackId;
 
+  @SerializedName("definition")
+  private String definition;
+
+  @SerializedName("description")
+  private String description;
+
   private String mpackUri;
 
   public Long getMpackId() {
@@ -94,14 +103,6 @@ public class Mpack {
     this.version = version;
   }
 
-  public String getBuildNumber() {
-    return buildNumber;
-  }
-
-  public void setBuildNumber(String buildNumber) {
-    this.buildNumber = buildNumber;
-  }
-
   public String getDescription() {
     return description;
   }
@@ -118,15 +119,14 @@ public class Mpack {
     this.prerequisites = prerequisites;
   }
 
-  public List<Packlet> getPacklets() {
-    return packlets;
+  public List<Module> getModules() {
+    return modules;
   }
 
-  public void setPacklets(List<Packlet> packlets) {
-    this.packlets = packlets;
+  public void setModules(List<Module> modules) {
+    this.modules = modules;
   }
 
-
   public String getStackId() {
     return stackId;
   }
@@ -135,139 +135,95 @@ public class Mpack {
     this.stackId = stackId;
   }
 
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public int hashCode() {
-    final int prime = 31;
-    int result = 1;
-    result = prime * result + ((mpackId == null) ? 0 : mpackId.hashCode());
-    result = prime * result + ((name == null) ? 0 : name.hashCode());
-    result = prime * result + ((version == null) ? 0 : version.hashCode());
-    result = prime * result + ((buildNumber == null) ? 0 : 
buildNumber.hashCode());
-    result = prime * result + ((registryId == null) ? 0 : 
registryId.hashCode());
-    result = prime * result + ((description == null) ? 0 : 
description.hashCode());
-    result = prime * result + ((prerequisites == null) ? 0 : 
prerequisites.hashCode());
-    result = prime * result + ((packlets == null) ? 0 : packlets.hashCode());
-    result = prime * result + ((stackId == null) ? 0 : stackId.hashCode());
-    result = prime * result + ((mpackUri == null) ? 0 : mpackUri.hashCode());
-    return result;
+  public String getArtifactsPath() {
+    return artifactsPath;
   }
 
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean equals(Object obj) {
-    if (this == obj) {
-      return true;
-    }
-
-    if (obj == null) {
-      return false;
-    }
-
-    if (getClass() != obj.getClass()) {
-      return false;
-    }
-
-    Mpack other = (Mpack) obj;
-
-    if (name != other.name) {
-      return false;
-    }
-
-    if (version == null) {
-      if (other.version != null) {
-        return false;
-      }
-    } else if (!version.equals(other.version)) {
-      return false;
-    }
-
-    if (buildNumber == null) {
-      if (other.buildNumber != null) {
-        return false;
-      }
-    } else if (!buildNumber.equals(other.buildNumber)) {
-      return false;
-    }
+  public void setArtifactsPath(String artifactsPath) {
+    this.artifactsPath = artifactsPath;
+  }
 
-    if (description == null) {
-      if (other.description != null) {
-        return false;
-      }
-    } else if (!description.equals(other.description)) {
-      return false;
-    }
+  public String getModulesPath() {
+    return modulesPath;
+  }
 
-    if (mpackId == null) {
-      if (other.mpackId != null) {
-        return false;
-      }
-    } else if (!mpackId.equals(other.mpackId)) {
-      return false;
-    }
+  public void setModulesPath(String modulesPath) {
+    this.modulesPath = modulesPath;
+  }
 
-    if (registryId == null) {
-      if (other.registryId != null) {
-        return false;
-      }
-    } else if (!registryId.equals(other.registryId)) {
-      return false;
-    }
+  public String getMpackPath() {
+    return mpackPath;
+  }
 
-    if (prerequisites == null) {
-      if (other.prerequisites != null) {
-        return false;
-      }
-    } else if (!prerequisites.equals(other.prerequisites)) {
-      return false;
-    }
+  public void setMpackPath(String mpackPath) {
+    this.mpackPath = mpackPath;
+  }
 
-    if (packlets == null) {
-      if (other.packlets != null) {
-        return false;
-      }
-    } else if (!packlets.equals(other.packlets)) {
-      return false;
-    }
+  public String getDefinition() {
+    return definition;
+  }
 
-    if (mpackUri == null) {
-      if (other.mpackUri != null) {
-        return false;
-      }
-    } else if (!mpackUri.equals(other.mpackUri)) {
-      return false;
-    }
+  public void setDefinition(String definition) {
+    this.definition = definition;
+  }
 
-    if (stackId == null) {
-      if (other.stackId != null) {
-        return false;
-      }
-    } else if (!stackId.equals(other.stackId)) {
-      return false;
-    }
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    Mpack mpack = (Mpack) o;
+
+    if (!mpackId.equals(mpack.mpackId)) return false;
+    if (registryId != null ? !registryId.equals(mpack.registryId) : 
mpack.registryId != null) return false;
+    if (!name.equals(mpack.name)) return false;
+    if (!version.equals(mpack.version)) return false;
+    if (!artifactsPath.equals(mpack.artifactsPath)) return false;
+    if (!prerequisites.equals(mpack.prerequisites)) return false;
+    if (!modules.equals(mpack.modules)) return false;
+    if (!modulesPath.equals(mpack.modulesPath)) return false;
+    if (!mpackPath.equals(mpack.mpackPath)) return false;
+    if (!stackId.equals(mpack.stackId)) return false;
+    if (!definition.equals(mpack.definition)) return false;
+    if (!description.equals(mpack.description)) return false;
+    return mpackUri.equals(mpack.mpackUri);
+  }
 
-    return true;
+  @Override
+  public int hashCode() {
+    int result = mpackId.hashCode();
+    result = 31 * result + (registryId != null ? registryId.hashCode() : 0);
+    result = 31 * result + name.hashCode();
+    result = 31 * result + version.hashCode();
+    result = 31 * result + artifactsPath.hashCode();
+    result = 31 * result + prerequisites.hashCode();
+    result = 31 * result + modules.hashCode();
+    result = 31 * result + modulesPath.hashCode();
+    result = 31 * result + mpackPath.hashCode();
+    result = 31 * result + stackId.hashCode();
+    result = 31 * result + definition.hashCode();
+    result = 31 * result + description.hashCode();
+    result = 31 * result + mpackUri.hashCode();
+    return result;
   }
 
   @Override
   public String toString() {
-    StringBuilder sb = new StringBuilder();
-    sb.append('{');
-    sb.append("name=").append(name).append(", ");
-    sb.append("mpackId=").append(mpackId).append(", ");
-    sb.append("version=").append(version).append(", ");
-    sb.append("buildNumber=").append(buildNumber).append(", ");
-    sb.append("stackid=").append(stackId).append(", ");
-    sb.append("registryId=").append(registryId).append(", ");
-    sb.append("description=").append(description).append(", ");
-    sb.append("prereq=").append(prerequisites.toString()).append(", ");
-    sb.append("packlets=").append(packlets.toString()).append(", ");
-        sb.append('}');
-    return sb.toString();
+    return "Mpack{" +
+            "mpackId=" + mpackId +
+            ", registryId=" + registryId +
+            ", name='" + name + '\'' +
+            ", version='" + version + '\'' +
+            ", artifactsPath='" + artifactsPath + '\'' +
+            ", prerequisites=" + prerequisites +
+            ", modules=" + modules +
+            ", modulesPath='" + modulesPath + '\'' +
+            ", mpackPath='" + mpackPath + '\'' +
+            ", stackId='" + stackId + '\'' +
+            ", definition='" + definition + '\'' +
+            ", description='" + description + '\'' +
+            ", mpackUri='" + mpackUri + '\'' +
+            '}';
   }
 
   public void copyFrom(Mpack mpack) {
@@ -280,9 +236,6 @@ public class Mpack {
     if (this.version == null) {
       this.version = mpack.getVersion();
     }
-    if (this.buildNumber == null) {
-      this.buildNumber = mpack.getBuildNumber();
-    }
     if (this.stackId == null) {
       this.stackId = mpack.getStackId();
     }
@@ -292,11 +245,23 @@ public class Mpack {
     if (this.description == null) {
       this.description = mpack.getDescription();
     }
+    if (this.modules == null) {
+      this.modules = mpack.getModules();
+    }
+    if (this.artifactsPath == null) {
+      this.artifactsPath = mpack.getArtifactsPath();
+    }
     if (this.prerequisites == null) {
       this.prerequisites = mpack.getPrerequisites();
     }
-    if (this.packlets == null) {
-      this.packlets = mpack.getPacklets();
+    if (this.modulesPath == null) {
+      this.modulesPath = mpack.getModulesPath();
+    }
+    if (this.mpackPath == null) {
+      this.mpackPath = mpack.getMpackPath();
+    }
+    if (this.definition == null) {
+      this.definition = mpack.getDefinition();
     }
   }
 }
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/Packlet.java 
b/ambari-server/src/main/java/org/apache/ambari/server/state/Packlet.java
deleted file mode 100644
index 9f884d3..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/Packlet.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ambari.server.state;
-
-import com.google.gson.annotations.SerializedName;
-
-
-public class Packlet {
-  public enum PackletType {
-    @SerializedName("service-packlet")
-    SERVICE_PACKLET
-  }
-
-  @SerializedName("type")
-  private PackletType type;
-  @SerializedName("name")
-  private String name;
-  @SerializedName("version")
-  private String version;
-  @SerializedName("service-id")
-  private String serviceId;
-  @SerializedName("source_location")
-  private String srcLocation;
-
-  public PackletType getType() {
-    return type;
-  }
-
-  public void setType(PackletType type) {
-    this.type = type;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public void setName(String name) {
-    this.name = name;
-  }
-
-  public String getVersion() {
-    return version;
-  }
-
-  public void setVersion(String version) {
-    this.version = version;
-  }
-
-  public String getSourceLocation() {
-    return srcLocation;
-  }
-
-  public void setSourceLocation(String srcLocation) {
-    this.srcLocation = srcLocation;
-  }
-
-
-  public String getServiceId() {
-    return serviceId;
-  }
-
-  public void setServiceId(String serviceId) {
-    this.serviceId = serviceId;
-  }
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public int hashCode() {
-    final int prime = 31;
-    int result = 1;
-    result = prime * result + ((type == null) ? 0 : type.hashCode());
-    result = prime * result + ((name == null) ? 0 : name.hashCode());
-    result = prime * result + ((version == null) ? 0 : version.hashCode());
-    result = prime * result + ((serviceId == null) ? 0 : serviceId.hashCode());
-    result = prime * result + ((srcLocation == null) ? 0 : 
srcLocation.hashCode());
-    return result;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean equals(Object obj) {
-    if (this == obj) {
-      return true;
-    }
-
-    if (obj == null) {
-      return false;
-    }
-
-    if (getClass() != obj.getClass()) {
-      return false;
-    }
-
-    Packlet other = (Packlet) obj;
-
-    if (type != other.type) {
-      return false;
-    }
-
-    if (name == null) {
-      if (other.name != null) {
-        return false;
-      }
-    } else if (!name.equals(other.name)) {
-      return false;
-    }
-
-    if (version == null) {
-      if (other.version != null) {
-        return false;
-      }
-    } else if (!version.equals(other.version)) {
-      return false;
-    }
-
-    if (serviceId == null) {
-      if (other.serviceId != null) {
-        return false;
-      }
-    } else if (!serviceId.equals(other.serviceId)) {
-      return false;
-    }
-
-    if (srcLocation == null) {
-      if (other.srcLocation != null) {
-        return false;
-      }
-    } else if (!srcLocation.equals(other.srcLocation)) {
-      return false;
-    }
-    return true;
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder sb = new StringBuilder();
-    sb.append('{');
-    sb.append("type=").append(type).append(", ");
-    sb.append("name=").append(name).append(", ");
-    sb.append("version=").append(version).append(", ");
-    sb.append("service id=").append(serviceId).append(", ");
-    sb.append("source location=").append(srcLocation).append(", ");
-    sb.append('}');
-    return sb.toString();
-  }
-
-}
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
index aca31c2..501310d 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
@@ -96,9 +96,9 @@ import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.DesiredConfig;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.MaintenanceState;
+import org.apache.ambari.server.state.Module;
 import org.apache.ambari.server.state.Mpack;
 import org.apache.ambari.server.state.OsSpecific;
-import org.apache.ambari.server.state.Packlet;
 import org.apache.ambari.server.state.PropertyInfo;
 import org.apache.ambari.server.state.RepositoryInfo;
 import org.apache.ambari.server.state.SecurityType;
@@ -126,7 +126,6 @@ import com.google.gson.Gson;
 import com.google.inject.Binder;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
-import com.google.inject.Module;
 import com.google.inject.util.Modules;
 
 import junit.framework.Assert;
@@ -2215,7 +2214,7 @@ public class AmbariManagementControllerImplTest {
     f.set(controller, metaInfo);
   }
 
-  private class MockModule implements Module {
+  private class MockModule implements com.google.inject.Module {
 
     @Override
     public void configure(Binder binder) {
@@ -2405,7 +2404,7 @@ public class AmbariManagementControllerImplTest {
     RequestStatusResponse response = new RequestStatusResponse(new Long(201));
     Mpack mpack = new Mpack();
     mpack.setMpackId((long)100);
-    mpack.setPacklets(new ArrayList<Packlet>());
+    mpack.setModules(new ArrayList<Module>());
     mpack.setPrerequisites(new HashMap<String, String>());
     mpack.setRegistryId(new Long(100));
     mpack.setVersion("3.0");
@@ -2429,21 +2428,21 @@ public class AmbariManagementControllerImplTest {
   @Test
   public void testGetPacklets() throws Exception {
     Long mpackId = new Long(100);
-    ArrayList<Packlet> packletArrayList = new ArrayList<>();
-    Packlet samplePacklet = new Packlet();
+    ArrayList<Module> packletArrayList = new ArrayList<>();
+    Module samplePacklet = new Module();
     Injector injector = createNiceMock(Injector.class);
-    samplePacklet.setType(Packlet.PackletType.SERVICE_PACKLET);
+    //samplePacklet.setType(Packlet.PackletType.SERVICE_PACKLET);
     samplePacklet.setVersion("3.0.0");
     samplePacklet.setName("NIFI");
-    samplePacklet.setSourceLocation("/abc/nifi.tar.gz");
+    samplePacklet.setDefinition("nifi.tar.gz");
     packletArrayList.add(samplePacklet);
     
expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(null).atLeastOnce();
-    
expect(ambariMetaInfo.getPacklets(mpackId)).andReturn(packletArrayList).atLeastOnce();
+    
expect(ambariMetaInfo.getModules(mpackId)).andReturn(packletArrayList).atLeastOnce();
     replay(ambariMetaInfo,injector);
     AmbariManagementController controller = new 
AmbariManagementControllerImpl(null, clusters, injector);
     setAmbariMetaInfo(ambariMetaInfo, controller);
 
-    Assert.assertEquals(packletArrayList,controller.getPacklets(mpackId));
+    Assert.assertEquals(packletArrayList,controller.getModules(mpackId));
 
   }
 }
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/MpackResponseTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/MpackResponseTest.java
index 8cee9a9..9273a04 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/MpackResponseTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/MpackResponseTest.java
@@ -20,8 +20,8 @@ package org.apache.ambari.server.controller;
 import java.util.ArrayList;
 import java.util.HashMap;
 
+import org.apache.ambari.server.state.Module;
 import org.apache.ambari.server.state.Mpack;
-import org.apache.ambari.server.state.Packlet;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -42,7 +42,7 @@ public class MpackResponseTest {
   public Mpack setupMpack() {
     Mpack mpack = new Mpack();
     mpack.setMpackId(100L);
-    mpack.setPacklets(new ArrayList<Packlet>());
+    mpack.setModules(new ArrayList<Module>());
     mpack.setPrerequisites(new HashMap<String, String>());
     mpack.setRegistryId(100L);
     mpack.setVersion("3.0");
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/MpackResourceProviderTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/MpackResourceProviderTest.java
index e7cb3c3..6faec3a 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/MpackResourceProviderTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/MpackResourceProviderTest.java
@@ -43,8 +43,8 @@ import 
org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.orm.dao.MpackDAO;
 import org.apache.ambari.server.orm.entities.MpackEntity;
+import org.apache.ambari.server.state.Module;
 import org.apache.ambari.server.state.Mpack;
-import org.apache.ambari.server.state.Packlet;
 import org.easymock.EasyMock;
 import org.junit.Assert;
 import org.junit.Before;
@@ -53,7 +53,6 @@ import org.junit.Test;
 import com.google.inject.Binder;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
-import com.google.inject.Module;
 import com.google.inject.util.Modules;
 
 
@@ -112,7 +111,9 @@ public class MpackResourceProviderTest {
     // replay
     replay(m_dao);
 
-    ResourceProvider provider = 
AbstractControllerResourceProvider.getResourceProvider(type, m_amc);
+    ResourceProvider provider = 
AbstractControllerResourceProvider.getResourceProvider(
+            type
+    );
 
     // create the request
     Request request = PropertyHelper.getReadRequest();
@@ -158,13 +159,13 @@ public class MpackResourceProviderTest {
     entity.setMpackVersion("3.0");
 
 
-    ArrayList<Packlet> packletArrayList = new ArrayList<>();
-    Packlet packlet = new Packlet();
-    packlet.setName("testService");
-    packlet.setType(Packlet.PackletType.SERVICE_PACKLET);
-    packlet.setSourceLocation("testDir/testDir");
-    packlet.setVersion("3.0");
-    packletArrayList.add(packlet);
+    ArrayList<Module> packletArrayList = new ArrayList<>();
+    Module module = new Module();
+    module.setName("testService");
+    //module.setType(Module.PackletType.SERVICE_PACKLET);
+    module.setDefinition("testDir");
+    module.setVersion("3.0");
+    packletArrayList.add(module);
 
     Resource resourceExpected1 = new ResourceImpl(Resource.Type.Mpack);
     resourceExpected1.setProperty(MpackResourceProvider.MPACK_ID, (long)1);
@@ -172,16 +173,17 @@ public class MpackResourceProviderTest {
     resourceExpected1.setProperty(MpackResourceProvider.MPACK_VERSION, "3.0");
     resourceExpected1.setProperty(MpackResourceProvider.MPACK_URI, 
"abcd.tar.gz");
     resourceExpected1.setProperty(MpackResourceProvider.REGISTRY_ID, null);
-    
resourceExpected1.setProperty(MpackResourceProvider.PACKLETS,packletArrayList);
+    
resourceExpected1.setProperty(MpackResourceProvider.MODULES,packletArrayList);
 
     // set expectations
     EasyMock.expect(m_dao.findById((long)1)).andReturn(entity).anyTimes();
-    
EasyMock.expect(m_amc.getPacklets((long)1)).andReturn(packletArrayList).anyTimes();
+    
EasyMock.expect(m_amc.getModules((long)1)).andReturn(packletArrayList).anyTimes();
 
     // replay
     replay(m_dao,m_amc);
 
-    ResourceProvider provider = 
AbstractControllerResourceProvider.getResourceProvider(type, m_amc);
+    ResourceProvider provider = 
AbstractControllerResourceProvider.getResourceProvider(
+            type);
 
     // create the request
     Request request = PropertyHelper.getReadRequest();
@@ -195,7 +197,7 @@ public class MpackResourceProviderTest {
       
Assert.assertEquals(resourceExpected1.getPropertyValue(MpackResourceProvider.MPACK_VERSION),
 (String) resource.getPropertyValue(MpackResourceProvider.MPACK_VERSION));
       
Assert.assertEquals(resourceExpected1.getPropertyValue(MpackResourceProvider.MPACK_URI),
 (String) resource.getPropertyValue(MpackResourceProvider.MPACK_URI));
       
Assert.assertEquals(resourceExpected1.getPropertyValue(MpackResourceProvider.REGISTRY_ID),
 (Long) resource.getPropertyValue(MpackResourceProvider.REGISTRY_ID));
-      
Assert.assertEquals(resourceExpected1.getPropertyValue(MpackResourceProvider.PACKLETS),(ArrayList)resource.getPropertyValue(MpackResourceProvider.PACKLETS));
+      
Assert.assertEquals(resourceExpected1.getPropertyValue(MpackResourceProvider.MODULES),(ArrayList)resource.getPropertyValue(MpackResourceProvider.MODULES));
   }
     // verify
     verify(m_dao,m_amc);
@@ -220,7 +222,8 @@ public class MpackResourceProviderTest {
     replay(m_amc,request);
     // end expectations
 
-    MpackResourceProvider provider = (MpackResourceProvider) 
AbstractControllerResourceProvider.getResourceProvider(Resource.Type.Mpack, 
m_amc);
+    MpackResourceProvider provider = (MpackResourceProvider) 
AbstractControllerResourceProvider.getResourceProvider(
+            Resource.Type.Mpack);
 
     AbstractResourceProviderTest.TestObserver observer = new 
AbstractResourceProviderTest.TestObserver();
     ((ObservableResourceProvider)provider).addObserver(observer);
@@ -248,7 +251,7 @@ public class MpackResourceProviderTest {
   public Mpack setupMpack() {
     Mpack mpack = new Mpack();
     mpack.setMpackId((long)100);
-    mpack.setPacklets(new ArrayList<Packlet>());
+    mpack.setModules(new ArrayList<Module>());
     mpack.setPrerequisites(new HashMap<String, String>());
     mpack.setRegistryId(new Long(100));
     mpack.setVersion("3.0");
@@ -262,7 +265,7 @@ public class MpackResourceProviderTest {
   /**
    *
    */
-  private class MockModule implements Module {
+  private class MockModule implements com.google.inject.Module {
     @Override
     public void configure(Binder binder) {
       
binder.bind(EntityManager.class).toInstance(EasyMock.createMock(EntityManager.class));
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/state/MpackTest.java 
b/ambari-server/src/test/java/org/apache/ambari/server/state/MpackTest.java
index d3dc73f..9184ca5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/MpackTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/MpackTest.java
@@ -47,50 +47,81 @@ public class MpackTest {
   @Test
   public void testMpacksUsingGson() {
     String mpackJsonContents = "{\n" +
-            "  \"name\" : \"hdf-ambari-mpack\",\n" +
-            "  \"version\": \"3.0.0.0-111\",\n" +
-            "  \"description\" : \"HDF 3.0.0 Ambari Management Pack\",\n" +
-            "  \"prerequisites\": {\n" +
-            "    \"min-ambari-version\" : \"3.0.0.0\"\n" +
-            "  },\n" +
-            "  \"packlets\": [\n" +
-            "    {\n" +
-            "      \"type\" : \"service-packlet\",\n" +
-            "      \"name\" : \"NIFI\",\n" +
-            "      \"version\" : \"1.2.0.0-123\",\n" +
-            "      \"source_location\": 
\"packlets/NIFI-1.2.0.0-123.tar.gz\"\n" +
-            "    },\n" +
+            "  \"definition\": \"hdpcore-1.0.0-b16-definition.tar.gz\",\n" +
+            "  \"description\": \"Hortonworks Data Platform Core\",\n" +
+            "  \"id\": \"hdpcore\",\n" +
+            "  \"modules\": [\n" +
             "    {\n" +
-            "      \"type\" : \"service-packlet\",\n" +
-            "      \"name\" : \"STREAMLINE\",\n" +
-            "      \"version\" : \"1.0.0.0-100\",\n" +
-            "      \"source_location\": 
\"packlets/STREAMLINE-1.0.0.0-100.tar.gz\"\n" +
+            "      \"category\": \"SERVER\",\n" +
+            "      \"components\": [\n" +
+            "        {\n" +
+            "          \"id\": \"zookeeper_server\",\n" +
+            "          \"version\": \"3.4.0.0-b17\",\n" +
+            "          \"name\": \"ZOOKEEPER_SERVER\",\n" +
+            "          \"category\": \"MASTER\",\n" +
+            "          \"isExternal\": \"False\"\n" +
+            "        }\n" +
+            "      ],\n" +
+            "      \"definition\": 
\"zookeeper-3.4.0.0-b17-definition.tar.gz\",\n" +
+            "      \"dependencies\": [\n" +
+            "        {\n" +
+            "          \"id\": \"zookeeper_clients\",\n" +
+            "          \"name\": \"ZOOKEEPER_CLIENTS\",\n" +
+            "          \"dependencyType\": \"INSTALL\"\n" +
+            "        }\n" +
+            "      ],\n" +
+            "      \"description\": \"Centralized service which provides 
highly reliable distributed coordination\",\n" +
+            "      \"displayName\": \"ZooKeeper\",\n" +
+            "      \"id\": \"zookeeper\",\n" +
+            "      \"name\": \"ZOOKEEPER\",\n" +
+            "      \"version\": \"3.4.0.0-b17\"\n" +
             "    }\n" +
-            "  ]\n" +
-            "}\n";
+            "  ],\n" +
+            "  \"name\": \"HDPCORE\",\n" +
+            "  \"prerequisites\": {\n" +
+            "    \"max-ambari-version\": \"3.1.0.0\",\n" +
+            "    \"min-ambari-version\": \"3.0.0.0\"\n" +
+            "  },\n" +
+            "  \"version\": \"1.0.0-b16\"\n" +
+            "}";
     HashMap<String, String> expectedPrereq = new HashMap<>();
     expectedPrereq.put("min-ambari-version","3.0.0.0");
-    ArrayList<Packlet> expectedPacklets = new ArrayList<>();
-    Packlet nifi = new Packlet();
-    nifi.setType(Packlet.PackletType.SERVICE_PACKLET);
-    nifi.setVersion("1.2.0.0-123");
-    nifi.setSourceLocation("packlets/NIFI-1.2.0.0-123.tar.gz");
-    nifi.setName("NIFI");
-    Packlet streamline = new Packlet();
-    streamline.setName("STREAMLINE");
-    streamline.setType(Packlet.PackletType.SERVICE_PACKLET);
-    streamline.setSourceLocation("packlets/STREAMLINE-1.0.0.0-100.tar.gz");
-    streamline.setVersion("1.0.0.0-100");
-    expectedPacklets.add(nifi);
-    expectedPacklets.add(streamline);
+    expectedPrereq.put("max-ambari-version","3.1.0.0");
+    ArrayList<Module> expectedModules = new ArrayList<>();
+    Module zkfc = new Module();
+    //nifi.setType(.PackletType.SERVICE_PACKLET);
+    zkfc.setVersion("3.4.0.0-b17");
+    zkfc.setDefinition("zookeeper-3.4.0.0-b17-definition.tar.gz");
+    zkfc.setName("ZOOKEEPER");
+    zkfc.setId("zookeeper");
+    zkfc.setDisplayName("ZooKeeper");
+    zkfc.setDescription("Centralized service which provides highly reliable 
distributed coordination");
+    zkfc.setCategory(Module.Category.SERVER);
+    ModuleDependency moduleDependency = new ModuleDependency();
+    moduleDependency.setId("zookeeper_clients");
+    moduleDependency.setName("ZOOKEEPER_CLIENTS");
+    
moduleDependency.setDependencyType(ModuleDependency.DependencyType.INSTALL);
+    ArrayList moduleDepList = new ArrayList();
+    moduleDepList.add(moduleDependency);
+    zkfc.setDependencies(moduleDepList);
+    ArrayList compList = new ArrayList();
+    ModuleComponent zk_server = new ModuleComponent();
+    zk_server.setId("zookeeper_server");
+    zk_server.setName("ZOOKEEPER_SERVER");
+    zk_server.setCategory("MASTER");
+    zk_server.setIsExternal(Boolean.FALSE);
+    zk_server.setVersion("3.4.0.0-b17");
+    compList.add(zk_server);
+    zkfc.setComponents(compList);
+    expectedModules.add(zkfc);
 
     Gson gson = new Gson();
     Mpack mpack = gson.fromJson(mpackJsonContents, Mpack.class);
-    Assert.assertEquals("hdf-ambari-mpack", mpack.getName());
-    Assert.assertEquals("3.0.0.0-111", mpack.getVersion());
-    Assert.assertEquals("HDF 3.0.0 Ambari Management Pack", 
mpack.getDescription());
+    Assert.assertEquals("HDPCORE", mpack.getName());
+    Assert.assertEquals("1.0.0-b16", mpack.getVersion());
+    Assert.assertEquals("Hortonworks Data Platform Core", 
mpack.getDescription());
     Assert.assertEquals(expectedPrereq, mpack.getPrerequisites());
-    Assert.assertEquals(expectedPacklets.toString(), 
mpack.getPacklets().toString());
+    Assert.assertEquals(expectedModules.toString(), 
mpack.getModules().toString());
   }
 
 }

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to