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

sendEvents Async #7138

Merged
merged 14 commits into from
Jan 24, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException;
import org.odpi.openmetadata.repositoryservices.connectors.openmetadatatopic.OpenMetadataTopicSenderConnectorBase;

import java.util.concurrent.CompletionException;


/**
* AssetConsumerOutTopicServerConnector is the java implementation of the
Expand All @@ -33,7 +35,7 @@ public void sendEvent(AssetConsumerOutTopicEvent event) throws InvalidParameterE
try
{
String eventString = objectMapper.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand All @@ -42,6 +44,17 @@ public void sendEvent(AssetConsumerOutTopicEvent event) throws InvalidParameterE
eventString);
}
}
catch (CompletionException error)
{
if (error.getCause() instanceof ConnectorCheckedException)
{
throw (ConnectorCheckedException) error.getCause();
}
else if (error.getCause() instanceof InvalidParameterException)
{
throw (InvalidParameterException) error.getCause();
}
}
catch (InvalidParameterException | ConnectorCheckedException error)
{
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException;
import org.odpi.openmetadata.repositoryservices.connectors.openmetadatatopic.OpenMetadataTopicSenderConnectorBase;

import java.util.concurrent.CompletionException;


/**
* AssetManagerOutTopicServerConnector is the java implementation of the
Expand All @@ -33,7 +35,7 @@ public void sendEvent(AssetManagerOutTopicEvent event) throws InvalidParameterEx
try
{
String eventString = objectMapper.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand All @@ -42,6 +44,17 @@ public void sendEvent(AssetManagerOutTopicEvent event) throws InvalidParameterEx
eventString);
}
}
catch (CompletionException error)
{
if (error.getCause() instanceof ConnectorCheckedException)
{
throw (ConnectorCheckedException) error.getCause();
}
else if (error.getCause() instanceof InvalidParameterException)
{
throw (InvalidParameterException) error.getCause();
}
}
catch (InvalidParameterException | ConnectorCheckedException error)
{
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException;
import org.odpi.openmetadata.repositoryservices.connectors.openmetadatatopic.OpenMetadataTopicSenderConnectorBase;

import java.util.concurrent.CompletionException;


/**
* AssetOwnerOutTopicServerConnector is the java implementation of the
Expand All @@ -33,7 +35,7 @@ public void sendEvent(AssetOwnerOutTopicEvent event) throws InvalidParameterExce
try
{
String eventString = objectMapper.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand All @@ -42,6 +44,17 @@ public void sendEvent(AssetOwnerOutTopicEvent event) throws InvalidParameterExce
eventString);
}
}
catch (CompletionException error)
{
if (error.getCause() instanceof ConnectorCheckedException)
{
throw (ConnectorCheckedException) error.getCause();
}
else if (error.getCause() instanceof InvalidParameterException)
{
throw (InvalidParameterException) error.getCause();
}
}
catch (InvalidParameterException | ConnectorCheckedException error)
{
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException;
import org.odpi.openmetadata.repositoryservices.connectors.openmetadatatopic.OpenMetadataTopicSenderConnectorBase;

import java.util.concurrent.CompletionException;


/**
* CommunityProfileOutTopicServerConnector is the java implementation of the
Expand All @@ -33,7 +35,7 @@ public void sendEvent(CommunityProfileOutboundEvent event) throws InvalidParamet
try
{
String eventString = objectMapper.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand All @@ -42,6 +44,17 @@ public void sendEvent(CommunityProfileOutboundEvent event) throws InvalidParamet
eventString);
}
}
catch (CompletionException error)
{
if (error.getCause() instanceof ConnectorCheckedException)
{
throw (ConnectorCheckedException) error.getCause();
}
else if (error.getCause() instanceof InvalidParameterException)
{
throw (InvalidParameterException) error.getCause();
}
}
catch (InvalidParameterException | ConnectorCheckedException error)
{
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
Expand Down Expand Up @@ -209,11 +208,10 @@ protected void upsertExternalRelationship(String userId, String firstGUID, Strin

TypeDef relationshipTypeDef = repositoryHelper.getTypeDefByName(userId, relationshipTypeName);

genericHandler.linkElementToElement(userId, externalSourceGUID, externalSourceName, firstGUID,
genericHandler.uncheckedLinkElementToElement(userId, externalSourceGUID, externalSourceName, firstGUID,
CommonMapper.GUID_PROPERTY_NAME, firstEntityTypeName, secondGUID, CommonMapper.GUID_PROPERTY_NAME,
secondEntityTypeName, false, false, null,
relationshipTypeDef.getGUID(), relationshipTypeName, relationshipProperties, null,
null, getNow(), methodName);
relationshipTypeDef.getGUID(), relationshipTypeName, relationshipProperties, getNow(), methodName);
} else {
Relationship originalRelationship = relationship.get();
String relationshipGUID = originalRelationship.getGUID();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ void upsertExternalRelationship() throws InvalidParameterException, PropertyServ
ENTITY_TYPE_NAME, EXTERNAL_SOURCE_DE_QUALIFIED_NAME, null);

verify(invalidParameterHandler, times(1)).validateUserId(USER, methodName);
verify(genericHandler, times(1)).linkElementToElement(USER, EXTERNAL_SOURCE_DE_GUID, EXTERNAL_SOURCE_DE_QUALIFIED_NAME, FIRST_GUID,
verify(genericHandler, times(1)).uncheckedLinkElementToElement(USER, EXTERNAL_SOURCE_DE_GUID, EXTERNAL_SOURCE_DE_QUALIFIED_NAME, FIRST_GUID,
CommonMapper.GUID_PROPERTY_NAME, ENTITY_TYPE_NAME, SECOND_GUID, CommonMapper.GUID_PROPERTY_NAME,
ENTITY_TYPE_NAME, false, false, null,
RELATIONSHIP_TYPE_GUID, RELATIONSHIP_TYPE_NAME, null, null, null, null, methodName);
RELATIONSHIP_TYPE_GUID, RELATIONSHIP_TYPE_NAME, null, null, methodName);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException;
import org.odpi.openmetadata.repositoryservices.connectors.openmetadatatopic.OpenMetadataTopicSenderConnectorBase;

import java.util.concurrent.CompletionException;


/**
Expand All @@ -36,7 +37,7 @@ public void sendEvent(DataEngineEventHeader event) throws InvalidParameterExcept
{

String eventString = objectMapper.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand All @@ -46,6 +47,17 @@ public void sendEvent(DataEngineEventHeader event) throws InvalidParameterExcept
}

}
catch (CompletionException error)
{
if (error.getCause() instanceof ConnectorCheckedException)
{
throw (ConnectorCheckedException) error.getCause();
}
else if (error.getCause() instanceof InvalidParameterException)
{
throw (InvalidParameterException) error.getCause();
}
}
catch (InvalidParameterException | ConnectorCheckedException error)
{
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException;
import org.odpi.openmetadata.repositoryservices.connectors.openmetadatatopic.OpenMetadataTopicSenderConnectorBase;

import java.util.concurrent.CompletionException;


/**
* DataManagerOutTopicServerConnector is the java implementation of the
Expand All @@ -33,7 +35,7 @@ public void sendEvent(DataManagerOutboundEvent event) throws InvalidParameterExc
try
{
String eventString = objectMapper.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand All @@ -42,6 +44,17 @@ public void sendEvent(DataManagerOutboundEvent event) throws InvalidParameterExc
eventString);
}
}
catch (CompletionException error)
{
if (error.getCause() instanceof ConnectorCheckedException)
{
throw (ConnectorCheckedException) error.getCause();
}
else if (error.getCause() instanceof InvalidParameterException)
{
throw (InvalidParameterException) error.getCause();
}
}
catch (InvalidParameterException | ConnectorCheckedException error)
{
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException;
import org.odpi.openmetadata.repositoryservices.connectors.openmetadatatopic.OpenMetadataTopicSenderConnectorBase;

import java.util.concurrent.CompletionException;


/**
* DigitalArchitectureOutTopicServerConnector is the java implementation of the
Expand All @@ -34,7 +36,7 @@ public void sendEvent(DigitalArchitectureOutTopicEvent event) throws InvalidPara
try
{
String eventString = objectMapper.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand All @@ -43,6 +45,17 @@ public void sendEvent(DigitalArchitectureOutTopicEvent event) throws InvalidPara
eventString);
}
}
catch (CompletionException error)
{
if (error.getCause() instanceof ConnectorCheckedException)
{
throw (ConnectorCheckedException) error.getCause();
}
else if (error.getCause() instanceof InvalidParameterException)
{
throw (InvalidParameterException) error.getCause();
}
}
catch (InvalidParameterException | ConnectorCheckedException error)
{
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException;
import org.odpi.openmetadata.repositoryservices.connectors.openmetadatatopic.OpenMetadataTopicSenderConnectorBase;

import java.util.concurrent.CompletionException;


/**
* GovernanceEngineOutTopicServerConnector is the java implementation of the
Expand All @@ -33,7 +35,7 @@ public void sendEvent(GovernanceEngineEvent event) throws InvalidParameterExcept
try
{
String eventString = objectMapper.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand All @@ -42,6 +44,17 @@ public void sendEvent(GovernanceEngineEvent event) throws InvalidParameterExcept
eventString);
}
}
catch (CompletionException error)
{
if (error.getCause() instanceof ConnectorCheckedException)
{
throw (ConnectorCheckedException) error.getCause();
}
else if (error.getCause() instanceof InvalidParameterException)
{
throw (InvalidParameterException) error.getCause();
}
}
catch (InvalidParameterException | ConnectorCheckedException error)
{
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException;
import org.odpi.openmetadata.repositoryservices.connectors.openmetadatatopic.OpenMetadataTopicSenderConnectorBase;

import java.util.concurrent.CompletionException;


/**
* ITInfrastructureOutTopicServerConnector is the java implementation of the
Expand All @@ -33,7 +35,7 @@ public void sendEvent(ITInfrastructureOutTopicEvent event) throws InvalidParamet
try
{
String eventString = objectMapper.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand All @@ -42,6 +44,17 @@ public void sendEvent(ITInfrastructureOutTopicEvent event) throws InvalidParamet
eventString);
}
}
catch (CompletionException error)
{
if (error.getCause() instanceof ConnectorCheckedException)
{
throw (ConnectorCheckedException) error.getCause();
}
else if (error.getCause() instanceof InvalidParameterException)
{
throw (InvalidParameterException) error.getCause();
}
}
catch (InvalidParameterException | ConnectorCheckedException error)
{
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException;
import org.odpi.openmetadata.repositoryservices.connectors.openmetadatatopic.OpenMetadataTopicSenderConnectorBase;

import java.util.concurrent.CompletionException;


/**
* SecurityManagerOutTopicServerConnector is the java implementation of the
Expand All @@ -33,7 +35,7 @@ public void sendEvent(SecurityManagerOutTopicEvent event) throws InvalidParamete
try
{
String eventString = objectMapper.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand All @@ -42,6 +44,17 @@ public void sendEvent(SecurityManagerOutTopicEvent event) throws InvalidParamete
eventString);
}
}
catch (CompletionException error)
{
if (error.getCause() instanceof ConnectorCheckedException)
{
throw (ConnectorCheckedException) error.getCause();
}
else if (error.getCause() instanceof InvalidParameterException)
{
throw (InvalidParameterException) error.getCause();
}
}
catch (InvalidParameterException | ConnectorCheckedException error)
{
throw error;
Expand Down
Loading