public class UpgradeContext extends Object
UpgradeContext
is used to hold all information pertaining to an
upgrade. It is initialized directly from an existing UpgradeEntity
or
from a request to create an upgrade/downgrade.Modifier and Type | Field and Description |
---|---|
static String |
COMMAND_PARAM_CLUSTER_NAME |
static String |
COMMAND_PARAM_DIRECTION |
static String |
COMMAND_PARAM_REQUEST_ID |
static String |
COMMAND_PARAM_STRUCT_OUT |
static String |
COMMAND_PARAM_TASKS |
static String |
COMMAND_PARAM_UPGRADE_PACK |
static String |
COMMAND_PARAM_UPGRADE_TYPE |
Constructor and Description |
---|
UpgradeContext(Cluster cluster,
Map<String,Object> upgradeRequestMap,
com.google.gson.Gson gson,
UpgradeHelper upgradeHelper,
UpgradeDAO upgradeDAO,
RepositoryVersionDAO repoVersionDAO,
ConfigHelper configHelper,
AmbariMetaInfo metaInfo) |
UpgradeContext(Cluster cluster,
UpgradeEntity upgradeEntity,
AmbariMetaInfo ambariMetaInfo,
ConfigHelper configHelper)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addUnhealthy(List<ServiceComponentHost> unhealthy) |
org.apache.ambari.spi.upgrade.UpgradeInformation |
buildUpgradeInformation()
Builds a
UpgradeInformation instance from a Cluster where
there is an upgrade in progress. |
AmbariMetaInfo |
getAmbariMetaInfo() |
Cluster |
getCluster()
Gets the cluster that the upgrade is for.
|
String |
getComponentDisplay(String service,
String component) |
int |
getDefaultMaxDegreeOfParallelism() |
Direction |
getDirection() |
HostRoleCommandFactory |
getHostRoleCommandFactory()
Gets the injected instance of a
HostRoleCommandFactory . |
Map<String,String> |
getInitializedCommandParameters()
Gets a map initialized with parameters required for upgrades to work.
|
KerberosDetails |
getKerberosDetails()
Gets Kerberos information about a cluster.
|
org.apache.ambari.spi.upgrade.OrchestrationOptions |
getOrchestrationOptions() |
org.apache.ambari.spi.RepositoryType |
getOrchestrationType()
Gets the repository type to determine if this upgrade is a complete upgrade
or a service/patch.
|
long |
getPatchRevertUpgradeId() |
RepositoryVersionEntity |
getRepositoryVersion()
Gets the single repository version for the upgrade depending on the
direction.
|
MasterHostResolver |
getResolver() |
RoleGraphFactory |
getRoleGraphFactory()
Gets the injected instance of a
RoleGraphFactory . |
String |
getServiceDisplay(String service) |
RepositoryVersionEntity |
getSourceRepositoryVersion(String serviceName)
Gets the version that service is being considered to be "coming from".
|
StackId |
getSourceStack()
Gets the single source stack for the upgrade depending on the
direction.
|
String |
getSourceVersion(String serviceName)
Gets the version that service is being considered to be "coming from".
|
Map<String,RepositoryVersionEntity> |
getSourceVersions()
Gets the version that components are being considered to be "coming from".
|
StackId |
getStackIdFromVersions(Map<String,RepositoryVersionEntity> version)
Getting stackId from the set of versions.
|
Set<String> |
getSupportedServices()
Gets the services participating in the upgrade.
|
RepositoryVersionEntity |
getTargetRepositoryVersion(String serviceName)
Gets the repository being upgraded to or downgraded to for the given
service.
|
StackId |
getTargetStack()
Gets the single target stack for the upgrade.
|
String |
getTargetVersion(String serviceName)
Gets the version being upgraded to or downgraded to for the given service.
|
Map<String,RepositoryVersionEntity> |
getTargetVersions()
Gets the version being upgraded to or downgraded to for all services
participating.
|
org.apache.ambari.spi.upgrade.UpgradeType |
getType() |
UpgradePack |
getUpgradePack()
Gets the upgrade pack for this upgrade.
|
UpgradeSummary |
getUpgradeSummary()
Gets a POJO of the upgrade suitable to serialize.
|
boolean |
isComponentFailureAutoSkipped()
Gets whether skippable components that failed are automatically skipped.
|
boolean |
isDowngradeAllowed()
Gets whether a downgrade is allowed for this upgrade.
|
boolean |
isManualVerificationAutoSkipped()
Gets whether manual verification tasks can be automatically skipped.
|
boolean |
isPatchRevert() |
boolean |
isScoped(UpgradeScope scope) |
boolean |
isServiceCheckFailureAutoSkipped()
Gets whether skippable service checks that failed are automatically
skipped.
|
boolean |
isServiceSupported(String serviceName)
Gets if a service is supported.
|
void |
setComponentDisplay(String service,
String component,
String displayName) |
void |
setServiceDisplay(String service,
String displayName) |
String |
toString() |
public static final String COMMAND_PARAM_CLUSTER_NAME
public static final String COMMAND_PARAM_DIRECTION
public static final String COMMAND_PARAM_UPGRADE_PACK
public static final String COMMAND_PARAM_REQUEST_ID
public static final String COMMAND_PARAM_UPGRADE_TYPE
public static final String COMMAND_PARAM_TASKS
public static final String COMMAND_PARAM_STRUCT_OUT
public UpgradeContext(Cluster cluster, Map<String,Object> upgradeRequestMap, com.google.gson.Gson gson, UpgradeHelper upgradeHelper, UpgradeDAO upgradeDAO, RepositoryVersionDAO repoVersionDAO, ConfigHelper configHelper, AmbariMetaInfo metaInfo) throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
public UpgradeContext(Cluster cluster, UpgradeEntity upgradeEntity, AmbariMetaInfo ambariMetaInfo, ConfigHelper configHelper)
cluster
- the cluster that the upgrade is forupgradeEntity
- the upgrade entitypublic StackId getStackIdFromVersions(Map<String,RepositoryVersionEntity> version)
public UpgradePack getUpgradePack()
public Cluster getCluster()
null
).public Map<String,RepositoryVersionEntity> getSourceVersions()
Direction.UPGRADE
, this value represent the services'
desired repository. However, Direction.DOWNGRADE
will use the same
value for all services which is the version that the downgrade is coming
from.public RepositoryVersionEntity getSourceRepositoryVersion(String serviceName)
Direction.UPGRADE
, this value represent the services'
desired repository. However, Direction.DOWNGRADE
will use the same
value for all services which is the version that the downgrade is coming
from.public String getSourceVersion(String serviceName)
Direction.UPGRADE
, this value represent the services'
desired repository. However, Direction.DOWNGRADE
will use the same
value for all services which is the version that the downgrade is coming
from.getSourceRepositoryVersion(String)
public Map<String,RepositoryVersionEntity> getTargetVersions()
Direction.UPGRADE
, all services should be targetting the
same repository version. However, Direction.DOWNGRADE
will target
the original repository that the service was on.public RepositoryVersionEntity getTargetRepositoryVersion(String serviceName)
Direction.UPGRADE
, all services should be targeting the
same repository version. However, Direction.DOWNGRADE
will target
the original repository that the service was on.public String getTargetVersion(String serviceName)
Direction.UPGRADE
, all services should be targetting the
same repository version. However, Direction.DOWNGRADE
will target
the original repository that the service was on.getTargetRepositoryVersion(String)
public Direction getDirection()
public org.apache.ambari.spi.upgrade.UpgradeType getType()
public MasterHostResolver getResolver()
public AmbariMetaInfo getAmbariMetaInfo()
public void addUnhealthy(List<ServiceComponentHost> unhealthy)
unhealthy
- a list of unhealthy host componentspublic RepositoryVersionEntity getRepositoryVersion()
Direction.UPGRADE
then this will return the
target repository which every service will be on if the upgrade is
finalized.
If the direction is Direction.DOWNGRADE
then this will return the
repository from which the downgrade is coming from.null
).public String getServiceDisplay(String service)
public String getComponentDisplay(String service, String component)
public void setServiceDisplay(String service, String displayName)
service
- the service namedisplayName
- the display name for the servicepublic void setComponentDisplay(String service, String component, String displayName)
service
- the service name that owns the componentcomponent
- the component namedisplayName
- the display name for the componentpublic boolean isComponentFailureAutoSkipped()
public boolean isServiceCheckFailureAutoSkipped()
public boolean isManualVerificationAutoSkipped()
public Set<String> getSupportedServices()
public boolean isServiceSupported(String serviceName)
serviceName
- the service name to check.true
when the service is supportedpublic boolean isScoped(UpgradeScope scope)
public RoleGraphFactory getRoleGraphFactory()
RoleGraphFactory
.RoleGraphFactory
instance (never null
).public HostRoleCommandFactory getHostRoleCommandFactory()
HostRoleCommandFactory
.HostRoleCommandFactory
instance (never null
).public org.apache.ambari.spi.RepositoryType getOrchestrationType()
public Map<String,String> getInitializedCommandParameters()
COMMAND_PARAM_CLUSTER_NAME
COMMAND_PARAM_DIRECTION
COMMAND_PARAM_UPGRADE_TYPE
KeyNames#REFRESH_CONFIG_TAGS_BEFORE_EXECUTION
- necessary in
order to have the commands contain the correct configurations. Otherwise,
they will contain the configurations that were available at the time the
command was created. For upgrades, this is problematic since the commands
are all created ahead of time, but the upgrade may change configs as part
of the upgrade pack.public boolean isDowngradeAllowed()
Direction.DOWNGRADE
, then this method always returns false.
Otherwise it will consule UpgradePack.isDowngradeAllowed()
.true
of a downgrade is allowed for this upgrade,
false
otherwise.public boolean isPatchRevert()
public long getPatchRevertUpgradeId()
public int getDefaultMaxDegreeOfParallelism()
public UpgradeSummary getUpgradeSummary()
public StackId getTargetStack()
null
).public StackId getSourceStack()
null
).public KerberosDetails getKerberosDetails() throws KerberosInvalidConfigurationException, org.apache.ambari.server.AmbariException
SecurityType.KERBEROS
, otherwise
it will throw an AmbariException
.KerberosInvalidConfigurationException
- if the kerberos-env
or krb5-conf
} configurations
can't be parsed.org.apache.ambari.server.AmbariException
- if the cluster is not Kerberized.public org.apache.ambari.spi.upgrade.OrchestrationOptions getOrchestrationOptions()
null
if not definedpublic org.apache.ambari.spi.upgrade.UpgradeInformation buildUpgradeInformation()
UpgradeInformation
instance from a Cluster
where
there is an upgrade in progress.UpgradeInformation
instance comprised of simple POJOs
and SPI classes.Copyright © 2022 Apache Software Foundation. All rights reserved.