aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandler.java12
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealth.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java17
3 files changed, 26 insertions, 11 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandler.java
index 425b464c4f..41d10737d3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandler.java
@@ -62,10 +62,6 @@ public class CambriaHandler implements ICambriaHandler {
private static final Logger log = Logger.getLogger(CambriaHandler.class.getName());
private static final String PARTITION_KEY = "asdc" + "aa";
private static final String SEND_NOTIFICATION = "send notification";
- private static final String CONSUMER_ID = ConfigurationManager.getConfigurationManager().getDistributionEngineConfiguration()
- .getDistributionStatusTopic().getConsumerId();
- private static final boolean USE_HTTPS_WITH_DMAAP = ConfigurationManager.getConfigurationManager().getDistributionEngineConfiguration()
- .isUseHttpsWithDmaap();
private final Gson gson = new Gson();
/**
@@ -284,7 +280,9 @@ public class CambriaHandler implements ICambriaHandler {
String managerSecretKey) {
AbstractAuthenticatedManagerBuilder<CambriaTopicManager> clientBuilder = createTopicManagerBuilder(hostSet)
.authenticatedBy(managerApiKey, managerSecretKey);
- if (USE_HTTPS_WITH_DMAAP) {
+ final boolean useHttpsWithDmaap = ConfigurationManager.getConfigurationManager().getDistributionEngineConfiguration()
+ .isUseHttpsWithDmaap();
+ if (useHttpsWithDmaap) {
clientBuilder = clientBuilder.usingHttps();
}
return clientBuilder;
@@ -506,7 +504,9 @@ public class CambriaHandler implements ICambriaHandler {
Either<ApiCredential, CambriaErrorResponse> result;
try {
CambriaIdentityManager createIdentityManager = buildCambriaClient(new IdentityManagerBuilder().usingHosts(hostSet));
- String description = String.format("ASDC Key for %s", CONSUMER_ID);
+ final String consumerId = ConfigurationManager.getConfigurationManager().getDistributionEngineConfiguration()
+ .getDistributionStatusTopic().getConsumerId();
+ String description = String.format("ASDC Key for %s", consumerId);
ApiCredential credential = createIdentityManager.createApiKey("", description);
createIdentityManager.setApiCredentials(credential.getApiKey(), credential.getApiSecret());
result = Either.left(credential);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealth.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealth.java
index b1bf59f3aa..0851f22c0a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealth.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealth.java
@@ -31,7 +31,6 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.ConfigurationManager;
@@ -66,9 +65,8 @@ public class DistributionEngineClusterHealth {
private HealthCheckInfo healthCheckInfo = HealthCheckInfoResult.UNKNOWN.getHealthCheckInfo();
private Map<String, AtomicBoolean> envNamePerStatus = null;
private ScheduledFuture<?> scheduledFuture = null;
-
- @PostConstruct
- protected void init() {
+
+ protected void init(final String publicApiKey) {
logger.trace("Enter init method of DistributionEngineClusterHealth");
Long reconnectIntervalConfig = ConfigurationManager.getConfigurationManager().getConfiguration()
.getUebHealthCheckReconnectIntervalInSeconds();
@@ -82,7 +80,7 @@ public class DistributionEngineClusterHealth {
DistributionEngineConfiguration distributionEngineConfiguration = ConfigurationManager.getConfigurationManager()
.getDistributionEngineConfiguration();
this.uebServers = distributionEngineConfiguration.getUebServers();
- this.publicApiKey = distributionEngineConfiguration.getUebPublicKey();
+ this.publicApiKey = publicApiKey;
this.healthCheckScheduledTask = new HealthCheckScheduledTask(this.uebServers);
logger.trace("Exit init method of DistributionEngineClusterHealth");
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java
index 26992b9c3d..afb311f452 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java
@@ -168,6 +168,7 @@ public class EnvironmentsEngine implements INotificationHandler {
String envId = opEnvEntry.getEnvironmentId();
DistributionEngineConfiguration distributionEngineConfiguration = ConfigurationManager.getConfigurationManager()
.getDistributionEngineConfiguration();
+ distributionEngineClusterHealth.init(opEnvEntry.getUebApikey());
DistributionEnginePollingTask distributionEnginePollingTask = new DistributionEnginePollingTask(distributionEngineConfiguration,
distributionCompleteReporter, componentUtils, distributionEngineClusterHealth, opEnvEntry);
String envName = configurationManager.getDistributionEngineConfiguration().getEnvironments().get(0);
@@ -430,9 +431,25 @@ public class EnvironmentsEngine implements INotificationHandler {
private Map<String, OperationalEnvironmentEntry> populateEnvironments() {
Map<String, OperationalEnvironmentEntry> envs = getEnvironmentsFromDb();
OperationalEnvironmentEntry confEntry = readEnvFromConfig();
+ readKeyFromDbOrCreate(envs, confEntry);
envs.put(confEntry.getEnvironmentId(), confEntry);
return envs;
}
+
+ private void readKeyFromDbOrCreate(Map<String, OperationalEnvironmentEntry> envs, OperationalEnvironmentEntry confEntry) {
+ if (envs.get(confEntry.getEnvironmentId()) == null){
+ log.debug("Creating UEB API key");
+ Wrapper<Boolean> errorWrapper = new Wrapper<>();
+ createUebKeys(errorWrapper, confEntry);
+ confEntry.setStatus(EnvironmentStatusEnum.COMPLETED);
+ log.debug("Saving UEB API key to DB");
+ operationalEnvironmentDao.save(confEntry);
+ } else {
+ log.debug("Reading UEB API key from DB");
+ confEntry.setUebApikey(envs.get(confEntry.getEnvironmentId()).getUebApikey());
+ confEntry.setUebSecretKey(envs.get(confEntry.getEnvironmentId()).getUebSecretKey());
+ }
+ }
private OperationalEnvironmentEntry readEnvFromConfig() {
OperationalEnvironmentEntry entry = new OperationalEnvironmentEntry();