public class MaintenanceStateHelper extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
MaintenanceStateHelper.HostPredicate
The
MaintenanceStateHelper.HostPredicate interaface is used as a way to pass a custom
implementation into one of the many
isOperationAllowed(org.apache.ambari.server.controller.spi.Resource.Type, Service)
methods. |
Constructor and Description |
---|
MaintenanceStateHelper(com.google.inject.Injector injector) |
Modifier and Type | Method and Description |
---|---|
Set<String> |
filterHostsInMaintenanceState(Set<String> candidateHosts,
MaintenanceStateHelper.HostPredicate condition)
Removes from a set all hosts that match a given condition.
|
MaintenanceState |
getEffectiveState(long clusterId,
Alert alert)
Gets the effective maintenance state for a given alert.
|
MaintenanceState |
getEffectiveState(ServiceComponentHost sch)
Gets the effective state for a HostComponent
|
MaintenanceState |
getEffectiveState(ServiceComponentHost sch,
Host host)
Get effective state of HostComponent
|
Set<Map<String,String>> |
getMaintenanceHostComponents(Clusters clusters,
Cluster cluster) |
Resource.Type |
guessOperationLevel(RequestResourceFilter filter)
Fallback logic for guessing operation level from request resource filter.
|
boolean |
isOperationAllowed(Cluster cluster,
RequestOperationLevel levelObj,
RequestResourceFilter reqFilter,
String serviceName,
String componentName,
String hostname) |
boolean |
isOperationAllowed(Host host,
long clusterId,
Resource.Type level) |
boolean |
isOperationAllowed(Resource.Type level,
Service service) |
boolean |
isOperationAllowed(Resource.Type operationLevel,
ServiceComponentHost sch)
Determine based on the requesting Resource level and the state of the
operand whether to allow operations on it.
|
@Inject public MaintenanceStateHelper(com.google.inject.Injector injector)
public boolean isOperationAllowed(Cluster cluster, RequestOperationLevel levelObj, RequestResourceFilter reqFilter, String serviceName, String componentName, String hostname) throws org.apache.ambari.server.AmbariException
cluster
- cluster for requestlevelObj
- operation level (can be null)reqFilter
- request resource filter for operation (can't be null)serviceName
- service name (can be null)componentName
- component name (can be null)hostname
- host name (can't be null)org.apache.ambari.server.AmbariException
public boolean isOperationAllowed(Resource.Type level, Service service) throws org.apache.ambari.server.AmbariException
level
- operation levelservice
- the serviceorg.apache.ambari.server.AmbariException
public boolean isOperationAllowed(Host host, long clusterId, Resource.Type level) throws org.apache.ambari.server.AmbariException
host
- the serviceclusterId
- cluster the host belongs tolevel
- operation level for requestorg.apache.ambari.server.AmbariException
public MaintenanceState getEffectiveState(ServiceComponentHost sch, Host host) throws org.apache.ambari.server.AmbariException
sch
- the host componenthost
- the hostorg.apache.ambari.server.AmbariException
public MaintenanceState getEffectiveState(ServiceComponentHost sch) throws org.apache.ambari.server.AmbariException
sch
- the host componentorg.apache.ambari.server.AmbariException
public MaintenanceState getEffectiveState(long clusterId, Alert alert) throws org.apache.ambari.server.AmbariException
clusterId
- the ID of the cluster for the alert.alert
- the alert (not null
).MaintenanceState.OFF
if the host/service/component all
report they are not in maintenance mode;
MaintenanceState.ON
otherwise.org.apache.ambari.server.AmbariException
public Set<Map<String,String>> getMaintenanceHostComponents(Clusters clusters, Cluster cluster) throws org.apache.ambari.server.AmbariException
clusters
- the collection of clusterscluster
- the specific cluster to checkMaintenanceState.ON
or
MaintenanceState.IMPLIED_FROM_HOST
or
MaintenanceState.IMPLIED_FROM_SERVICE
or
MaintenanceState.IMPLIED_FROM_SERVICE_AND_HOST
)org.apache.ambari.server.AmbariException
public boolean isOperationAllowed(Resource.Type operationLevel, ServiceComponentHost sch) throws org.apache.ambari.server.AmbariException
operationLevel
- Request Source: {CLUSTER, SERVICE, HOSTCOMPONENT, HOST}sch
- HostComponent which is the operand of the operationorg.apache.ambari.server.AmbariException
public Resource.Type guessOperationLevel(RequestResourceFilter filter)
public Set<String> filterHostsInMaintenanceState(Set<String> candidateHosts, MaintenanceStateHelper.HostPredicate condition) throws org.apache.ambari.server.AmbariException
candidateHosts
- source set that should to be modifiedcondition
- conditionorg.apache.ambari.server.AmbariException
Copyright © 2022 Apache Software Foundation. All rights reserved.