public abstract class AbstractUpgradeCatalog extends Object implements UpgradeCatalog
Modifier and Type | Class and Description |
---|---|
static class |
AbstractUpgradeCatalog.ConfigUpdateType |
protected static class |
AbstractUpgradeCatalog.VersionComparator |
Constructor and Description |
---|
AbstractUpgradeCatalog(com.google.inject.Injector injector) |
Modifier and Type | Method and Description |
---|---|
protected void |
addAuthorizationToRole(PermissionEntity role,
String roleAuthorizationID)
Add a new authorization to the set of authorizations for a role
|
protected void |
addAuthorizationToRole(String roleName,
String resourceType,
RoleAuthorizationEntity roleAuthorization)
Add a new authorization to the set of authorizations for a role
|
protected void |
addAuthorizationToRole(String roleName,
String resourceType,
String roleAuthorizationID)
Add a new authorization to the set of authorizations for a role
|
void |
addConnectionTimeoutParamForWebAndMetricAlerts() |
void |
addNewConfigurationsFromXml() |
protected void |
addRoleAuthorization(String roleAuthorizationID,
String roleAuthorizationName,
Collection<String> applicableRoles)
Add a new role authorization and optionally add it to 1 or more roles.
|
protected void |
addSequence(String seqName,
Long seqDefaultValue,
boolean ignoreFailure)
Add new sequence to
ambariSequencesTable . |
protected void |
addSequences(List<String> seqNames,
Long seqDefaultValue,
boolean ignoreFailure)
Add several new sequences to
ambariSequencesTable . |
protected void |
changePostgresSearchPath() |
protected static Document |
convertStringToDocument(String xmlStr) |
protected abstract void |
executeDDLUpdates()
Perform database schema transformation.
|
protected abstract void |
executeDMLUpdates()
Performs normal data upgrade
|
protected void |
executeInTransaction(Runnable func) |
protected abstract void |
executePreDMLUpdates()
Perform data insertion before running normal upgrade of data, requires started persist service
|
protected long |
fetchMaxId(String tableName,
String idColumnName)
Fetches the maximum value of the given ID column from the given table.
|
protected Set<String> |
getCapacitySchedulerLeafQueues(Map<String,String> capacitySchedulerMap)
Pars Capacity Scheduler Properties and get all YARN Capacity Scheduler leaf queue names
|
protected Map<String,Cluster> |
getCheckedClusterMap(Clusters clusters)
This method returns Map of clusters.
|
protected com.google.inject.Provider<javax.persistence.EntityManager> |
getEntityManagerProvider() |
protected KerberosDescriptor |
getKerberosDescriptor(Cluster cluster)
Retrieve the composite Kerberos Descriptor.
|
String |
getSourceVersion()
Return latest source version that can be upgraded from.
|
protected static UpgradeCatalog |
getUpgradeCatalog(String version) |
Map<String,String> |
getUpgradeJsonOutput() |
protected static boolean |
isConfigEnabled(Cluster cluster,
String configType,
String propertyName) |
boolean |
isFinal()
Defines if Upgrade Catalog should be executed last
|
protected boolean |
isNNHAEnabled(Cluster cluster) |
protected boolean |
isQueueNameValid(Cluster cluster,
Set<String> validLeafQueues,
String queueNameProperty,
String configType)
Validate queueNameProperty exists for configType in cluster and corresponds to one of validLeafQueues
|
void |
onPostUpgrade()
Called after
UpgradeCatalog.upgradeSchema() and UpgradeCatalog.upgradeData() , this
method is used to perform any operations after the catalog has finished. |
void |
preUpgradeData()
perform data insertion before running normal upgrade of data, requires started persist service
|
protected void |
registerCatalog(UpgradeCatalog upgradeCatalog)
Every subclass needs to register itself
|
protected void |
removeConfigurationPropertiesFromCluster(Cluster cluster,
String configType,
Set<String> removePropertiesList)
Remove properties from the cluster
|
void |
setConfigUpdatesFileName(String ambariUpgradeConfigUpdatesFileName)
Set the file name, to store all config changes during upgrade
|
String |
toString() |
protected void |
updateConfigurationProperties(String configType,
Map<String,String> properties,
boolean updateIfExists,
boolean createNewConfigType)
Create a new cluster scoped configuration with the new properties added
to the existing set of properties.
|
protected void |
updateConfigurationPropertiesForCluster(Cluster cluster,
String configType,
Map<String,String> properties,
boolean updateIfExists,
boolean createNewConfigType) |
protected void |
updateConfigurationPropertiesForCluster(Cluster cluster,
String configType,
Map<String,String> properties,
Set<String> removePropertiesList,
boolean updateIfExists,
boolean createNewConfigType)
Update properties for the cluster
|
protected void |
updateConfigurationPropertiesWithValuesFromXml(String configType,
Set<String> propertyNames,
boolean updateIfExists,
boolean createNewConfigType)
Create a new cluster scoped configuration with the new properties added
with the values from the coresponding xml files.
|
protected void |
updateConfigurationPropertiesWithValuesFromXml(String configType,
Set<String> propertyNames,
Set<String> toRemove,
boolean updateIfExists,
boolean createNewConfigType) |
void |
updateDatabaseSchemaVersion()
Update schema version in the database to the Target one
|
protected void |
updateKerberosDescriptorArtifact(ArtifactDAO artifactDAO,
ArtifactEntity artifactEntity)
Update the specified Kerberos Descriptor artifact to conform to the new structure.
|
protected void |
updateKerberosDescriptorArtifacts()
Update the stored Kerberos Descriptor artifacts to conform to the new structure.
|
protected void |
updateKerberosDescriptorIdentityReferences(AbstractKerberosDescriptorContainer descriptorContainer,
String referenceName,
String newReferenceName)
Given an AbstractKerberosDescriptorContainer, iterates through its contained identity descriptors
to find ones matching the reference name to change.
|
protected void |
updateKerberosDescriptorIdentityReferences(Map<String,? extends AbstractKerberosDescriptorContainer> descriptorMap,
String referenceName,
String newReferenceName)
Iterates through a collection of AbstractKerberosDescriptorContainers to find and update
identity descriptor references.
|
int |
updateMetaInfoVersion(String version)
Update metainfo to new version.
|
protected void |
updateQueueName(Cluster cluster,
Set<String> validLeafQueues,
String queueNameProperty,
String configType)
Update property queueNameProperty from configType of cluster to first of validLeafQueues
|
protected void |
updateWidgetDefinitionsForService(String serviceName,
Map<String,List<String>> widgetMap,
Map<String,String> sectionLayoutMap) |
void |
upgradeData()
perform data updates as necessary, requires started persist service
|
void |
upgradeSchema()
Run the upgrade scripts for upgrading ambari server from current version
to the new version.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getTargetVersion
@Inject protected DBAccessor dbAccessor
@Inject protected Configuration configuration
@Inject protected AmbariManagementControllerImpl ambariManagementController
protected com.google.inject.Injector injector
protected String ambariSequencesTable
protected static final String AUTHENTICATED_USER_NAME
public static final String CONFIGURATION_TYPE_RANGER_HBASE_PLUGIN_PROPERTIES
public static final String CONFIGURATION_TYPE_RANGER_KNOX_PLUGIN_PROPERTIES
public static final String CONFIGURATION_TYPE_RANGER_HIVE_PLUGIN_PROPERTIES
public static final String PROPERTY_RANGER_HBASE_PLUGIN_ENABLED
public static final String PROPERTY_RANGER_KNOX_PLUGIN_ENABLED
public static final String PROPERTY_RANGER_HIVE_PLUGIN_ENABLED
public static final String YARN_SCHEDULER_CAPACITY_ROOT_QUEUE
public static final String YARN_SCHEDULER_CAPACITY_ROOT_QUEUES
public static final String QUEUES
public static final String ALERT_URL_PROPERTY_CONNECTION_TIMEOUT
protected String ambariUpgradeConfigUpdatesFileName
@Inject public AbstractUpgradeCatalog(com.google.inject.Injector injector)
protected void registerCatalog(UpgradeCatalog upgradeCatalog)
protected final void addSequence(String seqName, Long seqDefaultValue, boolean ignoreFailure) throws SQLException
ambariSequencesTable
.seqName
- name of sequence to be insertedseqDefaultValue
- initial value for the sequenceignoreFailure
- true to ignore insert sql errorsSQLException
protected final void addSequences(List<String> seqNames, Long seqDefaultValue, boolean ignoreFailure) throws SQLException
ambariSequencesTable
.seqNames
- list of sequences to be insertedseqDefaultValue
- initial value for the sequenceignoreFailure
- true to ignore insert sql errorsSQLException
protected final long fetchMaxId(String tableName, String idColumnName) throws SQLException
tableName
- the name of the table to query the data fromidColumnName
- the name of the ID column you want to query the maximum value for.
This MUST refer an existing numeric type column0L
otherwise.SQLException
public String getSourceVersion()
UpgradeCatalog
getSourceVersion
in interface UpgradeCatalog
protected static UpgradeCatalog getUpgradeCatalog(String version)
protected static boolean isConfigEnabled(Cluster cluster, String configType, String propertyName)
public Map<String,String> getUpgradeJsonOutput()
getUpgradeJsonOutput
in interface UpgradeCatalog
public int updateMetaInfoVersion(String version)
public void addConnectionTimeoutParamForWebAndMetricAlerts()
protected com.google.inject.Provider<javax.persistence.EntityManager> getEntityManagerProvider()
protected void executeInTransaction(Runnable func)
protected void changePostgresSearchPath() throws SQLException
SQLException
public void addNewConfigurationsFromXml() throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
protected boolean isNNHAEnabled(Cluster cluster)
protected Map<String,Cluster> getCheckedClusterMap(Clusters clusters)
protected void updateConfigurationPropertiesWithValuesFromXml(String configType, Set<String> propertyNames, boolean updateIfExists, boolean createNewConfigType) throws org.apache.ambari.server.AmbariException
configType
- Configuration type. (hdfs-site, etc.)propertyNames
- Set property names.org.apache.ambari.server.AmbariException
protected void updateConfigurationPropertiesWithValuesFromXml(String configType, Set<String> propertyNames, Set<String> toRemove, boolean updateIfExists, boolean createNewConfigType) throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
protected void updateConfigurationPropertiesForCluster(Cluster cluster, String configType, Map<String,String> properties, Set<String> removePropertiesList, boolean updateIfExists, boolean createNewConfigType) throws org.apache.ambari.server.AmbariException
cluster
- cluster objectconfigType
- config to be updatedproperties
- properties to be added or updated. Couldn't be null
, but could be empty.removePropertiesList
- properties to be removed. Could be null
updateIfExists
- createNewConfigType
- org.apache.ambari.server.AmbariException
protected void updateConfigurationPropertiesForCluster(Cluster cluster, String configType, Map<String,String> properties, boolean updateIfExists, boolean createNewConfigType) throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
protected void removeConfigurationPropertiesFromCluster(Cluster cluster, String configType, Set<String> removePropertiesList) throws org.apache.ambari.server.AmbariException
cluster
- cluster objectconfigType
- config to be updatedremovePropertiesList
- properties to be removed. Could be null
org.apache.ambari.server.AmbariException
protected void updateConfigurationProperties(String configType, Map<String,String> properties, boolean updateIfExists, boolean createNewConfigType) throws org.apache.ambari.server.AmbariException
configType
- Configuration type. (hdfs-site, etc.)properties
- Map of key value pairs to add / update.org.apache.ambari.server.AmbariException
protected void updateKerberosDescriptorIdentityReferences(Map<String,? extends AbstractKerberosDescriptorContainer> descriptorMap, String referenceName, String newReferenceName)
descriptorMap
- a String to AbstractKerberosDescriptorContainer map to iterate troughreferenceName
- the reference name to changenewReferenceName
- the new reference nameprotected void updateKerberosDescriptorIdentityReferences(AbstractKerberosDescriptorContainer descriptorContainer, String referenceName, String newReferenceName)
descriptorContainer
- the AbstractKerberosDescriptorContainer to updatereferenceName
- the reference name to changenewReferenceName
- the new reference nameprotected void updateKerberosDescriptorArtifacts() throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
protected KerberosDescriptor getKerberosDescriptor(Cluster cluster) throws org.apache.ambari.server.AmbariException
The composite Kerberos Descriptor is the cluster's stack-specific Kerberos Descriptor overlaid with changes specified by the user via the cluster's Kerberos Descriptor artifact.
cluster
- the relevant clusterorg.apache.ambari.server.AmbariException
protected void addRoleAuthorization(String roleAuthorizationID, String roleAuthorizationName, Collection<String> applicableRoles) throws SQLException
The collection of roles to add the new role authorization to may be null or empty, indicating
that no roles are to be altered. If set, though, each role entry in the collection must be a
colon-delimited string like: ROLE:RESOURCE TYPE
. Examples:
roleAuthorizationID
- the ID of the new authorizationroleAuthorizationName
- the (descriptive) name of the new authorizationapplicableRoles
- an optional collection of role specification to add the new authorization toSQLException
protected void addAuthorizationToRole(String roleName, String resourceType, String roleAuthorizationID)
roleName
- the name of the roleresourceType
- the resource type of the role (AMBARI, CLUSTER, VIEW, etc...)roleAuthorizationID
- the ID of the authorizationaddAuthorizationToRole(String, String, RoleAuthorizationEntity)
protected void addAuthorizationToRole(String roleName, String resourceType, RoleAuthorizationEntity roleAuthorization)
roleName
- the name of the roleresourceType
- the resource type of the role (AMBARI, CLUSTER, VIEW, etc...)roleAuthorization
- the authorization to addprotected void addAuthorizationToRole(PermissionEntity role, String roleAuthorizationID)
role
- the role to add the authorization toroleAuthorizationID
- the authorization to addprotected void updateKerberosDescriptorArtifact(ArtifactDAO artifactDAO, ArtifactEntity artifactEntity) throws org.apache.ambari.server.AmbariException
artifactDAO
- the ArtifactDAO to use to store the updated ArtifactEntityartifactEntity
- the ArtifactEntity to updateorg.apache.ambari.server.AmbariException
public void upgradeSchema() throws org.apache.ambari.server.AmbariException, SQLException
UpgradeCatalog
upgradeSchema
in interface UpgradeCatalog
org.apache.ambari.server.AmbariException
SQLException
public void preUpgradeData() throws org.apache.ambari.server.AmbariException, SQLException
UpgradeCatalog
preUpgradeData
in interface UpgradeCatalog
org.apache.ambari.server.AmbariException
SQLException
public void setConfigUpdatesFileName(String ambariUpgradeConfigUpdatesFileName)
UpgradeCatalog
setConfigUpdatesFileName
in interface UpgradeCatalog
public void upgradeData() throws org.apache.ambari.server.AmbariException, SQLException
UpgradeCatalog
upgradeData
in interface UpgradeCatalog
org.apache.ambari.server.AmbariException
SQLException
public final void updateDatabaseSchemaVersion()
UpgradeCatalog
updateDatabaseSchemaVersion
in interface UpgradeCatalog
public boolean isFinal()
UpgradeCatalog
isFinal
in interface UpgradeCatalog
protected abstract void executeDDLUpdates() throws org.apache.ambari.server.AmbariException, SQLException
org.apache.ambari.server.AmbariException
SQLException
protected abstract void executePreDMLUpdates() throws org.apache.ambari.server.AmbariException, SQLException
org.apache.ambari.server.AmbariException
SQLException
protected abstract void executeDMLUpdates() throws org.apache.ambari.server.AmbariException, SQLException
org.apache.ambari.server.AmbariException
SQLException
public void onPostUpgrade() throws org.apache.ambari.server.AmbariException, SQLException
UpgradeCatalog.upgradeSchema()
and UpgradeCatalog.upgradeData()
, this
method is used to perform any operations after the catalog has finished.
Usually, this is cleanup work that does not directly affect the upgrade.onPostUpgrade
in interface UpgradeCatalog
org.apache.ambari.server.AmbariException
SQLException
protected boolean isQueueNameValid(Cluster cluster, Set<String> validLeafQueues, String queueNameProperty, String configType)
cluster
- cluster to operate withvalidLeafQueues
- Set of YARN capacity-scheduler leaf queuesqueueNameProperty
- queue name property to check and updateconfigType
- config type nameprotected void updateQueueName(Cluster cluster, Set<String> validLeafQueues, String queueNameProperty, String configType) throws org.apache.ambari.server.AmbariException
cluster
- cluster to operate withvalidLeafQueues
- Set of YARN capacity-scheduler leaf queuesqueueNameProperty
- queue name property to check and updateconfigType
- config type nameorg.apache.ambari.server.AmbariException
- if an error occurs while updating the configurationsprotected Set<String> getCapacitySchedulerLeafQueues(Map<String,String> capacitySchedulerMap)
capacitySchedulerMap
- capacity-scheduler properties mapprotected void updateWidgetDefinitionsForService(String serviceName, Map<String,List<String>> widgetMap, Map<String,String> sectionLayoutMap) throws org.apache.ambari.server.AmbariException
serviceName
- widgetMap
- sectionLayoutMap
- org.apache.ambari.server.AmbariException
Copyright © 2022 Apache Software Foundation. All rights reserved.