ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject [30/35] ambari git commit: AMBARI-21766 - When Matching New VDFs for Parent Repos only Consider STANDARD Types (jonathanhurley)
Date Tue, 22 Aug 2017 18:02:46 GMT
AMBARI-21766 - When Matching New VDFs for Parent Repos only Consider STANDARD Types (jonathanhurley)


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

Branch: refs/heads/branch-feature-logsearch-ui
Commit: d2e0c42a1d6f67ade14e867d069d73b2567d685b
Parents: 6f9f87c
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Mon Aug 21 11:52:03 2017 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Tue Aug 22 11:34:06 2017 -0400

----------------------------------------------------------------------
 .../VersionDefinitionResourceProvider.java      |  4 +++-
 .../server/orm/dao/RepositoryVersionDAO.java    | 20 ++++++++++++++++++++
 .../orm/entities/RepositoryVersionEntity.java   |  3 +++
 .../orm/dao/RepositoryVersionDAOTest.java       | 12 ++++++++++++
 4 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d2e0c42a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
index 162c8df..394a0bf 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
@@ -437,7 +437,9 @@ public class VersionDefinitionResourceProvider extends AbstractAuthorizedResourc
       return;
     }
 
-    List<RepositoryVersionEntity> entities = s_repoVersionDAO.findByStack(entity.getStackId());
+    List<RepositoryVersionEntity> entities = s_repoVersionDAO.findByStackAndType(
+        entity.getStackId(), RepositoryType.STANDARD);
+
     if (entities.isEmpty()) {
       throw new IllegalArgumentException(String.format("Patch %s was uploaded, but there
are no repositories for %s",
           entity.getVersion(), entity.getStackId().toString()));

http://git-wip-us.apache.org/repos/asf/ambari/blob/d2e0c42a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAO.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAO.java
index d59d229..c83375b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAO.java
@@ -134,6 +134,26 @@ public class RepositoryVersionDAO extends CrudDAO<RepositoryVersionEntity,
Long>
   }
 
   /**
+   * Retrieves repository version by stack.
+   *
+   * @param stackId
+   *          stack id stack with major version (like HDP-2.2)
+   * @param type
+   *          the repository type
+   *
+   * @return null if there is no suitable repository version
+   */
+  @RequiresSession
+  public List<RepositoryVersionEntity> findByStackAndType(StackId stackId, RepositoryType
type) {
+    final TypedQuery<RepositoryVersionEntity> query = entityManagerProvider.get().createNamedQuery(
+        "repositoryVersionByStackAndType", RepositoryVersionEntity.class);
+    query.setParameter("stackName", stackId.getStackName());
+    query.setParameter("stackVersion", stackId.getStackVersion());
+    query.setParameter("type", type);
+    return daoUtils.selectList(query);
+  }
+  
+  /**
    * Validates and creates an object.
    * The version must be unique within this stack name (e.g., HDP, HDPWIN, BIGTOP).
    * @param stackEntity Stack entity.

http://git-wip-us.apache.org/repos/asf/ambari/blob/d2e0c42a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryVersionEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryVersionEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryVersionEntity.java
index c746363..c7c6ff4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryVersionEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryVersionEntity.java
@@ -80,6 +80,9 @@ import com.google.inject.Provider;
         name = "repositoryVersionByStack",
         query = "SELECT repoversion FROM RepositoryVersionEntity repoversion WHERE repoversion.stack.stackName=:stackName
AND repoversion.stack.stackVersion=:stackVersion"),
     @NamedQuery(
+        name = "repositoryVersionByStackAndType",
+        query = "SELECT repoversion FROM RepositoryVersionEntity repoversion WHERE repoversion.stack.stackName=:stackName
AND repoversion.stack.stackVersion=:stackVersion AND repoversion.type=:type"),
+    @NamedQuery(
         name = "repositoryVersionByStackNameAndVersion",
         query = "SELECT repoversion FROM RepositoryVersionEntity repoversion WHERE repoversion.stack.stackName=:stackName
AND repoversion.version=:version"),
     @NamedQuery(

http://git-wip-us.apache.org/repos/asf/ambari/blob/d2e0c42a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAOTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAOTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAOTest.java
index d596084..c16a6f7 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAOTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAOTest.java
@@ -28,6 +28,7 @@ import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.orm.entities.StackEntity;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.StackId;
 import org.junit.After;
 import org.junit.Assert;
@@ -199,6 +200,17 @@ public class RepositoryVersionDAOTest {
         "1.0.1.0-1234"));
   }
 
+  @Test
+  public void testFindByStackAndType() {
+    createSingleRecord();
+
+    Assert.assertEquals(1,
+        repositoryVersionDAO.findByStackAndType(HDP_206, RepositoryType.STANDARD).size());
+
+    Assert.assertEquals(0,
+        repositoryVersionDAO.findByStackAndType(HDP_206, RepositoryType.MAINT).size());
+  }
+
   @After
   public void after() throws AmbariException, SQLException {
     H2DatabaseCleaner.clearDatabaseAndStopPersistenceService(injector);


Mime
View raw message