http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java new file mode 100644 index 0000000..8a47945 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java @@ -0,0 +1,858 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.admin; + +import org.apache.atlas.ocf.Connector; +import org.apache.atlas.ocf.ConnectorBroker; +import org.apache.atlas.ocf.properties.Connection; +import org.apache.atlas.omrs.admin.properties.CohortConfig; +import org.apache.atlas.omrs.admin.properties.EnterpriseAccessConfig; +import org.apache.atlas.omrs.admin.properties.LocalRepositoryConfig; +import org.apache.atlas.omrs.admin.properties.RepositoryServicesConfig; +import org.apache.atlas.omrs.archivemanager.OMRSArchiveManager; +import org.apache.atlas.omrs.archivemanager.store.OpenMetadataArchiveStore; +import org.apache.atlas.omrs.auditlog.OMRSAuditCode; +import org.apache.atlas.omrs.auditlog.OMRSAuditLog; +import org.apache.atlas.omrs.auditlog.OMRSAuditingComponent; +import org.apache.atlas.omrs.auditlog.store.OMRSAuditLogStore; +import org.apache.atlas.omrs.enterprise.connectormanager.OMRSConnectionConsumer; +import org.apache.atlas.omrs.enterprise.connectormanager.OMRSEnterpriseConnectorManager; +import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventExchangeRule; +import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventManager; +import org.apache.atlas.omrs.eventmanagement.repositoryeventmapper.OMRSRepositoryEventMapper; +import org.apache.atlas.omrs.ffdc.exception.OMRSConfigErrorException; +import org.apache.atlas.omrs.ffdc.OMRSErrorCode; +import org.apache.atlas.omrs.ffdc.exception.OMRSLogicErrorException; +import org.apache.atlas.omrs.ffdc.exception.OMRSRuntimeException; +import org.apache.atlas.omrs.enterprise.repositoryconnector.EnterpriseOMRSConnectorProvider; +import org.apache.atlas.omrs.localrepository.repositoryconnector.LocalOMRSConnectorProvider; +import org.apache.atlas.omrs.localrepository.repositoryconnector.LocalOMRSRepositoryConnector; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryContentManager; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSTypeDefValidator; +import org.apache.atlas.omrs.metadatahighway.OMRSMetadataHighwayManager; +import org.apache.atlas.omrs.rest.server.OMRSRepositoryRESTServices; +import org.apache.atlas.omrs.topicconnectors.OMRSTopicConnector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; + +/** + * OMRSOperationalServices provides the OMAG Server with access to the OMRS capabilities. + * This includes managing the local metadata repository, connecting and disconnecting from the metadata + * highway and supporting administrative + * actions captured through the OMAG REST interface. + * + * Examples of the types of capabilities offered by the OMRS Manager include: + * <ul> + * <li>Initialize and Shutdown the OMRS</li> + * <li>See the state of the cluster</li> + * <li>see the state of the connectors</li> + * <li>View the audit log</li> + * <li>Load new connector JARs</li> + * <li>Connect/disconnect from the metadata highway</li> + * </ul> + */ +public class OMRSOperationalServices +{ + /* + * The audit log provides a verifiable record of the membership of the open metadata repository cohort and the + * metadata exchange activity they are involved in. The Logger is for standard debug. + */ + private static final Logger log = LoggerFactory.getLogger(OMRSOperationalServices.class); + private static final OMRSAuditLog auditLog = new OMRSAuditLog(OMRSAuditingComponent.OPERATIONAL_SERVICES); + + + private String localServerName = null; + private String localServerType = null; + private String localOrganizationName = null; + private String localMetadataCollectionId = null; + + private OMRSRepositoryContentManager localRepositoryContentManager = null; + private OMRSRepositoryEventManager localRepositoryEventManager = null; + private OMRSMetadataHighwayManager metadataHighwayManager = null; + private OMRSEnterpriseConnectorManager enterpriseConnectorManager = null; + private OMRSTopicConnector enterpriseOMRSTopicConnector = null; + private LocalOMRSRepositoryConnector localRepositoryConnector = null; + private OMRSArchiveManager archiveManager = null; + + + /** + * Constructor used at server startup. + * + * @param localServerName - name of the local server + * @param localServerType - type of the local server + * @param organizationName - name of the organization that owns the local server + */ + public OMRSOperationalServices(String localServerName, + String localServerType, + String organizationName) + { + /* + * Save details about the local server + */ + this.localServerName = localServerName; + this.localServerType = localServerType; + this.localOrganizationName = organizationName; + } + + + /** + * Initialize the OMRS component for the Open Metadata Repository Services (OMRS). The configuration + * is taken as is. Any configuration errors are reported as exceptions. + * + * @param repositoryServicesConfig - current configuration values + */ + public void initialize(RepositoryServicesConfig repositoryServicesConfig) + { + final String actionDescription = "Initialize Repository Operational Services"; + final String methodName = "initialize()"; + OMRSAuditCode auditCode = null; + + + if (repositoryServicesConfig == null) + { + /* + * Throw exception as without configuration information the OMRS can not start. + */ + OMRSErrorCode errorCode = OMRSErrorCode.NULL_CONFIG; + String errorMessage = errorCode.getErrorMessageId() + + errorCode.getFormattedErrorMessage(); + + throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), + this.getClass().getName(), + methodName, + errorMessage, + errorCode.getSystemAction(), + errorCode.getUserAction()); + } + + /* + * Initialize the audit log + */ + OMRSAuditLog.initialize(localServerName, + localServerType, + localOrganizationName, + getAuditLogStore(repositoryServicesConfig.getAuditLogConnection())); + + /* + * Log that the OMRS is starting. There is another Audit log message logged at the end of this method + * to confirm that all of the pieces started successfully. + */ + auditCode = OMRSAuditCode.OMRS_INITIALIZING; + auditLog.logRecord(actionDescription, + auditCode.getLogMessageId(), + auditCode.getSeverity(), + auditCode.getFormattedLogMessage(), + null, + auditCode.getSystemAction(), + auditCode.getUserAction()); + /* + * There are 3 major groupings of components, each are optional and have linkages between one another. + * These are the enterprise access services, local repository and the metadata highway (cohort services). + * Each group as its own config. + */ + EnterpriseAccessConfig enterpriseAccessConfig = repositoryServicesConfig.getEnterpriseAccessConfig(); + LocalRepositoryConfig localRepositoryConfig = repositoryServicesConfig.getLocalRepositoryConfig(); + ArrayList<CohortConfig> cohortConfigList = repositoryServicesConfig.getCohortConfigList(); + + /* + * Begin with the enterprise repository services. They are always needed since the + * Open Metadata Access Services (OMAS) is dependent on them. There are 2 modes of operation: local only + * and enterprise access. Enterprise access provide an enterprise view of metadata + * across all of the open metadata repository cohorts that this server connects to. + * If EnterpriseAccessConfig is null, the enterprise repository services run in local only mode. + * Otherwise the supplied configuration properties enable it to be configured for enterprise access. + * + * The connector manager manages the list of connectors to metadata repositories that the enterprise + * repository services will use. The OMRS Topic is used to publish events from these repositories to support the + * OMASs' event notifications. + */ + enterpriseConnectorManager = initializeEnterpriseConnectorManager(enterpriseAccessConfig); + enterpriseOMRSTopicConnector = initializeEnterpriseOMRSTopicConnector(enterpriseAccessConfig); + + /* + * The archive manager loads pre-defined types and instances that are stored in open metadata archives. + */ + archiveManager = initializeOpenMetadataArchives(repositoryServicesConfig.getOpenMetadataArchiveConnectionList()); + + /* + * The local repository is optional. However, the repository content manager is still + * used to manage the validation of TypeDefs and the creation of metadata instances. + * It is loaded with any TypeDefs from the archives to seed its in-memory TypeDef cache. + */ + localRepositoryContentManager = new OMRSRepositoryContentManager(); + + /* + * The repository validator and helper are used by repository connectors to verify the types and instances + * they receive from external parties and to build new types and instances. Instances of these + * classes are created in each of the repository connectors (and possibly the event mappers as well). + * They are given a link to the repository content manager since it has the cache of TypeDefs. + */ + OMRSRepositoryValidator.setRepositoryContentManager(localRepositoryContentManager); + OMRSRepositoryHelper.setRepositoryContentManager(localRepositoryContentManager); + + /* + * Start up the local repository if one is configured. + */ + if (localRepositoryConfig != null) + { + localMetadataCollectionId = localRepositoryConfig.getMetadataCollectionId(); + + auditCode = OMRSAuditCode.LOCAL_REPOSITORY_INITIALIZING; + auditLog.logRecord(actionDescription, + auditCode.getLogMessageId(), + auditCode.getSeverity(), + auditCode.getFormattedLogMessage(localMetadataCollectionId), + null, + auditCode.getSystemAction(), + auditCode.getUserAction()); + + localRepositoryEventManager = + new OMRSRepositoryEventManager( + new OMRSRepositoryEventExchangeRule("Local Repository Events to Send", + localRepositoryContentManager, + localRepositoryConfig.getEventsToSendRule(), + localRepositoryConfig.getSelectedTypesToSend())); + + /* + * Pass the local metadata collectionId to the AuditLog + */ + OMRSAuditLog.setLocalMetadataCollectionId(localMetadataCollectionId); + + localRepositoryConnector = initializeLocalRepository(localRepositoryConfig); + + /* + * Set up the OMRS REST Services with the local repository + */ + OMRSRepositoryRESTServices.setLocalRepository(localRepositoryConnector); + } + + /* + * This is the point at which the open metadata archives will be processed. The archives are processed + * using the same mechanisms as TypeDef/Instance events received from other members of the cohort. This + * is because the metadata in the archives is effectively reference metadata that is owned by the archive + * and should not be updated in the local repository. + * + * Note that if the local repository is not configured then only TypeDefs are processed because there + * is nowhere to store the instances. The TypeDefs are used for validation of metadata that is passed to + * the enterprise repository services. + */ + if (localRepositoryConnector != null) + { + archiveManager.setLocalRepository(localRepositoryContentManager, + localRepositoryConnector.getIncomingInstanceEventProcessor()); + } + else + { + archiveManager.setLocalRepository(localRepositoryContentManager, + null); + } + + /* + * Connect the local repository connector to the connector manager if they both exist. This means + * that enterprise repository requests will include metadata from the local repository. + */ + if ((localRepositoryConnector != null) && (enterpriseConnectorManager != null)) + { + enterpriseConnectorManager.setLocalConnector(localRepositoryConnector.getMetadataCollectionId(), + localRepositoryConnector); + } + + /* + * local operation is ready, now connect to the metadata highway. + */ + if (cohortConfigList != null) + { + auditCode = OMRSAuditCode.METADATA_HIGHWAY_INITIALIZING; + auditLog.logRecord(actionDescription, + auditCode.getLogMessageId(), + auditCode.getSeverity(), + auditCode.getFormattedLogMessage(), + null, + auditCode.getSystemAction(), + auditCode.getUserAction()); + + metadataHighwayManager = initializeCohorts(localServerName, + localServerType, + localOrganizationName, + localRepositoryConnector, + localRepositoryContentManager, + enterpriseConnectorManager, + enterpriseOMRSTopicConnector, + cohortConfigList); + } + + /* + * All done and no exceptions :) + */ + auditCode = OMRSAuditCode.OMRS_INITIALIZED; + auditLog.logRecord(actionDescription, + auditCode.getLogMessageId(), + auditCode.getSeverity(), + auditCode.getFormattedLogMessage(), + null, + auditCode.getSystemAction(), + auditCode.getUserAction()); + } + + + /** + * Return the connector to the Enterprise OMRS Topic. If null is returned it means the Enterprise OMRS Topic + * is not needed. A configuration error exception is thrown if there is a problem with the connection properties + * + * @param enterpriseAccessConfig - configuration from the OMAG server + * @return connector to the Enterprise OMRS Topic or null + */ + private OMRSTopicConnector initializeEnterpriseOMRSTopicConnector(EnterpriseAccessConfig enterpriseAccessConfig) + { + OMRSTopicConnector enterpriseOMRSTopicConnector = null; + + if (enterpriseAccessConfig != null) + { + Connection enterpriseOMRSTopicConnection = enterpriseAccessConfig.getEnterpriseOMRSTopicConnection(); + + if (enterpriseOMRSTopicConnection != null) + { + enterpriseOMRSTopicConnector = getTopicConnector("Enterprise Access", + enterpriseOMRSTopicConnection); + } + } + + return enterpriseOMRSTopicConnector; + } + + + /** + * Initialize the OMRSEnterpriseConnectorManager and the EnterpriseOMRSConnector class. If the + * enterprise access configuration + * + * @param enterpriseAccessConfig - enterprise access configuration from the OMAG server + * @return initialized OMRSEnterpriseConnectorManager object + */ + private OMRSEnterpriseConnectorManager initializeEnterpriseConnectorManager(EnterpriseAccessConfig enterpriseAccessConfig) + { + OMRSEnterpriseConnectorManager enterpriseConnectorManager = null; + + if (enterpriseAccessConfig == null) + { + /* + * Federation is not enabled in this server + */ + enterpriseConnectorManager = new OMRSEnterpriseConnectorManager(false); + + /* + * Pass the address of the enterprise connector manager to the OMRSEnterpriseConnectorProvider class as + * the connector manager is needed by each instance of the EnterpriseOMRSConnector. + */ + EnterpriseOMRSConnectorProvider.initialize(enterpriseConnectorManager, + null, + null); + } + else + { + /* + * Enterprise access is enabled in this server + */ + final String actionDescription = "Initialize Repository Operational Services"; + + OMRSAuditCode auditCode = OMRSAuditCode.ENTERPRISE_ACCESS_INITIALIZING; + auditLog.logRecord(actionDescription, + auditCode.getLogMessageId(), + auditCode.getSeverity(), + auditCode.getFormattedLogMessage(), + null, + auditCode.getSystemAction(), + auditCode.getUserAction()); + + enterpriseConnectorManager = new OMRSEnterpriseConnectorManager(true); + + /* + * Pass the address of the enterprise connector manager to the OMRSEnterpriseConnectorProvider class as + * the connector manager is needed by each instance of the EnterpriseOMRSConnector. + */ + EnterpriseOMRSConnectorProvider.initialize(enterpriseConnectorManager, + enterpriseAccessConfig.getEnterpriseMetadataCollectionId(), + enterpriseAccessConfig.getEnterpriseMetadataCollectionName()); + } + + return enterpriseConnectorManager; + } + + + /** + * If the local repository is configured then set up the local repository connector. The + * information for the local repository's OMRS Repository Connector is configured as a OCF connection in + * the local repository config. In fact there are potentially 2 connections configured. There is a connection + * for remote access to the local repository and an optional connection for a locally optimized connector to use + * within the local server. + * + * @param localRepositoryConfig - local repository config. + * @return wrapped OMRS Repository Connector + */ + private LocalOMRSRepositoryConnector initializeLocalRepository(LocalRepositoryConfig localRepositoryConfig) + { + LocalOMRSRepositoryConnector localRepositoryConnector = null; + + /* + * If the local repository is configured then create the connector to the local repository and + * configure it. It is valid to have a server with no local repository. + */ + if (localRepositoryConfig != null) + { + /* + * Create the local repository's Connector Provider. This is a special connector provider that + * creates an OMRS Repository Connector that wraps the real OMRS Repository Connector. The + * outer OMRS Repository Connector manages events, audit logging and error handling. + */ + LocalOMRSConnectorProvider localConnectorProvider = + new LocalOMRSConnectorProvider(localMetadataCollectionId, + localRepositoryConfig.getLocalRepositoryRemoteConnection(), + localServerName, + localServerType, + localOrganizationName, + getLocalRepositoryEventMapper(localRepositoryConfig.getEventMapperConnection()), + localRepositoryEventManager, + localRepositoryContentManager, + new OMRSRepositoryEventExchangeRule("Local Repository Events To Save", + localRepositoryContentManager, + localRepositoryConfig.getEventsToSaveRule(), + localRepositoryConfig.getSelectedTypesToSave())); + + + /* + * Create the local repository's connector. If there is no locally optimized connection, the + * remote connection is used. + */ + Connection localRepositoryConnection = null; + + if (localRepositoryConfig.getLocalRepositoryLocalConnection() != null) + { + localRepositoryConnection = localRepositoryConfig.getLocalRepositoryLocalConnection(); + } + else + { + localRepositoryConnection = localRepositoryConfig.getLocalRepositoryRemoteConnection(); + } + localRepositoryConnector = this.getLocalOMRSConnector(localRepositoryConnection, + localConnectorProvider); + } + + return localRepositoryConnector; + } + + + /** + * Return an OMRS archive manager configured with the list of Open Metadata Archive Stores to use. + * + * @param openMetadataArchiveConnections - connections to the open metadata archive stores + * @return OMRS archive manager + */ + private OMRSArchiveManager initializeOpenMetadataArchives(ArrayList<Connection> openMetadataArchiveConnections) + { + ArrayList<OpenMetadataArchiveStore> openMetadataArchives = null; + + if (openMetadataArchiveConnections != null) + { + openMetadataArchives = new ArrayList<>(); + + for (Connection archiveConnection : openMetadataArchiveConnections) + { + if (archiveConnection != null) + { + /* + * Any problems creating the connectors will result in an exception. + */ + openMetadataArchives.add(this.getOpenMetadataArchiveStore(archiveConnection)); + } + } + } + + return new OMRSArchiveManager(openMetadataArchives); + } + + + /** + * A server can optionally connect to one or more open metadata repository cohorts. There is one + * CohortConfig for each cohort that the server is to connect to. The communication between + * members of a cohort is event-based. The parameters provide supplied to the metadata highway manager + * include values need to send compliant OMRS Events. + * + * @param localServerName - the name of the local server. This value flows in OMRS Events. + * @param localServerType - the type of the local server. This value flows in OMRS Events. + * @param localOrganizationName - the name of the organization that owns this server. + * This value flows in OMRS Events. + * @param localRepositoryConnector - the local repository connector is supplied if there is a local repository + * for this server. + * @param localTypeDefValidator - the TypeDef validator validates the TypeDefs sent by the other members of + * the cohort(s). It is looking for conflicting TypeDefs that may cause + * metadata integrity issues as the metadata is exchanged between the servers. + * @param connectionConsumer - the connection consumer is from the enterprise repository services. It + * receives connection information about the other members of the cohort(s) + * to enable enterprise access. + * @param enterpriseTopicConnector - connector to the enterprise repository services Topic Connector. + * The cohorts replicate their events to the enterprise OMRS Topic so + * the Open Metadata Access Services (OMASs) can monitor changing metadata. + * @param cohortConfigList - list of cohorts to connect to (and the configuration to do it) + * @return newly created and initialized metadata highway manager. + */ + private OMRSMetadataHighwayManager initializeCohorts(String localServerName, + String localServerType, + String localOrganizationName, + LocalOMRSRepositoryConnector localRepositoryConnector, + OMRSTypeDefValidator localTypeDefValidator, + OMRSConnectionConsumer connectionConsumer, + OMRSTopicConnector enterpriseTopicConnector, + ArrayList<CohortConfig> cohortConfigList) + { + /* + * The metadata highway manager is constructed with the values that are the same for every cohort. + */ + OMRSMetadataHighwayManager metadataHighwayManager = new OMRSMetadataHighwayManager(localServerName, + localServerType, + localOrganizationName, + localRepositoryConnector, + localTypeDefValidator, + connectionConsumer, + enterpriseTopicConnector); + + /* + * The metadata highway manager is initialize with the details specific to each cohort. + */ + metadataHighwayManager.initialize(cohortConfigList); + + return metadataHighwayManager; + } + + + /** + * Shutdown the Open Metadata Repository Services. + * + * @param permanent - boolean flag indicating whether this server permanently shutting down or not + * @return boolean indicated whether the disconnect was successful. + */ + public boolean disconnect(boolean permanent) + { + /* + * Log that the OMRS is disconnecting. There is another Audit log message logged at the end of this method + * to confirm that all of the pieces disconnected successfully. + */ + final String actionDescription = "Disconnect Repository Operational Services"; + OMRSAuditCode auditCode = OMRSAuditCode.OMRS_DISCONNECTING; + auditLog.logRecord(actionDescription, + auditCode.getLogMessageId(), + auditCode.getSeverity(), + auditCode.getFormattedLogMessage(), + null, + auditCode.getSystemAction(), + auditCode.getUserAction()); + + + if (metadataHighwayManager != null) + { + metadataHighwayManager.disconnect(permanent); + } + + if (enterpriseOMRSTopicConnector != null) + { + try + { + enterpriseOMRSTopicConnector.disconnect(); + } + catch (Throwable error) + { + // TODO + } + } + + if (enterpriseConnectorManager != null) + { + enterpriseConnectorManager.disconnect(); + } + + if (localRepositoryConnector != null) + { + try + { + localRepositoryConnector.disconnect(); + } + catch (Throwable error) + { + + } + } + + if (archiveManager != null) + { + archiveManager.close(); + } + + auditCode = OMRSAuditCode.OMRS_DISCONNECTED; + auditLog.logRecord(actionDescription, + auditCode.getLogMessageId(), + auditCode.getSeverity(), + auditCode.getFormattedLogMessage(), + null, + auditCode.getSystemAction(), + auditCode.getUserAction()); + + return true; + } + + + /** + * Return the connector to the AuditLog store using the connection information supplied. If there is a + * problem with the connection information that means a connector can not be created, an exception is thrown. + * + * @param auditLogStoreConnection - properties for the audit log + * @return audit log store connector + */ + private OMRSAuditLogStore getAuditLogStore(Connection auditLogStoreConnection) + { + try + { + ConnectorBroker connectorBroker = new ConnectorBroker(); + Connector connector = connectorBroker.getConnector(auditLogStoreConnection); + + return (OMRSAuditLogStore)connector; + } + catch (Throwable error) + { + String methodName = "getAuditLogStore()"; + + if (log.isDebugEnabled()) + { + log.debug("Unable to create audit log store connector: " + error.toString()); + } + + /* + * Throw runtime exception to indicate that the audit log is not available. + */ + OMRSErrorCode errorCode = OMRSErrorCode.NULL_AUDIT_LOG_STORE; + String errorMessage = errorCode.getErrorMessageId() + + errorCode.getFormattedErrorMessage(localServerName); + + throw new OMRSConfigErrorException(errorCode.getHTTPErrorCode(), + this.getClass().getName(), + methodName, + errorMessage, + errorCode.getSystemAction(), + errorCode.getUserAction(), + error); + } + } + + + + /** + * Creates a topic connector using information from the supplied topic connection. This connector supported + * the Open Connector Framework (OCF) so it is possible to configure different connector implementations for + * different event/messaging infrastructure. If there is a problem with the connection information + * that means a connector can not be created, an exception is thrown. + * + * @param sourceName - name of the user of this topic + * @param topicConnection - connection parameters + * @return OMRSTopicConnector for managing communications with the event/messaging infrastructure. + */ + private OMRSTopicConnector getTopicConnector(String sourceName, + Connection topicConnection) + { + try + { + ConnectorBroker connectorBroker = new ConnectorBroker(); + Connector connector = connectorBroker.getConnector(topicConnection); + + return (OMRSTopicConnector)connector; + } + catch (Throwable error) + { + String methodName = "getTopicConnector()"; + + if (log.isDebugEnabled()) + { + log.debug("Unable to create topic connector: " + error.toString()); + } + + OMRSErrorCode errorCode = OMRSErrorCode.NULL_TOPIC_CONNECTOR; + String errorMessage = errorCode.getErrorMessageId() + + errorCode.getFormattedErrorMessage(sourceName); + + throw new OMRSConfigErrorException(errorCode.getHTTPErrorCode(), + this.getClass().getName(), + methodName, + errorMessage, + errorCode.getSystemAction(), + errorCode.getUserAction(), + error); + + } + } + + + /** + * Return the connector to an open metadata archive store. Each connector instance can access a single + * open metadata archive. If there is a problem with the connection information + * that means a connector can not be created, an exception is thrown. + * + * @param openMetadataArchiveStoreConnection - properties used to create the connection + * @return open metadata archive connector + */ + private OpenMetadataArchiveStore getOpenMetadataArchiveStore(Connection openMetadataArchiveStoreConnection) + { + try + { + ConnectorBroker connectorBroker = new ConnectorBroker(); + Connector connector = connectorBroker.getConnector(openMetadataArchiveStoreConnection); + + return (OpenMetadataArchiveStore)connector; + } + catch (Throwable error) + { + String methodName = "getOpenMetadataArchiveStore()"; + + if (log.isDebugEnabled()) + { + log.debug("Unable to create open metadata archive connector: " + error.toString()); + } + + /* + * Throw runtime exception to indicate that the open metadata archive store is not available. + */ + OMRSErrorCode errorCode = OMRSErrorCode.NULL_ARCHIVE_STORE; + String errorMessage = errorCode.getErrorMessageId() + + errorCode.getFormattedErrorMessage(localServerName); + + throw new OMRSRuntimeException(errorCode.getHTTPErrorCode(), + this.getClass().getName(), + methodName, + errorMessage, + errorCode.getSystemAction(), + errorCode.getUserAction(), + error); + } + } + + + /** + * The local repository may need an event mapper to convert its proprietary events to OMRS Events. + * An event mapper is implemented as an OMRSRepositoryEventMapper Connector and it is initialized through the + * OCF Connector Broker using an OCF connection. + * + * @param localRepositoryEventMapperConnection - connection to the local repository's event mapper. + * @return local repository's event mapper + */ + private OMRSRepositoryEventMapper getLocalRepositoryEventMapper(Connection localRepositoryEventMapperConnection) + { + /* + * If the event mapper is null it means the local repository does not need an event mapper. + * This is not an error. + */ + if (localRepositoryEventMapperConnection == null) + { + return null; + } + + /* + * The event mapper is a pluggable component that is implemented as an OCF connector. Its configuration is + * passed to it in a Connection object and the ConnectorBroker manages its creation and initialization. + */ + try + { + ConnectorBroker connectorBroker = new ConnectorBroker(); + Connector connector = connectorBroker.getConnector(localRepositoryEventMapperConnection); + + return (OMRSRepositoryEventMapper)connector; + } + catch (Throwable error) + { + String methodName = "getLocalRepositoryEventMapper()"; + + if (log.isDebugEnabled()) + { + log.debug("Unable to create local repository event mapper connector: " + error.toString()); + } + + /* + * Throw runtime exception to indicate that the local repository's event mapper is not available. + */ + OMRSErrorCode errorCode = OMRSErrorCode.NULL_EVENT_MAPPER; + String errorMessage = errorCode.getErrorMessageId() + + errorCode.getFormattedErrorMessage(localServerName); + + throw new OMRSConfigErrorException(errorCode.getHTTPErrorCode(), + this.getClass().getName(), + methodName, + errorMessage, + errorCode.getSystemAction(), + errorCode.getUserAction(), + error); + } + } + + + + /** + * Private method to convert a Connection into a LocalOMRSRepositoryConnector using the LocalOMRSConnectorProvider. + * The supplied connection is for the real local connector. LocalOMRSRepositoryConnector will create the + * real local connector and ensure all requests it receives are passed to it. + * + * @param connection - Connection properties for the real local connection + * @param connectorProvider - connector provider to create the repository connector + * @return LocalOMRSRepositoryConnector wrapping the real local connector + */ + private LocalOMRSRepositoryConnector getLocalOMRSConnector(Connection connection, + LocalOMRSConnectorProvider connectorProvider) + { + String methodName = "getLocalOMRSConnector()"; + + /* + * Although the localOMRSConnector is an OMRSRepositoryConnector, its initialization is + * managed directly with its connector provider (rather than using the connector broker) because it + * needs access to a variety of OMRS components in order for it to support access to the local + * repository by other OMRS components. As such it needs more variables at initialization. + */ + try + { + return (LocalOMRSRepositoryConnector)connectorProvider.getConnector(connection); + } + catch (Throwable error) + { + /* + * If there is a problem initializing the connector then the ConnectorBroker will have created a + * detailed exception already. The only error case that this method has introduced is the cast + * of the Connector to OMRSRepositoryConnector. This could occur if the connector configured is a valid + * OCF Connector but not an OMRSRepositoryConnector. + */ + String connectionName = connection.getConnectionName(); + + OMRSErrorCode errorCode = OMRSErrorCode.INVALID_OMRS_CONNECTION; + String errorMessage = errorCode.getErrorMessageId() + + errorCode.getFormattedErrorMessage(connectionName); + + throw new OMRSRuntimeException(errorCode.getHTTPErrorCode(), + this.getClass().getName(), + methodName, + errorMessage, + errorCode.getSystemAction(), + errorCode.getUserAction(), + error); + } + } +}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/CohortConfig.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/CohortConfig.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/CohortConfig.java new file mode 100644 index 0000000..5fc5983 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/CohortConfig.java @@ -0,0 +1,233 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.admin.properties; + + +import org.apache.atlas.ocf.properties.Connection; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary; + +import java.util.ArrayList; + +/** + * CohortConfig provides the configuration properties used to connect to an open metadata repository cohort. + * <ul> + * <li> + * cohortName is a descriptive name for the cohort that is used primarily for messages and diagnostics. + * It is also used to create a default name for the cohort's OMRS Topic and the cohortRegistry's store + * if these names are not explicitly defined. + * </li> + * <li> + * cohortRegistryConnection is the connection properties necessary to create the connector to the + * cohort registry store. This is the store where the cohort registry keeps information about its + * local metadata collection Id and details of other repositories in the cohort. + * + * The default value is to use a local file called "cohort.registry" that is stored in the server's + * home directory. + * </li> + * <li> + * cohortOMRSTopicConnection is the connection properties necessary to create the connector to the OMRS Topic. + * This is used to send/receive events between members of the open metadata repository cohort. + * </li> + * <li> + * cohortOMRSTopicProtocolVersion defines the versionName of the event payload to use when communicating with other + * members of the cohort through the OMRS Topic. + * </li> + * <li> + * eventsToProcessRule defines how incoming events on the OMRS Topic should be processed. + * </li> + * <li> + * selectedTypesToProcess - list of TypeDefs used if the eventsToProcess rule (above) says + * "SELECTED_TYPES" - otherwise it is set to null. + * </li> + * </ul> + */ +public class CohortConfig +{ + private String cohortName = null; + private Connection cohortRegistryConnection = null; + private Connection cohortOMRSTopicConnection = null; + private OpenMetadataEventProtocolVersion cohortOMRSTopicProtocolVersion = null; + private OpenMetadataExchangeRule eventsToProcessRule = null; + private ArrayList<TypeDefSummary> selectedTypesToProcess = null; + + + + /** + * Default constructor does nothing. + */ + public CohortConfig() + { + } + + + /** + * Constructor to populate all config values. + * + * @param cohortName - name of the cohort + * @param cohortRegistryConnection - connection to the cohort registry store + * @param cohortOMRSTopicConnection - connection to the OMRS Topic + * @param eventsToProcessRule - rule indicating whether metadata events should be sent to the federated OMRS Topic. + * @param selectedTypesToProcess - if the rule says "SELECTED_TYPES" then this is the list of types - otherwise + * it is set to null. + */ + public CohortConfig(String cohortName, + Connection cohortRegistryConnection, + Connection cohortOMRSTopicConnection, + OpenMetadataExchangeRule eventsToProcessRule, + ArrayList<TypeDefSummary> selectedTypesToProcess) + { + this.cohortName = cohortName; + this.cohortRegistryConnection = cohortRegistryConnection; + this.cohortOMRSTopicConnection = cohortOMRSTopicConnection; + this.eventsToProcessRule = eventsToProcessRule; + this.selectedTypesToProcess = selectedTypesToProcess; + } + + + /** + * Return the name of the cohort. + * + * @return String name + */ + public String getCohortName() + { + return cohortName; + } + + + /** + * Set up the name of the cohort. + * + * @param cohortName String + */ + public void setCohortName(String cohortName) + { + this.cohortName = cohortName; + } + + + /** + * Set up the connection to the cohort registry store. + * + * @return Connection object + */ + public Connection getCohortRegistryConnection() + { + return cohortRegistryConnection; + } + + + /** + * Set up the connection for the cohort registry store. + * + * @param cohortRegistryConnection - Connection object + */ + public void setCohortRegistryConnection(Connection cohortRegistryConnection) + { + this.cohortRegistryConnection = cohortRegistryConnection; + } + + + /** + * Return the connection to the cohort's OMRS Topic. + * + * @return Connection object + */ + public Connection getCohortOMRSTopicConnection() + { + return cohortOMRSTopicConnection; + } + + /** + * Set up the connection to the cohort's OMRS Topic. + * + * @param cohortOMRSTopicConnection - Connection object + */ + public void setCohortOMRSTopicConnection(Connection cohortOMRSTopicConnection) + { + this.cohortOMRSTopicConnection = cohortOMRSTopicConnection; + } + + + /** + * Return the protocol versionName to use when exchanging events amongst the cohort members. + * + * @return protocol versionName enum + */ + public OpenMetadataEventProtocolVersion getCohortOMRSTopicProtocolVersion() + { + return cohortOMRSTopicProtocolVersion; + } + + + /** + * Set up the protocol versionName to use when exchanging events amongst the cohort members. + * + * @param cohortOMRSTopicProtocolVersion - protocol versionName enum + */ + public void setCohortOMRSTopicProtocolVersion(OpenMetadataEventProtocolVersion cohortOMRSTopicProtocolVersion) + { + this.cohortOMRSTopicProtocolVersion = cohortOMRSTopicProtocolVersion; + } + + + /** + * Return the rule indicating whether incoming metadata events from a cohort should be processed. + * + * @return OpenMetadataExchangeRule - NONE, JUST_TYPEDEFS, SELECTED_TYPES and ALL. + */ + public OpenMetadataExchangeRule getEventsToProcessRule() + { + return eventsToProcessRule; + } + + + /** + * Set up the rule indicating whether incoming metadata events from a cohort should be processed. + * + * @param eventsToProcessRule - OpenMetadataExchangeRule - NONE, JUST_TYPEDEFS, SELECTED_TYPES and ALL. + */ + public void setEventsToProcessRule(OpenMetadataExchangeRule eventsToProcessRule) + { + this.eventsToProcessRule = eventsToProcessRule; + } + + + /** + * Return the list of TypeDefs used if the eventsToProcess rule (above) says "SELECTED_TYPES" - otherwise + * it is set to null. + * + * @return list of TypeDefs that determine which metadata instances to process + */ + public ArrayList<TypeDefSummary> getSelectedTypesToProcess() + { + return selectedTypesToProcess; + } + + + /** + * Set up the list of TypeDefs used if the EventsToProcess rule (above) says "SELECTED_TYPES" - otherwise + * it is set to null. + * + * @param selectedTypesToProcess - list of TypeDefs that determine which metadata instances to process + */ + public void setSelectedTypesToProcess(ArrayList<TypeDefSummary> selectedTypesToProcess) + { + this.selectedTypesToProcess = selectedTypesToProcess; + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/EnterpriseAccessConfig.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/EnterpriseAccessConfig.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/EnterpriseAccessConfig.java new file mode 100644 index 0000000..72e84af --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/EnterpriseAccessConfig.java @@ -0,0 +1,167 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.admin.properties; + +import org.apache.atlas.ocf.properties.Connection; + +/** + * EnterpriseAccessConfig describes the properties that control the enterprise access services that the + * OMRS provides to the Open Metadata Access Services (OMASs). + * <ul> + * <li> + * enterpriseMetadataCollectionName - name of the combined metadata collection covered by the connected open + * metadata repositories. Used for messages. + * </li> + * <li> + * enterpriseMetadataCollectionId - unique identifier for the combined metadata collection covered by the + * connected open metadata repositories. + * </li> + * <li> + * enterpriseOMRSTopicConnection - connection for the enterprise OMRS Topic connector. + * </li> + * </ul> + */ +public class EnterpriseAccessConfig +{ + private String enterpriseMetadataCollectionName = null; + private String enterpriseMetadataCollectionId = null; + private Connection enterpriseOMRSTopicConnection = null; + private OpenMetadataEventProtocolVersion enterpriseOMRSTopicProtocolVersion = null; + + + /** + * Default Constructor does nothing. + */ + public EnterpriseAccessConfig() + { + } + + + /** + * Constructor to set up all configuration values. + * + * @param enterpriseMetadataCollectionName - name of the combined metadata collection covered by the connected open + * metadata repositories. Used for messages. + * @param enterpriseMetadataCollectionId - unique identifier for the combined metadata collection covered by the + * connected open metadata repositories. + * @param enterpriseOMRSTopicConnection - connection for the OMRS Topic connector. + * @param enterpriseOMRSTopicProtocolVersion - protocol versionName enum + */ + public EnterpriseAccessConfig(String enterpriseMetadataCollectionName, + String enterpriseMetadataCollectionId, + Connection enterpriseOMRSTopicConnection, + OpenMetadataEventProtocolVersion enterpriseOMRSTopicProtocolVersion) + { + this.enterpriseMetadataCollectionName = enterpriseMetadataCollectionName; + this.enterpriseMetadataCollectionId = enterpriseMetadataCollectionId; + this.enterpriseOMRSTopicConnection = enterpriseOMRSTopicConnection; + this.enterpriseOMRSTopicProtocolVersion = enterpriseOMRSTopicProtocolVersion; + } + + + /** + * Return the name of the combined metadata collection covered by the connected open + * metadata repositories. Used for messages. + * + * @return String name + */ + public String getEnterpriseMetadataCollectionName() + { + return enterpriseMetadataCollectionName; + } + + + /** + * Set up the name of the combined metadata collection covered by the connected open + * metadata repositories. Used for messages. + * + * @param enterpriseMetadataCollectionName - String name + */ + public void setEnterpriseMetadataCollectionName(String enterpriseMetadataCollectionName) + { + this.enterpriseMetadataCollectionName = enterpriseMetadataCollectionName; + } + + + /** + * Return the unique identifier for the combined metadata collection covered by the + * connected open metadata repositories. + * + * @return Unique identifier (guid) + */ + public String getEnterpriseMetadataCollectionId() + { + return enterpriseMetadataCollectionId; + } + + + /** + * Set up the unique identifier for the combined metadata collection covered by the + * connected open metadata repositories. + * + * @param enterpriseMetadataCollectionId - Unique identifier (guid) + */ + public void setEnterpriseMetadataCollectionId(String enterpriseMetadataCollectionId) + { + this.enterpriseMetadataCollectionId = enterpriseMetadataCollectionId; + } + + + /** + * Return the connection for the Enterprise OMRS Topic connector. + * + * @return Connection object + */ + public Connection getEnterpriseOMRSTopicConnection() + { + return enterpriseOMRSTopicConnection; + } + + + /** + * Set up the connection for the Enterprise OMRS Topic connector. + * + * @param enterpriseOMRSTopicConnection - Connection object + */ + public void setEnterpriseOMRSTopicConnection(Connection enterpriseOMRSTopicConnection) + { + this.enterpriseOMRSTopicConnection = enterpriseOMRSTopicConnection; + } + + + /** + * Return the protocol versionName to use on the EnterpriseOMRSTopicConnector. + * + * @return protocol versionName enum + */ + public OpenMetadataEventProtocolVersion getEnterpriseOMRSTopicProtocolVersion() + { + return enterpriseOMRSTopicProtocolVersion; + } + + + /** + * Set up the protocol versionName to use on the EnterpriseOMRSTopicConnector. + * + * @param enterpriseOMRSTopicProtocolVersion - protocol versionName enum + */ + public void setEnterpriseOMRSTopicProtocolVersion(OpenMetadataEventProtocolVersion enterpriseOMRSTopicProtocolVersion) + { + this.enterpriseOMRSTopicProtocolVersion = enterpriseOMRSTopicProtocolVersion; + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/LocalRepositoryConfig.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/LocalRepositoryConfig.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/LocalRepositoryConfig.java new file mode 100644 index 0000000..d35b788 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/LocalRepositoryConfig.java @@ -0,0 +1,310 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.admin.properties; + +import org.apache.atlas.ocf.properties.Connection; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary; + +import java.util.ArrayList; + + +/** + * LocalRepositoryConfig provides the properties to control the behavior of the metadata repository associated with + * this server. + * <ul> + * <li> + * metadataCollectionId - unique id of local repository's metadata collection. If this value is set to + * null, the server will generate a unique Id. + * </li> + * <li> + * localRepositoryLocalConnection - the connection properties used to create a locally optimized connector + * to the local repository for use by this local server's components. If this value is null then the + * localRepositoryRemoteConnection is used. + * </li> + * <li> + * localRepositoryRemoteConnection - the connection properties used to create a connector + * to the local repository for use by remote servers. + * </li> + * <li> + * eventsToSaveRule - enumeration describing which open metadata repository events should be saved to + * the local repository. + * </li> + * <li> + * selectedTypesToSave - list of TypeDefs in supported of the eventsToSave.SELECTED_TYPES option. + * </li> + * <li> + * eventsToSendRule - enumeration describing which open metadata repository events should be sent from + * the local repository. + * </li> + * <li> + * selectedTypesToSend - list of TypeDefs in supported of the eventsToSend.SELECTED_TYPES option. + * </li> + * <li> + * eventMapperConnection - the connection properties for the event mapper for the local repository. + * The event mapper is an optional component used when the local repository has proprietary external + * APIs that can change metadata in the repository without going through the OMRS interfaces. + * It maps the proprietary events from the local repository to the OMRS Events. + * </li> + * </ul> + */ +public class LocalRepositoryConfig +{ + private String metadataCollectionId = null; + private Connection localRepositoryLocalConnection = null; + private Connection localRepositoryRemoteConnection = null; + private OpenMetadataExchangeRule eventsToSaveRule = null; + private ArrayList<TypeDefSummary> selectedTypesToSave = null; + private OpenMetadataExchangeRule eventsToSendRule = null; + private ArrayList<TypeDefSummary> selectedTypesToSend = null; + private Connection eventMapperConnection = null; + + + /** + * Constructor + * + * @param metadataCollectionId - unique id of local repository's metadata collection + * @param localRepositoryLocalConnection - the connection properties used to create a locally optimized connector + * to the local repository for use by this local server's components. + * @param localRepositoryRemoteConnection - the connection properties used to create a connector + * to the local repository for use by remote servers. + * @param eventsToSaveRule - enumeration describing which open metadata repository events should be saved to + * the local repository. + * @param selectedTypesToSave - list of TypeDefs in supported of the eventsToSave.SELECTED_TYPES option. + * @param eventsToSendRule - enumeration describing which open metadata repository events should be sent from + * the local repository. + * @param selectedTypesToSend - list of TypeDefs in supported of the eventsToSend.SELECTED_TYPES option. + * @param eventMapperConnection - Connection for the local repository's event mapper. This is optional. + */ + public LocalRepositoryConfig(String metadataCollectionId, + Connection localRepositoryLocalConnection, + Connection localRepositoryRemoteConnection, + OpenMetadataExchangeRule eventsToSaveRule, + ArrayList<TypeDefSummary> selectedTypesToSave, + OpenMetadataExchangeRule eventsToSendRule, + ArrayList<TypeDefSummary> selectedTypesToSend, + Connection eventMapperConnection) + { + this.metadataCollectionId = metadataCollectionId; + this.localRepositoryLocalConnection = localRepositoryLocalConnection; + this.localRepositoryRemoteConnection = localRepositoryRemoteConnection; + this.eventsToSaveRule = eventsToSaveRule; + this.selectedTypesToSave = selectedTypesToSave; + this.eventsToSendRule = eventsToSendRule; + this.selectedTypesToSend = selectedTypesToSend; + this.eventMapperConnection = eventMapperConnection; + } + + + /** + * Default constructor used for JSON to Java processes - does not do anything useful because all + * local variables are initialized to null in their declaration. + */ + public LocalRepositoryConfig() + { + } + + + /** + * Return the unique id of local repository's metadata collection. If this value is set to + * null, the server will generate a unique Id. + * + * @return String unique Id + */ + public String getMetadataCollectionId() + { + return metadataCollectionId; + } + + + /** + * Set up the unique id of local repository's metadata collection. If this value is set to + * null, the server will generate a unique Id. + * + * @param metadataCollectionId - String unique Id + */ + public void setMetadataCollectionId(String metadataCollectionId) + { + this.metadataCollectionId = metadataCollectionId; + } + + + /** + * Return the connection properties used to create a locally optimized connector to the local repository for + * use by this local server's components. If this value is null then the localRepositoryRemoteConnection is used. + * + * @return Connection properties object + */ + public Connection getLocalRepositoryLocalConnection() + { + return localRepositoryLocalConnection; + } + + + /** + * Set up the connection properties used to create a locally optimized connector to the local repository for + * use by this local server's components. If this value is null then the localRepositoryRemoteConnection is used. + * + * @param localRepositoryLocalConnection - Connection properties object + */ + public void setLocalRepositoryLocalConnection(Connection localRepositoryLocalConnection) + { + this.localRepositoryLocalConnection = localRepositoryLocalConnection; + } + + + /** + * Return the connection properties used to create a connector to the local repository for use by remote servers. + * + * @return Connection properties object + */ + public Connection getLocalRepositoryRemoteConnection() + { + return localRepositoryRemoteConnection; + } + + + /** + * Set up the connection properties used to create a connector to the local repository for use by remote servers. + * + * @param localRepositoryRemoteConnection - Connection properties object + */ + public void setLocalRepositoryRemoteConnection(Connection localRepositoryRemoteConnection) + { + this.localRepositoryRemoteConnection = localRepositoryRemoteConnection; + } + + + /** + * Return the enumeration describing which open metadata repository events should be saved to + * the local repository. + * + * @return OpenMetadataExchangeRule enum + */ + public OpenMetadataExchangeRule getEventsToSaveRule() + { + return eventsToSaveRule; + } + + + /** + * Set up the enumeration describing which open metadata repository events should be saved to + * the local repository. + * + * @param eventsToSaveRule - OpenMetadataExchangeRule enum + */ + public void setEventsToSaveRule(OpenMetadataExchangeRule eventsToSaveRule) + { + this.eventsToSaveRule = eventsToSaveRule; + } + + + /** + * Return the list of TypeDefs in supported of the eventsToSave.SELECTED_TYPES option. + * + * @return list of types + */ + public ArrayList<TypeDefSummary> getSelectedTypesToSave() + { + return selectedTypesToSave; + } + + + /** + * Set up the list of TypeDefs in supported of the eventsToSave.SELECTED_TYPES option. + * + * @param selectedTypesToSave - list of types + */ + public void setSelectedTypesToSave(ArrayList<TypeDefSummary> selectedTypesToSave) + { + this.selectedTypesToSave = selectedTypesToSave; + } + + + /** + * Return the enumeration describing which open metadata repository events should be sent from + * the local repository. + * + * @return OpenMetadataExchangeRule enum + */ + public OpenMetadataExchangeRule getEventsToSendRule() + { + return eventsToSendRule; + } + + + /** + * Set up the enumeration describing which open metadata repository events should be sent from + * the local repository. + * + * @param eventsToSendRule - OpenMetadataExchangeRule enum + */ + public void setEventsToSendRule(OpenMetadataExchangeRule eventsToSendRule) + { + this.eventsToSendRule = eventsToSendRule; + } + + + /** + * Return the list of TypeDefs in supported of the eventsToSend.SELECTED_TYPES option. + * + * @return list of types + */ + public ArrayList<TypeDefSummary> getSelectedTypesToSend() + { + return selectedTypesToSend; + } + + + /** + * Set up the list of TypeDefs in supported of the eventsToSend.SELECTED_TYPES option. + * + * @param selectedTypesToSend - list of types + */ + public void setSelectedTypesToSend(ArrayList<TypeDefSummary> selectedTypesToSend) + { + this.selectedTypesToSend = selectedTypesToSend; + } + + + /** + * Return the connection properties for the event mapper for the local repository. The event mapper is an + * optional component used when the local repository has proprietary external APIs that can change metadata + * in the repository without going through the OMRS interfaces. It maps the proprietary events from + * the local repository to the OMRS Events. + * + * @return Connection properties object + */ + public Connection getEventMapperConnection() + { + return eventMapperConnection; + } + + + /** + * Set up the connection properties for the event mapper for the local repository. The event mapper is an + * optional component used when the local repository has proprietary external APIs that can change metadata + * in the repository without going through the OMRS interfaces. It maps the proprietary events from + * the local repository to the OMRS Events. + * + * @param eventMapperConnection - Connection properties object + */ + public void setEventMapperConnection(Connection eventMapperConnection) + { + this.eventMapperConnection = eventMapperConnection; + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/OpenMetadataEventProtocolVersion.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/OpenMetadataEventProtocolVersion.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/OpenMetadataEventProtocolVersion.java new file mode 100644 index 0000000..301a589 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/OpenMetadataEventProtocolVersion.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.admin.properties; + + +/** + * OpenMetadataEventProtocolVersion provides the identifier for the version number of the event payload. There is + * only one version at the moment which is why it looks a little sad. + */ +public enum OpenMetadataEventProtocolVersion +{ + V1 +} http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/OpenMetadataExchangeRule.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/OpenMetadataExchangeRule.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/OpenMetadataExchangeRule.java new file mode 100644 index 0000000..2bcc087 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/OpenMetadataExchangeRule.java @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.admin.properties; + + +/** + * OpenMetadataExchangeRule controls the sending/receiving of metadata instances on the metadata highway. + * <ul> + * <li> + * REGISTRATION_ONLY means do not send/receive reference metadata - just perform the minimal registration + * exchanges. + * </li> + * <li> + * JUST_TYPEDEFS - means only send/receive/validate type definitions (TypeDefs). + * </li> + * <li> + * SELECTED_TYPES means that in addition to TypeDefs events, only metadata instances of the types + * supplied in the related list of TypeDefs (see typesToSend, typesToSave and typesToFederate) should be processed. + * </li> + * <li> + * LEARNED_TYPES means that the local repository requests reference copies of metadata based on the requests of + * the local user community. + * </li> + * <li> + * ALL means send/receive all types of metadata that are supported by the local repository. + * </li> + * </ul> + */ +public enum OpenMetadataExchangeRule +{ + REGISTRATION_ONLY (0, "Registration Only", "Only registration exchange; no TypeDefs or metadata instances."), + JUST_TYPEDEFS (1, "Just TypeDefs", "Only registration and type definitions (TypeDefs) exchange."), + SELECTED_TYPES (2, "Selected Types", "Registration plus all type definitions (TypeDefs) and metadata " + + "instances (Entities and Relationships) of selected types."), + LEARNED_TYPES (3, "Learned Types", "Registration plus all type definitions (TypeDefs) and metadata " + + "instances (Entities and Relationships) of types " + + "requested by local users to this server."), + ALL (99, "All", "Registration plus all type definitions (TypeDefs) and metadata " + + "instances (Entities and Relationships)."); + + private int replicationRuleCode; + private String replicationRuleName; + private String replicationRuleDescription; + + /** + * Constructor for the metadata instance replication rule. + * + * @param replicationRuleCode - the code number of this metadata instance replication rule. + * @param replicationRuleName - the name of this metadata instance replication rule. + * @param replicationRuleDescription - the description of this metadata instance replication rule. + */ + OpenMetadataExchangeRule(int replicationRuleCode, String replicationRuleName, String replicationRuleDescription) + { + this.replicationRuleCode = replicationRuleCode; + this.replicationRuleName = replicationRuleName; + this.replicationRuleDescription = replicationRuleDescription; + } + + + /** + * Return the code number of this metadata instance replication rule. + * + * @return int replication rule code number + */ + public int getReplicationRuleCode() + { + return replicationRuleCode; + } + + + /** + * Return the name of this metadata instance replication rule. + * + * @return String replication rule name + */ + public String getReplicationRuleName() + { + return replicationRuleName; + } + + + /** + * Return the description of this metadata instance replication rule. + * + * @return String replication rule description + */ + public String getReplicationRuleDescription() + { + return replicationRuleDescription; + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/RepositoryServicesConfig.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/RepositoryServicesConfig.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/RepositoryServicesConfig.java new file mode 100644 index 0000000..f7e303c --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/RepositoryServicesConfig.java @@ -0,0 +1,207 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.admin.properties; + +import org.apache.atlas.ocf.properties.Connection; + +import java.util.ArrayList; + +/** + * RepositoryServicesConfig provides the configuration properties that are needed by the OMRS components + * to manage access to the metadata repositories that are members of the open metadata repository clusters that + * this server connects to. + * <ul> + * <li> + * auditLogConnection is a connection describing the connector to the AuditLog that the OMRS + * component should use. + * </li> + * <li> + * openMetadataArchiveConnectionList is a list of Open Metadata Archive Connections. + * An open metadata archive connection provides properties needed to create a connector to manage + * an open metadata archive. This contains pre-built TypeDefs and metadata instance. + * The archives are managed by the OMRSArchiveManager. + * </li> + * <li> + * localRepositoryConfig describes the properties used to manage the local metadata repository for this server. + * </li> + * <li> + * enterpriseAccessConfig describes the properties that control the cluster federation services that the + * OMRS provides to the Open Metadata AccessServices (OMASs). + * </li> + * <li> + * cohortConfigList provides details of each open metadata repository cluster that the local server is + * connected to. + * </li> + * </ul> + */ +public class RepositoryServicesConfig +{ + private Connection auditLogConnection = null; + private ArrayList<Connection> openMetadataArchiveConnectionList = new ArrayList<>(); + private LocalRepositoryConfig localRepositoryConfig = null; + private EnterpriseAccessConfig enterpriseAccessConfig = null; + private ArrayList<CohortConfig> cohortConfigList = new ArrayList<>(); + + + /** + * Default constructor does nothing + */ + public RepositoryServicesConfig() + { + } + + + /** + * Constructor to set all properties. + * + * @param auditLogConnection - connection to the audit log. + * @param openMetadataArchiveConnectionList - list of open metadata archive files to load. + * @param localRepositoryConfig - properties to configure the behavior of the local repository. + * @param enterpriseAccessConfig - properties to configure the behavior of the federation services provided + * to the Open Metadata Access Services (OMASs). + * @param cohortConfigList - properties about the open metadata repository clusters that this server connects to. + */ + public RepositoryServicesConfig(Connection auditLogConnection, + ArrayList<Connection> openMetadataArchiveConnectionList, + LocalRepositoryConfig localRepositoryConfig, + EnterpriseAccessConfig enterpriseAccessConfig, + ArrayList<CohortConfig> cohortConfigList) + { + this.auditLogConnection = auditLogConnection; + this.openMetadataArchiveConnectionList = openMetadataArchiveConnectionList; + this.localRepositoryConfig = localRepositoryConfig; + this.enterpriseAccessConfig = enterpriseAccessConfig; + this.cohortConfigList = cohortConfigList; + } + + + /** + * Return the Connection properties used to create an OCF Connector to the AuditLog. + * + * @return Connection object + */ + public Connection getAuditLogConnection() + { + return auditLogConnection; + } + + + /** + * Set up the Connection properties used to create an OCF Connector to the AuditLog. + * + * @param auditLogConnection - Connection object + */ + public void setAuditLogConnection(Connection auditLogConnection) + { + this.auditLogConnection = auditLogConnection; + } + + + /** + * Return the list of Connection object, each of which is used to create the Connector to an Open Metadata + * Archive. Open Metadata Archive contains pre-built metadata types and instances. + * + * @return list of Connection objects + */ + public ArrayList<Connection> getOpenMetadataArchiveConnectionList() + { + return openMetadataArchiveConnectionList; + } + + + /** + * Set up the list of Connection object, each of which is used to create the Connector to an Open Metadata + * Archive. Open Metadata Archive contains pre-built metadata types and instances. + * + * @param openMetadataArchiveConnectionList - list of Connection objects + */ + public void setOpenMetadataArchiveConnectionList(ArrayList<Connection> openMetadataArchiveConnectionList) + { + this.openMetadataArchiveConnectionList = openMetadataArchiveConnectionList; + } + + + /** + * Return the configuration properties for the local repository. + * + * @return configuration properties + */ + public LocalRepositoryConfig getLocalRepositoryConfig() + { + return localRepositoryConfig; + } + + + /** + * Set up the configuration properties for the local repository. + * + * @param localRepositoryConfig - configuration properties + */ + public void setLocalRepositoryConfig(LocalRepositoryConfig localRepositoryConfig) + { + this.localRepositoryConfig = localRepositoryConfig; + } + + + /** + * Return the configuration for the federation services provided by OMRS to the Open Metadata Access + * Services (OMASs). + * + * @return configuration properties + */ + public EnterpriseAccessConfig getEnterpriseAccessConfig() + { + return enterpriseAccessConfig; + } + + + /** + * Set up the configuration for the federation services provided by OMRS to the Open Metadata Access + * Services (OMASs). + * + * @param enterpriseAccessConfig configuration properties + */ + public void setEnterpriseAccessConfig(EnterpriseAccessConfig enterpriseAccessConfig) + { + this.enterpriseAccessConfig = enterpriseAccessConfig; + } + + + /** + * Return the configuration properties for each open metadata repository cluster that this local server + * connects to. + * + * @return list of cluster configuration properties + */ + public ArrayList<CohortConfig> getCohortConfigList() + { + return cohortConfigList; + } + + + /** + * Set up the configuration properties for each open metadata repository cluster that this local server + * connects to. + * + * @param cohortConfigList - list of cluster configuration properties + */ + public void setCohortConfigList(ArrayList<CohortConfig> cohortConfigList) + { + this.cohortConfigList = cohortConfigList; + } +}
