Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved error handling for JanusGraph repository #7655

Merged
merged 2 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bom/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ dependencies {
api("org.janusgraph:janusgraph-berkeleyje:${janusVersion}")
api("org.janusgraph:janusgraph-cql:${janusVersion}")
api("org.janusgraph:janusgraph-lucene:${janusVersion}")
api("org.xerial.snappy:snappy-java:${snappyVersion}")
api("org.janusgraph:janusgraph-es:${janusVersion}")
api("org.janusgraph:janusgraph-hbase:${janusVersion}")
api("org.xerial.snappy:snappy-java:${snappyVersion}")
api("javax.servlet:javax.servlet-api:${servletVersion}")
api("io.jsonwebtoken:jjwt-impl:${jwtImplVersion}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

/**
* The AssetManagerAuditCode is used to define the message content for the OMRS Audit Log.
*
* The 5 fields in the enum are:
* <ul>
* <li>Log Message Id - to uniquely identify the message</li>
Expand Down Expand Up @@ -150,12 +149,12 @@ public enum AssetManagerAuditCode implements AuditLogMessageSet
/**
* The constructor for AssetManagerAuditCode expects to be passed one of the enumeration rows defined in
* AssetManagerAuditCode above. For example:
*
* <br>
* AssetManagerAuditCode auditCode = AssetManagerAuditCode.SERVER_NOT_AVAILABLE;
*
* <br>
* This will expand out to the 4 parameters shown below.
*
* @param messageId - unique Id for the message
* @param messageId - unique id for the message
* @param severity - severity of the message
* @param message - text for the message
* @param systemAction - description of the action taken by the system when the condition happened
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public enum AssetManagerErrorCode implements ExceptionMessageSet
* This will expand out to the 5 parameters shown below.
*
* @param httpErrorCode error code to use over REST calls
* @param errorMessageId unique Id for the message
* @param errorMessageId unique id for the message
* @param errorMessage text for the message
* @param systemAction description of the action taken by the system when the error condition happened
* @param userAction instructions for resolving the error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ dependencies {
implementation 'org.slf4j:slf4j-api'
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.fasterxml.jackson.core:jackson-core'
implementation project(':open-metadata-implementation:frameworks:audit-log-framework')
implementation project(':open-metadata-implementation:frameworks:open-connector-framework')
implementation project(':open-metadata-implementation:repository-services:repository-services-apis')
compileOnly project(':open-metadata-implementation:frameworks:audit-log-framework')
compileOnly project(':open-metadata-implementation:frameworks:open-connector-framework')
compileOnly project(':open-metadata-implementation:repository-services:repository-services-apis')
implementation 'org.apache.tinkerpop:gremlin-core'
implementation 'org.apache.commons:commons-collections4'
runtimeOnly 'org.janusgraph:janusgraph-berkeleyje'
runtimeOnly 'org.janusgraph:janusgraph-lucene'
runtimeOnly 'org.janusgraph:janusgraph-es'
runtimeOnly 'org.janusgraph:janusgraph-hbase'
runtimeOnly 'org.janusgraph:janusgraph-cql'
runtimeOnly 'joda-time:joda-time'
runtimeOnly 'org.antlr:antlr-runtime'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ public enum OMAGAdminErrorCode implements ExceptionMessageSet

UNEXPECTED_EXCEPTION(500, "OMAG-ADMIN-500-001",
"Method {1} for OMAG server {0} returned an unexpected exception of {2} with message {3}",
"The system is unable to configure the OMAG server. No change was made to the server's configuration document.",
"This is likely to be either an operational or logic error. Look for other errors. Validate the request. If you are stuck, raise an issue."),
"The system is unable to work with the OMAG server. No change was made to the server's configuration document.",
"This is likely to be either a configuration, operational or logic error. Look for other errors. Validate the request. If you are stuck, raise an issue."),

UNEXPECTED_PLATFORM_EXCEPTION(500, "OMAG-ADMIN-500-002",
"Method {0} returned an unexpected exception of {1} with message {2}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@

/**
* The OMRSAuditCode is used to define the message content for the OMRS Audit Log.
*
* The 5 fields in the enum are:
* <ul>
* <li>Log Message Id: to uniquely identify the message</li>
* <li>Log Message id: to uniquely identify the message</li>
* <li>Severity: is this an event, decision, action, error or exception</li>
* <li>Log Message Text: includes placeholder to allow additional values to be captured</li>
* <li>Additional Information: further parameters and data relating to the audit message (optional)</li>
Expand Down Expand Up @@ -369,10 +368,21 @@ public enum OMRSAuditCode implements AuditLogMessageSet
"Verify that the correct type of repository, with the correct type of storage has been configured for this server."),

NEW_REAL_CONNECTOR("OMRS-AUDIT-0045",
OMRSAuditLogRecordSeverity.STARTUP,
"The connector for the local repository has been initialized",
"The connector configuration identified a valid connector. The server continues initializing.",
"Verify that the repository connector initialized without error."),

STARTING_REAL_CONNECTOR("OMRS-AUDIT-0046",
OMRSAuditLogRecordSeverity.STARTUP,
"The connector for the local repository is about to be started",
"The server calls start() on the connector.",
"Verify that the repository connector returns from the start() without error. Look for message OMRS-AUDIT-0047"),
STARTED_REAL_CONNECTOR("OMRS-AUDIT-0047",
OMRSAuditLogRecordSeverity.STARTUP,
"The connector for the local repository has been started",
"The server continues initializing.",
"Verify that the repository connector initialized without error."),
"Verify that the repository connector started without error."),
PROCESSING_ARCHIVE("OMRS-AUDIT-0050",
OMRSAuditLogRecordSeverity.INFO,
"The Open Metadata Repository Services (OMRS) is about to process open metadata archive {0}",
Expand Down Expand Up @@ -1148,19 +1158,19 @@ public enum OMRSAuditCode implements AuditLogMessageSet

;

AuditLogMessageDefinition messageDefinition;
final AuditLogMessageDefinition messageDefinition;



/**
* The constructor for OMRSAuditCode expects to be passed one of the enumeration rows defined in
* OMRSAuditCode above. For example:
*
* <br>
* OMRSAuditCode auditCode = OMRSAuditCode.SERVER_SHUTDOWN;
*
* <br>
* This will expand out to the 4 parameters shown below.
*
* @param messageId - unique Id for the message
* @param messageId - unique id for the message
* @param severity - severity of the message
* @param message - text for the message
* @param systemAction - description of the action taken by the system when the condition happened
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import org.odpi.openmetadata.frameworks.auditlog.messagesets.ExceptionMessageDefinition;
import org.odpi.openmetadata.frameworks.auditlog.messagesets.ExceptionMessageSet;
import org.odpi.openmetadata.repositoryservices.auditlog.OMRSAuditLogRecordSeverity;


/**
Expand Down Expand Up @@ -129,8 +130,8 @@ public enum OMRSErrorCode implements ExceptionMessageSet
"The system is unable to perform the request because the identifier for the AttributeTypeDef is needed to proceed.",
"Correct the caller's code and try the request again."),
NULL_METADATA_COLLECTION(400, "OMRS-REPOSITORY-400-025",
"Local metadata repository has not initialized correctly because it has a null metadata collection.",
"The system is unable to process requests for this repository without a metadata collection.",
"Local metadata repository has not initialized correctly because it was unable to create its metadata collection",
"The metadata collection object provides access to the storage, or remote metadata service that is supporting the repository. The system is unable to process requests for this repository without a metadata collection.",
"The repository connector for the local repository has not initialized correctly. This may be an " +
"error in the repository connector's logic, or a missing or incorrect property in the connector's connection object stored in " +
"the server's configuration document, or a missing resource, or permission needed by the connector. The repository connector should " +
Expand Down Expand Up @@ -433,6 +434,12 @@ public enum OMRSErrorCode implements ExceptionMessageSet
"The connection {0} passed to the EnterpriseOMRSRepositoryConnector is invalid.",
"The system is not able to populate the EnterpriseOMRSRepositoryConnector object because it needs the connection to identify the repository.",
"Look for other error messages to identify what caused this error. When the issue is fixed, retry the request."),

BAD_REAL_LOCAL_REPOSITORY_CONNECTOR(400, "OMRS-CONNECTOR-400-005",
"The connector to the local repository failed with a {0} exception and the following error message: {1}",
"The server fails to start.",
"Correct the configuration to ensure that the local repository local connection is valid."),

NULL_TOPIC_CONNECTOR(400, "OMRS-TOPIC-CONNECTOR-400-001",
"Unable to send or receive events for source {0} because the connector to the OMRS Topic failed to initialize",
"The local server will not connect to the cohort.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1260,14 +1260,13 @@ private LocalOMRSRepositoryConnector getLocalOMRSConnector(Connection
* of the Connector to OMRSRepositoryConnector. This could occur if the connector configured is a valid
* OCF Connector but not an OMRSRepositoryConnector.
*/
String connectionName = connection.getQualifiedName();

auditLog.logException(methodName,
OMRSAuditCode.BAD_REAL_LOCAL_REPOSITORY_CONNECTOR.getMessageDefinition(error.getClass().getName(),
error.getMessage()),
error);

throw new OMRSConfigErrorException(OMRSErrorCode.INVALID_OMRS_CONNECTION.getMessageDefinition(connectionName),
throw new OMRSConfigErrorException(OMRSErrorCode.BAD_REAL_LOCAL_REPOSITORY_CONNECTOR.getMessageDefinition(error.getClass().getName(),
error.getMessage()),
this.getClass().getName(),
methodName,
error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryConnector;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryeventmapper.OMRSRepositoryEventMapperConnector;
import org.odpi.openmetadata.repositoryservices.eventmanagement.*;
import org.odpi.openmetadata.repositoryservices.ffdc.OMRSAuditCode;
import org.odpi.openmetadata.repositoryservices.ffdc.OMRSErrorCode;
import org.odpi.openmetadata.repositoryservices.ffdc.exception.OMRSLogicErrorException;
import org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException;
Expand All @@ -27,7 +28,7 @@
/**
* LocalOMRSRepositoryConnector provides access the local metadata repository plus manages outbound
* repository events.
*
* <br><br>
* It passes each request to both the real OMRS connector for the local metadata repository and an
* OMRSEventPublisher. The OMRSEventPublisher will use its configuration to decide if it needs to
* pass on the request to the rest of the metadata repository cohort.
Expand Down Expand Up @@ -126,7 +127,7 @@ protected LocalOMRSRepositoryConnector(OMRSRepositoryConnector realLo
/**
* Set up a new security verifier (the cohort manager runs with a default verifier until this
* method is called).
*
* <br><br>
* The security verifier provides authorization checks for access and maintenance
* changes to open metadata. Authorization checks are enabled through the
* OpenMetadataServerSecurityConnector.
Expand Down Expand Up @@ -155,13 +156,25 @@ public void setSecurityVerifier(OpenMetadataServerSecurityVerifier securityVerif
@Override
public void start() throws ConnectorCheckedException
{
final String methodName = "start";

super.start();

if (auditLog != null)
{
auditLog.logMessage(methodName, OMRSAuditCode.STARTING_REAL_CONNECTOR.getMessageDefinition());
}

if (realLocalConnector != null)
{
realLocalConnector.start();
}

if (auditLog != null)
{
auditLog.logMessage(methodName, OMRSAuditCode.STARTED_REAL_CONNECTOR.getMessageDefinition());
}

if (realEventMapper != null)
{
realEventMapper.start();
Expand Down Expand Up @@ -394,6 +407,7 @@ public void setServerUserId(String localServerUserId)
}
}


/**
* Receive an audit log object that can be used to record audit log messages. The caller has initialized it
* with the correct component description and log destinations.
Expand Down Expand Up @@ -423,18 +437,20 @@ public void setMetadataCollectionId(String metadataCollectionId)

super.setMetadataCollectionId(metadataCollectionId);

if (realLocalConnector != null)
try
{
/*
* This is typically where the metadata collection for the real repository is created. This object issues the requests to the
* storage (or remote metadata system) and this may be the first point of contact for the real connector.
* Configuration errors are likely to emerge at this point.
*/
realLocalConnector.setMetadataCollectionId(metadataCollectionId);
}

if (realEventMapper != null)
{
realEventMapper.setMetadataCollectionId(metadataCollectionId);
}
if (realEventMapper != null)
{
realEventMapper.setMetadataCollectionId(metadataCollectionId);
}

try
{
/*
* Initialize the metadata collection only once the connector is properly set up.
*/
Expand Down Expand Up @@ -465,7 +481,7 @@ public void setMetadataCollectionId(String metadataCollectionId)
this.incomingInstanceEventProcessor = localOMRSInstanceEventProcessor;
this.instanceRetrievalEventProcessor = localOMRSInstanceEventProcessor;
}
catch (Exception error)
catch (Throwable error) // Typically we catch Exception, but this is a key error point for real repositories.
{
throw new OMRSLogicErrorException(OMRSErrorCode.NULL_METADATA_COLLECTION.getMessageDefinition(repositoryName),
this.getClass().getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public GlossaryBrowserResource()
@GetMapping(path = "/glossaries/terms/status-list")

@Operation(summary="getGlossaryTermStatuses",
description="Return the list of glossary term status enum values.",
description="Return the list of glossary term status enum values. These values are used in a glossary workflow to describe the state of the content of the term.",
externalDocs=@ExternalDocumentation(description="Controlled glossary terms",
url="https://egeria-project.org/services/omvs/glossary-workflow/overview/#controlled-glossary-terms"))

Expand All @@ -110,7 +110,7 @@ public GlossaryTermStatusListResponse getGlossaryTermStatuses(@PathVariable Stri
@GetMapping(path = "/glossaries/terms/relationships/status-list")

@Operation(summary="getGlossaryTermRelationshipStatuses",
description="Return the list of glossary term relationship status enum values.",
description="Return the list of glossary term relationship status enum values. These values are stored in a term-ot-term, or term-to-category, relationship and are used to indicate how much the relationship should be trusted",
externalDocs=@ExternalDocumentation(description="Relationship statuses",
url="https://egeria-project.org/services/omvs/glossary-workflow/overview/#relationship-statuses"))

Expand All @@ -131,7 +131,7 @@ public GlossaryTermRelationshipStatusListResponse getGlossaryTermRelationshipSta
@GetMapping(path = "/glossaries/terms/activity-types")

@Operation(summary="getGlossaryTermActivityTypes",
description="Return the list of glossary term activity type enum values.",
description="Return the list of glossary term activity type enum values. These values are used in the ActivityDescription classification that is attached to a glossary term that represents some type of activity.",
externalDocs=@ExternalDocumentation(description="Activity description",
url="https://egeria-project.org/types/3/0340-Dictionary/#activitydescription"))

Expand Down