@Singleton public class ViewRegistry extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
ViewRegistry.ViewModule
Module for stand alone view registry.
|
Modifier and Type | Field and Description |
---|---|
static String |
API_PREFIX |
static String |
DEFAULT_AUTO_INSTANCE_URL |
protected static int |
DEFAULT_REQUEST_CONNECT_TIMEOUT |
protected static int |
DEFAULT_REQUEST_READ_TIMEOUT |
protected ViewDataMigrationUtility |
viewDataMigrationUtility
View Data Migration Utility
|
Constructor and Description |
---|
ViewRegistry(AmbariEventPublisher publisher)
Create the view registry.
|
Modifier and Type | Method and Description |
---|---|
void |
addDefinition(ViewEntity definition)
Add a view definition to the registry.
|
void |
addInstanceDefinition(ViewEntity definition,
ViewInstanceEntity instanceDefinition)
Add an instance definition for the given view definition.
|
protected void |
bindViewInstance(ViewEntity viewDefinition,
ViewInstanceEntity viewInstanceDefinition) |
boolean |
checkAdmin()
Determine whether or not the current view user has admin rights.
|
boolean |
checkPermission(String viewName,
String version,
String instanceName,
boolean readOnly)
Determine whether or not access to the view instance resource identified
by the given instance name should be allowed based on the permissions
granted to the current user.
|
boolean |
checkPermission(ViewInstanceEntity instanceEntity,
boolean readOnly)
Determine whether or not access to the given view instance should be allowed based
on the permissions granted to the current user.
|
protected boolean |
checkViewVersions(ViewEntity view,
String serverVersion)
Check the configured view max and min Ambari versions for the given view entity
against the given Ambari server version.
|
protected void |
clear()
Clear the registry.
|
void |
copyPrivileges(ViewInstanceEntity sourceInstanceEntity,
ViewInstanceEntity targetInstanceEntity)
Copy all privileges from one view instance to another
|
protected ViewAmbariStreamProvider |
createAmbariStreamProvider()
Factory method to create a view Ambari stream provider.
|
protected org.apache.ambari.view.AmbariStreamProvider |
createRemoteAmbariStreamProvider(Long clusterId)
Get Remote Ambari Cluster Stream provider
|
protected ViewURLStreamProvider |
createURLStreamProvider(org.apache.ambari.view.ViewContext viewContext)
Factory method to create a view URL stream provider.
|
protected ViewInstanceEntity |
createViewInstanceDefinition(ViewConfig viewConfig,
ViewEntity viewDefinition,
InstanceConfig instanceConfig) |
protected static boolean |
extractViewArchive(String archivePath,
ViewRegistry.ViewModule viewModule,
boolean systemOnly) |
void |
fireEvent(org.apache.ambari.view.events.Event event)
Notify any registered listeners of the given event.
|
org.apache.ambari.view.cluster.Cluster |
getCluster(org.apache.ambari.view.ViewInstanceDefinition viewInstance)
Get the cluster associated with the given view instance.
|
ViewEntity |
getDefinition(ResourceTypeEntity resourceTypeEntity)
Get the view definition for the given resource type.
|
ViewEntity |
getDefinition(String viewName,
String version)
Get a view definition for the given name.
|
Collection<ViewEntity> |
getDefinitions()
Get the collection of all the view definitions.
|
static ViewRegistry |
getInstance()
Get the view registry singleton.
|
ViewInstanceEntity |
getInstanceDefinition(String viewName,
String version,
String instanceName)
Get the instance definition for the given view name and instance name.
|
Collection<ViewInstanceEntity> |
getInstanceDefinitions(ViewEntity definition)
Get the collection of view instances for the given view definition.
|
protected Map<Resource.Type,ResourceProvider> |
getResourceProviders()
Get the view resource provider mapping.
|
Set<SubResourceDefinition> |
getSubResourceDefinitions(String viewName,
String version)
Get the sub-resource definitions for the given view name.
|
protected ViewDataMigrationUtility |
getViewDataMigrationUtility() |
ViewInstanceEntity |
getViewInstanceEntity(String viewName,
String instanceName)
Get a view instance entity for the given view name and instance name.
|
boolean |
hasPermission(PermissionEntity permissionEntity,
ResourceEntity resourceEntity,
String userName)
Determine whether or not the access specified by the given permission
is permitted for the given user on the view instance identified by
the given resource.
|
boolean |
includeDefinition(ViewEntity definitionEntity)
Determine whether or not the given view definition resource should be included
based on the permissions granted to the current user.
|
static void |
initInstance(ViewRegistry singleton)
Init the singleton instance.
|
void |
installViewInstance(ViewInstanceEntity instanceEntity)
TODO : This should move to
ViewInstanceOperationHandler
Install the given view instance with its associated view. |
boolean |
instanceExists(ViewInstanceEntity instanceEntity)
Determine whether or not the given view instance exists.
|
static void |
main(String[] args)
Registry main method.
|
void |
onAmbariEvent(ServiceInstalledEvent event)
Receive notification that a new service has been added to a cluster.
|
void |
onClusterConfigFinishedEvent(ClusterConfigFinishedEvent event) |
protected void |
onDeploy(ViewEntity definition) |
void |
readViewArchive(Path path)
Extract a view archive at the specified path
|
void |
readViewArchives()
Read all view archives.
|
void |
readViewArchives(String viewNameRegExp)
Read only view archives with names corresponding to given regular expression.
|
void |
registerListener(org.apache.ambari.view.events.Listener listener,
String viewName,
String viewVersion)
Register the given listener to listen for events from the view identified by the given name and version.
|
void |
removeInstanceData(ViewInstanceEntity instanceEntity,
String key)
Remove the data entry keyed by the given key from the given instance entity.
|
void |
removeInstanceDefinition(ViewEntity definition,
String instanceName)
Remove an instance definition for the given view definition.
|
protected ViewEntity |
setupViewDefinition(ViewEntity viewDefinition,
ClassLoader cl) |
protected void |
setViewDataMigrationUtility(ViewDataMigrationUtility viewDataMigrationUtility) |
void |
setViewInstanceProperties(ViewInstanceEntity instanceEntity,
Map<String,String> properties,
ViewConfig viewConfig,
ClassLoader classLoader)
Set the properties of the given view instance from the given property set.
|
protected void |
setViewInstanceRoleAccess(ViewInstanceEntity viewInstanceEntity,
Collection<String> roles)
Set access to the a particular view instance based on a set of roles.
|
void |
uninstallViewInstance(ViewInstanceEntity instanceEntity)
Uninstall a view instance for the view with the given view name.
|
void |
unregisterListener(org.apache.ambari.view.events.Listener listener,
String viewName,
String viewVersion)
Un-register the given listener from the view identified by the given name and version.
|
void |
updateView(ViewInstanceEntity instanceEntity)
Calls onUpdate hook on View class
|
void |
updateViewInstance(ViewInstanceEntity instanceEntity)
Update a view instance for the view with the given view name.
|
protected static final int DEFAULT_REQUEST_CONNECT_TIMEOUT
protected static final int DEFAULT_REQUEST_READ_TIMEOUT
public static final String API_PREFIX
public static final String DEFAULT_AUTO_INSTANCE_URL
protected ViewDataMigrationUtility viewDataMigrationUtility
@Inject public ViewRegistry(AmbariEventPublisher publisher)
public static void main(String[] args)
args
- the command line argumentspublic Collection<ViewEntity> getDefinitions()
public ViewEntity getDefinition(String viewName, String version)
viewName
- the view nameversion
- the versionpublic ViewEntity getDefinition(ResourceTypeEntity resourceTypeEntity)
resourceTypeEntity
- the resource typepublic void addDefinition(ViewEntity definition)
definition
- the definitionpublic Collection<ViewInstanceEntity> getInstanceDefinitions(ViewEntity definition)
definition
- the view definitionpublic ViewInstanceEntity getInstanceDefinition(String viewName, String version, String instanceName)
viewName
- the view nameversion
- the versioninstanceName
- the instance namepublic void addInstanceDefinition(ViewEntity definition, ViewInstanceEntity instanceDefinition)
definition
- the owning view definitioninstanceDefinition
- the instance definitionpublic void removeInstanceDefinition(ViewEntity definition, String instanceName)
definition
- the owning view definitioninstanceName
- the instance namepublic static void initInstance(ViewRegistry singleton)
singleton
- the view registrypublic static ViewRegistry getInstance()
public Set<SubResourceDefinition> getSubResourceDefinitions(String viewName, String version)
viewName
- the instance nameversion
- the versionpublic void readViewArchives()
public void readViewArchives(String viewNameRegExp)
viewNameRegExp
- view name regular expressionpublic boolean instanceExists(ViewInstanceEntity instanceEntity)
instanceEntity
- the view instance entitypublic void installViewInstance(ViewInstanceEntity instanceEntity) throws ValidationException, IllegalArgumentException, org.apache.ambari.view.SystemException
ViewInstanceOperationHandler
Install the given view instance with its associated view.instanceEntity
- the view instance entityValidationException
- if the given instance fails the validation checksIllegalArgumentException
- if the view associated with the given instance
does not existorg.apache.ambari.view.SystemException
- if the instance can not be installedpublic void updateViewInstance(ViewInstanceEntity instanceEntity) throws ValidationException, org.apache.ambari.view.SystemException
instanceEntity
- the view instance entityValidationException
- if the given instance fails the validation checksorg.apache.ambari.view.SystemException
- if the instance can not be updatedpublic void updateView(ViewInstanceEntity instanceEntity)
instanceEntity
- public ViewInstanceEntity getViewInstanceEntity(String viewName, String instanceName)
viewName
- the view nameinstanceName
- the instance namepublic void uninstallViewInstance(ViewInstanceEntity instanceEntity) throws IllegalStateException
instanceEntity
- the view instance entityIllegalStateException
- if the given instance is not in a valid statepublic void removeInstanceData(ViewInstanceEntity instanceEntity, String key)
instanceEntity
- the instance entitykey
- the data keypublic void copyPrivileges(ViewInstanceEntity sourceInstanceEntity, ViewInstanceEntity targetInstanceEntity)
sourceInstanceEntity
- the source instance entitytargetInstanceEntity
- the target instance entitypublic void fireEvent(org.apache.ambari.view.events.Event event)
event
- the eventpublic void registerListener(org.apache.ambari.view.events.Listener listener, String viewName, String viewVersion)
listener
- the listenerviewName
- the view nameviewVersion
- the view version; null indicates all versionspublic void unregisterListener(org.apache.ambari.view.events.Listener listener, String viewName, String viewVersion)
listener
- the listenerviewName
- the view nameviewVersion
- the view version; null indicates all versionspublic boolean hasPermission(PermissionEntity permissionEntity, ResourceEntity resourceEntity, String userName)
permissionEntity
- the permission entityresourceEntity
- the resource entityuserName
- the user namepublic boolean checkPermission(String viewName, String version, String instanceName, boolean readOnly)
viewName
- the view nameversion
- the view versioninstanceName
- the name of the view instance resourcereadOnly
- indicate whether or not this is for a read only operationpublic boolean checkPermission(ViewInstanceEntity instanceEntity, boolean readOnly)
instanceEntity
- the view instance entityreadOnly
- indicate whether or not this is for a read only operationpublic boolean checkAdmin()
public boolean includeDefinition(ViewEntity definitionEntity)
definitionEntity
- the view definition entitypublic void setViewInstanceProperties(ViewInstanceEntity instanceEntity, Map<String,String> properties, ViewConfig viewConfig, ClassLoader classLoader) throws org.apache.ambari.view.SystemException
instanceEntity
- the view instance entityproperties
- the view instance propertiesviewConfig
- the view configurationclassLoader
- the class loader for the vieworg.apache.ambari.view.SystemException
- if the view instance properties can not be setpublic org.apache.ambari.view.cluster.Cluster getCluster(org.apache.ambari.view.ViewInstanceDefinition viewInstance)
viewInstance
- the view instancepublic void onAmbariEvent(ServiceInstalledEvent event)
event
- the service installed eventpublic void onClusterConfigFinishedEvent(ClusterConfigFinishedEvent event)
protected void clear()
protected Map<Resource.Type,ResourceProvider> getResourceProviders()
protected ViewEntity setupViewDefinition(ViewEntity viewDefinition, ClassLoader cl) throws ClassNotFoundException, IntrospectionException
protected ViewInstanceEntity createViewInstanceDefinition(ViewConfig viewConfig, ViewEntity viewDefinition, InstanceConfig instanceConfig) throws ValidationException, ClassNotFoundException, org.apache.ambari.view.SystemException
ValidationException
ClassNotFoundException
org.apache.ambari.view.SystemException
protected void bindViewInstance(ViewEntity viewDefinition, ViewInstanceEntity viewInstanceDefinition) throws ClassNotFoundException
ClassNotFoundException
protected void onDeploy(ViewEntity definition)
public void readViewArchive(Path path)
path
- protected void setViewInstanceRoleAccess(ViewInstanceEntity viewInstanceEntity, Collection<String> roles)
View access to the specified view instances will be granted to anyone directly or indirectly assigned to one of the roles in the suppled set of role names.
viewInstanceEntity
- a view instance entityroles
- the set of roles to use to for granting accessprotected boolean checkViewVersions(ViewEntity view, String serverVersion)
view
- the viewserverVersion
- the server versionprotected static boolean extractViewArchive(String archivePath, ViewRegistry.ViewModule viewModule, boolean systemOnly) throws Exception
Exception
protected ViewURLStreamProvider createURLStreamProvider(org.apache.ambari.view.ViewContext viewContext)
viewContext
- the view contextprotected ViewAmbariStreamProvider createAmbariStreamProvider()
protected org.apache.ambari.view.AmbariStreamProvider createRemoteAmbariStreamProvider(Long clusterId)
clusterId
- protected ViewDataMigrationUtility getViewDataMigrationUtility()
protected void setViewDataMigrationUtility(ViewDataMigrationUtility viewDataMigrationUtility)
Copyright © 2022 Apache Software Foundation. All rights reserved.