http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventProcessor.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventProcessor.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventProcessor.java new file mode 100644 index 0000000..b2f0ceb --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventProcessor.java @@ -0,0 +1,667 @@ +/* + * 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.eventmanagement.events; + +import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail; +import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceProvenanceType; +import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary; + +/** + * OMRSInstanceEventProcessor is an interface implemented by a component that is able to process incoming + * metadata instance events for an Open Metadata Repository. Instance events are used to replicate metadata + * instances across an Open Metadata Repository Cohort. + */ +public interface OMRSInstanceEventProcessor +{ + /** + * A new entity has been created. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param entity - details of the new entity + */ + void processNewEntityEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + EntityDetail entity); + + + /** + * An existing entity has been updated. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param entity - details of the new version of the entity. + */ + void processUpdatedEntityEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + EntityDetail entity); + + + /** + * An update to an entity has been undone. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param entity - details of the version of the entity that has been restored. + */ + void processUndoneEntityEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + EntityDetail entity); + + + /** + * A new classification has been added to an entity. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param entity - details of the entity with the new classification added. + */ + void processClassifiedEntityEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + EntityDetail entity); + + + /** + * A classification has been removed from an entity. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param entity - details of the entity after the classification has been removed. + */ + void processDeclassifiedEntityEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + EntityDetail entity); + + + /** + * An existing classification has been changed on an entity. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param entity - details of the entity after the classification has been changed. + */ + void processReclassifiedEntityEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + EntityDetail entity); + + + /** + * An existing entity has been deleted. This is a soft delete. This means it is still in the repository + * but it is no longer returned on queries. + * + * All relationships to the entity are also soft-deleted and will no longer be usable. These deleted relationships + * will be notified through separate events. + * + * Details of the TypeDef are included with the entity's unique id (guid) to ensure the right entity is deleted in + * the remote repositories. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param typeDefGUID - unique identifier for this entity's TypeDef + * @param typeDefName - name of this entity's TypeDef + * @param instanceGUID - unique identifier for the entity + */ + void processDeletedEntityEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String typeDefGUID, + String typeDefName, + String instanceGUID); + + + /** + * A deleted entity has been permanently removed from the repository. This request can not be undone. + * + * Details of the TypeDef are included with the entity's unique id (guid) to ensure the right entity is purged in + * the remote repositories. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param typeDefGUID - unique identifier for this entity's TypeDef + * @param typeDefName - name of this entity's TypeDef + * @param instanceGUID - unique identifier for the entity + */ + void processPurgedEntityEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String typeDefGUID, + String typeDefName, + String instanceGUID); + + + /** + * A deleted entity has been restored to the state it was before it was deleted. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param entity - details of the version of the entity that has been restored. + */ + void processRestoredEntityEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + EntityDetail entity); + + + /** + * An existing entity has had its type changed. Typically this action is taken to move an entity's + * type to either a super type (so the subtype can be deleted) or a new subtype (so additional properties can be + * added.) However, the type can be changed to any compatible type. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param originalTypeDef - description of this entity's original TypeDef. + * @param entity - new values for this entity, including the new type information. + */ + void processReTypedEntityEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + TypeDefSummary originalTypeDef, + EntityDetail entity); + + + /** + * An existing entity has changed home repository. This action is taken for example, if a repository + * becomes permanently unavailable, or if the user community updating this entity move to working + * from a different repository in the open metadata repository cluster. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param originalHomeMetadataCollectionId - unique identifier for the original home metadata collection/repository. + * @param entity - new values for this entity, including the new home information. + */ + void processReHomedEntityEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String originalHomeMetadataCollectionId, + EntityDetail entity); + + /** + * The guid of an existing entity has been changed to a new value. This is used if two different + * entities are discovered to have the same guid. This is extremely unlikely but not impossible so + * the open metadata protocol has provision for this. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param originalEntityGUID - the existing identifier for the entity. + * @param entity - new values for this entity, including the new guid. + */ + void processReIdentifiedEntityEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String originalEntityGUID, + EntityDetail entity); + + + /** + * The local repository is requesting that an entity from another repository's metadata collection is + * refreshed so the local repository can create a reference copy. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param typeDefGUID - - unique identifier for this entity's TypeDef + * @param typeDefName - name of this entity's TypeDef + * @param instanceGUID - unique identifier for the entity + * @param homeMetadataCollectionId - metadata collection id for the home of this instance. + */ + void processRefreshEntityRequested(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String typeDefGUID, + String typeDefName, + String instanceGUID, + String homeMetadataCollectionId); + + + /** + * A remote repository in the cohort has sent entity details in response to a refresh request. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param entity - details of the requested entity + */ + void processRefreshEntityEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + EntityDetail entity); + + /** + * A new relationship has been created. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param relationship - details of the new relationship + */ + void processNewRelationshipEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + Relationship relationship); + + + /** + * An existing relationship has been updated. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param relationship - details of the new version of the relationship. + */ + void processUpdatedRelationshipEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + Relationship relationship); + + + /** + * An update to a relationship has been undone. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param relationship - details of the version of the relationship that has been restored. + */ + void processUndoneRelationshipEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + Relationship relationship); + + + /** + * An existing relationship has been deleted. This is a soft delete. This means it is still in the repository + * but it is no longer returned on queries. + * + * Details of the TypeDef are included with the relationship's unique id (guid) to ensure the right + * relationship is deleted in the remote repositories. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param typeDefGUID - unique identifier for this relationship's TypeDef + * @param typeDefName - name of this relationship's TypeDef + * @param instanceGUID - unique identifier for the relationship + */ + void processDeletedRelationshipEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String typeDefGUID, + String typeDefName, + String instanceGUID); + + + /** + * A deleted relationship has been permanently removed from the repository. This request can not be undone. + * + * Details of the TypeDef are included with the relationship's unique id (guid) to ensure the right + * relationship is purged in the remote repositories. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param typeDefGUID - unique identifier for this relationship's TypeDef. + * @param typeDefName - name of this relationship's TypeDef. + * @param instanceGUID - unique identifier for the relationship. + */ + void processPurgedRelationshipEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String typeDefGUID, + String typeDefName, + String instanceGUID); + + + /** + * A deleted relationship has been restored to the state it was before it was deleted. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param relationship - details of the version of the relationship that has been restored. + */ + void processRestoredRelationshipEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + Relationship relationship); + + + /** + * An existing relationship has had its type changed. Typically this action is taken to move a relationship's + * type to either a super type (so the subtype can be deleted) or a new subtype (so additional properties can be + * added.) However, the type can be changed to any compatible type. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param originalTypeDef - description of this relationship's original TypeDef. + * @param relationship - new values for this relationship, including the new type information. + */ + void processReTypedRelationshipEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + TypeDefSummary originalTypeDef, + Relationship relationship); + + + /** + * An existing relationship has changed home repository. This action is taken for example, if a repository + * becomes permanently unavailable, or if the user community updating this relationship move to working + * from a different repository in the open metadata repository cluster. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param originalHomeMetadataCollectionId - unique identifier for the original home repository. + * @param relationship - new values for this relationship, including the new home information. + */ + void processReHomedRelationshipEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String originalHomeMetadataCollectionId, + Relationship relationship); + + + /** + * The guid of an existing relationship has changed. This is used if two different + * relationships are discovered to have the same guid. This is extremely unlikely but not impossible so + * the open metadata protocol has provision for this. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param originalRelationshipGUID - the existing identifier for the relationship. + * @param relationship - new values for this relationship, including the new guid. + */ + void processReIdentifiedRelationshipEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String originalRelationshipGUID, + Relationship relationship); + + + + /** + * An open metadata repository has requested the home repository of a relationship send details of the relationship so + * its local metadata collection can create a reference copy of the instance. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param typeDefGUID - unique identifier for this instance's TypeDef + * @param typeDefName - name of this relationship's TypeDef + * @param instanceGUID - unique identifier for the instance + * @param homeMetadataCollectionId - metadata collection id for the home of this instance. + */ + void processRefreshRelationshipRequest(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String typeDefGUID, + String typeDefName, + String instanceGUID, + String homeMetadataCollectionId); + + + /** + * An open metadata repository is refreshing the information about a relationship for the other + * repositories in the cohort. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param relationship - relationship details + */ + void processRefreshRelationshipEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + Relationship relationship); + + + /** + * An open metadata repository has detected two metadata instances with the same identifier (guid). + * This is a serious error because it could lead to corruption of the metadata collections within the cohort. + * When this occurs, all repositories in the cohort delete their reference copies of the metadata instances and + * at least one of the instances has its GUID changed in its respective home repository. The updated instance(s) + * are redistributed around the cohort. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - metadata collection id of the repository reporting the conflicting instance + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param targetMetadataCollectionId - metadata collection id of other repository with the conflicting instance + * @param targetTypeDef - details of the target instance's TypeDef + * @param targetInstanceGUID - unique identifier for the source instance + * @param otherOrigin - origin of the other (older) metadata instance + * @param otherMetadataCollectionId - metadata collection of the other (older) metadata instance + * @param otherTypeDef - details of the other (older) instance's TypeDef + * @param otherInstanceGUID - unique identifier for the other (older) instance + * @param errorMessage - description of the error. + */ + void processConflictingInstancesEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String targetMetadataCollectionId, + TypeDefSummary targetTypeDef, + String targetInstanceGUID, + String otherMetadataCollectionId, + InstanceProvenanceType otherOrigin, + TypeDefSummary otherTypeDef, + String otherInstanceGUID, + String errorMessage); + + + /** + * An open metadata repository has detected an inconsistency in the version number of the type used in an updated metadata + * instance compared to its stored version. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - metadata collection id of the repository reporting the conflicting instance + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param targetMetadataCollectionId - metadata collection id of other repository with the conflicting instance + * @param targetTypeDef - description of the target instance's TypeDef + * @param targetInstanceGUID - unique identifier for the source instance + * @param otherTypeDef - details of the other (older) instance's TypeDef + * @param errorMessage - description of the error. + */ + void processConflictingTypeEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String targetMetadataCollectionId, + TypeDefSummary targetTypeDef, + String targetInstanceGUID, + TypeDefSummary otherTypeDef, + String errorMessage); +} +
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventType.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventType.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventType.java new file mode 100644 index 0000000..8d94980 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventType.java @@ -0,0 +1,148 @@ +/* + * 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.eventmanagement.events; + +/** + * OMRSInstanceEventType defines the different types of instance events in the open metadata repository services + * protocol. + */ +public enum OMRSInstanceEventType +{ + UNKNOWN_INSTANCE_EVENT (0, "UnknownInstanceEvent", + "An event that is not recognized by the local server."), + NEW_ENTITY_EVENT (1, "NewEntityEvent", + "A new entity has been created."), + UPDATED_ENTITY_EVENT (2, "UpdatedEntityEvent", + "An existing entity has been updated."), + UNDONE_ENTITY_EVENT (3, "UndoneEntityEvent", + "An update to an entity has been undone."), + CLASSIFIED_ENTITY_EVENT (4, "ClassifiedEntityEvent", + "A new classification has been added to an entity."), + DECLASSIFIED_ENTITY_EVENT (5, "DeclassifiedEntityEvent", + "A classification has been removed from an entity."), + RECLASSIFIED_ENTITY_EVENT (6, "ReclassifiedEntityEvent", + "An existing classification has been changed on an entity."), + DELETED_ENTITY_EVENT (7, "DeletedEntityEvent", + "An existing entity has been deleted. This is a soft delete. " + + "This means it is still in the repository " + + "but it is no longer returned on queries."), + PURGED_ENTITY_EVENT (8, "PurgedEntityEvent", + "A deleted entity has been permanently removed from the repository. " + + "This request can not be undone."), + RESTORED_ENTITY_EVENT (9, "RestoredEntityEvent", + "A deleted entity has been restored to the state it was before it was deleted."), + RE_IDENTIFIED_ENTITY_EVENT (10, "ReIdentifiedEntityEvent", + "The guid of an existing entity has been changed to a new value."), + RETYPED_ENTITY_EVENT (11, "ReTypedEntityEvent", + "An existing entity has had its type changed."), + RE_HOMED_ENTITY_EVENT (12, "ReHomedEntityEvent", + "An existing entity has changed home repository."), + REFRESH_ENTITY_REQUEST (13, "RefreshEntityRequestEvent", + "The local repository is requesting that an entity from another repository's " + + "metadata collection is " + + "refreshed so the local repository can create a reference copy."), + REFRESHED_ENTITY_EVENT (14, "RefreshedEntityEvent", + "A remote repository in the cohort has sent entity details in response " + + "to a refresh request."), + NEW_RELATIONSHIP_EVENT (15, "NewRelationshipEvent", + "A new relationship has been created."), + UPDATED_RELATIONSHIP_EVENT (16, "UpdateRelationshipEvent", + "An existing relationship has been updated."), + UNDONE_RELATIONSHIP_EVENT (17, "UndoneRelationshipEvent", + "An earlier change to a relationship has been undone."), + DELETED_RELATIONSHIP_EVENT (18, "DeletedRelationshipEvent", + "An existing relationship has been deleted. This is a soft delete. " + + "This means it is still in the repository " + + "but it is no longer returned on queries."), + PURGED_RELATIONSHIP_EVENT (19, "PurgedRelationshipEvent", + "A deleted relationship has been permanently removed from the repository. " + + "This request can not be undone."), + RESTORED_RELATIONSHIP_EVENT (20, "RestoredRelationshipEvent", + "A deleted relationship has been restored to the state it was before it was deleted."), + RE_IDENTIFIED_RELATIONSHIP_EVENT(21, "ReIdentifiedRelationshipEvent", + "The guid of an existing relationship has changed."), + RETYPED_RELATIONSHIP_EVENT (22, "ReTypedRelationshipEvent", + "An existing relationship has had its type changed."), + RE_HOMED_RELATIONSHIP_EVENT (23, "ReHomedRelationshipEvent", + "An existing relationship has changed home repository."), + REFRESH_RELATIONSHIP_REQUEST (24, "RefreshRelationshipRequestEvent", + "A repository has requested the home repository of a relationship send " + + "details of hte relationship so " + + "the local repository can create a reference copy of the instance."), + REFRESHED_RELATIONSHIP_EVENT (25, "RefreshedRelationshipEvent", + "The local repository is refreshing the information about a relationship for the " + + "other repositories in the cohort."), + INSTANCE_ERROR_EVENT (99, "InstanceErrorEvent", + "An error has been detected in the exchange of instances between members of the cohort.") + ; + + + private int eventTypeCode; + private String eventTypeName; + private String eventTypeDescription; + + + /** + * Default Constructor - sets up the specific values for this instance of the enum. + * + * @param eventTypeCode - int identifier used for indexing based on the enum. + * @param eventTypeName - string name used for messages that include the enum. + * @param eventTypeDescription - default description for the enum value - used when natural resource + * bundle is not available. + */ + OMRSInstanceEventType(int eventTypeCode, String eventTypeName, String eventTypeDescription) + { + this.eventTypeCode = eventTypeCode; + this.eventTypeName = eventTypeName; + this.eventTypeDescription = eventTypeDescription; + } + + + /** + * Return the int identifier used for indexing based on the enum. + * + * @return int identifier code + */ + public int getInstanceEventTypeCode() + { + return eventTypeCode; + } + + + /** + * Return the string name used for messages that include the enum. + * + * @return String name + */ + public String getInstanceEventTypeName() + { + return eventTypeName; + } + + + /** + * Return the default description for the enum value - used when natural resource + * bundle is not available. + * + * @return String default description + */ + public String getInstanceEventTypeDescription() + { + return eventTypeDescription; + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEvent.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEvent.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEvent.java new file mode 100644 index 0000000..6db78a0 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEvent.java @@ -0,0 +1,289 @@ +/* + * 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.eventmanagement.events; + +import org.apache.atlas.ocf.properties.Connection; +import org.apache.atlas.omrs.eventmanagement.events.v1.OMRSEventV1; +import org.apache.atlas.omrs.eventmanagement.events.v1.OMRSEventV1RegistrySection; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Date; + + +/** + * OMRSRegistryEvent provides the conversion between the properties of a registry event and the serialized event body. + * It supports conversion in either direction through its inner class called OMRSRegistryEventPayload: + * <ul> + * <li> + * Converting from registry event properties to an OMRSEvent body for sending outbound events. + * </li> + * <li> + * Converting from an event body to registry event properties for inbound events. + * </li> + * </ul> + * OMRSRegistryEvent also provides a specialized interface to allow the cohort registry to work effectively + * with registry events. + */ +public class OMRSRegistryEvent extends OMRSEvent +{ + /* + * The type of the registry event that defines how the rest of the values should be interpreted. + */ + private OMRSRegistryEventType registryEventType = OMRSRegistryEventType.UNKNOWN_REGISTRY_EVENT; + + /* + * Registration information describing a specific repository. + */ + private Date registrationTimestamp = null; + private Connection remoteConnection = null; + + /* + * Used in the registration process to enable the repositories to detect incompatible TypeDefs. + */ + private ArrayList<TypeDefSummary> typeDefSummaries = null; + + /* + * Specific variables only used in error reporting. It defines the subset of error codes from OMRSEvent + * that are specific to registry events. + */ + private OMRSRegistryEventErrorCode errorCode = OMRSRegistryEventErrorCode.NOT_IN_USE; + + + private static final Logger log = LoggerFactory.getLogger(OMRSRegistryEvent.class); + + + /** + * Inbound event constructor that takes the object created by the Jackson JSON mapper and unpacks the + * properties into the registry event. + * + * @param inboundEvent - incoming Event. + */ + public OMRSRegistryEvent(OMRSEventV1 inboundEvent) + { + super(inboundEvent); + + OMRSEventV1RegistrySection registrySection = inboundEvent.getRegistryEventSection(); + + if (registrySection != null) + { + this.registryEventType = registrySection.getRegistryEventType(); + this.registrationTimestamp = registrySection.getRegistrationTimestamp(); + this.remoteConnection = registrySection.getRemoteConnection(); + this.typeDefSummaries = registrySection.getTypeDefList(); + } + + if (super.genericErrorCode != null) + { + switch (errorCode) + { + case BAD_REMOTE_CONNECTION: + this.errorCode = OMRSRegistryEventErrorCode.BAD_REMOTE_CONNECTION; + break; + + case CONFLICTING_COLLECTION_ID: + this.errorCode = OMRSRegistryEventErrorCode.CONFLICTING_COLLECTION_ID; + break; + + default: + this.errorCode = OMRSRegistryEventErrorCode.UNKNOWN_ERROR_CODE; + } + } + } + + + /** + * Constructor for a normal outbound event. It sets the event type and the other parameters + * used in a registry event payload. + * + * @param registryEventType - type of event (REGISTRATION_EVENT, REFRESH_REGISTRATION_REQUEST, RE_REGISTRATION_EVENT) + * @param registrationTimestamp - time that the local repository registered. + * @param remoteConnection - remote connection to this local repository. + * @param typeDefSummaries - Summary list of supported TypeDefs + */ + public OMRSRegistryEvent(OMRSRegistryEventType registryEventType, + Date registrationTimestamp, + Connection remoteConnection, + ArrayList<TypeDefSummary> typeDefSummaries) + { + super(OMRSEventCategory.REGISTRY); + + this.registryEventType = registryEventType; + this.registrationTimestamp = registrationTimestamp; + this.remoteConnection = remoteConnection; + this.typeDefSummaries = typeDefSummaries; + } + + + /** + * Constructor for an UnRegistration Event. + * + * @param registryEventType - the type of event + */ + public OMRSRegistryEvent(OMRSRegistryEventType registryEventType) + { + super(OMRSEventCategory.REGISTRY); + + this.registryEventType = registryEventType; + } + + + /** + * Constructor for the REGISTRATION_ERROR_EVENT outbound event. + * + * @param errorCode - detailed error code + * @param errorMessage - Optional error message + * @param targetMetadataCollectionId - the identifier of the server that sent bad information. + * @param remoteConnection - remote connection to the target repository. (Optional - only supplied if + * relevant to the reported error; otherwise null.) + */ + public OMRSRegistryEvent(OMRSRegistryEventErrorCode errorCode, + String errorMessage, + String targetMetadataCollectionId, + Connection remoteConnection) + { + super(OMRSEventCategory.REGISTRY, + errorCode.getErrorCodeEncoding(), + errorMessage, + targetMetadataCollectionId, + remoteConnection); + + this.registryEventType = OMRSRegistryEventType.REGISTRATION_ERROR_EVENT; + } + + + /** + * Return the specific registry event type. + * + * @return registry event type enum + */ + public OMRSRegistryEventType getRegistryEventType() + { + return registryEventType; + } + + + /** + * Return the date/time that the repository registered with the open metadata repository cohort. + * If this is a normal registry event then this timestamp is the registration time for the local repository. + * If this an error event, then this is the registration time for the target repository. + * + * @return Date object for timestamp + */ + public Date getRegistrationTimestamp() + { + return registrationTimestamp; + } + + + /** + * Return the remote connection used to create a connector used to call the repository across the network. + * If this is a normal registry event then this connection is for the local repository. + * If this an error event, then this is the connection for the target repository. + * + * @return Connection object + */ + public Connection getRemoteConnection() + { + return remoteConnection; + } + + + /** + * Return the list of TypeDef summaries included in the event. + * If this is a normal registry event then these TypeDefs are from the local repository. + * If this an error event, then these TypeDefs are from the targeted repository. + * + * @return TypeDefSummaries object + */ + public ArrayList<TypeDefSummary> getTypeDefSummaries() + { + return typeDefSummaries; + } + + + /** + * Return the error code for the event. This property is only used for error events. + * + * @return OMRSRegistryEventErrorCode enum + */ + public OMRSRegistryEventErrorCode getErrorCode() + { + return errorCode; + } + + + /** + * Returns an OMRSEvent populated with details from this RegistryEvent + * + * @return OMRSEvent (Version 1) object + */ + public OMRSEventV1 getOMRSEventV1() + { + OMRSEventV1 omrsEvent = super.getOMRSEventV1(); + + OMRSEventV1RegistrySection registrySection = new OMRSEventV1RegistrySection(); + + registrySection.setRegistryEventType(this.registryEventType); + registrySection.setRegistrationTimestamp(this.registrationTimestamp); + registrySection.setRemoteConnection(this.remoteConnection); + registrySection.setTypeDefList(this.typeDefSummaries); + + omrsEvent.setRegistryEventSection(registrySection); + + return omrsEvent; + } + + + /** + * Standard toString method. + * + * @return JSON style description of variables. + */ + @Override + public String toString() + { + return "OMRSRegistryEvent{" + + "registryEventType=" + registryEventType + + ", registrationTimestamp=" + registrationTimestamp + + ", remoteConnection=" + remoteConnection + + ", typeDefSummaries=" + typeDefSummaries + + ", errorCode=" + errorCode + + ", eventTimestamp=" + eventTimestamp + + ", eventDirection=" + eventDirection + + ", eventCategory=" + eventCategory + + ", eventOriginator=" + eventOriginator + + ", genericErrorCode=" + genericErrorCode + + ", errorMessage='" + errorMessage + '\'' + + ", targetMetadataCollectionId='" + targetMetadataCollectionId + '\'' + + ", targetRemoteConnection=" + targetRemoteConnection + + ", targetTypeDefSummary=" + targetTypeDefSummary + + ", targetAttributeTypeDef=" + targetAttributeTypeDef + + ", targetInstanceGUID='" + targetInstanceGUID + '\'' + + ", otherOrigin=" + otherOrigin + + ", otherMetadataCollectionId='" + otherMetadataCollectionId + '\'' + + ", otherTypeDefSummary=" + otherTypeDefSummary + + ", otherTypeDef=" + otherTypeDef + + ", otherAttributeTypeDef=" + otherAttributeTypeDef + + ", otherInstanceGUID='" + otherInstanceGUID + '\'' + + '}'; + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventErrorCode.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventErrorCode.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventErrorCode.java new file mode 100644 index 0000000..95022cd --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventErrorCode.java @@ -0,0 +1,126 @@ +/* + * 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.eventmanagement.events; + +import org.apache.atlas.omrs.eventmanagement.events.OMRSEventErrorCode; + +/** + * OMRSRegistryEventErrorCode defines the list of error codes that are used to record errors in the registration + * process that is used by the cluster registries when managing the membership of the open metadata repository cluster. + * <ul> + * <li> + * NOT_IN_USE - There has been no error detected and so the error code is not in use. + * </li> + * <li> + * CONFLICTING_REPOSITORY_ID - Remote server/repository is using the same metadata collection id as the local server. + * </li> + * <li> + * CONFLICTING_TYPEDEFS - There are conflicting type definitions (TypeDefs) detected between two repositories + * in the open metadata repository cluster. + * </li> + * </ul> + */ +public enum OMRSRegistryEventErrorCode +{ + NOT_IN_USE (0, "No Error", + "There has been no error detected and so the error code is not in use.", + null), + CONFLICTING_COLLECTION_ID (1, "Conflicting metadata collection Id", + "Remote server/repository is using the same metadata collection id as the local server.", + OMRSEventErrorCode.CONFLICTING_COLLECTION_ID), + BAD_REMOTE_CONNECTION (2, "Unusable Remote Connection to Repository", + "The remote connection send by one of the member of the cohort is resulting in errors " + + "when it is used to create an OMRS Connector to the repository.", + OMRSEventErrorCode.BAD_REMOTE_CONNECTION), + UNKNOWN_ERROR_CODE (99, "Unknown Error Code", + "Unrecognized error code from incoming event.", + null) + ; + + + private int errorCodeId; + private String errorCodeName; + private String errorCodeDescription; + private OMRSEventErrorCode errorCodeEncoding ; + + + /** + * Typical constructor sets up the values for this enum instance. + * + * @param errorCodeId - int identifier for the enum, used for indexing arrays etc with the enum. + * @param errorCodeName - String name for the enum, used for message content. + * @param errorCodeDescription - String default description for the enum, used when there is not natural + * language resource bundle available. + * @param errorCodeEncoding - code value to use in OMRSEvents + */ + OMRSRegistryEventErrorCode(int errorCodeId, + String errorCodeName, + String errorCodeDescription, + OMRSEventErrorCode errorCodeEncoding) + { + this.errorCodeId = errorCodeId; + this.errorCodeName = errorCodeName; + this.errorCodeDescription = errorCodeDescription; + this.errorCodeEncoding = errorCodeEncoding; + } + + + /** + * Return the identifier for the enum, used for indexing arrays etc with the enum. + * + * @return int identifier + */ + public int getErrorCodeId() + { + return errorCodeId; + } + + + /** + * Return the name for the enum, used for message content. + * + * @return String name + */ + public String getErrorCodeName() + { + return errorCodeName; + } + + + /** + * Return the default description for the enum, used when there is not natural + * language resource bundle available. + * + * @return String default description + */ + public String getErrorCodeDescription() + { + return errorCodeDescription; + } + + + /** + * Return the encoding to use in OMRSEvents. + * + * @return String OMRSEvent encoding for this errorCode + */ + public OMRSEventErrorCode getErrorCodeEncoding() + { + return errorCodeEncoding; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventProcessor.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventProcessor.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventProcessor.java new file mode 100644 index 0000000..91ae433 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventProcessor.java @@ -0,0 +1,159 @@ +/* + * 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.eventmanagement.events; + + +import org.apache.atlas.ocf.properties.Connection; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary; + +import java.util.ArrayList; +import java.util.Date; + +/** + * OMRSRegistryEventProcessor is an interface implemented by a component that is able to process + * registry events for an Open Metadata Repository's membership of an Open Metadata Repository Cohort. + */ +public interface OMRSRegistryEventProcessor +{ + /** + * Introduces a new server/repository to the metadata repository cohort. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection that is registering with the cohort. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param registrationTimestamp - the time that the server/repository issued the registration request. + * @param remoteConnection - the Connection properties for the connector used to call the registering server. + * @param typeDefList - the list of TypeDefs supported by the registering server/repository. + * @return flag indicating if the event was sent or not. + */ + boolean processRegistrationEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + Date registrationTimestamp, + Connection remoteConnection, + ArrayList<TypeDefSummary> typeDefList); + + + /** + * Requests that the other servers in the cohort send re-registration events. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @return flag indicating if the event was sent or not. + */ + boolean processRegistrationRefreshRequest(String sourceName, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName); + + + /** + * Refreshes the other servers in the cohort with the originating server's registration. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection that is registering with the cohort. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param registrationTimestamp - the time that the server/repository first registered with the cohort. + * @param remoteConnection - the Connection properties for the connector used to call the registering server. + * @param typeDefList - the list of TypeDefs supported by the registering server/repository. + * @return flag indicating if the event was sent or not. + */ + boolean processReRegistrationEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + Date registrationTimestamp, + Connection remoteConnection, + ArrayList<TypeDefSummary> typeDefList); + + + /** + * A server/repository is being removed from the metadata repository cohort. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - metadata collectionId of originator. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @return flag indicating if the event was sent or not. + */ + boolean processUnRegistrationEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName); + + + /** + * There is more than one member of the open metadata repository cohort that is using the same metadata + * collection Id. This means that their metadata instances can be updated in more than one server and their + * is a potential for data integrity issues. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - metadata collectionId of originator. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param conflictingMetadataCollectionId - unique identifier for the metadata collection that is registering with the cohort. + * @param errorMessage - details of the conflict + */ + void processConflictingCollectionIdEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String conflictingMetadataCollectionId, + String errorMessage); + + + /** + * A connection to one of the members of the open metadata repository cohort is not usable by one of the members. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - metadata collectionId of originator. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param targetMetadataCollectionId - Id for the repository with the bad remote connection. + * @param remoteConnection - the Connection properties for the connector used to call the registering server. + * @param errorMessage - details of the error that occurs when the connection is used. + */ + void processBadConnectionEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String targetMetadataCollectionId, + Connection remoteConnection, + String errorMessage); +} http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventType.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventType.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventType.java new file mode 100644 index 0000000..5dcd411 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventType.java @@ -0,0 +1,128 @@ +/* + * 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.eventmanagement.events; + +/** + * OMRSRegistryEventType defines the different types of registry events in the open metadata repository services + * protocol. There are 4 basic values. + * <ul> + * <li> + * UNKNOWN_REGISTRY_EVENT - the event is not recognized by this local server, probably because it is back-level + * from other servers in the cohort. It is logged in the audit log and then ignored. The registration + * protocol should evolve so that new message types can be ignored by back-level servers without damage + * to the cohort's integrity. + * </li> + * <li> + * REGISTRATION_EVENT - this event is a server's first contact with the cohort. It publicises the id of the + * local repository, the connection information needed to connect remotely to this local server's + * repository (localServerRemoteConnection) plus a list of typedef names and GUIDs. Other servers in the + * cohort will respond either with a RE_REGISTRATION_EVENT if all is ok or REGISTRATION_ERROR if there + * is a problem with any information in the REGISTRATION_EVENT. + * </li> + * <li> + * REFRESH_REGISTRATION_EVENT - this event is used after a local server has experienced configuration issues + * and needs to receive the registration information from other members of the cohort again. + * </li> + * <li> + * RE_REGISTRATION_EVENT - this event is used by a previously registered server to broadcast its current + * configuration. It is used in response to a REGISTRATION_EVENT and a REFRESH_REGISTRATION_EVENT to + * let the other servers know about its configuration, or whenever its configuration may have changed + * (such as after a server restart or administrator action). + * </li> + * <li> + * UN_REGISTRATION_EVENT - this event is used when a server is being removed from the cohort. The other + * servers can choose whether to remove its replicated metadata from their repository, or mark it as + * deregistered repository's metadata. + * </li> + * <li> + * REGISTRATION_ERROR_EVENT - ths event is used to report anomalies in the registration information being + * passed between the repositories and the actions taken. Each of these errors should be investigated + * since they should not occur. + * </li> + * </ul> + */ +public enum OMRSRegistryEventType +{ + UNKNOWN_REGISTRY_EVENT (0, "UnknownRegistryEvent", + "An event that is not recognized by the local server."), + REGISTRATION_EVENT (1, "RegistrationEvent", + "Introduces a new server/repository to the metadata repository cohort."), + REFRESH_REGISTRATION_REQUEST (2, "RefreshRegistrationRequest", + "Requests that the other servers in the cohort send re-registration events."), + RE_REGISTRATION_EVENT (3, "ReRegistrationEvent", + "Refreshes the other servers in the cohort with the local server's configuration."), + UN_REGISTRATION_EVENT (4, "UnRegistrationEvent", + "A server/repository is being removed from the metadata repository cohort."), + REGISTRATION_ERROR_EVENT (99, "RegistrationErrorEvent", + "An anomaly has been detected in the information received from a member in the metadata repository cohort."); + + + private int registryEventTypeCode; + private String registryEventTypeName; + private String registryEventTypeDescription; + + + /** + * Default Constructor - sets up the specific values for this instance of the enum. + * + * @param registryEventTypeCode - int identifier used for indexing based on the enum. + * @param registryEventTypeName - string name used for messages that include the enum. + * @param registryEventTypeDescription - default description for the enum value - used when natural resource + * bundle is not available. + */ + OMRSRegistryEventType(int registryEventTypeCode, String registryEventTypeName, String registryEventTypeDescription) + { + this.registryEventTypeCode = registryEventTypeCode; + this.registryEventTypeName = registryEventTypeName; + this.registryEventTypeDescription = registryEventTypeDescription; + } + + + /** + * Return the int identifier used for indexing based on the enum. + * + * @return int identifier code + */ + public int getRegistryEventTypeCode() + { + return registryEventTypeCode; + } + + + /** + * Return the string name used for messages that include the enum. + * + * @return String name + */ + public String getRegistryEventTypeName() + { + return registryEventTypeName; + } + + + /** + * Return the default description for the enum value - used when natural resource + * bundle is not available. + * + * @return String default description + */ + public String getRegistryEventTypeDescription() + { + return registryEventTypeDescription; + } +}
