ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject ambari git commit: Revert "AMBARI-502-PROXY-ERROR - Alert History Cannot Insert Into Oracle Database (jonathanhurley)"
Date Fri, 05 Jun 2015 15:52:13 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk d65accdcf -> ae679e4ef


Revert "AMBARI-502-PROXY-ERROR - Alert History Cannot Insert Into Oracle Database (jonathanhurley)"

This reverts commit d65accdcf859616d942754c87b12bec46ccd099b.


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

Branch: refs/heads/trunk
Commit: ae679e4efa85ee99748ccde00bde8775dc0a4dcb
Parents: d65accd
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Fri Jun 5 11:52:03 2015 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Fri Jun 5 11:52:03 2015 -0400

----------------------------------------------------------------------
 .../server/orm/entities/AlertHistoryEntity.java |   4 +-
 .../server/upgrade/UpgradeCatalog210.java       |  52 ++++-----
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql |   2 +-
 .../server/upgrade/UpgradeCatalog210Test.java   | 112 +++++--------------
 4 files changed, 54 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ae679e4e/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertHistoryEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertHistoryEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertHistoryEntity.java
index 9091398..8423abe 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertHistoryEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertHistoryEntity.java
@@ -25,7 +25,6 @@ import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.JoinColumn;
-import javax.persistence.Lob;
 import javax.persistence.ManyToOne;
 import javax.persistence.NamedQueries;
 import javax.persistence.NamedQuery;
