public abstract class AbstractResourceProvider extends BaseProvider implements ResourceProvider, ObservableResourceProvider
Modifier and Type | Class and Description |
---|---|
protected static interface |
AbstractResourceProvider.Command<T>
Command to invoke against the Ambari backend.
|
Modifier and Type | Field and Description |
---|---|
protected Map<Resource.Type,String> |
keyPropertyIds
Key property mapping by resource type.
|
protected static org.slf4j.Logger |
LOG |
protected static String |
PROPERTIES_ATTRIBUTES_REGEX |
Modifier | Constructor and Description |
---|---|
protected |
AbstractResourceProvider(Set<String> propertyIds,
Map<Resource.Type,String> keyPropertyIds)
Create a new resource provider.
|
Modifier and Type | Method and Description |
---|---|
void |
addObserver(ResourceProviderObserver observer)
Add an observer.
|
protected <T> T |
createResources(AbstractResourceProvider.Command<T> command)
Invoke a command against the Ambari backend to create resources and map
any
AmbariException to the types appropriate for the
ResourceProvider interface. |
static List<ConfigurationRequest> |
getConfigurationRequests(String parentCategory,
Map<String,Object> properties)
Helper method to get a configuration request, if one exists.
|
Map<Resource.Type,String> |
getKeyPropertyIds()
Get the key property ids for the resource type associated with this resource
provider.
|
protected abstract Set<String> |
getPKPropertyIds()
Get the set of property ids that uniquely identify the resources
of this provider.
|
protected Set<Map<String,Object>> |
getPropertyMaps(Map<String,Object> requestPropertyMap,
Predicate givenPredicate)
Get a set of properties from the given property map and predicate.
|
protected Set<Map<String,Object>> |
getPropertyMaps(Predicate givenPredicate)
Get a set of properties from the given predicate.
|
protected static Object |
getQueryParameterValue(String queryParameterId,
Predicate predicate)
Extracting given query_parameter value from the predicate
|
protected RequestStatus |
getRequestStatus(RequestStatusResponse response)
Get a request status
|
protected RequestStatus |
getRequestStatus(RequestStatusResponse response,
Set<Resource> associatedResources)
Get a request status
|
protected RequestStatus |
getRequestStatus(RequestStatusResponse response,
Set<Resource> associatedResources,
RequestStatusMetaData requestStatusMetaData) |
protected <T> T |
getResources(AbstractResourceProvider.Command<T> command)
Invoke a command against the Ambari backend to get resources and map
any
AmbariException to the types appropriate for the
ResourceProvider interface. |
protected <T> T |
modifyResources(AbstractResourceProvider.Command<T> command)
Invoke a command against the Ambari backend to modify resources and map
any
AmbariException to the types appropriate for the
ResourceProvider interface. |
protected void |
notifyCreate(Resource.Type type,
Request request)
Notify all listeners of a creation event.
|
protected void |
notifyDelete(Resource.Type type,
Predicate predicate)
Notify all listeners of a delete event.
|
protected void |
notifyUpdate(Resource.Type type,
Request request,
Predicate predicate)
Notify all listeners of a update event.
|
static void |
parseProperties(ConfigurationRequest config,
String absCategory,
String propName,
String propValue) |
void |
updateObservers(ResourceProviderEvent event)
Update all registered observers with the given event.
|
checkCategory, checkConfigPropertyIds, checkPropertyIds, containsArguments, getCategoryIds, getPropertyIds, getRegexEntry, getRegexGroups, getRequestPropertyIds, isPatternKey, isPropertyCategoryRequested, isPropertyEntryRequested, isPropertyRequested, setResourceProperty
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
checkPropertyIds, createResources, deleteResources, getResources, updateResources
protected final Map<Resource.Type,String> keyPropertyIds
protected static final org.slf4j.Logger LOG
protected static final String PROPERTIES_ATTRIBUTES_REGEX
protected AbstractResourceProvider(Set<String> propertyIds, Map<Resource.Type,String> keyPropertyIds)
propertyIds
- the property idskeyPropertyIds
- the key property idspublic Map<Resource.Type,String> getKeyPropertyIds()
ResourceProvider
getKeyPropertyIds
in interface ResourceProvider
public void updateObservers(ResourceProviderEvent event)
ObservableResourceProvider
updateObservers
in interface ObservableResourceProvider
event
- the eventpublic void addObserver(ResourceProviderObserver observer)
ObservableResourceProvider
addObserver
in interface ObservableResourceProvider
observer
- the observerprotected abstract Set<String> getPKPropertyIds()
protected void notifyCreate(Resource.Type type, Request request)
type
- the type of the resources being createdrequest
- the request used to create the resourcesprotected void notifyUpdate(Resource.Type type, Request request, Predicate predicate)
type
- the type of the resources being updatedrequest
- the request used to update the resourcespredicate
- the predicate used to update the resourcesprotected void notifyDelete(Resource.Type type, Predicate predicate)
type
- the type of the resources being deletedpredicate
- the predicate used to delete the resourcesprotected Set<Map<String,Object>> getPropertyMaps(Predicate givenPredicate)
givenPredicate
- the predicateprotected Set<Map<String,Object>> getPropertyMaps(Map<String,Object> requestPropertyMap, Predicate givenPredicate) throws UnsupportedPropertyException, SystemException, NoSuchResourceException, NoSuchParentResourceException
requestPropertyMap
- the request update properties; may not be nullgivenPredicate
- the predicateUnsupportedPropertyException
SystemException
NoSuchResourceException
NoSuchParentResourceException
protected RequestStatus getRequestStatus(RequestStatusResponse response, Set<Resource> associatedResources)
protected RequestStatus getRequestStatus(RequestStatusResponse response, Set<Resource> associatedResources, RequestStatusMetaData requestStatusMetaData)
protected RequestStatus getRequestStatus(RequestStatusResponse response)
protected static Object getQueryParameterValue(String queryParameterId, Predicate predicate)
queryParameterId
- query parameter idpredicate
- predicateprotected <T> T createResources(AbstractResourceProvider.Command<T> command) throws SystemException, ResourceAlreadyExistsException, NoSuchParentResourceException
AmbariException
to the types appropriate for the
ResourceProvider
interface.T
- the type of the responsecommand
- the command to invokeSystemException
- thrown if a system exception occurredResourceAlreadyExistsException
- thrown if a resource already existsNoSuchParentResourceException
- thrown if a parent of a resource doesn't existprotected <T> T getResources(AbstractResourceProvider.Command<T> command) throws SystemException, NoSuchResourceException, NoSuchParentResourceException
AmbariException
to the types appropriate for the
ResourceProvider
interface.T
- the type of the responsecommand
- the command to invokeSystemException
- thrown if a system exception occurredNoSuchParentResourceException
- thrown if a parent of a resource doesn't existNoSuchResourceException
protected <T> T modifyResources(AbstractResourceProvider.Command<T> command) throws SystemException, NoSuchResourceException, NoSuchParentResourceException
AmbariException
to the types appropriate for the
ResourceProvider
interface.T
- the type of the responsecommand
- the command to invokeSystemException
- thrown if a system exception occurredNoSuchParentResourceException
- thrown if a parent of a resource doesn't existNoSuchResourceException
public static List<ConfigurationRequest> getConfigurationRequests(String parentCategory, Map<String,Object> properties)
parentCategory
- the parent category name. Checks for a property
whose category is the parent and marked as a desired config.properties
- the properties on the request.public static void parseProperties(ConfigurationRequest config, String absCategory, String propName, String propValue)
Copyright © 2022 Apache Software Foundation. All rights reserved.