use of org.odpi.openmetadata.frameworks.connectors.properties.EndpointProperties in project egeria-connector-sas-viya by odpi.
the class RepositoryConnector method connectToCatalog.
private void connectToCatalog(String methodName) throws Exception {
if (this.sasCatalogClient == null) {
EndpointProperties endpointProperties = connectionProperties.getEndpoint();
if (endpointProperties == null) {
raiseConnectorCheckedException(ErrorCode.REST_CLIENT_FAILURE, methodName, null, "null");
} else {
this.url = endpointProperties.getProtocol() + "://" + endpointProperties.getAddress();
this.sasCatalogClient = new SASCatalogRestClient(this.url, this.securedProperties.get("userId"), this.securedProperties.get("password"));
}
}
metadataCollection = new MetadataCollection(this, serverName, repositoryHelper, repositoryValidator, metadataCollectionId);
}
use of org.odpi.openmetadata.frameworks.connectors.properties.EndpointProperties in project egeria-connector-sas-viya by odpi.
the class RepositoryEventMapper method initialize.
@Override
public void initialize(String repositoryEventMapperName, OMRSRepositoryConnector repositoryConnector) {
super.initialize(repositoryEventMapperName, repositoryConnector);
final String methodName = "initialize";
auditLog.logMessage(methodName, AuditCode.EVENT_MAPPER_INITIALIZING.getMessageDefinition());
this.mapper = new ObjectMapper();
this.mapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
try {
log.debug("Set up connection factory for RabbitMQ");
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.useSslProtocol();
ConnectionProperties connProperties = this.connectionProperties;
if (connProperties != null) {
EndpointProperties connEndpoint = connProperties.getEndpoint();
Map<String, Object> cfgProperties = connProperties.getConfigurationProperties();
if (connEndpoint != null) {
String host = "";
String portAsString = "";
String address = connEndpoint.getAddress();
if (StringUtils.isNotEmpty(address)) {
if (address.contains(":")) {
String[] addressParts = address.split(":", 2);
host = addressParts[0];
portAsString = addressParts[1];
} else {
host = address;
}
}
if (StringUtils.isEmpty(host)) {
host = "sas-rabbitmq-server";
}
// RabbitMQ host was configured, so set it in ConnectionFactory
log.debug("Setting RabbitMQ host to: " + host);
connectionFactory.setHost(host);
if (StringUtils.isEmpty(portAsString)) {
portAsString = "5672";
}
try {
int port = Integer.valueOf(portAsString);
// RabbitMQ port was configured, so set it in ConnectionFactory
log.debug("Setting RabbitMQ port to: " + portAsString);
connectionFactory.setPort(port);
} catch (NumberFormatException nfe) {
log.error("Could not convert '{}' to a port number. Default port will be used.", portAsString);
}
String username = System.getenv("RABBITMQ_USER");
String password = System.getenv("RABBITMQ_PASS");
if (cfgProperties != null) {
username = (String) cfgProperties.getOrDefault("username", username);
password = (String) cfgProperties.getOrDefault("password", password);
}
if (StringUtils.isNotEmpty(username)) {
// RabbitMQ username was configured, so set it in ConnectionFactory
log.debug("Setting RabbitMQ username");
connectionFactory.setUsername(username);
}
if (StringUtils.isNotEmpty(password)) {
// RabbitMQ password was configured, so set it in ConnectionFactory
log.debug("Setting RabbitMQ password");
connectionFactory.setPassword(password);
}
}
}
log.debug("Create RabbitMQ connection");
Connection connection = connectionFactory.newConnection();
log.debug("Create RabbitMQ channel");
channel = connection.createChannel();
log.debug("Declare RabbitMQ exchange: " + EXCHANGE_NAME);
channel.exchangeDeclare(EXCHANGE_NAME, "topic", true);
log.debug("Declare RabbitMQ queue");
queueName = channel.queueDeclare().getQueue();
log.debug("Bind RabbitMQ queue: {}", queueName);
channel.queueBind(queueName, EXCHANGE_NAME, "application.integration.catalog.change.*.success");
log.debug("Finished establishment of RabbitMQ connection");
} catch (Exception e) {
log.error("Failed to initialize RabbitMQ connection " + e.getMessage());
}
auditLog.logMessage(methodName, AuditCode.EVENT_MAPPER_INITIALIZED.getMessageDefinition(repositoryConnector.getServerName()));
}
use of org.odpi.openmetadata.frameworks.connectors.properties.EndpointProperties in project egeria-connector-integration-topic-strimzi by odpi.
the class StrimziMonitorIntegrationConnector method start.
/**
* Indicates that the connector is completely configured and can begin processing.
* This call can be used to register with non-blocking services.
*
* @throws ConnectorCheckedException there is a problem within the connector.
*/
@Override
public void start() throws ConnectorCheckedException {
super.start();
final String methodName = "start";
myContext = super.getContext();
if (connectionProperties != null) {
EndpointProperties endpoint = connectionProperties.getEndpoint();
if (endpoint != null) {
targetURL = endpoint.getAddress();
try {
new URI(targetURL);
} catch (URISyntaxException e) {
throwException(StrimziIntegrationConnectorErrorCode.INVALID_URL_IN_CONFIGURATION, "Endpoint address");
}
}
Map<String, Object> configurationProperties = connectionProperties.getConfigurationProperties();
templateQualifiedName = (String) configurationProperties.get(StrimziMonitorIntegrationProvider.TEMPLATE_QUALIFIED_NAME_CONFIGURATION_PROPERTY);
// TODO check that this exists - manditory ???
token = (String) configurationProperties.get(StrimziMonitorIntegrationProvider.TOKEN_PROPERTY);
topicNamePrefix = (String) configurationProperties.get(StrimziMonitorIntegrationProvider.TOPIC_NAME_PREFIX);
/*
* Record the configuration
*/
if (auditLog != null) {
// do not record the token in the log which could be sensitive
auditLog.logMessage(methodName, StrimziIntegrationConnectorAuditCode.CONNECTOR_CONFIGURATION.getMessageDefinition(connectorName, targetURL, templateQualifiedName));
}
} else {
if (auditLog != null) {
auditLog.logMessage(methodName, StrimziIntegrationConnectorAuditCode.NO_CONNECTION_PROPERTIES.getMessageDefinition(connectorName, targetURL));
}
throwException(StrimziIntegrationConnectorErrorCode.NO_CONNECTION_CONFIGURATION, StrimziMonitorIntegrationProvider.TOKEN_PROPERTY);
}
/*
* Retrieve the template if one has been requested
*/
if (templateQualifiedName != null) {
try {
List<TopicElement> templateElements = myContext.getTopicsByName(templateQualifiedName, 0, 0);
if (templateElements != null) {
for (TopicElement templateElement : templateElements) {
String qualifiedName = templateElement.getProperties().getQualifiedName();
if (templateQualifiedName.equals(qualifiedName)) {
templateGUID = templateElement.getElementHeader().getGUID();
}
}
}
} catch (Exception error) {
if (auditLog != null) {
auditLog.logException(methodName, StrimziIntegrationConnectorAuditCode.MISSING_TEMPLATE.getMessageDefinition(connectorName, templateQualifiedName), error);
}
}
}
}
Aggregations