@@ -69,8 +68,7 @@ public class AlertHistoryEntity {
   @Column(name = "alert_state", nullable = false, length = 255)
   private AlertState alertState;
 
-  @Lob
-  @Column(name = "alert_text")
+  @Column(name = "alert_text", length = 32672)
   private String alertText;
 
   @Column(name = "alert_timestamp", nullable = false)

http://git-wip-us.apache.org/repos/asf/ambari/blob/ae679e4e/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java
index a7a8cee..d83940e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java
@@ -18,22 +18,12 @@
 
 package org.apache.ambari.server.upgrade;
 
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaDelete;
-import javax.persistence.criteria.Root;
-
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.persist.Transactional;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.configuration.Configuration;
@@ -60,12 +50,20 @@ import org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.gson.Gson;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.persist.Transactional;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaDelete;
+import javax.persistence.criteria.Root;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 
 /**
@@ -120,7 +118,7 @@ public class UpgradeCatalog210 extends AbstractUpgradeCatalog {
 
   @Inject
   private OsFamily osFamily;
-
+  
   /**
    * {@inheritDoc}
    */
@@ -165,7 +163,7 @@ public class UpgradeCatalog210 extends AbstractUpgradeCatalog {
    */
   @Override
   protected void executeDDLUpdates() throws AmbariException, SQLException {
-    executeAlertDDLUpdates();
+    executeDDLFixes();
     executeHostsDDLUpdates();
     executeWidgetDDLUpdates();
     executeStackDDLUpdates();
@@ -260,15 +258,13 @@ public class UpgradeCatalog210 extends AbstractUpgradeCatalog {
     cleanupStackUpdates();
   }
 
-  private void executeAlertDDLUpdates() throws AmbariException, SQLException {
+  private void executeDDLFixes() throws AmbariException, SQLException {
     //Fix latest_text column type to match for all DBMS
     Configuration.DatabaseType databaseType = configuration.getDatabaseType();
     if (Configuration.DatabaseType.MYSQL == databaseType) {
       dbAccessor.alterColumn("alert_current", new DBColumnInfo("latest_text", new FieldTypeDefinition("TEXT"),
null));
-      dbAccessor.alterColumn("alert_history", new DBColumnInfo("alert_text", new FieldTypeDefinition("TEXT"),
null));
     } else {
       dbAccessor.alterColumn("alert_current", new DBColumnInfo("latest_text", Character[].class,
null));
-      dbAccessor.alterColumn("alert_history", new DBColumnInfo("alert_text", Character[].class,
null));
     }
 
   }
@@ -1042,7 +1038,7 @@ public class UpgradeCatalog210 extends AbstractUpgradeCatalog {
     updateHiveConfigs();
     updateHdfsConfigs();
   }
-
+  
   protected void updateHdfsConfigs() throws AmbariException {
     /***
      * Append -Dorg.mortbay.jetty.Request.maxFormContentSize=-1 to HADOOP_NAMENODE_OPTS from
hadoop-env.sh

http://git-wip-us.apache.org/repos/asf/ambari/blob/ae679e4e/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 93d6f6e..fdd5ef8 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -768,7 +768,7 @@ CREATE TABLE alert_history (
   alert_timestamp NUMBER(19) NOT NULL,
   alert_label VARCHAR2(1024),
   alert_state VARCHAR2(255) NOT NULL,
-  alert_text CLOB,
+  alert_text VARCHAR2(4000),
   PRIMARY KEY (alert_id),
   FOREIGN KEY (alert_definition_id) REFERENCES alert_definition(definition_id),
   FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id)

http://git-wip-us.apache.org/repos/asf/ambari/blob/ae679e4e/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog210Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog210Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog210Test.java
index d8a2565..e41ce0b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog210Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog210Test.java
@@ -18,29 +18,12 @@
 
 package org.apache.ambari.server.upgrade;
 
-import static junit.framework.Assert.assertEquals;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createMockBuilder;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.persistence.EntityManager;
-
+import com.google.inject.Binder;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.Provider;
+import com.google.inject.persist.PersistService;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.AmbariManagementController;
@@ -71,13 +54,27 @@ import org.junit.After;
 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.Provider;
-import com.google.inject.persist.PersistService;
+import javax.persistence.EntityManager;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import static junit.framework.Assert.assertEquals;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.createMockBuilder;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reset;
+import static org.easymock.EasyMock.verify;
 
 /**
  * {@link org.apache.ambari.server.upgrade.UpgradeCatalog210} unit tests.
@@ -113,18 +110,17 @@ public class UpgradeCatalog210Test {
   @Test
   public void testExecuteDDLUpdates() throws Exception {
     final DBAccessor dbAccessor = createNiceMock(DBAccessor.class);
+    Connection connection = createNiceMock(Connection.class);
     Configuration configuration = createNiceMock(Configuration.class);
     ResultSet resultSet = createNiceMock(ResultSet.class);
     expect(configuration.getDatabaseUrl()).andReturn(Configuration.JDBC_IN_MEMORY_URL).anyTimes();
 
     // Create DDL sections with their own capture groups
-    AlertSectionDDL alertSectionDDL = new AlertSectionDDL();
     HostSectionDDL hostSectionDDL = new HostSectionDDL();
     WidgetSectionDDL widgetSectionDDL = new WidgetSectionDDL();
     ViewSectionDDL viewSectionDDL = new ViewSectionDDL();
 
     // Execute any DDL schema changes
-    alertSectionDDL.execute(dbAccessor);
     hostSectionDDL.execute(dbAccessor);
     widgetSectionDDL.execute(dbAccessor);
     viewSectionDDL.execute(dbAccessor);
@@ -142,7 +138,6 @@ public class UpgradeCatalog210Test {
     verify(dbAccessor, configuration, resultSet);
 
     // Verify sections
-    alertSectionDDL.verify(dbAccessor);
     hostSectionDDL.verify(dbAccessor);
     widgetSectionDDL.verify(dbAccessor);
     viewSectionDDL.verify(dbAccessor);
@@ -542,55 +537,4 @@ public class UpgradeCatalog210Test {
       Assert.assertEquals("cluster_config", clusterConfigColumn.getName());
     }
   }
-
-  /**
-   * Verify view changes
-   */
-  class AlertSectionDDL implements SectionDDL {
-
-    HashMap<String, Capture<DBColumnInfo>> captures;
-
-    public AlertSectionDDL() {
-      captures = new HashMap<String, Capture<DBColumnInfo>>();
-
-      Capture<DBAccessor.DBColumnInfo> alertCurrentColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
-      Capture<DBAccessor.DBColumnInfo> alertHistoryColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
-
-      captures.put("alert_current", alertCurrentColumnCapture);
-      captures.put("alert_history", alertHistoryColumnCapture);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void execute(DBAccessor dbAccessor) throws SQLException {
-      Capture<DBColumnInfo> alertCurrentColumnCapture = captures.get("alert_current");
-      Capture<DBColumnInfo> alertHistoryColumnCapture = captures.get("alert_history");
-
-      dbAccessor.alterColumn(eq("alert_current"), capture(alertCurrentColumnCapture));
-      dbAccessor.alterColumn(eq("alert_history"), capture(alertHistoryColumnCapture));
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void verify(DBAccessor dbAccessor) throws SQLException {
-      verifyAlertCurrent(captures.get("alert_current"));
-      verifyAlertHistory(captures.get("alert_history"));
-    }
-
-    private void verifyAlertCurrent(Capture<DBAccessor.DBColumnInfo> alertCurrentColumnCapture)
{
-      DBColumnInfo latestTextColumn = alertCurrentColumnCapture.getValue();
-      Assert.assertEquals(Character[].class, latestTextColumn.getType());
-      Assert.assertEquals("latest_text", latestTextColumn.getName());
-    }
-
-    private void verifyAlertHistory(Capture<DBAccessor.DBColumnInfo> alertHistoryColumnCapture)
{
-      DBColumnInfo alertTextColumn = alertHistoryColumnCapture.getValue();
-      Assert.assertEquals(Character[].class, alertTextColumn.getType());
-      Assert.assertEquals("alert_text", alertTextColumn.getName());
-    }
-  }
 }


Mime
View raw message