Skip to content
Permalink
Browse files
AMBARI-24992. Updated ambari_configuration.property_value to support …
…longer input (#2694)
  • Loading branch information
smolnar82 committed Dec 5, 2018
1 parent e70dd4e commit 129632c94aa339571d0fa278a2259157b5244fcb
Showing 7 changed files with 25 additions and 5 deletions.
@@ -44,6 +44,9 @@ public class UpgradeCatalog280 extends AbstractUpgradeCatalog {
private static final String UPGRADE_TABLE = "upgrade";
private static final String UPGRADE_PACK_STACK_ID = "upgrade_pack_stack_id";

protected static final String AMBARI_CONFIGURATION_TABLE = "ambari_configuration";
protected static final String AMBARI_CONFIGURATION_PROPERTY_VALUE_COLUMN = "property_value";

@Inject
public UpgradeCatalog280(Injector injector) {
super(injector);
@@ -64,6 +67,12 @@ protected void executeDDLUpdates() throws AmbariException, SQLException {
removeLastValidState();
addColumnsToRequestScheduleTable();
addColumnsToUpgradeTable();
modifyPropertyValueColumnInAmbariConfigurationTable();
}

private void modifyPropertyValueColumnInAmbariConfigurationTable() throws SQLException {
dbAccessor.alterColumn(AMBARI_CONFIGURATION_TABLE, new DBAccessor.DBColumnInfo(AMBARI_CONFIGURATION_PROPERTY_VALUE_COLUMN, String.class, 4000, null, false));
LOG.info("Altered {}.{} to NOT NULL and extended its length to 4000", AMBARI_CONFIGURATION_TABLE, AMBARI_CONFIGURATION_PROPERTY_VALUE_COLUMN);
}

@Override
@@ -106,7 +106,7 @@ CREATE TABLE clusterconfig (
CREATE TABLE ambari_configuration (
category_name VARCHAR(100) NOT NULL,
property_name VARCHAR(100) NOT NULL,
property_value VARCHAR(2048),
property_value VARCHAR(4000) NOT NULL,
CONSTRAINT PK_ambari_configuration PRIMARY KEY (category_name, property_name));

CREATE TABLE serviceconfig (
@@ -125,7 +125,7 @@ CREATE TABLE clusterconfig (
CREATE TABLE ambari_configuration (
category_name VARCHAR(100) NOT NULL,
property_name VARCHAR(100) NOT NULL,
property_value VARCHAR(2048),
property_value VARCHAR(4000) NOT NULL,
CONSTRAINT PK_ambari_configuration PRIMARY KEY (category_name, property_name));

CREATE TABLE serviceconfig (
@@ -88,7 +88,7 @@ CREATE TABLE clusters (
CREATE TABLE ambari_configuration (
category_name VARCHAR(100) NOT NULL,
property_name VARCHAR(100) NOT NULL,
property_value VARCHAR(2048),
property_value VARCHAR(4000) NOT NULL,
CONSTRAINT PK_ambari_configuration PRIMARY KEY (category_name, property_name)
);

@@ -105,7 +105,7 @@ CREATE TABLE clusterconfig (
CREATE TABLE ambari_configuration (
category_name VARCHAR(100) NOT NULL,
property_name VARCHAR(100) NOT NULL,
property_value VARCHAR(2048),
property_value VARCHAR(4000) NOT NULL,
CONSTRAINT PK_ambari_configuration PRIMARY KEY (category_name, property_name));

CREATE TABLE serviceconfig (
@@ -119,7 +119,7 @@ CREATE TABLE clusterconfig (
CREATE TABLE ambari_configuration (
category_name VARCHAR(100) NOT NULL,
property_name VARCHAR(100) NOT NULL,
property_value VARCHAR(2048),
property_value VARCHAR(4000) NOT NULL,
CONSTRAINT PK_ambari_configuration PRIMARY KEY (category_name, property_name)
);

@@ -18,6 +18,8 @@
package org.apache.ambari.server.upgrade;


import static org.apache.ambari.server.upgrade.UpgradeCatalog280.AMBARI_CONFIGURATION_PROPERTY_VALUE_COLUMN;
import static org.apache.ambari.server.upgrade.UpgradeCatalog280.AMBARI_CONFIGURATION_TABLE;
import static org.apache.ambari.server.upgrade.UpgradeCatalog280.HOST_COMPONENT_STATE_TABLE;
import static org.apache.ambari.server.upgrade.UpgradeCatalog280.LAST_LIVE_STATE_COLUMN;
import static org.easymock.EasyMock.capture;
@@ -67,6 +69,10 @@ public void testExecuteDDLUpdates() throws Exception {
Capture<DBAccessor.DBColumnInfo> upgradePackStackColumn = newCapture(CaptureType.ALL);
dbAccessor.addColumn(eq("upgrade"), capture(upgradePackStackColumn));
expectLastCall().once();

final Capture<DBAccessor.DBColumnInfo> alterPropertyValueColumnCapture = newCapture(CaptureType.ALL);
dbAccessor.alterColumn(eq(AMBARI_CONFIGURATION_TABLE), capture(alterPropertyValueColumnCapture));
expectLastCall().once();

replay(dbAccessor, injector);

@@ -93,6 +99,11 @@ public void testExecuteDDLUpdates() throws Exception {
Assert.assertEquals(String.class, capturedUpgradeColumn.getType());
Assert.assertEquals((Integer) 255, capturedUpgradeColumn.getLength());

final DBAccessor.DBColumnInfo alterPropertyValueColumn = alterPropertyValueColumnCapture.getValue();
Assert.assertEquals(AMBARI_CONFIGURATION_PROPERTY_VALUE_COLUMN, alterPropertyValueColumn.getName());
Assert.assertEquals(String.class, alterPropertyValueColumn.getType());
Assert.assertEquals((Integer) 4000, alterPropertyValueColumn.getLength());
Assert.assertFalse(alterPropertyValueColumn.isNullable());

verify(dbAccessor);
}

0 comments on commit 129632c

Please sign in to comment.