aboutsummaryrefslogtreecommitdiffstats
path: root/datafile-app-server/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'datafile-app-server/src/main')
-rw-r--r--datafile-app-server/src/main/docker/Dockerfile4
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfig.java25
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfigParser.java18
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/Scheme.java2
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/Counters.java21
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/logging/MappedDiagnosticContext.java6
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DMaaPMessageConsumer.java5
-rw-r--r--datafile-app-server/src/main/resources/application.properties13
-rw-r--r--datafile-app-server/src/main/resources/scheduled-context.xml16
9 files changed, 28 insertions, 82 deletions
diff --git a/datafile-app-server/src/main/docker/Dockerfile b/datafile-app-server/src/main/docker/Dockerfile
index 6f62e65f..7343128a 100644
--- a/datafile-app-server/src/main/docker/Dockerfile
+++ b/datafile-app-server/src/main/docker/Dockerfile
@@ -23,10 +23,8 @@ WORKDIR /opt/app/datafile
RUN mkdir -p /var/log/ONAP
ADD /target/datafile-app-server.jar /opt/app/datafile/
-
ADD /config/application.yaml /opt/app/datafile/config/
ADD /config/dfc.jks.b64 /opt/app/datafile/config/
-ADD /config/datafile_endpoints.json /opt/app/datafile/config/
ADD /config/ftp.jks.b64 /opt/app/datafile/config/
EXPOSE 8100 8433
@@ -40,4 +38,4 @@ RUN chmod -R 755 /opt/app/datafile/config/
USER datafile
-ENTRYPOINT ["/usr/bin/java", "-jar", "/opt/app/datafile/datafile-app-server.jar"] \ No newline at end of file
+ENTRYPOINT ["/usr/bin/java", "-jar", "/opt/app/datafile/datafile-app-server.jar"]
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfig.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfig.java
index 6e9f7702..58081a89 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfig.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfig.java
@@ -99,8 +99,10 @@ public class AppConfig {
}
Flux<AppConfig> createRefreshTask(Map<String, String> context) {
- return getEnvironment(systemEnvironment, context).flatMap(this::createCbsClient)
- .flatMapMany(this::periodicConfigurationUpdates).map(this::parseCloudConfig)
+ return getEnvironment(systemEnvironment, context) //
+ .flatMap(this::createCbsClient) //
+ .flatMapMany(this::periodicConfigurationUpdates) //
+ .map(this::parseCloudConfig) //
.onErrorResume(this::onErrorResume);
}
@@ -208,22 +210,17 @@ public class AppConfig {
throw new JsonSyntaxException("Root is not a json object");
}
parseCloudConfig(rootObject);
+ logger.info("Local configuration file loaded: {}", filepath);
} catch (JsonSyntaxException | IOException e) {
- logger.warn("Local configuration file not loaded: {}", filepath, e);
+ logger.trace("Local configuration file not loaded: {}", filepath, e);
}
}
- private synchronized void setConfiguration(ConsumerConfiguration consumerConfiguration,
- Map<String, PublisherConfiguration> publisherConfiguration, FtpesConfig ftpesConfig) {
- if (consumerConfiguration == null || publisherConfiguration == null || ftpesConfig == null) {
- logger.error(
- "Problem with configuration consumerConfiguration: {}, publisherConfiguration: {}, ftpesConfig: {}",
- consumerConfiguration, publisherConfiguration, ftpesConfig);
- } else {
- this.dmaapConsumerConfiguration = consumerConfiguration;
- this.publishingConfigurations = publisherConfiguration;
- this.ftpesConfiguration = ftpesConfig;
- }
+ private synchronized void setConfiguration(@NotNull ConsumerConfiguration consumerConfiguration,
+ @NotNull Map<String, PublisherConfiguration> publisherConfiguration, @NotNull FtpesConfig ftpesConfig) {
+ this.dmaapConsumerConfiguration = consumerConfiguration;
+ this.publishingConfigurations = publisherConfiguration;
+ this.ftpesConfiguration = ftpesConfig;
}
JsonElement getJsonElement(JsonParser parser, InputStream inputStream) {
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfigParser.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfigParser.java
index d9a9b76a..fc550ab0 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfigParser.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfigParser.java
@@ -25,6 +25,9 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
+
+import javax.validation.constraints.NotNull;
+
import java.util.Set;
import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
@@ -57,14 +60,12 @@ public class CloudConfigParser {
*
* @throws DatafileTaskException if a member of the configuration is missing.
*/
- public Map<String, PublisherConfiguration> getDmaapPublisherConfigurations() throws DatafileTaskException {
+ public @NotNull Map<String, PublisherConfiguration> getDmaapPublisherConfigurations() throws DatafileTaskException {
JsonObject producerCfgs = jsonObject.get("streams_publishes").getAsJsonObject();
Iterator<String> changeIdentifierList = producerCfgs.keySet().iterator();
-
Map<String, PublisherConfiguration> result = new HashMap<>();
while (changeIdentifierList.hasNext()) {
-
String changeIdentifier = changeIdentifierList.next();
JsonObject producerCfg = getAsJson(producerCfgs, changeIdentifier);
JsonObject feedConfig = get(producerCfg, "dmaap_info").getAsJsonObject();
@@ -85,7 +86,6 @@ public class CloudConfigParser {
result.put(cfg.changeIdentifier(), cfg);
}
return result;
-
}
/**
@@ -94,7 +94,7 @@ public class CloudConfigParser {
* @return the consumer configuration.
* @throws DatafileTaskException if a member of the configuration is missing.
*/
- public ConsumerConfiguration getDmaapConsumerConfig() throws DatafileTaskException {
+ public @NotNull ConsumerConfiguration getDmaapConsumerConfig() throws DatafileTaskException {
JsonObject consumerCfg = jsonObject.get("streams_subscribes").getAsJsonObject();
Set<Entry<String, JsonElement>> topics = consumerCfg.entrySet();
if (topics.size() != 1) {
@@ -119,7 +119,7 @@ public class CloudConfigParser {
* @return the xNF communication security configuration.
* @throws DatafileTaskException if a member of the configuration is missing.
*/
- public FtpesConfig getFtpesConfig() throws DatafileTaskException {
+ public @NotNull FtpesConfig getFtpesConfig() throws DatafileTaskException {
return new ImmutableFtpesConfig.Builder() //
.keyCert(getAsString(jsonObject, "dmaap.ftpesConfig.keyCert"))
.keyPassword(getAsString(jsonObject, "dmaap.ftpesConfig.keyPassword"))
@@ -128,7 +128,7 @@ public class CloudConfigParser {
.build();
}
- private static JsonElement get(JsonObject obj, String memberName) throws DatafileTaskException {
+ private static @NotNull JsonElement get(JsonObject obj, String memberName) throws DatafileTaskException {
JsonElement elem = obj.get(memberName);
if (elem == null) {
throw new DatafileTaskException("Could not find member: " + memberName + " in: " + obj);
@@ -136,11 +136,11 @@ public class CloudConfigParser {
return elem;
}
- private static String getAsString(JsonObject obj, String memberName) throws DatafileTaskException {
+ private static @NotNull String getAsString(JsonObject obj, String memberName) throws DatafileTaskException {
return get(obj, memberName).getAsString();
}
- private static JsonObject getAsJson(JsonObject obj, String memberName) throws DatafileTaskException {
+ private static @NotNull JsonObject getAsJson(JsonObject obj, String memberName) throws DatafileTaskException {
return get(obj, memberName).getAsJsonObject();
}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/Scheme.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/Scheme.java
index e5ca9351..c10c0f1e 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/Scheme.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/Scheme.java
@@ -37,7 +37,7 @@ public enum Scheme {
*
* @param schemeString the string to convert to <code>Scheme</code>.
* @return The corresponding <code>Scheme</code>
- * @throws Exception if the value of the string doesn't match any defined scheme.
+ * @throws DatafileTaskException if the value of the string doesn't match any defined scheme.
*/
public static Scheme getSchemeFromString(String schemeString) throws DatafileTaskException {
Scheme result;
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/Counters.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/Counters.java
index 878bb554..8e8d847c 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/Counters.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/Counters.java
@@ -100,9 +100,9 @@ public class Counters {
return str.toString();
}
- private String format(String name, Object value) {
+ private static String format(String name, Object value) {
String header = name + ":";
- return String.format("%-24s%-22s\n", header, value);
+ return String.format("%-24s%-22s%n", header, value);
}
public int getNoOfCollectedFiles() {
@@ -132,21 +132,4 @@ public class Counters {
public int getTotalReceivedEvents() {
return totalReceivedEvents;
}
-
- /**
- * Resets all data.
- */
- public void clear() {
- numberOfTasks.set(0);
- numberOfSubscriptions.set(0);
- noOfCollectedFiles = 0;
- noOfFailedFtpAttempts = 0;
- noOfFailedFtp = 0;
- noOfFailedPublishAttempts = 0;
- totalPublishedFiles = 0;
- noOfFailedPublish = 0;
- lastPublishedTime = Instant.MIN;
- totalReceivedEvents = 0;
- lastEventTime = Instant.MIN;
- }
}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/logging/MappedDiagnosticContext.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/logging/MappedDiagnosticContext.java
index 72d18437..18a30eeb 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/logging/MappedDiagnosticContext.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/logging/MappedDiagnosticContext.java
@@ -50,12 +50,10 @@ public final class MappedDiagnosticContext {
*/
public static void appendTraceInfo(HttpRequestBase httpRequest) {
String requestId = MDC.get(MdcVariables.REQUEST_ID);
- httpRequest.addHeader(MdcVariables.X_ONAP_REQUEST_ID, requestId);
httpRequest.addHeader("X-RequestID", requestId); // deprecated
httpRequest.addHeader("X-TransactionID", requestId); // deprecated
String invocationId = UUID.randomUUID().toString();
- httpRequest.addHeader(MdcVariables.X_INVOCATION_ID, invocationId);
logger.info(INVOKE, "Invoking request with invocation ID {}", invocationId);
}
@@ -65,11 +63,11 @@ public final class MappedDiagnosticContext {
* @param headers a received HTPP header
*/
public static void initializeTraceContext(HttpHeaders headers) {
- String requestId = headers.getFirst(MdcVariables.X_ONAP_REQUEST_ID);
+ String requestId = headers.getFirst(MdcVariables.httpHeader(MdcVariables.REQUEST_ID));
if (StringUtils.isBlank(requestId)) {
requestId = UUID.randomUUID().toString();
}
- String invocationId = headers.getFirst(MdcVariables.X_INVOCATION_ID);
+ String invocationId = headers.getFirst(MdcVariables.httpHeader(MdcVariables.INVOCATION_ID));
if (StringUtils.isBlank(invocationId)) {
invocationId = UUID.randomUUID().toString();
}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DMaaPMessageConsumer.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DMaaPMessageConsumer.java
index 9c33484d..066983ae 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DMaaPMessageConsumer.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DMaaPMessageConsumer.java
@@ -68,8 +68,8 @@ public class DMaaPMessageConsumer {
public Flux<FileReadyMessage> getMessageRouterResponse() {
logger.trace("getMessageRouterResponse called");
try {
- DMaaPConsumerReactiveHttpClient dMaaPConsumerReactiveHttpClient = createHttpClient();
- return consume((dMaaPConsumerReactiveHttpClient.getDMaaPConsumerResponse(Optional.empty())));
+ DMaaPConsumerReactiveHttpClient client = createHttpClient();
+ return consume((client.getDMaaPConsumerResponse(Optional.empty())));
} catch (DatafileTaskException e) {
logger.warn("Unable to get response from message router", e);
return Flux.empty();
@@ -82,7 +82,6 @@ public class DMaaPMessageConsumer {
}
public DMaaPConsumerReactiveHttpClient createHttpClient() throws DatafileTaskException {
-
return httpClientFactory.create(datafileAppConfig.getDmaapConsumerConfiguration().toDmaap());
}
diff --git a/datafile-app-server/src/main/resources/application.properties b/datafile-app-server/src/main/resources/application.properties
deleted file mode 100644
index 2b9d7b1d..00000000
--- a/datafile-app-server/src/main/resources/application.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-spring.profiles.active=prod
-server.port=8433
-server.ssl.key-store-type=PKCS12
-server.ssl.key-store-password=ericssondfc
-server.ssl.key-store=classpath:keystore.jks
-server.ssl.key-password=ericssondfc
-server.ssl.key-alias=tomcat-localhost
-logging.level.root=ERROR
-logging.level.org.springframework=ERROR
-logging.level.org.springframework.data=ERROR
-logging.level.org.onap.dcaegen2.collectors.datafile=INFO
-logging.file=logs/log/application.log
-app.filepath=config/datafile_endpoints.json
diff --git a/datafile-app-server/src/main/resources/scheduled-context.xml b/datafile-app-server/src/main/resources/scheduled-context.xml
deleted file mode 100644
index 21996319..00000000
--- a/datafile-app-server/src/main/resources/scheduled-context.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:task="http://www.springframework.org/schema/task"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
-
- <context:component-scan
- base-package="org.onap.dcaegen2.collectors.datafile" />
- <task:scheduled-tasks>
- <task:scheduled ref="scheduleController"
- method="startTasks" fixed-rate="1000" />
- </task:scheduled-tasks>
-</beans>