You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jl...@apache.org on 2017/07/07 20:17:22 UTC

[1/2] ambari git commit: AMBARI-21425: Add Rest API endpoint for software registry (jluniya)

Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-14714 7849de66b -> 6fdf4d116


http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/registry/Registry.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/registry/Registry.java b/ambari-server/src/main/java/org/apache/ambari/server/registry/Registry.java
new file mode 100644
index 0000000..bbdc0e2
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/registry/Registry.java
@@ -0,0 +1,47 @@
+/**
+ * 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.registry;
+
+/**
+ *
+ */
+public interface Registry {
+  /**
+   * Get software registry id
+   * @return registry id
+   */
+  public Long getRegistryId();
+
+  /**
+   * Get software registry name
+   * @return registry name
+   */
+  public String getRegistryName();
+
+  /**
+   * Get software registry type
+   * @return registry type
+   */
+  public RegistryType getRegistryType();
+
+  /**
+   * Get software registry Uri
+   * @return registry uri
+   */
+  public String getRegistryUri();
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryFactory.java
new file mode 100644
index 0000000..75a2b2c
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryFactory.java
@@ -0,0 +1,29 @@
+/**
+ * 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.registry;
+
+import org.apache.ambari.server.orm.entities.RegistryEntity;
+
+/**
+ * Factory interface for Guice injections
+ */
+public interface RegistryFactory {
+
+  Registry create(RegistryEntity registryEntity);
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryImpl.java
new file mode 100644
index 0000000..73a3719
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryImpl.java
@@ -0,0 +1,96 @@
+/**
+ * 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.registry;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
+import org.apache.ambari.server.orm.entities.RegistryEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.assistedinject.Assisted;
+
+/**
+ *
+ */
+public class RegistryImpl implements Registry {
+  private static final Logger LOG = LoggerFactory.getLogger(RegistryImpl.class);
+
+  /**
+   * The software registry id
+   */
+  private final Long registryId;
+
+  /**
+   * The software registry name
+   */
+  private final String registryName;
+
+  /**
+   * The software registry type (See {@link RegistryType}
+   */
+  private final RegistryType registryType;
+
+  /**
+   * The software registry Uri
+   */
+  private final String registryUri;
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public Long getRegistryId() {
+    return registryId;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getRegistryName() {
+    return registryName;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public RegistryType getRegistryType() {
+    return registryType;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getRegistryUri() {
+    return registryUri;
+  }
+
+  @Inject
+  public RegistryImpl(@Assisted RegistryEntity registryEntity, Injector injector, AmbariEventPublisher eventPublisher)
+    throws AmbariException {
+    this.registryId = registryEntity.getRegistryId();
+    this.registryName = registryEntity.getRegistryName();
+    this.registryType = registryEntity.getRegistryType();
+    this.registryUri = registryEntity.getRegistryUri();
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryManager.java b/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryManager.java
new file mode 100644
index 0000000..36f4d56
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryManager.java
@@ -0,0 +1,59 @@
+/**
+ * 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.registry;
+
+import java.util.Map;
+
+import org.apache.ambari.server.AmbariException;
+
+/**
+ * Provides high-level access to software registries
+ */
+public interface RegistryManager {
+
+  /**
+   * Connect a software registry with provided registry name, type and uri with this Ambari instance
+   *
+   * @param registryName software registry name
+   * @param registryType software registry type
+   * @param registryUri software registry uri
+   */
+  public Registry addRegistry(String registryName, RegistryType registryType, String registryUri);
+
+  /**
+   * Get a software registry given the registry ID
+   * @param registryId the registry ID to use to retrieve the software registry
+   * @return {@link Registry} identified by the given registry ID
+   * @throws AmbariException
+   */
+  public Registry getRegistry(Long registryId) throws AmbariException;
+
+  /**
+   * Get a software registry given the registry name
+   * @param registryName the registry name to use to retrieve the software registry
+   * @return {@link Registry} identified by the given registry name
+   * @throws AmbariException
+   */
+  public Registry getRegistry(String registryName) throws AmbariException;
+
+  /**
+   * Get all software registries associated with this Ambari instance
+   * @return {@link Map<Long, Registry>} of all software registries indexed by registry id
+   */
+  public Map<Long, Registry> getRegistries();
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryManagerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryManagerImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryManagerImpl.java
new file mode 100644
index 0000000..72d61fc
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryManagerImpl.java
@@ -0,0 +1,147 @@
+/**
+ * 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.registry;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.persistence.EntityManager;
+
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
+import org.apache.ambari.server.exceptions.RegistryNotFoundException;
+import org.apache.ambari.server.orm.dao.RegistryDAO;
+import org.apache.ambari.server.orm.entities.RegistryEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+import com.google.inject.persist.Transactional;
+
+/**
+ * Provides high-level access to software registries
+ */
+@Singleton
+public class RegistryManagerImpl implements RegistryManager {
+
+  private static final Logger LOG = LoggerFactory.getLogger(RegistryManagerImpl.class);
+
+  @Inject
+  Provider<EntityManager> entityManagerProvider;
+  @Inject
+  private RegistryDAO registryDAO;
+  @Inject
+  private RegistryFactory registryFactory;
+
+  /**
+   * Used to publish events relating to software registry CRUD operations.
+   */
+  @Inject
+  private AmbariEventPublisher eventPublisher;
+
+  private Map<Long, Registry> registriesById = new ConcurrentHashMap<>();
+  private Map<String, Registry> registriesByName = new ConcurrentHashMap<>();
+
+  @Inject
+  public RegistryManagerImpl(RegistryDAO registryDAO, RegistryFactory registryFactory) {
+
+    this.registryDAO = registryDAO;
+    this.registryFactory = registryFactory;
+  }
+
+  /**
+   * Inititalizes all of the in-memory state collections that this class
+   * unfortunately uses. It's annotated with {@link com.google.inject.Inject} as a way to define a
+   * very simple lifecycle with Guice where the constructor is instantiated
+   * (allowing injected members) followed by this method which initiailizes the
+   * state of the instance.
+   * <p/>
+   * Because some of these stateful initializations may actually reference this
+   * {@link RegistryManager} instance, we must do this after the object has been
+   * instantiated and injected.
+   */
+  @Inject
+  @Transactional
+  void loadRegistries() {
+    for (RegistryEntity registryEntity : registryDAO.findAll()) {
+      Registry registry = registryFactory.create(registryEntity);
+      registriesById.put(registryEntity.getRegistryId(), registry);
+      registriesByName.put(registryEntity.getRegistryName(), registry);
+    }
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public synchronized Registry addRegistry(String registryName, RegistryType registryType, String registryUri) {
+
+    RegistryEntity registryEntity = new RegistryEntity();
+    registryEntity.setRegistryName(registryName);
+    registryEntity.setRegistryUri(registryUri);
+    registryEntity.setRegistryType(registryType);
+    Long registryId = registryDAO.create(registryEntity);
+    registryEntity.setRegistryId(registryId);
+    Registry registry = registryFactory.create(registryEntity);
+    registriesById.put(registry.getRegistryId(), registry);
+    registriesByName.put(registry.getRegistryName(), registry);
+    return registry;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public Registry getRegistry(final Long registryId) throws AmbariException {
+    Registry registry = null;
+    if(registryId != null) {
+      registry = registriesById.get(registryId);
+    }
+    if(registry == null) {
+      throw new RegistryNotFoundException(registryId);
+    }
+    return registry;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public Registry getRegistry(final String registryName) throws AmbariException {
+    Registry registry = null;
+    if(registryName != null) {
+      registry = registriesByName.get(registryName);
+    }
+    if(registry == null) {
+      throw new RegistryNotFoundException(registryName);
+    }
+    return registry;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override public Map<Long, Registry> getRegistries() {
+    return Collections.unmodifiableMap(registriesById);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryType.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryType.java b/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryType.java
new file mode 100644
index 0000000..895b217
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryType.java
@@ -0,0 +1,29 @@
+/**
+ * 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.registry;
+
+/**
+ *
+ */
+public enum RegistryType {
+  /**
+   * Json Registry Type
+   */
+  JSON
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/state/Mpack.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..9090f28
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Mpack.java
@@ -0,0 +1,271 @@
+/**
+ * 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.state;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Represents the state of an mpack.
+ */
+public class Mpack {
+
+  private Long mpackId;
+
+  private Long registryId;
+
+  @SerializedName("name")
+  private String name;
+
+  @SerializedName("version")
+  private String version;
+
+  @SerializedName("description")
+  private String description;
+
+  @SerializedName("prerequisites")
+  private HashMap<String, String> prerequisites;
+
+  @SerializedName("packlets")
+  private ArrayList<Packlet> packlets;
+
+  @SerializedName("stack-id")
+  private String stackId;
+
+  private String mpackUri;
+
+  public Long getMpackId() {
+    return mpackId;
+  }
+
+  public void setMpackId(Long mpackId) {
+    this.mpackId = mpackId;
+  }
+
+  public Long getRegistryId() {
+    return registryId;
+  }
+
+  public void setRegistryId(Long registryId) {
+    this.registryId = registryId;
+  }
+
+  public String getMpackUri() {
+    return mpackUri;
+  }
+
+  public void setMpackUri(String mpackUri) {
+    this.mpackUri = mpackUri;
+  }
+
+  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 getDescription() {
+    return description;
+  }
+
+  public void setDescription(String description) {
+    this.description = description;
+  }
+
+  public HashMap<String, String> getPrerequisites() {
+    return prerequisites;
+  }
+
+  public void setPrerequisites(HashMap<String, String> prerequisites) {
+    this.prerequisites = prerequisites;
+  }
+
+  public ArrayList<Packlet> getPacklets() {
+    return packlets;
+  }
+
+  public void setPacklets(ArrayList<Packlet> packlets) {
+    this.packlets = packlets;
+  }
+
+
+  public String getStackId() {
+    return stackId;
+  }
+
+  public void setStackId(String stackId) {
+    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 + ((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;
+  }
+
+  /**
+   * {@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 (description == null) {
+      if (other.description != null) {
+        return false;
+      }
+    } else if (!description.equals(other.description)) {
+      return false;
+    }
+
+    if (mpackId == null) {
+      if (other.mpackId != null) {
+        return false;
+      }
+    } else if (!mpackId.equals(other.mpackId)) {
+      return false;
+    }
+
+    if (registryId == null) {
+      if (other.registryId != null) {
+        return false;
+      }
+    } else if (!registryId.equals(other.registryId)) {
+      return false;
+    }
+
+    if (prerequisites == null) {
+      if (other.prerequisites != null) {
+        return false;
+      }
+    } else if (!prerequisites.equals(other.prerequisites)) {
+      return false;
+    }
+
+    if (packlets == null) {
+      if (other.packlets != null) {
+        return false;
+      }
+    } else if (!packlets.equals(other.packlets)) {
+      return false;
+    }
+
+    if (mpackUri == null) {
+      if (other.mpackUri != null) {
+        return false;
+      }
+    } else if (!mpackUri.equals(other.mpackUri)) {
+      return false;
+    }
+
+    if (stackId == null) {
+      if (other.stackId != null) {
+        return false;
+      }
+    } else if (!stackId.equals(other.stackId)) {
+      return false;
+    }
+
+    return true;
+  }
+
+  @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("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();
+  }
+
+  public void copyFrom(Mpack mpack) {
+    if (this.name == null)
+      this.name = mpack.getName();
+    if (this.mpackId == null)
+      this.mpackId = mpack.getMpackId();
+    if (this.version == null)
+      this.version = mpack.getVersion();
+    if (this.stackId == null)
+      this.stackId = mpack.getStackId();
+    if (this.registryId == null)
+      this.registryId = mpack.getRegistryId();
+    if (this.description == null)
+      this.description = mpack.getDescription();
+    if (this.prerequisites == null)
+      this.prerequisites = mpack.getPrerequisites();
+    if (this.packlets == null)
+      this.packlets = mpack.getPacklets();
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/state/Mpacks.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/Mpacks.java b/ambari-server/src/main/java/org/apache/ambari/server/state/Mpacks.java
deleted file mode 100644
index 8b7d055..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/Mpacks.java
+++ /dev/null
@@ -1,271 +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
- *
- *     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.state;
-
-import com.google.gson.annotations.SerializedName;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-/**
- * Represents the state of an mpack.
- */
-public class Mpacks {
-
-  private Long mpackId;
-
-  private Long registryId;
-
-  @SerializedName("name")
-  private String name;
-
-  @SerializedName("version")
-  private String version;
-
-  @SerializedName("description")
-  private String description;
-
-  @SerializedName("prerequisites")
-  private HashMap<String, String> prerequisites;
-
-  @SerializedName("packlets")
-  private ArrayList<Packlet> packlets;
-
-  @SerializedName("stack-id")
-  private String stackId;
-
-  private String mpacksUri;
-
-  public Long getMpackId() {
-    return mpackId;
-  }
-
-  public void setMpackId(Long mpackId) {
-    this.mpackId = mpackId;
-  }
-
-  public Long getRegistryId() {
-    return registryId;
-  }
-
-  public void setRegistryId(Long registryId) {
-    this.registryId = registryId;
-  }
-
-  public String getMpacksUri() {
-    return mpacksUri;
-  }
-
-  public void setMpacksUri(String mpacksUri) {
-    this.mpacksUri = mpacksUri;
-  }
-
-  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 getDescription() {
-    return description;
-  }
-
-  public void setDescription(String description) {
-    this.description = description;
-  }
-
-  public HashMap<String, String> getPrerequisites() {
-    return prerequisites;
-  }
-
-  public void setPrerequisites(HashMap<String, String> prerequisites) {
-    this.prerequisites = prerequisites;
-  }
-
-  public ArrayList<Packlet> getPacklets() {
-    return packlets;
-  }
-
-  public void setPacklets(ArrayList<Packlet> packlets) {
-    this.packlets = packlets;
-  }
-
-
-  public String getStackId() {
-    return stackId;
-  }
-
-  public void setStackId(String stackId) {
-    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 + ((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 + ((mpacksUri == null) ? 0 : mpacksUri.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;
-    }
-
-    Mpacks other = (Mpacks) 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 (description == null) {
-      if (other.description != null) {
-        return false;
-      }
-    } else if (!description.equals(other.description)) {
-      return false;
-    }
-
-    if (mpackId == null) {
-      if (other.mpackId != null) {
-        return false;
-      }
-    } else if (!mpackId.equals(other.mpackId)) {
-      return false;
-    }
-
-    if (registryId == null) {
-      if (other.registryId != null) {
-        return false;
-      }
-    } else if (!registryId.equals(other.registryId)) {
-      return false;
-    }
-
-    if (prerequisites == null) {
-      if (other.prerequisites != null) {
-        return false;
-      }
-    } else if (!prerequisites.equals(other.prerequisites)) {
-      return false;
-    }
-
-    if (packlets == null) {
-      if (other.packlets != null) {
-        return false;
-      }
-    } else if (!packlets.equals(other.packlets)) {
-      return false;
-    }
-
-    if (mpacksUri == null) {
-      if (other.mpacksUri != null) {
-        return false;
-      }
-    } else if (!mpacksUri.equals(other.mpacksUri)) {
-      return false;
-    }
-
-    if (stackId == null) {
-      if (other.stackId != null) {
-        return false;
-      }
-    } else if (!stackId.equals(other.stackId)) {
-      return false;
-    }
-
-    return true;
-  }
-
-  @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("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();
-  }
-
-  public void copyFrom(Mpacks mpack) {
-    if (this.name == null)
-      this.name = mpack.getName();
-    if (this.mpackId == null)
-      this.mpackId = mpack.getMpackId();
-    if (this.version == null)
-      this.version = mpack.getVersion();
-    if (this.stackId == null)
-      this.stackId = mpack.getStackId();
-    if (this.registryId == null)
-      this.registryId = mpack.getRegistryId();
-    if (this.description == null)
-      this.description = mpack.getDescription();
-    if (this.prerequisites == null)
-      this.prerequisites = mpack.getPrerequisites();
-    if (this.packlets == null)
-      this.packlets = mpack.getPacklets();
-
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog251.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog251.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog251.java
index 5ed33a8..dd7434a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog251.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog251.java
@@ -31,11 +31,12 @@ import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.SecurityType;
 import org.apache.commons.lang.StringUtils;
 
-import com.google.inject.Inject;
-import com.google.inject.Injector;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+
 /**
  * The {@link UpgradeCatalog251} upgrades Ambari from 2.5.0 to 2.5.1.
  */

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
index 43057fb..67f2998 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
@@ -17,14 +17,15 @@
 --
 
 ------create tables and grant privileges to db user---------
-CREATE TABLE registries(
+CREATE TABLE registries (
  id BIGINT NOT NULL,
- registy_name VARCHAR(255) NOT NULL,
+ registry_name VARCHAR(255) NOT NULL,
  registry_type VARCHAR(255) NOT NULL,
  registry_uri VARCHAR(255) NOT NULL,
- CONSTRAINT PK_registries PRIMARY KEY (id));
+ CONSTRAINT PK_registries PRIMARY KEY (id),
+ CONSTRAINT UQ_registry_name UNIQUE (registry_name));
 
-CREATE TABLE mpacks(
+CREATE TABLE mpacks (
  id BIGINT NOT NULL,
  mpack_name VARCHAR(255) NOT NULL,
  mpack_version VARCHAR(255) NOT NULL,
@@ -32,9 +33,9 @@ CREATE TABLE mpacks(
  registry_id BIGINT,
  CONSTRAINT PK_mpacks PRIMARY KEY (id),
  CONSTRAINT FK_registries FOREIGN KEY (registry_id) REFERENCES registries(id),
- CONSTRAINT uni_mpack_name_version UNIQUE(mpack_name, mpack_version));
+ CONSTRAINT UQ_mpack_name_version UNIQUE(mpack_name, mpack_version));
 
-CREATE TABLE stack(
+CREATE TABLE stack (
   stack_id BIGINT NOT NULL,
   stack_name VARCHAR(255) NOT NULL,
   stack_version VARCHAR(255) NOT NULL,
@@ -1146,6 +1147,8 @@ INSERT INTO ambari_sequences (sequence_name, sequence_value)
   union all
   select 'mpack_id_seq', 0 FROM SYSIBM.SYSDUMMY1
   union all
+  select 'registry_id_seq', 0 FROM SYSIBM.SYSDUMMY1
+  union all
   select 'extension_id_seq', 0 FROM SYSIBM.SYSDUMMY1
   union all
   select 'link_id_seq', 0 FROM SYSIBM.SYSDUMMY1

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index f20882b..7e415db 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -36,24 +36,25 @@ prepare statement from @engine_stmt;
 execute statement;
 DEALLOCATE PREPARE statement;
 
-CREATE TABLE registries(
+CREATE TABLE registries (
  id BIGINT NOT NULL,
- registy_name VARCHAR(255) NOT NULL,
+ registry_name VARCHAR(255) NOT NULL,
  registry_type VARCHAR(255) NOT NULL,
  registry_uri VARCHAR(255) NOT NULL,
- CONSTRAINT PK_registries PRIMARY KEY (id));
+ CONSTRAINT PK_registries PRIMARY KEY (id),
+ CONSTRAINT UQ_registry_name UNIQUE (registry_name));
 
-CREATE TABLE mpacks(
+CREATE TABLE mpacks (
  id BIGINT NOT NULL,
  mpack_name VARCHAR(255) NOT NULL,
  mpack_version VARCHAR(255) NOT NULL,
  mpack_uri VARCHAR(255),
  registry_id BIGINT,
  CONSTRAINT PK_mpacks PRIMARY KEY (id),
- CONSTRAINT uni_mpack_name_version UNIQUE(mpack_name, mpack_version),
+ CONSTRAINT UQ_mpack_name_version UNIQUE(mpack_name, mpack_version),
  CONSTRAINT FK_registries FOREIGN KEY (registry_id) REFERENCES registries(id));
 
-CREATE TABLE stack(
+CREATE TABLE stack (
   stack_id BIGINT NOT NULL,
   stack_name VARCHAR(100) NOT NULL,
   stack_version VARCHAR(100) NOT NULL,
@@ -1124,6 +1125,7 @@ INSERT INTO ambari_sequences(sequence_name, sequence_value) VALUES
   ('upgrade_item_id_seq', 0),
   ('stack_id_seq', 0),
   ('mpack_id_seq', 0),
+  ('registry_id_seq', 0),
   ('extension_id_seq', 0),
   ('link_id_seq', 0),
   ('widget_id_seq', 0),

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index 05779b0..c09f7fa 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -17,24 +17,25 @@
 --
 
 ------create tables---------
-CREATE TABLE registries(
+CREATE TABLE registries (
  id BIGINT NOT NULL,
- registy_name VARCHAR(255) NOT NULL,
+ registry_name VARCHAR(255) NOT NULL,
  registry_type VARCHAR(255) NOT NULL,
  registry_uri VARCHAR(255) NOT NULL,
- CONSTRAINT PK_registries PRIMARY KEY (id));
+ CONSTRAINT PK_registries PRIMARY KEY (id),
+ CONSTRAINT UQ_registry_name UNIQUE (registry_name));
 
-CREATE TABLE mpacks(
+CREATE TABLE mpacks (
  id BIGINT NOT NULL,
  mpack_name VARCHAR(255) NOT NULL,
  mpack_version VARCHAR(255) NOT NULL,
  mpack_uri VARCHAR(255),
  registry_id BIGINT,
  CONSTRAINT PK_mpacks PRIMARY KEY (id),
- CONSTRAINT uni_mpack_name_version UNIQUE(mpack_name, mpack_version),
+ CONSTRAINT UQ_mpack_name_version UNIQUE(mpack_name, mpack_version),
  CONSTRAINT FK_registries FOREIGN KEY (registry_id) REFERENCES registries(id));
 
-CREATE TABLE stack(
+CREATE TABLE stack (
   stack_id NUMBER(19) NOT NULL,
   stack_name VARCHAR2(255) NOT NULL,
   stack_version VARCHAR2(255) NOT NULL,
@@ -1104,6 +1105,7 @@ INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('upgrade_gro
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('upgrade_item_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('stack_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('mpack_id_seq', 0);
+INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('registry_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('extension_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('link_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('widget_id_seq', 0);

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index afb676d..5396944 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -17,14 +17,15 @@
 --
 
 ------create tables and grant privileges to db user---------
-CREATE TABLE registries(
+CREATE TABLE registries (
  id BIGINT NOT NULL,
- registy_name VARCHAR(255) NOT NULL,
+ registry_name VARCHAR(255) NOT NULL,
  registry_type VARCHAR(255) NOT NULL,
  registry_uri VARCHAR(255) NOT NULL,
- CONSTRAINT PK_registries PRIMARY KEY (id));
+ CONSTRAINT PK_registries PRIMARY KEY (id),
+ CONSTRAINT UQ_registry_name UNIQUE (registry_name));
 
-CREATE TABLE mpacks(
+CREATE TABLE mpacks (
  id BIGINT NOT NULL,
  mpack_name VARCHAR(255) NOT NULL,
  mpack_version VARCHAR(255) NOT NULL,
@@ -32,9 +33,9 @@ CREATE TABLE mpacks(
  registry_id BIGINT,
  CONSTRAINT PK_mpacks PRIMARY KEY (id),
  CONSTRAINT FK_registries FOREIGN KEY (registry_id) REFERENCES registries(id),
- CONSTRAINT uni_mpack_name_version UNIQUE(mpack_name, mpack_version));
+ CONSTRAINT UQ_mpack_name_version UNIQUE(mpack_name, mpack_version));
 
-CREATE TABLE stack(
+CREATE TABLE stack (
   stack_id BIGINT NOT NULL,
   stack_name VARCHAR(255) NOT NULL,
   stack_version VARCHAR(255) NOT NULL,
@@ -1107,6 +1108,7 @@ INSERT INTO ambari_sequences (sequence_name, sequence_value) VALUES
   ('upgrade_item_id_seq', 0),
   ('stack_id_seq', 0),
   ('mpack_id_seq',0),
+  ('registry_id_seq',0),
   ('extension_id_seq', 0),
   ('link_id_seq', 0),
   ('topology_host_info_id_seq', 0),

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
index 8df88f1..a78a520 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -16,24 +16,25 @@
 -- limitations under the License.
 --
 
-CREATE TABLE registries(
- id BIGINT NOT NULL,
- registy_name VARCHAR(255) NOT NULL,
+CREATE TABLE registries (
+ id NUMERIC(19) NOT NULL,
+ registry_name VARCHAR(255) NOT NULL,
  registry_type VARCHAR(255) NOT NULL,
  registry_uri VARCHAR(255) NOT NULL,
- CONSTRAINT PK_registries PRIMARY KEY (id));
+ CONSTRAINT PK_registries PRIMARY KEY (id),
+ CONSTRAINT UQ_registry_name UNIQUE (registry_name));
 
-CREATE TABLE mpacks(
- id BIGINT NOT NULL,
+CREATE TABLE mpacks (
+ id NUMERIC(19) NOT NULL,
  mpack_name VARCHAR(255) NOT NULL,
  mpack_version VARCHAR(255) NOT NULL,
  mpack_uri VARCHAR(255),
  registry_id BIGINT,
  CONSTRAINT PK_mpacks PRIMARY KEY (id),
- CONSTRAINT uni_mpack_name_version UNIQUE(mpack_name, mpack_version),
+ CONSTRAINT UQ_mpack_name_version UNIQUE(mpack_name, mpack_version),
  CONSTRAINT FK_registries FOREIGN KEY (registry_id) REFERENCES registries(id));
 
-CREATE TABLE stack(
+CREATE TABLE stack (
   stack_id NUMERIC(19) NOT NULL,
   stack_name VARCHAR(255) NOT NULL,
   stack_version VARCHAR(255) NOT NULL,
@@ -1103,6 +1104,7 @@ INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('upgrade_gro
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('upgrade_item_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('stack_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('mpack_id_seq', 0);
+INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('registry_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('extension_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('link_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('widget_id_seq', 0);

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
index b9a18f3..ce91db1 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -29,24 +29,25 @@ sqlcmd -S localhost\SQLEXPRESS -i C:\app\ambari-server-1.3.0-SNAPSHOT\resources\
 ------create the database------
 
 ------create tables and grant privileges to db user---------
-CREATE TABLE registries(
+CREATE TABLE registries (
  id BIGINT NOT NULL,
- registy_name VARCHAR(255) NOT NULL,
+ registry_name VARCHAR(255) NOT NULL,
  registry_type VARCHAR(255) NOT NULL,
  registry_uri VARCHAR(255) NOT NULL,
- CONSTRAINT PK_registries PRIMARY KEY (id));
+ CONSTRAINT PK_registries PRIMARY KEY (id),
+ CONSTRAINT UQ_registry_name UNIQUE (registry_name));
 
-CREATE TABLE mpacks(
+CREATE TABLE mpacks (
  id BIGINT NOT NULL,
  mpack_name VARCHAR(255) NOT NULL,
  mpack_version VARCHAR(255) NOT NULL,
  mpack_uri VARCHAR(255),
  registry_id BIGINT,
  CONSTRAINT PK_mpacks PRIMARY KEY (id),
- CONSTRAINT uni_mpack_name_version UNIQUE(mpack_name, mpack_version),
+ CONSTRAINT UQ_mpack_name_version UNIQUE(mpack_name, mpack_version),
  CONSTRAINT FK_registries FOREIGN KEY (registry_id) REFERENCES registries(id));
 
-CREATE TABLE stack(
+CREATE TABLE stack (
   stack_id BIGINT NOT NULL,
   stack_name VARCHAR(255) NOT NULL,
   stack_version VARCHAR(255) NOT NULL,
@@ -1132,6 +1133,7 @@ BEGIN TRANSACTION
     ('upgrade_item_id_seq', 0),
     ('stack_id_seq', 0),
     ('mpack_id_seq', 0),
+    ('registry_id_seq', 0),
     ('extension_id_seq', 0),
     ('link_id_seq', 0),
     ('topology_host_info_id_seq', 0),

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/META-INF/persistence.xml b/ambari-server/src/main/resources/META-INF/persistence.xml
index 3755321..30cd900 100644
--- a/ambari-server/src/main/resources/META-INF/persistence.xml
+++ b/ambari-server/src/main/resources/META-INF/persistence.xml
@@ -99,6 +99,7 @@
     <class>org.apache.ambari.server.orm.entities.RemoteAmbariClusterEntity</class>
     <class>org.apache.ambari.server.orm.entities.RemoteAmbariClusterServiceEntity</class>
     <class>org.apache.ambari.server.orm.entities.MpackEntity</class>
+    <class>org.apache.ambari.server.orm.entities.RegistryEntity</class>
 
     <properties>
       <property name="eclipselink.cache.size.default" value="10000" />

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/test/java/org/apache/ambari/server/api/resources/MpackResourceDefinitionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/MpackResourceDefinitionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/MpackResourceDefinitionTest.java
index 08166b8..08e6c68 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/MpackResourceDefinitionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/MpackResourceDefinitionTest.java
@@ -20,6 +20,7 @@
 package org.apache.ambari.server.api.resources;
 
 import static junit.framework.Assert.assertEquals;
+
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
index de4c9a0..71b14e3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
@@ -18,27 +18,6 @@
 
 package org.apache.ambari.server.api.services;
 
-import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
-import org.apache.ambari.server.orm.dao.MetainfoDAO;
-import org.apache.ambari.server.state.AutoDeployInfo;
-import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.ComponentInfo;
-import org.apache.ambari.server.state.CustomCommandDefinition;
-import org.apache.ambari.server.state.DependencyInfo;
-import org.apache.ambari.server.state.OperatingSystemInfo;
-import org.apache.ambari.server.state.PropertyDependencyInfo;
-import org.apache.ambari.server.state.PropertyInfo;
-import org.apache.ambari.server.state.RepositoryInfo;
-import org.apache.ambari.server.state.ServiceInfo;
-import org.apache.ambari.server.state.StackId;
-import org.apache.ambari.server.state.StackInfo;
-import org.apache.ambari.server.state.Packlet;
-import org.apache.ambari.server.state.Mpacks;
-import org.apache.ambari.server.controller.MpackRequest;
-import org.apache.ambari.server.controller.MpackResponse;
-import org.apache.ambari.server.mpack.MpackManager;
-import org.apache.ambari.server.mpack.MpackManagerFactory;
 import static org.easymock.EasyMock.createNiceMock;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.replay;
@@ -53,8 +32,10 @@ import static org.junit.Assert.fail;
 import java.io.File;
 import java.io.FileReader;
 import java.lang.reflect.Field;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -63,8 +44,6 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 import java.util.UUID;
-import java.util.HashMap;
-import java.util.ArrayList;
 
 import javax.persistence.EntityManager;
 
@@ -72,17 +51,38 @@ import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.H2DatabaseCleaner;
 import org.apache.ambari.server.StackAccessException;
 import org.apache.ambari.server.configuration.Configuration;
+import org.apache.ambari.server.controller.MpackRequest;
+import org.apache.ambari.server.controller.MpackResponse;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
 import org.apache.ambari.server.metadata.ActionMetadata;
 import org.apache.ambari.server.metadata.AmbariServiceAlertDefinitions;
+import org.apache.ambari.server.mpack.MpackManager;
+import org.apache.ambari.server.mpack.MpackManagerFactory;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.orm.OrmTestHelper;
+import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
+import org.apache.ambari.server.orm.dao.MetainfoDAO;
 import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
 import org.apache.ambari.server.orm.entities.MetainfoEntity;
 import org.apache.ambari.server.stack.StackManager;
 import org.apache.ambari.server.stack.StackManagerFactory;
+import org.apache.ambari.server.state.AutoDeployInfo;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.ComponentInfo;
+import org.apache.ambari.server.state.CustomCommandDefinition;
+import org.apache.ambari.server.state.DependencyInfo;
+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.PropertyDependencyInfo;
+import org.apache.ambari.server.state.PropertyInfo;
+import org.apache.ambari.server.state.RepositoryInfo;
+import org.apache.ambari.server.state.ServiceInfo;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.StackInfo;
 import org.apache.ambari.server.state.alert.AlertDefinition;
 import org.apache.ambari.server.state.alert.AlertDefinitionFactory;
 import org.apache.ambari.server.state.alert.MetricSource;
@@ -579,16 +579,16 @@ public class AmbariMetaInfoTest {
   public void testRegisterMpacks() throws Exception{
     MpackManager mm = metaInfo.getMpackManager();
     MpackRequest mpackRequest = createNiceMock(MpackRequest.class);
-    Mpacks mpacks = new Mpacks();
-    mpacks.setMpackId((long)100);
-    mpacks.setPacklets(new ArrayList<Packlet>());
-    mpacks.setPrerequisites(new HashMap<String, String>());
-    mpacks.setRegistryId(new Long(100));
-    mpacks.setVersion("3.0");
-    mpacks.setMpacksUri("abc.tar.gz");
-    mpacks.setDescription("Test mpacks");
-    mpacks.setName("testMpack");
-    MpackResponse mpackResponse = new MpackResponse(mpacks);
+    Mpack mpack = new Mpack();
+    mpack.setMpackId((long)100);
+    mpack.setPacklets(new ArrayList<Packlet>());
+    mpack.setPrerequisites(new HashMap<String, String>());
+    mpack.setRegistryId(new Long(100));
+    mpack.setVersion("3.0");
+    mpack.setMpackUri("abc.tar.gz");
+    mpack.setDescription("Test mpack");
+    mpack.setName("testMpack");
+    MpackResponse mpackResponse = new MpackResponse(mpack);
     expect(mm.registerMpack(mpackRequest)).andReturn(mpackResponse);
     replay(mm);
     assertEquals(mpackResponse,metaInfo.registerMpack(mpackRequest));

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/test/java/org/apache/ambari/server/api/services/MpackServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/MpackServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/MpackServiceTest.java
deleted file mode 100644
index 06eb15d..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/MpackServiceTest.java
+++ /dev/null
@@ -1,94 +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
- *
- *     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.api.services;
-
-import org.apache.ambari.server.api.resources.ResourceInstance;
-import org.apache.ambari.server.api.services.parsers.RequestBodyParser;
-import org.apache.ambari.server.api.services.serializers.ResultSerializer;
-
-import org.apache.ambari.server.api.util.ApiVersion;
-import org.apache.ambari.server.controller.spi.Resource;
-
-
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.UriInfo;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Unit tests for MpackService
- */
-public class MpackServiceTest extends BaseServiceTest{
-  @Override
-  public List<BaseServiceTest.ServiceTestInvocation> getTestInvocations() throws Exception {
-    List<BaseServiceTest.ServiceTestInvocation> listInvocations = new ArrayList<>();
-
-    // getMpacks
-    MpacksService service = new TestMpackService("null");
-    Method m = service.getClass().getMethod("getMpacks", String.class, HttpHeaders.class, UriInfo.class);
-    Object[] args = new Object[]{null, getHttpHeaders(), getUriInfo()};
-    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
-
-    // getMpack
-    service = new TestMpackService("1");
-    m = service.getClass().getMethod("getMpack", String.class, HttpHeaders.class, UriInfo.class, String.class);
-    args = new Object[]{null, getHttpHeaders(), getUriInfo(), ""};
-    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
-
-    //createMpacks
-    service = new TestMpackService(null);
-    m = service.getClass().getMethod("createMpacks", String.class, HttpHeaders.class, UriInfo.class);
-    args = new Object[]{"body", getHttpHeaders(), getUriInfo()};
-    listInvocations.add(new ServiceTestInvocation(Request.Type.POST, service, m, args, "body"));
-
-    return listInvocations;
-  }
-  private class TestMpackService extends MpacksService {
-
-    private String m_mpackId;
-
-    private TestMpackService(String mpackId) {
-      super(ApiVersion.Default);
-      m_mpackId = mpackId;
-    }
-
-    @Override
-    protected ResourceInstance createResource(Resource.Type type, Map<Resource.Type, String> mapIds) {
-      return getTestResource();
-    }
-
-    @Override
-    RequestFactory getRequestFactory() {
-      return getTestRequestFactory();
-    }
-
-    @Override
-    protected RequestBodyParser getBodyParser() {
-      return getTestBodyParser();
-    }
-
-    @Override
-    protected ResultSerializer getResultSerializer() {
-      return getTestResultSerializer();
-    }
-  }
-
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/test/java/org/apache/ambari/server/api/services/MpacksServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/MpacksServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/MpacksServiceTest.java
new file mode 100644
index 0000000..d2c655a
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/MpacksServiceTest.java
@@ -0,0 +1,94 @@
+/**
+ * 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.api.services;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.ambari.server.api.resources.ResourceInstance;
+import org.apache.ambari.server.api.services.parsers.RequestBodyParser;
+import org.apache.ambari.server.api.services.serializers.ResultSerializer;
+
+import org.apache.ambari.server.api.util.ApiVersion;
+import org.apache.ambari.server.controller.spi.Resource;
+
+/**
+ * Unit tests for MpacksService
+ */
+public class MpacksServiceTest extends BaseServiceTest{
+  @Override
+  public List<BaseServiceTest.ServiceTestInvocation> getTestInvocations() throws Exception {
+    List<BaseServiceTest.ServiceTestInvocation> listInvocations = new ArrayList<>();
+
+    // getMpacks
+    MpacksService service = new TestMpacksService("null");
+    Method m = service.getClass().getMethod("getMpacks", String.class, HttpHeaders.class, UriInfo.class);
+    Object[] args = new Object[]{null, getHttpHeaders(), getUriInfo()};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getMpack
+    service = new TestMpacksService("1");
+    m = service.getClass().getMethod("getMpack", String.class, HttpHeaders.class, UriInfo.class, String.class);
+    args = new Object[]{null, getHttpHeaders(), getUriInfo(), ""};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    //createMpacks
+    service = new TestMpacksService(null);
+    m = service.getClass().getMethod("createMpacks", String.class, HttpHeaders.class, UriInfo.class);
+    args = new Object[]{"body", getHttpHeaders(), getUriInfo()};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.POST, service, m, args, "body"));
+
+    return listInvocations;
+  }
+  private class TestMpacksService extends MpacksService {
+
+    private String m_mpackId;
+
+    private TestMpacksService(String mpackId) {
+      super(ApiVersion.Default);
+      m_mpackId = mpackId;
+    }
+
+    @Override
+    protected ResourceInstance createResource(Resource.Type type, Map<Resource.Type, String> mapIds) {
+      return getTestResource();
+    }
+
+    @Override
+    RequestFactory getRequestFactory() {
+      return getTestRequestFactory();
+    }
+
+    @Override
+    protected RequestBodyParser getBodyParser() {
+      return getTestBodyParser();
+    }
+
+    @Override
+    protected ResultSerializer getResultSerializer() {
+      return getTestResultSerializer();
+    }
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
----------------------------------------------------------------------
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 b5161b2..c58cedd 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
@@ -24,30 +24,7 @@ import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.JAVA_VERS
 import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.NOT_MANAGED_HDFS_PATH_LIST;
 import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.STACK_NAME;
 import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.STACK_VERSION;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.security.authorization.Users;
-import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.ComponentInfo;
-import org.apache.ambari.server.state.Config;
-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.PropertyInfo;
-import org.apache.ambari.server.state.RepositoryInfo;
-import org.apache.ambari.server.state.RepositoryVersionState;
-import org.apache.ambari.server.state.SecurityType;
-import org.apache.ambari.server.state.Service;
-import org.apache.ambari.server.state.ServiceComponent;
-import org.apache.ambari.server.state.ServiceComponentHost;
-import org.apache.ambari.server.state.ServiceInfo;
-import org.apache.ambari.server.state.ServiceOsSpecific;
-import org.apache.ambari.server.state.StackId;
-import org.apache.ambari.server.state.StackInfo;
-import org.apache.ambari.server.state.State;
-import org.apache.ambari.server.state.Mpacks;
-import org.apache.ambari.server.state.Packlet;
+
 import static org.easymock.EasyMock.anyBoolean;
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.capture;
@@ -83,6 +60,7 @@ import java.util.Set;
 
 import javax.persistence.RollbackException;
 
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ClusterNotFoundException;
 import org.apache.ambari.server.HostNotFoundException;
@@ -90,22 +68,48 @@ import org.apache.ambari.server.ParentObjectNotFoundException;
 import org.apache.ambari.server.ServiceComponentHostNotFoundException;
 import org.apache.ambari.server.ServiceComponentNotFoundException;
 import org.apache.ambari.server.ServiceNotFoundException;
+
 import org.apache.ambari.server.actionmanager.ActionDBAccessorImpl;
 import org.apache.ambari.server.actionmanager.ActionManager;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.internal.RequestStageContainer;
+import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.orm.dao.ClusterVersionDAO;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
 import org.apache.ambari.server.orm.entities.LdapSyncSpecEntity;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
+import org.apache.ambari.server.security.authorization.Users;
 import org.apache.ambari.server.security.authorization.internal.InternalAuthenticationToken;
 import org.apache.ambari.server.security.encryption.CredentialStoreService;
 import org.apache.ambari.server.security.encryption.CredentialStoreType;
 import org.apache.ambari.server.security.ldap.AmbariLdapDataPopulator;
 import org.apache.ambari.server.security.ldap.LdapBatchDto;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.ComponentInfo;
+import org.apache.ambari.server.state.Config;
+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.Mpack;
+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.RepositoryVersionState;
+import org.apache.ambari.server.state.SecurityType;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.ServiceComponent;
+import org.apache.ambari.server.state.ServiceComponentHost;
+import org.apache.ambari.server.state.ServiceInfo;
+import org.apache.ambari.server.state.ServiceOsSpecific;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.StackInfo;
+import org.apache.ambari.server.state.State;
+
 import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.junit.Before;
@@ -2401,16 +2405,16 @@ public class AmbariManagementControllerImplTest {
   @Test
   public void testRegisterMpacks() throws Exception{
     MpackRequest mpackRequest = createNiceMock(MpackRequest.class);
-    Mpacks mpacks = new Mpacks();
-    mpacks.setMpackId((long)100);
-    mpacks.setPacklets(new ArrayList<Packlet>());
-    mpacks.setPrerequisites(new HashMap<String, String>());
-    mpacks.setRegistryId(new Long(100));
-    mpacks.setVersion("3.0");
-    mpacks.setMpacksUri("abc.tar.gz");
-    mpacks.setDescription("Test mpacks");
-    mpacks.setName("testMpack");
-    MpackResponse mpackResponse = new MpackResponse(mpacks);
+    Mpack mpack = new Mpack();
+    mpack.setMpackId((long)100);
+    mpack.setPacklets(new ArrayList<Packlet>());
+    mpack.setPrerequisites(new HashMap<String, String>());
+    mpack.setRegistryId(new Long(100));
+    mpack.setVersion("3.0");
+    mpack.setMpackUri("abc.tar.gz");
+    mpack.setDescription("Test mpack");
+    mpack.setName("testMpack");
+    MpackResponse mpackResponse = new MpackResponse(mpack);
     Injector injector = createNiceMock(Injector.class);
     expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(null).atLeastOnce();
     expect(ambariMetaInfo.registerMpack(mpackRequest)).andReturn(mpackResponse);

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/test/java/org/apache/ambari/server/controller/MpackRequestTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/MpackRequestTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/MpackRequestTest.java
index e858e54..694c499 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/MpackRequestTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/MpackRequestTest.java
@@ -18,8 +18,8 @@
 package org.apache.ambari.server.controller;
 
 
-import org.junit.Test;
 import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Unit tests for MpackRequest
@@ -28,15 +28,15 @@ public class MpackRequestTest {
   @Test
   public void testBasicGetAndSet() {
     MpackRequest mpackRequest =
-            new MpackRequest(new Long(1));
-    Assert.assertEquals("1", mpackRequest.getMpackId());
+            new MpackRequest(1L);
+    Assert.assertEquals((Long)1L, mpackRequest.getMpackId());
     mpackRequest.setMpackUri("abc.tar.gz");
-    mpackRequest.setRegistryId(new Long(1));
+    mpackRequest.setRegistryId(1L);
     mpackRequest.setMpackVersion("3.0");
     mpackRequest.setMpackName("testmpack");
 
     Assert.assertEquals("abc.tar.gz", mpackRequest.getMpackUri());
-    Assert.assertEquals("1", mpackRequest.getRegistryId());
+    Assert.assertEquals((Long)1L, mpackRequest.getRegistryId());
     Assert.assertEquals("3.0", mpackRequest.getMpackVersion());
     Assert.assertEquals("testmpack", mpackRequest.getMpackName());
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/test/java/org/apache/ambari/server/controller/MpackResponseTest.java
----------------------------------------------------------------------
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 c61d515..8cee9a9 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
@@ -17,38 +17,39 @@
  */
 package org.apache.ambari.server.controller;
 
-import org.apache.ambari.server.state.Mpacks;
-import org.apache.ambari.server.state.Packlet;
-import org.junit.Test;
-import org.junit.Assert;
 import java.util.ArrayList;
 import java.util.HashMap;
 
+import org.apache.ambari.server.state.Mpack;
+import org.apache.ambari.server.state.Packlet;
+import org.junit.Assert;
+import org.junit.Test;
+
 /**
  * Unit tests for MpackResponse
  */
 public class MpackResponseTest {
   @Test
   public void testBasicGetAndSet() {
-    MpackResponse mpackResponse = new MpackResponse(setupMpacks());
-    Assert.assertEquals(new Long(100), mpackResponse.getMpackId());
-    Assert.assertEquals("100",mpackResponse.getRegistryId());
+    MpackResponse mpackResponse = new MpackResponse(setupMpack());
+    Assert.assertEquals((Long)100L, mpackResponse.getMpackId());
+    Assert.assertEquals((Long)100L, mpackResponse.getRegistryId());
     Assert.assertEquals("3.0",mpackResponse.getMpackVersion());
     Assert.assertEquals("abc.tar.gz",mpackResponse.getMpackUri());
     Assert.assertEquals("testMpack", mpackResponse.getMpackName());
 
   }
-  public Mpacks setupMpacks(){
-    Mpacks mpacks = new Mpacks();
-    mpacks.setMpackId((long)100);
-    mpacks.setPacklets(new ArrayList<Packlet>());
-    mpacks.setPrerequisites(new HashMap<String, String>());
-    mpacks.setRegistryId(new Long(100));
-    mpacks.setVersion("3.0");
-    mpacks.setMpacksUri("abc.tar.gz");
-    mpacks.setDescription("Test mpacks");
-    mpacks.setName("testMpack");
+  public Mpack setupMpack() {
+    Mpack mpack = new Mpack();
+    mpack.setMpackId(100L);
+    mpack.setPacklets(new ArrayList<Packlet>());
+    mpack.setPrerequisites(new HashMap<String, String>());
+    mpack.setRegistryId(100L);
+    mpack.setVersion("3.0");
+    mpack.setMpackUri("abc.tar.gz");
+    mpack.setDescription("Test mpack");
+    mpack.setName("testMpack");
 
-    return mpacks;
+    return mpack;
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/MpackResourceProviderTest.java
----------------------------------------------------------------------
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 d6638c6..3a65e26 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
@@ -17,42 +17,44 @@
  */
 package org.apache.ambari.server.controller.internal;
 
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.persistence.EntityManager;
 
-import com.google.inject.Injector;
-import com.google.inject.Binder;
-import com.google.inject.Guice;
-import com.google.inject.util.Modules;
-import com.google.inject.Module;
 import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.MpackRequest;
 import org.apache.ambari.server.controller.MpackResponse;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
-import org.apache.ambari.server.controller.spi.Request;
-import org.apache.ambari.server.controller.spi.Predicate;
-import org.apache.ambari.server.controller.MpackRequest;
-import org.apache.ambari.server.controller.utilities.*;
+import org.apache.ambari.server.controller.utilities.PredicateBuilder;
+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.Mpacks;
+import org.apache.ambari.server.state.Mpack;
 import org.apache.ambari.server.state.Packlet;
 import org.easymock.EasyMock;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.verify;
-import org.junit.Test;
 import org.junit.Assert;
 import org.junit.Before;
+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;
 
-import javax.persistence.EntityManager;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.List;
 
 public class MpackResourceProviderTest {
 
@@ -212,7 +214,7 @@ public class MpackResourceProviderTest {
     MpackRequest mpackRequest = new MpackRequest();
     mpackRequest.setMpackUri("abc.tar.gz");
     Request request = createMock(Request.class);
-    MpackResponse response = new MpackResponse(setupMpacks());
+    MpackResponse response = new MpackResponse(setupMpack());
     Set<Map<String, Object>> properties = new HashSet<>();
     Map propertyMap = new HashMap();
     propertyMap.put(MpackResourceProvider.MPACK_URI,"abc.tar.gz");
@@ -253,18 +255,18 @@ public class MpackResourceProviderTest {
     verify(m_amc,request);
   }
 
-  public Mpacks setupMpacks(){
-    Mpacks mpacks = new Mpacks();
-    mpacks.setMpackId((long)100);
-    mpacks.setPacklets(new ArrayList<Packlet>());
-    mpacks.setPrerequisites(new HashMap<String, String>());
-    mpacks.setRegistryId(new Long(100));
-    mpacks.setVersion("3.0");
-    mpacks.setMpacksUri("abc.tar.gz");
-    mpacks.setDescription("Test mpacks");
-    mpacks.setName("testMpack");
-
-    return mpacks;
+  public Mpack setupMpack() {
+    Mpack mpack = new Mpack();
+    mpack.setMpackId((long)100);
+    mpack.setPacklets(new ArrayList<Packlet>());
+    mpack.setPrerequisites(new HashMap<String, String>());
+    mpack.setRegistryId(new Long(100));
+    mpack.setVersion("3.0");
+    mpack.setMpackUri("abc.tar.gz");
+    mpack.setDescription("Test mpack");
+    mpack.setName("testMpack");
+
+    return mpack;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestStageContainerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestStageContainerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestStageContainerTest.java
index 4fcc814..c001ab0 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestStageContainerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestStageContainerTest.java
@@ -18,7 +18,6 @@
 
 package org.apache.ambari.server.controller.internal;
 
-import static org.easymock.EasyMock.anyString;
 import static org.easymock.EasyMock.createNiceMock;
 import static org.easymock.EasyMock.createStrictMock;
 import static org.easymock.EasyMock.expect;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/MpackDAOTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/MpackDAOTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/MpackDAOTest.java
index 7b45815..64dae36 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/MpackDAOTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/MpackDAOTest.java
@@ -17,19 +17,22 @@
  */
 package org.apache.ambari.server.orm.dao;
 
-import com.google.inject.Injector;
-import com.google.inject.Guice;
-import org.apache.ambari.server.orm.entities.MpackEntity;
-import org.junit.Before;
-import org.junit.Test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
+import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.orm.entities.MpackEntity;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
 import com.google.inject.persist.UnitOfWork;
 
-import java.util.List;
-import java.util.ArrayList;
 
 /**
  * Tests {@link MpackDAO}.

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/MpackEntityTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/MpackEntityTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/MpackEntityTest.java
index 7948111..87ac934 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/MpackEntityTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/MpackEntityTest.java
@@ -18,11 +18,11 @@
 
 package org.apache.ambari.server.orm.entities;
 
-import org.junit.Test;
-import org.junit.Assert;
-
 import java.util.Objects;
 
+import org.junit.Assert;
+import org.junit.Test;
+
 /**
  * Tests methods on {@link MpackEntity}.
  */

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/test/java/org/apache/ambari/server/state/MpackTest.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..266dff5
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/MpackTest.java
@@ -0,0 +1,96 @@
+/**
+ * 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.state;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.google.gson.Gson;
+
+public class MpackTest {
+  @Test
+  public void testMpacks() {
+    Mpack mpack = new Mpack();
+    mpack.setName("name");
+    mpack.setMpackId((long)100);
+    mpack.setDescription("desc");
+    mpack.setVersion("3.0");
+    mpack.setMpackUri("abc.tar.gz");
+    mpack.setRegistryId(new Long(100));
+
+    Assert.assertEquals("name", mpack.getName());
+    Assert.assertEquals(new Long(100), mpack.getMpackId());
+    Assert.assertEquals("desc", mpack.getDescription());
+    Assert.assertEquals("abc.tar.gz", mpack.getMpackUri());
+    Assert.assertEquals(new Long(100), mpack.getRegistryId());
+
+  }
+
+  @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_dir\": \"packlets/NIFI-1.2.0.0-123.tar.gz\"\n" +
+            "    },\n" +
+            "    {\n" +
+            "      \"type\" : \"service-packlet\",\n" +
+            "      \"name\" : \"STREAMLINE\",\n" +
+            "      \"version\" : \"1.0.0.0-100\",\n" +
+            "      \"source_dir\": \"packlets/STREAMLINE-1.0.0.0-100.tar.gz\"\n" +
+            "    }\n" +
+            "  ]\n" +
+            "}\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("service-packlet");
+    nifi.setVersion("1.2.0.0-123");
+    nifi.setSourceDir("packlets/NIFI-1.2.0.0-123.tar.gz");
+    nifi.setName("NIFI");
+    Packlet streamline = new Packlet();
+    streamline.setName("STREAMLINE");
+    streamline.setType("service-packlet");
+    streamline.setSourceDir("packlets/STREAMLINE-1.0.0.0-100.tar.gz");
+    streamline.setVersion("1.0.0.0-100");
+    expectedPacklets.add(nifi);
+    expectedPacklets.add(streamline);
+
+    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(expectedPrereq, mpack.getPrerequisites());
+    Assert.assertEquals(expectedPacklets.toString(), mpack.getPacklets().toString());
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/test/java/org/apache/ambari/server/state/MpacksTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/MpacksTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/MpacksTest.java
deleted file mode 100644
index 6d87a60..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/MpacksTest.java
+++ /dev/null
@@ -1,95 +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
- *
- *     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.state;
-
-import com.google.gson.Gson;
-import org.junit.Test;
-import org.junit.Assert;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-public class MpacksTest {
-  @Test
-  public void testMpacks() {
-    Mpacks mpacks = new Mpacks();
-    mpacks.setName("name");
-    mpacks.setMpackId((long)100);
-    mpacks.setDescription("desc");
-    mpacks.setVersion("3.0");
-    mpacks.setMpacksUri("abc.tar.gz");
-    mpacks.setRegistryId(new Long(100));
-
-    Assert.assertEquals("name", mpacks.getName());
-    Assert.assertEquals(new Long(100), mpacks.getMpackId());
-    Assert.assertEquals("desc", mpacks.getDescription());
-    Assert.assertEquals("abc.tar.gz", mpacks.getMpacksUri());
-    Assert.assertEquals(new Long(100), mpacks.getRegistryId());
-
-  }
-
-  @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_dir\": \"packlets/NIFI-1.2.0.0-123.tar.gz\"\n" +
-            "    },\n" +
-            "    {\n" +
-            "      \"type\" : \"service-packlet\",\n" +
-            "      \"name\" : \"STREAMLINE\",\n" +
-            "      \"version\" : \"1.0.0.0-100\",\n" +
-            "      \"source_dir\": \"packlets/STREAMLINE-1.0.0.0-100.tar.gz\"\n" +
-            "    }\n" +
-            "  ]\n" +
-            "}\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("service-packlet");
-    nifi.setVersion("1.2.0.0-123");
-    nifi.setSourceDir("packlets/NIFI-1.2.0.0-123.tar.gz");
-    nifi.setName("NIFI");
-    Packlet streamline = new Packlet();
-    streamline.setName("STREAMLINE");
-    streamline.setType("service-packlet");
-    streamline.setSourceDir("packlets/STREAMLINE-1.0.0.0-100.tar.gz");
-    streamline.setVersion("1.0.0.0-100");
-    expectedPacklets.add(nifi);
-    expectedPacklets.add(streamline);
-
-    Gson gson = new Gson();
-    Mpacks mpacks = gson.fromJson(mpackJsonContents, Mpacks.class);
-    Assert.assertEquals("hdf-ambari-mpack",mpacks.getName());
-    Assert.assertEquals("3.0.0.0-111", mpacks.getVersion());
-    Assert.assertEquals("HDF 3.0.0 Ambari Management Pack",mpacks.getDescription());
-    Assert.assertEquals(expectedPrereq, mpacks.getPrerequisites());
-    Assert.assertEquals(expectedPacklets.toString(), mpacks.getPacklets().toString());
-  }
-
-}


[2/2] ambari git commit: AMBARI-21425: Add Rest API endpoint for software registry (jluniya)

Posted by jl...@apache.org.
AMBARI-21425: Add Rest API endpoint for software registry (jluniya)


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

Branch: refs/heads/branch-feature-AMBARI-14714
Commit: 6fdf4d11642c213893c396b2d49a35a22cdf7961
Parents: 7849de6
Author: Jayush Luniya <jl...@hortonworks.com>
Authored: Fri Jul 7 13:17:16 2017 -0700
Committer: Jayush Luniya <jl...@hortonworks.com>
Committed: Fri Jul 7 13:17:16 2017 -0700

----------------------------------------------------------------------
 .../api/resources/MpackResourceDefinition.java  |   8 +-
 .../resources/RegistryResourceDefinition.java   |  38 +++
 .../resources/ResourceInstanceFactoryImpl.java  |   4 +
 .../StackVersionResourceDefinition.java         |   1 +
 .../api/services/AbstractVersionService.java    |  12 +-
 .../server/api/services/AmbariMetaInfo.java     |   7 +-
 .../server/api/services/MpacksService.java      |   9 +-
 .../server/api/services/RegistryService.java    |  99 +++++++
 .../controller/AmbariManagementController.java  |  23 +-
 .../AmbariManagementControllerImpl.java         | 101 +++++--
 .../server/controller/ControllerModule.java     |   8 +
 .../ambari/server/controller/MpackResponse.java |  16 +-
 .../server/controller/RegistryRequest.java      |  67 +++++
 .../server/controller/RegistryResponse.java     |  90 ++++++
 .../AbstractControllerResourceProvider.java     |   2 +
 .../internal/DefaultProviderModule.java         |   2 +
 .../internal/MpackResourceProvider.java         |  38 +--
 .../internal/RegistryResourceProvider.java      | 230 ++++++++++++++++
 .../internal/StageResourceProvider.java         |   1 -
 .../ambari/server/controller/spi/Resource.java  |   2 +
 .../exceptions/RegistryNotFoundException.java   |  33 +++
 .../ambari/server/mpack/MpackManager.java       | 126 ++++-----
 .../server/mpack/MpackManagerFactory.java       |   4 +-
 .../apache/ambari/server/orm/dao/MpackDAO.java  |  17 +-
 .../ambari/server/orm/dao/RegistryDAO.java      | 101 +++++++
 .../ambari/server/orm/entities/MpackEntity.java |  21 +-
 .../server/orm/entities/RegistryEntity.java     | 146 ++++++++++
 .../apache/ambari/server/registry/Registry.java |  47 ++++
 .../ambari/server/registry/RegistryFactory.java |  29 ++
 .../ambari/server/registry/RegistryImpl.java    |  96 +++++++
 .../ambari/server/registry/RegistryManager.java |  59 ++++
 .../server/registry/RegistryManagerImpl.java    | 147 ++++++++++
 .../ambari/server/registry/RegistryType.java    |  29 ++
 .../org/apache/ambari/server/state/Mpack.java   | 271 +++++++++++++++++++
 .../org/apache/ambari/server/state/Mpacks.java  | 271 -------------------
 .../server/upgrade/UpgradeCatalog251.java       |   5 +-
 .../main/resources/Ambari-DDL-Derby-CREATE.sql  |  15 +-
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  |  14 +-
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql |  14 +-
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |  14 +-
 .../resources/Ambari-DDL-SQLAnywhere-CREATE.sql |  18 +-
 .../resources/Ambari-DDL-SQLServer-CREATE.sql   |  14 +-
 .../src/main/resources/META-INF/persistence.xml |   1 +
 .../resources/MpackResourceDefinitionTest.java  |   1 +
 .../server/api/services/AmbariMetaInfoTest.java |  66 ++---
 .../server/api/services/MpackServiceTest.java   |  94 -------
 .../server/api/services/MpacksServiceTest.java  |  94 +++++++
 .../AmbariManagementControllerImplTest.java     |  72 ++---
 .../server/controller/MpackRequestTest.java     |  10 +-
 .../server/controller/MpackResponseTest.java    |  37 +--
 .../internal/MpackResourceProviderTest.java     |  70 ++---
 .../internal/RequestStageContainerTest.java     |   1 -
 .../ambari/server/orm/dao/MpackDAOTest.java     |  19 +-
 .../server/orm/entities/MpackEntityTest.java    |   6 +-
 .../apache/ambari/server/state/MpackTest.java   |  96 +++++++
 .../apache/ambari/server/state/MpacksTest.java  |  95 -------
 56 files changed, 2126 insertions(+), 785 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/api/resources/MpackResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/MpackResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/MpackResourceDefinition.java
index 26972d8..aaf7fd9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/MpackResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/MpackResourceDefinition.java
@@ -17,6 +17,10 @@
  */
 package org.apache.ambari.server.api.resources;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.ambari.server.api.services.Request;
 import org.apache.ambari.server.api.util.TreeNode;
 import org.apache.ambari.server.controller.internal.ResourceImpl;
@@ -25,10 +29,6 @@ import org.apache.ambari.server.controller.spi.Resource.Type;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Map;
-import java.util.List;
-import java.util.ArrayList;
-
 /**
  * Resource Definition for Mpack Resource types.
  */

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RegistryResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RegistryResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RegistryResourceDefinition.java
new file mode 100644
index 0000000..e48b058
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RegistryResourceDefinition.java
@@ -0,0 +1,38 @@
+/**
+ * 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.api.resources;
+
+import org.apache.ambari.server.controller.spi.Resource.Type;
+
+/**
+ * Resource Definition for Registry Resource types.
+ */
+public class RegistryResourceDefinition extends BaseResourceDefinition {
+
+    public RegistryResourceDefinition() {
+        super(Type.Registry);
+    }
+
+    @Override public String getPluralName() {
+        return "registries";
+    }
+
+    @Override public String getSingularName() {
+        return "registry";
+    }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
index 1466b86..5a68353 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
@@ -153,6 +153,10 @@ public class ResourceInstanceFactoryImpl implements ResourceInstanceFactory {
         resourceDefinition = new MemberResourceDefinition();
         break;
 
+      case Registry:
+        resourceDefinition = new RegistryResourceDefinition();
+        break;
+
       case Mpack:
         resourceDefinition = new MpackResourceDefinition();
         break;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackVersionResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackVersionResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackVersionResourceDefinition.java
index 5b32c06..3cbde0c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackVersionResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackVersionResourceDefinition.java
@@ -20,6 +20,7 @@ package org.apache.ambari.server.api.resources;
 
 import java.util.HashSet;
 import java.util.Set;
+
 import org.apache.ambari.server.controller.spi.Resource;
 
 public class StackVersionResourceDefinition extends BaseResourceDefinition {

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/api/services/AbstractVersionService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AbstractVersionService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AbstractVersionService.java
index 2d81602..a5712d4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AbstractVersionService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AbstractVersionService.java
@@ -349,6 +349,16 @@ public abstract class AbstractVersionService {
   }
 
   /**
+   * Handles /registries request.
+   *
+   * @return registry service
+   */
+  @Path("/registries")
+  public RegistryService getRegistryService(@PathParam("apiVersion") String apiVersion) {
+    return new RegistryService(ApiVersion.valueOf(apiVersion));
+  }
+
+  /**
    * Handles /mpacks request.
    *
    * @return mpacks service
@@ -357,6 +367,4 @@ public abstract class AbstractVersionService {
   public MpacksService getMpacksService(@PathParam("apiVersion") String apiVersion) {
     return new MpacksService(ApiVersion.valueOf(apiVersion));
   }
-
-
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
----------------------------------------------------------------------
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 a68bf48..5b93f53 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
@@ -59,7 +59,6 @@ import org.apache.ambari.server.mpack.MpackManager;
 import org.apache.ambari.server.mpack.MpackManagerFactory;
 import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
 import org.apache.ambari.server.orm.dao.MetainfoDAO;
-import org.apache.ambari.server.orm.dao.StackDAO;
 import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
 import org.apache.ambari.server.orm.entities.MetainfoEntity;
 import org.apache.ambari.server.stack.StackDirectory;
@@ -71,13 +70,13 @@ 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.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;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.StackInfo;
-import org.apache.ambari.server.state.Packlet;
 import org.apache.ambari.server.state.alert.AlertDefinition;
 import org.apache.ambari.server.state.alert.AlertDefinitionFactory;
 import org.apache.ambari.server.state.kerberos.KerberosDescriptor;
@@ -278,8 +277,8 @@ public class AmbariMetaInfo {
 
     customActionRoot = new File(conf.getCustomActionDefinitionPath());
 
-    String mpackV2StagingPath = conf.getMpacksV2StagingPath();
-    mpacksV2Staging = new File(mpackV2StagingPath);
+    String mpacksV2StagingPath = conf.getMpacksV2StagingPath();
+    mpacksV2Staging = new File(mpacksV2StagingPath);
 
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/api/services/MpacksService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/MpacksService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/MpacksService.java
index 9912f88..47c1af4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/MpacksService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/MpacksService.java
@@ -17,10 +17,8 @@
  */
 package org.apache.ambari.server.api.services;
 
-import org.apache.ambari.server.api.resources.ResourceInstance;
+import java.util.Collections;
 
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.api.util.ApiVersion;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
@@ -30,7 +28,10 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
-import java.util.Collections;
+
+import org.apache.ambari.server.api.resources.ResourceInstance;
+import org.apache.ambari.server.api.util.ApiVersion;
+import org.apache.ambari.server.controller.spi.Resource;
 
 /**
  * Service for Mpacks Management.

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/api/services/RegistryService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/RegistryService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RegistryService.java
new file mode 100644
index 0000000..5f1a0e4
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RegistryService.java
@@ -0,0 +1,99 @@
+/**
+ * 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.api.services;
+
+import java.util.Collections;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.ambari.server.api.resources.ResourceInstance;
+import org.apache.ambari.server.api.util.ApiVersion;
+import org.apache.ambari.server.controller.spi.Resource;
+
+public class RegistryService extends BaseService {
+
+    public RegistryService(final ApiVersion apiVersion) {
+        super(apiVersion);
+    }
+
+    /**
+     * Handles: POST /registries/
+     *
+     * @param headers http headers
+     * @param ui      uri info
+     * @param body    request body
+     * @return information regarding the softare registry
+     */
+    @POST
+    @Produces("text/plain")
+    public Response createRegistries(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
+        return handleRequest(headers, body, ui, Request.Type.POST, createRegistryResource(null));
+    }
+
+    /**
+     * Handles: GET /registries/
+     *
+     * @param headers http headers
+     * @param ui      uri info
+     * @param body    request body
+     * @return All software registries
+     *
+     */
+    @GET
+    @Produces("text/plain")
+    public Response getRegistries(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
+        return handleRequest(headers, body, ui, Request.Type.GET,
+                createRegistryResource(null));
+    }
+
+
+    /***
+     * Handles: GET /registries/{registry_id}
+     * Return a specific software registry given an registry_id
+     *
+     * @param
+     */
+    @GET
+    @Path("{registry_id}")
+    @Produces("text/plain")
+    public Response getRegistry(String body, @Context HttpHeaders headers, @Context UriInfo ui,
+            @PathParam("registry_id") String registryId) {
+
+        return handleRequest(headers, body, ui, Request.Type.GET,
+                createRegistryResource(registryId));
+    }
+
+    /**
+     * Create an software registry resource instance
+     * @param registryId
+     * @return ResourceInstance
+     */
+    private ResourceInstance createRegistryResource(String registryId) {
+        return createResource(Resource.Type.Registry,
+                Collections.singletonMap(Resource.Type.Registry, registryId));
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
----------------------------------------------------------------------
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 de7ef5e..ab4c256 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
@@ -19,11 +19,11 @@
 package org.apache.ambari.server.controller;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.ArrayList;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.RoleCommand;
@@ -55,6 +55,7 @@ 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.Packlet;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.ServiceComponentFactory;
@@ -62,7 +63,6 @@ import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.state.ServiceOsSpecific;
 import org.apache.ambari.server.state.State;
-import org.apache.ambari.server.state.Packlet;
 import org.apache.ambari.server.state.configgroup.ConfigGroupFactory;
 import org.apache.ambari.server.state.quicklinksprofile.QuickLinkVisibilityController;
 import org.apache.ambari.server.state.scheduler.RequestExecutionFactory;
@@ -150,6 +150,13 @@ public interface AmbariManagementController {
   void createMembers(Set<MemberRequest> requests) throws AmbariException;
 
   /**
+   * Add a software registry.
+   *
+   * @param request the request object which defines the software registry to be added
+   */
+  RegistryResponse addRegistry(RegistryRequest request);
+
+  /**
    * Register the mpack defined by the attributes in the given request object.
    *
    * @param request the request object which defines the mpack to be created
@@ -941,5 +948,17 @@ public interface AmbariManagementController {
    * @return List of packlets
    */
   ArrayList<Packlet> getPacklets(Long mpackId);
+
+  /**
+   * Get the software registries identified by the given request objects.
+   *
+   * @param requests  the request objects which identify the software registries to be returned
+   *
+   * @return a set of software registry responses
+   *
+   * @throws AmbariException thrown if the resource cannot be read
+   */
+  Set<RegistryResponse> getRegistries(Set<RegistryRequest> requests)
+    throws AmbariException;
 }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
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 8a564c9..471e924 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
@@ -131,6 +131,8 @@ import org.apache.ambari.server.orm.entities.SettingEntity;
 import org.apache.ambari.server.orm.entities.WidgetEntity;
 import org.apache.ambari.server.orm.entities.WidgetLayoutEntity;
 import org.apache.ambari.server.orm.entities.WidgetLayoutUserWidgetEntity;
+import org.apache.ambari.server.registry.Registry;
+import org.apache.ambari.server.registry.RegistryManager;
 import org.apache.ambari.server.scheduler.ExecutionScheduleManager;
 import org.apache.ambari.server.security.authorization.AuthorizationException;
 import org.apache.ambari.server.security.authorization.AuthorizationHelper;
@@ -153,40 +155,41 @@ import org.apache.ambari.server.stack.ExtensionHelper;
 import org.apache.ambari.server.stack.RepoUtil;
 import org.apache.ambari.server.stageplanner.RoleGraph;
 import org.apache.ambari.server.stageplanner.RoleGraphFactory;
-import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.ServiceComponentFactory;
-import org.apache.ambari.server.state.ServiceComponentHostFactory;
-import org.apache.ambari.server.state.ConfigFactory;
-import org.apache.ambari.server.state.StackId;
+
 import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.ConfigHelper;
-import org.apache.ambari.server.state.StackInfo;
-import org.apache.ambari.server.state.State;
-import org.apache.ambari.server.state.Service;
-import org.apache.ambari.server.state.ServiceComponent;
-import org.apache.ambari.server.state.Host;
-import org.apache.ambari.server.state.ServiceComponentHost;
+import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.CommandScriptDefinition;
-import org.apache.ambari.server.state.PropertyInfo.PropertyType;
-import org.apache.ambari.server.state.configgroup.ConfigGroupFactory;
-import org.apache.ambari.server.state.PropertyInfo;
+import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.Config;
+import org.apache.ambari.server.state.ConfigFactory;
+import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.DesiredConfig;
+import org.apache.ambari.server.state.ExtensionInfo;
+import org.apache.ambari.server.state.Host;
+import org.apache.ambari.server.state.HostComponentAdminState;
+import org.apache.ambari.server.state.HostState;
 import org.apache.ambari.server.state.MaintenanceState;
+import org.apache.ambari.server.state.OperatingSystemInfo;
+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;
+import org.apache.ambari.server.state.RepositoryInfo;
+import org.apache.ambari.server.state.RepositoryVersionState;
 import org.apache.ambari.server.state.SecurityType;
-import org.apache.ambari.server.state.HostState;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.ServiceComponent;
+import org.apache.ambari.server.state.ServiceComponentFactory;
+import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.ServiceComponentHostEvent;
-import org.apache.ambari.server.state.ComponentInfo;
+import org.apache.ambari.server.state.ServiceComponentHostFactory;
 import org.apache.ambari.server.state.ServiceInfo;
-import org.apache.ambari.server.state.RepositoryVersionState;
 import org.apache.ambari.server.state.ServiceOsSpecific;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.StackInfo;
+import org.apache.ambari.server.state.State;
 import org.apache.ambari.server.state.UnlimitedKeyJCERequirement;
-import org.apache.ambari.server.state.ExtensionInfo;
-import org.apache.ambari.server.state.RepositoryInfo;
-import org.apache.ambari.server.state.OperatingSystemInfo;
-import org.apache.ambari.server.state.Packlet;
-import org.apache.ambari.server.state.HostComponentAdminState;
-import org.apache.ambari.server.state.PropertyDependencyInfo;
+import org.apache.ambari.server.state.configgroup.ConfigGroupFactory;
 import org.apache.ambari.server.state.quicklinksprofile.QuickLinkVisibilityController;
 import org.apache.ambari.server.state.quicklinksprofile.QuickLinkVisibilityControllerFactory;
 import org.apache.ambari.server.state.quicklinksprofile.QuickLinksProfile;
@@ -274,6 +277,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
   @Inject
   private AmbariMetaInfo ambariMetaInfo;
   @Inject
+  private RegistryManager registryManager;
+  @Inject
   private Users users;
   @Inject
   private HostsMap hostsMap;
@@ -512,8 +517,54 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     }
   }
 
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public RegistryResponse addRegistry(RegistryRequest request) {
+    Registry registry = registryManager.addRegistry(
+      request.getRegistryName(), request.getRegistryType(), request.getRegistryUri());
+    return new RegistryResponse(registry);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public Set<RegistryResponse> getRegistries(Set<RegistryRequest> requests)
+    throws AmbariException {
+    Set<RegistryResponse> responses = new HashSet<>();
+    for (RegistryRequest request : requests) {
+      responses.addAll(getRegistries(request));
+    }
+    return responses;
+  }
+
+  private Set<RegistryResponse> getRegistries(RegistryRequest request)
+    throws AmbariException {
+    Set<RegistryResponse> responses;
+
+    Long registryId = request.getRegistryId();
+
+    if (registryId != null) {
+      Registry registry = registryManager.getRegistry(registryId);
+      responses = Collections.singleton(new RegistryResponse(registry));
+    } else {
+      Collection<Registry> registries = registryManager.getRegistries().values();
+      responses = new HashSet<>();
+      for (Registry registry: registries) {
+        responses.add(new RegistryResponse(registry));
+      }
+    }
+    return responses;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
   @Override
-  public MpackResponse registerMpack(MpackRequest request) throws IOException, AuthorizationException, ResourceAlreadyExistsException{
+  public MpackResponse registerMpack(MpackRequest request)
+    throws IOException, AuthorizationException, ResourceAlreadyExistsException{
     MpackResponse mpackResponse = ambariMetaInfo.registerMpack(request);
     updateStacks();
     return mpackResponse;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
index 404f394..b5f99bf 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
@@ -101,6 +101,11 @@ import org.apache.ambari.server.orm.DBAccessor;
 import org.apache.ambari.server.orm.DBAccessorImpl;
 import org.apache.ambari.server.orm.PersistenceType;
 import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
+import org.apache.ambari.server.registry.Registry;
+import org.apache.ambari.server.registry.RegistryFactory;
+import org.apache.ambari.server.registry.RegistryImpl;
+import org.apache.ambari.server.registry.RegistryManager;
+import org.apache.ambari.server.registry.RegistryManagerImpl;
 import org.apache.ambari.server.scheduler.ExecutionScheduler;
 import org.apache.ambari.server.scheduler.ExecutionSchedulerImpl;
 import org.apache.ambari.server.security.SecurityHelper;
@@ -347,6 +352,7 @@ public class ControllerModule extends AbstractModule {
     bind(SecureRandom.class).in(Scopes.SINGLETON);
 
     bind(Clusters.class).to(ClustersImpl.class);
+    bind(RegistryManager.class).to(RegistryManagerImpl.class);
     bind(AmbariCustomCommandExecutionHelper.class);
     bind(ActionDBAccessor.class).to(ActionDBAccessorImpl.class);
     bindConstant().annotatedWith(Names.named("schedulerSleeptime")).to(
@@ -494,6 +500,8 @@ public class ControllerModule extends AbstractModule {
     install(new FactoryModuleBuilder().build(MetricPropertyProviderFactory.class));
     install(new FactoryModuleBuilder().build(UpgradeContextFactory.class));
     install(new FactoryModuleBuilder().build(MpackManagerFactory.class));
+    install(new FactoryModuleBuilder().implement(
+      Registry.class, RegistryImpl.class).build(RegistryFactory.class));
 
     bind(HostRoleCommandFactory.class).to(HostRoleCommandFactoryImpl.class);
     bind(SecurityHelper.class).toInstance(SecurityHelperImpl.getInstance());

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/controller/MpackResponse.java
----------------------------------------------------------------------
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 d111913..76b0aba 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
@@ -17,7 +17,7 @@
  */
 package org.apache.ambari.server.controller;
 
-import org.apache.ambari.server.state.Mpacks;
+import org.apache.ambari.server.state.Mpack;
 
 /**
  * Represents a mpack response.
@@ -31,13 +31,13 @@ public class MpackResponse {
   private Long registryId;
   private String stackId;
 
-  public MpackResponse(Mpacks mpacks) {
-    this.mpackId = mpacks.getMpackId();
-    this.mpackVersion = mpacks.getVersion();
-    this.mpackUri = mpacks.getMpacksUri();
-    this.mpackName = mpacks.getName();
-    this.registryId = mpacks.getRegistryId();
-    this.stackId = mpacks.getStackId();
+  public MpackResponse(Mpack mpack) {
+    this.mpackId = mpack.getMpackId();
+    this.mpackVersion = mpack.getVersion();
+    this.mpackUri = mpack.getMpackUri();
+    this.mpackName = mpack.getName();
+    this.registryId = mpack.getRegistryId();
+    this.stackId = mpack.getStackId();
   }
 
   public String getMpackVersion() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryRequest.java
new file mode 100644
index 0000000..04f354f
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryRequest.java
@@ -0,0 +1,67 @@
+/**
+ * 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.controller;
+
+import org.apache.ambari.server.registry.RegistryType;
+
+public class RegistryRequest {
+    private Long registryId;
+    private String registryName;
+    private RegistryType registryType;
+    private String registryUri;
+
+    public RegistryRequest(Long registryId, String registryName, RegistryType registryType, String registryUri) {
+        this.registryId = registryId;
+        this.registryName = registryName;
+        this.registryType = registryType;
+        this.registryUri = registryUri;
+    }
+
+    public Long getRegistryId() {
+        return registryId;
+    }
+
+    public void setRegistryId(Long registryId) {
+        this.registryId = registryId;
+    }
+
+    public String getRegistryName() {
+        return registryName;
+    }
+
+    public void setRegistryName(String registryName) {
+        this.registryName = registryName;
+    }
+
+    public RegistryType getRegistryType() {
+        return registryType;
+    }
+
+    public void setRegistryType(RegistryType registryType) {
+        this.registryType = registryType;
+    }
+
+    public String getRegistryUri() {
+        return registryUri;
+    }
+
+    public void setRegistryUri(String registryUri) {
+        this.registryUri = registryUri;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryResponse.java
new file mode 100644
index 0000000..adb512c
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryResponse.java
@@ -0,0 +1,90 @@
+/**
+ * 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.controller;
+
+import org.apache.ambari.server.registry.Registry;
+import org.apache.ambari.server.registry.RegistryType;
+
+/**
+ * Represents a software registry response.
+ */
+public class RegistryResponse {
+    private Long registryId;
+    private String registryName;
+    private RegistryType registryType;
+    private String registryUri;
+
+    public RegistryResponse(Registry registry) {
+        this.registryId = registry.getRegistryId();
+        this.registryName = registry.getRegistryName();
+        this.registryType = registry.getRegistryType();
+        this.registryUri = registry.getRegistryUri();
+    }
+
+    public Long getRegistryId() {
+        return registryId;
+    }
+
+    public void setRegistryId(Long registryId) {
+        this.registryId = registryId;
+    }
+
+    public String getRegistryName() {
+        return registryName;
+    }
+
+    public void setRegistryName(String registryName) {
+        this.registryName = registryName;
+    }
+
+    public RegistryType getRegistryType() {
+        return registryType;
+    }
+
+    public void setRegistryType(RegistryType registryType) {
+        this.registryType = registryType;
+    }
+
+    public String getRegistryUri() {
+        return registryUri;
+    }
+
+
+    public void setRegistryUri(String registryUri) {
+        this.registryUri = registryUri;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+        result = 31 + getRegistryId().hashCode();
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof RegistryResponse)) {
+            return false;
+        }
+        if (this == obj) {
+            return true;
+        }
+        RegistryResponse registryResponse = (RegistryResponse) obj;
+        return getRegistryId().equals(registryResponse.getRegistryId());
+    }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
index 92d4890..2874d94 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
@@ -157,6 +157,8 @@ public abstract class AbstractControllerResourceProvider extends AbstractAuthori
         return resourceProviderFactory.getUpgradeResourceProvider(managementController);
       case Stack:
         return new StackResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case Registry:
+        return new RegistryResourceProvider(managementController);
       case Mpack:
         return new MpackResourceProvider(managementController);
       case StackVersion:

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java
index e7ecd65..2714ac4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java
@@ -90,6 +90,8 @@ public class DefaultProviderModule extends AbstractProviderModule {
         return new GroupPrivilegeResourceProvider();
       case Alert:
         return new AlertResourceProvider(managementController);
+      case Registry:
+        return new RegistryResourceProvider(managementController);
       case Mpack:
         return new MpackResourceProvider(managementController);
       case AlertDefinition:

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java
----------------------------------------------------------------------
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 6f90e04..99a28cb 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
@@ -18,31 +18,30 @@
 package org.apache.ambari.server.controller.internal;
 
 import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Map;
-import java.util.HashMap;
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.LinkedHashSet;
-import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
-import com.google.inject.Inject;
 import org.apache.ambari.server.StaticallyInject;
 import org.apache.ambari.server.api.services.parsers.BodyParseException;
-import org.apache.ambari.server.controller.spi.RequestStatus;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.MpackRequest;
+import org.apache.ambari.server.controller.MpackResponse;
 import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
 import org.apache.ambari.server.controller.spi.NoSuchResourceException;
-import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
-import org.apache.ambari.server.controller.spi.SystemException;
-import org.apache.ambari.server.controller.spi.Request;
 import org.apache.ambari.server.controller.spi.Predicate;
-import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
 import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.AmbariManagementController;
-import org.apache.ambari.server.controller.MpackResponse;
-import org.apache.ambari.server.controller.MpackRequest;
+import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
 import org.apache.ambari.server.controller.utilities.PredicateHelper;
 import org.apache.ambari.server.orm.dao.MpackDAO;
 import org.apache.ambari.server.orm.dao.StackDAO;
@@ -50,6 +49,8 @@ import org.apache.ambari.server.orm.entities.MpackEntity;
 import org.apache.ambari.server.orm.entities.StackEntity;
 import org.apache.ambari.server.state.Packlet;
 
+import com.google.inject.Inject;
+
 /**
  * ResourceProvider for Mpack instances
  */
@@ -113,8 +114,8 @@ public class MpackResourceProvider extends AbstractControllerResourceProvider {
 
   @Override
   public RequestStatus createResources(final Request request)
-          throws SystemException, UnsupportedPropertyException,
-          ResourceAlreadyExistsException, NoSuchParentResourceException, IllegalArgumentException {
+    throws SystemException, UnsupportedPropertyException, ResourceAlreadyExistsException,
+    NoSuchParentResourceException, IllegalArgumentException {
     Set<Resource> associatedResources = new HashSet<>();
     try {
       MpackRequest mpackRequest = getRequest(request);
@@ -169,8 +170,8 @@ public class MpackResourceProvider extends AbstractControllerResourceProvider {
 
     Set<Resource> results = new LinkedHashSet<>();
     Long mpackId = null;
-    //Fetch all mpacks
     if (predicate == null) {
+      // Fetch all mpacks
       List<MpackEntity> entities = mpackDAO.findAll();
       if (null == entities) {
         entities = Collections.emptyList();
@@ -184,8 +185,9 @@ public class MpackResourceProvider extends AbstractControllerResourceProvider {
         resource.setProperty(REGISTRY_ID, entity.getRegistryId());
         results.add(resource);
       }
-    } //Fetch a particular mpack based on id
+    }
     else {
+      // Fetch a particular mpack based on id
       Map<String, Object> propertyMap = new HashMap<>(PredicateHelper.getProperties(predicate));
       if (propertyMap.containsKey(STACK_NAME_PROPERTY_ID) && propertyMap.containsKey(STACK_VERSION_PROPERTY_ID)) {
         String stackName = (String) propertyMap.get(STACK_NAME_PROPERTY_ID);

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryResourceProvider.java
new file mode 100644
index 0000000..112b30f
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryResourceProvider.java
@@ -0,0 +1,230 @@
+/**
+ * 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.controller.internal;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.StaticallyInject;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.RegistryRequest;
+import org.apache.ambari.server.controller.RegistryResponse;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.registry.RegistryType;
+import org.apache.commons.lang.Validate;
+
+/**
+ * ResourceProvider for software registry
+ */
+@StaticallyInject
+public class RegistryResourceProvider extends AbstractControllerResourceProvider {
+  public static final String REGISTRY_ID = "RegistryInfo/registry_id";
+  public static final String REGISTRY_NAME = "RegistryInfo/registry_name";
+  public static final String REGISTRY_TYPE = "RegistryInfo/registry_type";
+  public static final String REGISTRY_URI = "RegistryInfo/registry_uri";
+
+  private static Set<String> pkPropertyIds = new HashSet<>(
+    Arrays.asList(REGISTRY_ID, REGISTRY_NAME));
+
+  /**
+   * The property ids for a software registry resource.
+   */
+  private static final Set<String> PROPERTY_IDS = new HashSet<>();
+
+  /**
+   * The key property ids for a software registry resource.
+   */
+  private static final Map<Resource.Type, String> KEY_PROPERTY_IDS = new HashMap<>();
+
+  static {
+    // properties
+    PROPERTY_IDS.add(REGISTRY_ID);
+    PROPERTY_IDS.add(REGISTRY_NAME);
+    PROPERTY_IDS.add(REGISTRY_TYPE);
+    PROPERTY_IDS.add(REGISTRY_URI);
+
+    // keys
+    KEY_PROPERTY_IDS.put(Resource.Type.Registry, REGISTRY_ID);
+
+  }
+
+  /**
+   * Create a  new resource provider for the given management controller.
+   *
+   * @param managementController the management controller
+   */
+  protected RegistryResourceProvider(
+    final AmbariManagementController managementController) {
+    super(PROPERTY_IDS, KEY_PROPERTY_IDS, managementController);
+  }
+
+  @Override
+  protected Set<String> getPKPropertyIds() {
+    return pkPropertyIds;
+  }
+
+  @Override
+  public RequestStatus createResourcesAuthorized(Request request)
+    throws SystemException,
+    UnsupportedPropertyException,
+    ResourceAlreadyExistsException,
+    NoSuchParentResourceException {
+
+    final Set<RegistryRequest> requests = new HashSet<>();
+    for (Map<String, Object> propertyMap : request.getProperties()) {
+      RegistryRequest registryRequest = getRequest(propertyMap);
+      if(registryRequest.getRegistryType() == null) {
+        registryRequest.setRegistryType(RegistryType.JSON);
+      }
+      requests.add(registryRequest);
+    }
+    Set<RegistryResponse> responses = createResources(new Command<Set<RegistryResponse>>() {
+      @Override
+      public Set<RegistryResponse> invoke() throws AmbariException {
+        return addRegistries(requests);
+      }
+    });
+    notifyCreate(Resource.Type.Registry, request);
+
+    Set<Resource> associatedResources = new HashSet<>();
+    for(RegistryResponse response : responses) {
+      Resource resource = new ResourceImpl(Resource.Type.Registry);
+      resource.setProperty(REGISTRY_ID, response.getRegistryId());
+      resource.setProperty(REGISTRY_NAME, response.getRegistryName());
+      resource.setProperty(REGISTRY_TYPE, response.getRegistryType());
+      resource.setProperty(REGISTRY_URI, response.getRegistryUri());
+      associatedResources.add(resource);
+    }
+    return getRequestStatus(null, associatedResources);
+  }
+
+  @Override
+  public Set<Resource> getResourcesAuthorized(Request request, Predicate predicate)
+    throws SystemException, UnsupportedPropertyException,
+    NoSuchResourceException, NoSuchParentResourceException {
+
+    final Set<RegistryRequest> requests = new HashSet<>();
+
+    if (predicate == null) {
+      requests.add(getRequest(Collections.<String, Object>emptyMap()));
+    } else {
+      for (Map<String, Object> propertyMap : getPropertyMaps(predicate)) {
+        requests.add(getRequest(propertyMap));
+      }
+    }
+
+    Set<String> requestedIds = getRequestPropertyIds(request, predicate);
+
+    Set<RegistryResponse> responses = getResources(new Command<Set<RegistryResponse>>() {
+      @Override
+      public Set<RegistryResponse> invoke() throws AmbariException {
+        return getManagementController().getRegistries(requests);
+      }
+    });
+
+    Set<Resource> resources = new HashSet<>();
+    for (RegistryResponse response : responses) {
+      Resource resource = new ResourceImpl(Resource.Type.Registry);
+      setResourceProperty(resource, REGISTRY_ID, response.getRegistryId(), requestedIds);
+      setResourceProperty(resource, REGISTRY_NAME, response.getRegistryName(), requestedIds);
+      setResourceProperty(resource, REGISTRY_TYPE, response.getRegistryType(), requestedIds);
+      setResourceProperty(resource, REGISTRY_URI, response.getRegistryUri(), requestedIds);
+      resources.add(resource);
+    }
+    return resources;
+  }
+
+
+  private RegistryRequest getRequest(Map<String, Object> properties) {
+
+    Long registryId = properties.containsKey(REGISTRY_ID) && properties.get(REGISTRY_ID) != null?
+      Long.valueOf((String) properties.get(REGISTRY_ID)) : null;
+    String registryName = properties.containsKey(REGISTRY_NAME)? (String) properties.get(REGISTRY_NAME) : null;
+    RegistryType registryType = properties.containsKey(REGISTRY_TYPE) && properties.get(REGISTRY_TYPE) != null?
+      Enum.valueOf(RegistryType.class, (String) properties.get(REGISTRY_TYPE)) : null;
+    String registryUri = properties.containsKey(REGISTRY_URI)? (String) properties.get(REGISTRY_URI) : null;
+    RegistryRequest registryRequest = new RegistryRequest(
+      registryId,
+      registryName,
+      registryType,
+      registryUri
+    );
+    return registryRequest;
+  }
+
+  /**
+   * Add software registries for the given requests
+   *
+   * @param requests software registry requests
+   */
+  private Set<RegistryResponse> addRegistries(Set<RegistryRequest> requests) {
+    Set<RegistryResponse> responses = new HashSet<>();
+    if (requests.isEmpty()) {
+      LOG.warn("Received an empty requests set");
+      // Return an empty response set
+      return responses;
+    }
+
+    validateCreateRequests(requests);
+
+    for (RegistryRequest request : requests) {
+      RegistryResponse response = getManagementController().addRegistry(request);
+      if (response != null) {
+        responses.add(response);
+      }
+    }
+
+    return responses;
+  }
+
+  private void validateCreateRequests(Set<RegistryRequest> requests) {
+    for (RegistryRequest request : requests) {
+      final Long registryId = request.getRegistryId();
+      final String registryName = request.getRegistryName();
+      final RegistryType registryType = request.getRegistryType();
+      final String registryUri = request.getRegistryUri();
+
+      Validate.notEmpty(registryName, "Registry name should be provided when adding a new software registry");
+      Validate.notNull(registryType, "Registry type should be provided when adding a new software registry");
+      Validate.notEmpty(registryUri, "Registry uri should be provided when adding a new software registry");
+      Validate.isTrue(registryId == null, "Registry ID should not be set when adding a new software registry");
+
+      LOG.info("Received a createRegistry request"
+        + ", registryName=" + registryName
+        + ", registryType=" + registryType
+        + ", registryUri=" + registryUri);
+
+      // TODO : Check if the software registry is already registered
+      // TODO : Check for duplicates in the request.
+      // TODO : Authorization??
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java
index 06aa68b..77757c6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java
@@ -47,7 +47,6 @@ import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
 import org.apache.ambari.server.controller.utilities.PredicateHelper;
 import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
 import org.apache.ambari.server.orm.dao.HostRoleCommandStatusSummaryDTO;
-import org.apache.ambari.server.orm.dao.RequestDAO;
 import org.apache.ambari.server.orm.dao.StageDAO;
 import org.apache.ambari.server.orm.entities.StageEntity;
 import org.apache.ambari.server.state.Cluster;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
index 58c48c8..3928c4e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
@@ -90,6 +90,7 @@ public interface Resource {
     User,
     Group,
     Member,
+    Registry,
     Mpack,
     Stack,
     StackVersion,
@@ -212,6 +213,7 @@ public interface Resource {
     public static final Type User = InternalType.User.getType();
     public static final Type Group = InternalType.Group.getType();
     public static final Type Member = InternalType.Member.getType();
+    public static final Type Registry = InternalType.Registry.getType();
     public static final Type Mpack = InternalType.Mpack.getType();
     public static final Type Stack = InternalType.Stack.getType();
     public static final Type StackVersion = InternalType.StackVersion.getType();

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/exceptions/RegistryNotFoundException.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/exceptions/RegistryNotFoundException.java b/ambari-server/src/main/java/org/apache/ambari/server/exceptions/RegistryNotFoundException.java
new file mode 100644
index 0000000..687b8c4
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/exceptions/RegistryNotFoundException.java
@@ -0,0 +1,33 @@
+/**
+ * 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.exceptions;
+
+import org.apache.ambari.server.ObjectNotFoundException;
+
+@SuppressWarnings("serial")
+public class RegistryNotFoundException extends ObjectNotFoundException {
+
+  public RegistryNotFoundException(String registryName) {
+    super("Software registry not found, registryName=" + registryName);
+  }
+
+  public RegistryNotFoundException(Long registryId) {
+    super("Software registry not found, registryId=" + registryId);
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/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 f19320e..077b05a 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,22 @@
  */
 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.ArrayList;
+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;
@@ -27,51 +40,36 @@ 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.Mpacks;
+import org.apache.ambari.server.state.Mpack;
 import org.apache.ambari.server.state.Packlet;
-import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
 import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
 import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
 import org.apache.commons.io.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
-import java.nio.file.Paths;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
-import java.util.List;
-import java.io.File;
-import java.io.OutputStream;
-import java.io.FileInputStream;
-import java.io.BufferedInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
+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
  * mpack information.
  */
 public class MpackManager {
-  protected Map<Long, Mpacks> mpackMap = new HashMap<>();
-  private File mpackStaging;
-  private MpackDAO mpackDAO;
-  private StackDAO stackDAO;
-  private Mpacks mpack;
-  private File stackRoot;
   private static final String MPACK_METADATA = "mpack.json";
   private static final String MPACK_TAR_LOCATION = "staging";
-
   private final static Logger LOG = LoggerFactory.getLogger(MpackManager.class);
+  protected Map<Long, Mpack> mpackMap = new ConcurrentHashMap<>();
+  private File mpacksStaging;
+  private MpackDAO mpackDAO;
+  private StackDAO stackDAO;
+  private File stackRoot;
 
   @AssistedInject
-  public MpackManager(@Assisted("mpackv2Staging") File mpackStagingLocation, @Assisted("stackRoot") File stackRootDir, MpackDAO mpackDAOObj, StackDAO stackDAOObj) {
-    mpackStaging = mpackStagingLocation;
+  public MpackManager(@Assisted("mpacksv2Staging") File mpacksStagingLocation, @Assisted("stackRoot") File stackRootDir, MpackDAO mpackDAOObj, StackDAO stackDAOObj) {
+    mpacksStaging = mpacksStagingLocation;
     mpackDAO = mpackDAOObj;
     stackRoot = stackRootDir;
     stackDAO = stackDAOObj;
@@ -88,7 +86,7 @@ public class MpackManager {
    */
   private void parseMpackDirectories() {
     try {
-      for (final File dirEntry : mpackStaging.listFiles()) {
+      for (final File dirEntry : mpacksStaging.listFiles()) {
         if (dirEntry.isDirectory()) {
           String mpackName = dirEntry.getName();
           if (!mpackName.equals(MPACK_TAR_LOCATION)) {
@@ -101,7 +99,7 @@ public class MpackManager {
                 //Read the mpack.json file into Mpack Object for further use.
                 String mpackJsonContents = new String((Files.readAllBytes(Paths.get(file + "/" + MPACK_METADATA))), "UTF-8");
                 Gson gson = new Gson();
-                Mpacks existingMpack = gson.fromJson(mpackJsonContents, Mpacks.class);
+                Mpack existingMpack = gson.fromJson(mpackJsonContents, Mpack.class);
                 mpackMap.put(mpackEntity.getMpackId(), existingMpack);
               }
             }
@@ -129,7 +127,7 @@ public class MpackManager {
     Long mpackId;
     String mpackName = "";
     String mpackVersion = "";
-    mpack = new Mpacks();
+    Mpack mpack = new Mpack();
     boolean isValidMetadata;
     String mpackDirectory = "";
     Path mpackTarPath;
@@ -143,10 +141,10 @@ public class MpackManager {
       //Todo : Madhu implement GET /registries/{registryId}/mpacks
       mpackTarPath = downloadMpack(mpackRequest.getMpackUri());
 
-      if (createMpackDirectory(mpackTarPath)) {
+      if (createMpackDirectory(mpack, mpackTarPath)) {
         isValidMetadata = validateMpackInfo(mpackName, mpackVersion, mpack.getName(), mpack.getVersion());
         if (isValidMetadata) {
-          mpackDirectory = mpackStaging + File.separator + mpack.getName() + File.separator + mpack.getVersion();
+          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
@@ -156,12 +154,12 @@ public class MpackManager {
     } else {    //Mpack registration using direct download
       mpackTarPath = downloadMpack(mpackRequest.getMpackUri());
 
-      if (createMpackDirectory(mpackTarPath)) {
-        mpackDirectory = mpackStaging + File.separator + mpack.getName() + File.separator + mpack.getVersion();
-        mpack.setMpacksUri(mpackRequest.getMpackUri());
+      if (createMpackDirectory(mpack, mpackTarPath)) {
+        mpackDirectory = mpacksStaging + File.separator + mpack.getName() + File.separator + mpack.getVersion();
+        mpack.setMpackUri(mpackRequest.getMpackUri());
       }
     }
-    extractMpackTar(mpackTarPath, mpackDirectory);
+    extractMpackTar(mpack, mpackTarPath, mpackDirectory);
     mpackId = populateDB(mpack);
 
     if (mpackId != null) {
@@ -178,18 +176,19 @@ public class MpackManager {
   /**
    * Mpack is downloaded as a tar.gz file. It is extracted into mpack-v2-staging/{mpack-name}/{mpack-version}/ directory
    *
-   * @param mpackTarPath
-   * @param mpackDirectory
+   * @param mpack Mpack to process
+   * @param mpackTarPath Path to mpack tarball
+   * @param mpackDirectory Mpack directory
    * @throws IOException
    */
-  private void extractMpackTar(Path mpackTarPath, String mpackDirectory) throws IOException {
+  private void extractMpackTar(Mpack mpack, Path mpackTarPath, String mpackDirectory) throws IOException {
     TarArchiveInputStream mpackTarFile = new TarArchiveInputStream(new GzipCompressorInputStream(new BufferedInputStream(new FileInputStream(new File(String.valueOf(mpackTarPath))))));
     // To read individual TAR file
     TarArchiveEntry entry = null;
     File outputFile = null;
     //Create a loop to read every single entry in TAR file
     while ((entry = mpackTarFile.getNextTarEntry()) != null) {
-      outputFile = new File(mpackStaging, entry.getName());
+      outputFile = new File(mpacksStaging, entry.getName());
       if (entry.isDirectory()) {
         LOG.debug("Attempting to write output directory" + outputFile.getAbsolutePath());
         if (!outputFile.exists()) {
@@ -208,21 +207,22 @@ public class MpackManager {
     mpackTarFile.close();
     String mpackTarDirectory = mpackTarPath.toString();
     Path extractedMpackDirectory = Files.move
-            (Paths.get(mpackStaging + File.separator + mpackTarDirectory.substring(mpackTarDirectory.lastIndexOf('/') + 1, mpackTarDirectory.indexOf(".tar")) + File.separator),
+            (Paths.get(mpacksStaging + File.separator + mpackTarDirectory.substring(mpackTarDirectory.lastIndexOf('/') + 1, mpackTarDirectory.indexOf(".tar")) + File.separator),
                     Paths.get(mpackDirectory), StandardCopyOption.REPLACE_EXISTING);
 
-    createSymLinks();
+    createSymLinks(mpack);
   }
 
   /**
    * 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.
    *
-   * @param mpackTarPath
+   * @param mpack Mpack to process
+   * @param mpackTarPath Path to mpack tarball
    * @return boolean
    * @throws IOException
    */
-  private Boolean createMpackDirectory(Path mpackTarPath) throws IOException {
+  private Boolean createMpackDirectory(Mpack mpack, Path mpackTarPath) throws IOException {
     TarArchiveInputStream mpackTarFile = new TarArchiveInputStream(new GzipCompressorInputStream(new BufferedInputStream(new FileInputStream(new File(mpackTarPath.toString())))));
     // To read individual TAR file
     TarArchiveEntry entry = null;
@@ -246,12 +246,12 @@ public class MpackManager {
         //Read the mpack.json file into Mpack Object for further use.
         String mpackJsonContents = new String(content, "UTF-8");
         Gson gson = new Gson();
-        Mpacks tempMpack = gson.fromJson(mpackJsonContents, Mpacks.class);
+        Mpack tempMpack = gson.fromJson(mpackJsonContents, Mpack.class);
         mpack.copyFrom(tempMpack);
 
         mpackTarFile.close();
 
-        File mpackDirectory = new File(mpackStaging + File.separator + mpack.getName());
+        File mpackDirectory = new File(mpacksStaging + File.separator + mpack.getName());
         if (!mpackDirectory.exists())
           return mpackDirectory.mkdir();
         else
@@ -265,15 +265,17 @@ public class MpackManager {
   /***
    * Create a linkage between the staging directory and the working directory i.e from mpacks-v2 to stackRoot.
    * This will enable StackManager to parse the newly registered mpack as part of the stacks.
+   *
+   * @param mpack Mpack to process
    * @throws IOException
    */
-  private void createSymLinks() throws IOException {
+  private void createSymLinks(Mpack mpack) throws IOException {
     String stackId = mpack.getStackId();
     String[] stackMetaData = stackId.split("-");
     String stackName = stackMetaData[0];
     String stackVersion = stackMetaData[1];
     Path stackPath = Paths.get(stackRoot + "/" + stackName + "/" + stackVersion);
-    Path mpackPath = Paths.get(mpackStaging + "/" + mpack.getName() + "/" + mpack.getVersion());
+    Path mpackPath = Paths.get(mpacksStaging + "/" + mpack.getName() + "/" + mpack.getVersion());
     if(Files.isSymbolicLink(stackPath))
       Files.delete(stackPath);
     Files.createSymbolicLink(stackPath, mpackPath);
@@ -288,7 +290,7 @@ public class MpackManager {
   public Path downloadMpack(String mpackURI) throws IOException {
     URL url = new URL(mpackURI);
     String fileName = mpackURI.substring(mpackURI.lastIndexOf('/') + 1, mpackURI.length());
-    Path targetPath = new File(mpackStaging.toString() + File.separator + MPACK_TAR_LOCATION + File.separator + fileName).toPath();
+    Path targetPath = new File(mpacksStaging.toString() + File.separator + MPACK_TAR_LOCATION + File.separator + fileName).toPath();
     Files.copy(url.openStream(), targetPath, StandardCopyOption.REPLACE_EXISTING);
 
     return targetPath;
@@ -315,20 +317,20 @@ public class MpackManager {
   /**
    * Make an entry in the mpacks database for the newly registered mpack.
    *
-   * @param mpacks
+   * @param mpack
    * @return
    * @throws IOException
    */
-  protected Long populateDB(Mpacks mpacks) throws IOException {
-    String mpackName = mpacks.getName();
-    String mpackVersion = mpacks.getVersion();
+  protected Long populateDB(Mpack mpack) throws IOException {
+    String mpackName = mpack.getName();
+    String mpackVersion = mpack.getVersion();
     List resultSet = mpackDAO.findByNameVersion(mpackName, mpackVersion);
     if (resultSet.size() == 0) {
       LOG.info("Adding mpack {}-{} to the database", mpackName, mpackVersion);
       MpackEntity mpackEntity = new MpackEntity();
       mpackEntity.setMpackName(mpackName);
       mpackEntity.setMpackVersion(mpackVersion);
-      mpackEntity.setMpackUri(mpacks.getMpacksUri());
+      mpackEntity.setMpackUri(mpack.getMpackUri());
 
       Long mpackId = mpackDAO.create(mpackEntity);
       return mpackId;
@@ -339,10 +341,10 @@ public class MpackManager {
 
   /***
    * Makes an entry or updates the entry in the stack table to establish a link between the mpack and the associated stack
-   * @param mpacks
+   * @param mpack
    * @throws IOException
    */
-  protected void populateStackDB(Mpacks mpacks) throws IOException {
+  protected void populateStackDB(Mpack mpack) throws IOException {
 
     String stackId = mpack.getStackId();
     String[] stackMetaData = stackId.split("-");
@@ -355,11 +357,11 @@ public class MpackManager {
       stackEntity = new StackEntity();
       stackEntity.setStackName(stackName);
       stackEntity.setStackVersion(stackVersion);
-      stackEntity.setCurrentMpackId(mpacks.getMpackId());
+      stackEntity.setCurrentMpackId(mpack.getMpackId());
       stackDAO.create(stackEntity);
     } else {
       LOG.info("Updating stack {}-{} to the database", stackName, stackVersion);
-      stackEntity.setCurrentMpackId(mpacks.getMpackId());
+      stackEntity.setCurrentMpackId(mpack.getMpackId());
       stackDAO.merge(stackEntity);
     }
   }
@@ -370,7 +372,7 @@ public class MpackManager {
    * @return ArrayList
    */
   public ArrayList<Packlet> getPacklets(Long mpackId) {
-    Mpacks mpack = mpackMap.get(mpackId);
+    Mpack mpack = mpackMap.get(mpackId);
     if (mpack.getPacklets() != null)
       return mpack.getPacklets();
     return null;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManagerFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManagerFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManagerFactory.java
index 2336b1a..064257e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManagerFactory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManagerFactory.java
@@ -29,10 +29,10 @@ import com.google.inject.assistedinject.AssistedInject;
 public interface MpackManagerFactory {
 
   /**
-   * @param mpackStaging
+   * @param mpacksV2Staging
    *        the folder location where mpack is downloaded. (not {@code null}).
    * @param stackRoot
    * @return a mpack manager instance.
    */
-  MpackManager create(@Assisted("mpackv2Staging") File mpackStaging, @Assisted("stackRoot") File stackRoot);
+  MpackManager create(@Assisted("mpacksv2Staging") File mpacksV2Staging, @Assisted("stackRoot") File stackRoot);
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/MpackDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/MpackDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/MpackDAO.java
index a19ceaf..3078759 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/MpackDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/MpackDAO.java
@@ -17,18 +17,21 @@
  */
 package org.apache.ambari.server.orm.dao;
 
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import com.google.inject.Singleton;
-import com.google.inject.persist.Transactional;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.TypedQuery;
+
 import org.apache.ambari.server.orm.RequiresSession;
 import org.apache.ambari.server.orm.entities.MpackEntity;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.persistence.EntityManager;
-import javax.persistence.TypedQuery;
-import java.util.List;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+import com.google.inject.persist.Transactional;
 
 
 @Singleton

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RegistryDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RegistryDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RegistryDAO.java
new file mode 100644
index 0000000..a25ea6e
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RegistryDAO.java
@@ -0,0 +1,101 @@
+/**
+ * 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.orm.dao;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.TypedQuery;
+
+import org.apache.ambari.server.orm.RequiresSession;
+import org.apache.ambari.server.orm.entities.RegistryEntity;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+import com.google.inject.persist.Transactional;
+
+/**
+ * Software Registry Data Access Object
+ */
+@Singleton
+public class RegistryDAO {
+  protected final static Logger LOG = LoggerFactory.getLogger(RegistryDAO.class);
+
+  /**
+   * JPA entity manager
+   */
+  @Inject
+  Provider<EntityManager> m_entityManagerProvider;
+
+  /**
+   * DAO utilities for dealing mostly with {@link TypedQuery} results.
+   */
+  @Inject
+  private DaoUtils m_daoUtils;
+
+  /**
+   * Persists a new software registry
+   */
+  @Transactional
+  public Long create(RegistryEntity registryEntity) {
+    m_entityManagerProvider.get().persist(registryEntity);
+    return registryEntity.getRegistryId();
+  }
+
+  /**
+   * Gets all software registries stored in the database.
+   *
+   * @return all software registries or an empty list if none exist (never {@code null}).
+   */
+  @RequiresSession
+  public List<RegistryEntity> findAll() {
+    TypedQuery<RegistryEntity> query = m_entityManagerProvider.get().createNamedQuery(
+      "RegistryEntity.findAll", RegistryEntity.class);
+    return m_daoUtils.selectList(query);
+  }
+
+  /**
+   * Gets a software registry with the specified ID.
+   *
+   * @param registryId
+   *          the ID of the software registry to be retrieved.
+   * @return the software registry or {@code null} if none exists.
+   */
+  @RequiresSession
+  public RegistryEntity findById(Long registryId) {
+    return m_entityManagerProvider.get().find(RegistryEntity.class, registryId);
+  }
+
+  /**
+   * Gets software registry with specified mpack name and mpack version.
+   *
+   * @param registryName the software registry name
+   * @return the software registry or {@code null} if none exists.
+   */
+  @RequiresSession
+  public RegistryEntity findByName(String registryName) {
+    TypedQuery<RegistryEntity> query = m_entityManagerProvider.get().createNamedQuery(
+      "RegistryEntity.findByName", RegistryEntity.class);
+    query.setParameter("registryName", registryName);
+    return m_daoUtils.selectSingle(query);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/MpackEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/MpackEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/MpackEntity.java
index ed5aa6e..d3f6f28 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/MpackEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/MpackEntity.java
@@ -17,20 +17,21 @@
  */
 package org.apache.ambari.server.orm.entities;
 
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.Objects;
 
-import javax.persistence.NamedQuery;
-import javax.persistence.NamedQueries;
-import javax.persistence.Table;
+import javax.persistence.Column;
 import javax.persistence.Entity;
-import javax.persistence.TableGenerator;
-import javax.persistence.Id;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
-import javax.persistence.Column;
-import java.util.Objects;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * The {@link MpackEntity} class represents the mpack objects in the cluster.

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdf4d11/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RegistryEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RegistryEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RegistryEntity.java
new file mode 100644
index 0000000..f9cfbe1
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RegistryEntity.java
@@ -0,0 +1,146 @@
+/**
+ * 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.orm.entities;
+
+import java.util.Objects;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+
+import org.apache.ambari.server.registry.RegistryType;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The {@link RegistryEntity} class represents the registry object.
+ */
+
+@Table(name = "registries")
+@Entity
+@TableGenerator(name = "registry_id_generator", table = "ambari_sequences", pkColumnName = "sequence_name", valueColumnName = "sequence_value", pkColumnValue = "registry_id_seq", initialValue = 1)
+@NamedQueries({
+  @NamedQuery(name = "RegistryEntity.findById", query = "SELECT registry FROM RegistryEntity registry where registry.registryId = :registryId"),
+  @NamedQuery(name = "RegistryEntity.findAll", query = "SELECT registry FROM RegistryEntity registry"),
+  @NamedQuery(name = "RegistryEntity.findByName", query = "SELECT registry FROM RegistryEntity registry where registry.registryName = :registryName") })
+
+public class RegistryEntity {
+  protected final static Logger LOG = LoggerFactory.getLogger(RegistryEntity.class);
+  @Id
+  @GeneratedValue(strategy = GenerationType.TABLE, generator = "registry_id_generator")
+  @Column(name = "id", nullable = false, updatable = false)
+  private Long registryId;
+
+  @Column(name = "registry_name", nullable = false, updatable = true)
+  private String registryName;
+
+  @Enumerated(value = EnumType.STRING)
+  @Column(name = "registry_type", nullable = false, updatable = true)
+  private RegistryType registryType;
+
+  @Column(name = "registry_uri", nullable = false, updatable = true)
+  private String registryUri;
+
+  public Long getRegistryId() {
+    return registryId;
+  }
+
+  public void setRegistryId(Long registryId) {
+    this.registryId = registryId;
+  }
+
+  public String getRegistryName() {
+    return registryName;
+  }
+
+  public void setRegistryName(String registryName) {
+    this.registryName = registryName;
+  }
+
+  public RegistryType getRegistryType() {
+    return registryType;
+  }
+
+  public void setRegistryType(RegistryType registryType) {
+    this.registryType = registryType;
+  }
+
+  public String getRegistryUri() {
+    return registryUri;
+  }
+
+  public void setRegistryUri(String registryUri) {
+    this.registryUri = registryUri;
+  }
+
+  public RegistryEntity() {
+
+  }
+
+  @Override
+  public boolean equals(Object object) {
+    if (this == object) {
+      return true;
+    }
+
+    if (object == null || getClass() != object.getClass()) {
+      return false;
+    }
+
+    RegistryEntity that = (RegistryEntity) object;
+    EqualsBuilder equalsBuilder = new EqualsBuilder();
+
+    equalsBuilder.append(registryId, that.registryId);
+    equalsBuilder.append(registryName, that.registryName);
+    equalsBuilder.append(registryType, that.registryType);
+    equalsBuilder.append(registryUri, that.registryUri);
+    return equalsBuilder.isEquals();
+  }
+
+  /**
+   * Generates a hash for the software registry
+   * {@inheritDoc}
+   */
+  @Override
+  public int hashCode() {
+    return Objects.hash(registryId, registryName, registryType, registryUri);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String toString() {
+    StringBuilder buffer = new StringBuilder("RegistryEntity{");
+    buffer.append("registryId=").append(registryId);
+    buffer.append(", registryName=").append(registryName);
+    buffer.append(", registryType=").append(registryType);
+    buffer.append(", registryUri=").append(registryUri);
+    buffer.append("}");
+    return buffer.toString();
+  }
+}