summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuobiao Mo <guobiaomo@chinamobile.com>2019-04-14 19:44:20 -0700
committerGuobiao Mo <guobiaomo@chinamobile.com>2019-04-14 19:44:20 -0700
commitdda9f177f0d04073d4b5a13753fdd4b652443df1 (patch)
tree3b1e6abd907f5e355fb6a0648d650e113d4823ff
parent115e9b9ca1a4fdbdeba84bbb6f83ebf69ea5b08d (diff)
Introduce global SSL flag
Issue-ID: DCAEGEN2-1411 Change-Id: Ic7723aeb2c5aa9012d969432c3cc3846a49f728f Signed-off-by: Guobiao Mo <guobiaomo@chinamobile.com>
-rw-r--r--components/datalake-handler/feeder/src/assembly/scripts/init_db.sql7
-rw-r--r--components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/config/ApplicationConfiguration.java1
-rw-r--r--components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/MongodbService.java21
-rw-r--r--components/datalake-handler/feeder/src/main/resources/application.properties7
-rw-r--r--components/datalake-handler/pom.xml2
5 files changed, 27 insertions, 11 deletions
diff --git a/components/datalake-handler/feeder/src/assembly/scripts/init_db.sql b/components/datalake-handler/feeder/src/assembly/scripts/init_db.sql
index 48cb5f9b..32b9268c 100644
--- a/components/datalake-handler/feeder/src/assembly/scripts/init_db.sql
+++ b/components/datalake-handler/feeder/src/assembly/scripts/init_db.sql
@@ -43,9 +43,9 @@ CREATE TABLE `map_db_topic` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-insert into db (name,host,login,pass,database) values ('Couchbase','dl_couchbase','dl','dl1234','datalake');
+insert into db (name,host,login,pass,`database`) values ('Couchbase','dl_couchbase','dl','dl1234','datalake');
insert into db (name,host) values ('Elasticsearch','dl_es');
-insert into db (name,host,port,database) values ('MongoDB','dl_mongodb',27017,'datalake');
+insert into db (name,host,port,`database`) values ('MongoDB','dl_mongodb',27017,'datalake');
insert into db (name,host) values ('Druid','dl_druid');
@@ -54,4 +54,7 @@ insert into `topic`(`name`,`enabled`,`save_raw`,`ttl`,`data_format`) values ('_D
insert into `topic`(`name`,`enabled`) values ('__consumer_offsets',0);
+insert into `map_db_topic`(`db_name`,`topic_name`) values ('Couchbase','_DL_DEFAULT_');
+insert into `map_db_topic`(`db_name`,`topic_name`) values ('Elasticsearch','_DL_DEFAULT_');
insert into `map_db_topic`(`db_name`,`topic_name`) values ('MongoDB','_DL_DEFAULT_');
+insert into `map_db_topic`(`db_name`,`topic_name`) values ('Druid','_DL_DEFAULT_');
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/config/ApplicationConfiguration.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/config/ApplicationConfiguration.java
index 1136e304..6bacf136 100644
--- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/config/ApplicationConfiguration.java
+++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/config/ApplicationConfiguration.java
@@ -51,5 +51,6 @@ public class ApplicationConfiguration {
private int kafkaConsumerCount;
private boolean async;
+ private boolean enableSSL;
}
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/MongodbService.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/MongodbService.java
index 9008fc9a..35426afb 100644
--- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/MongodbService.java
+++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/MongodbService.java
@@ -32,7 +32,7 @@ import org.apache.commons.lang3.StringUtils;
import org.bson.Document;
import org.json.JSONObject;
-
+import org.onap.datalake.feeder.config.ApplicationConfiguration;
import org.onap.datalake.feeder.domain.Db;
import org.onap.datalake.feeder.domain.Topic;
import org.slf4j.Logger;
@@ -50,7 +50,7 @@ import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
/**
- * Service to use MongoDB
+ * Service for using MongoDB
*
* @author Guobiao Mo
*
@@ -61,6 +61,9 @@ public class MongodbService {
private final Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
+ private ApplicationConfiguration config;
+
+ @Autowired
private DbService dbService;
private MongoDatabase database;
@@ -89,13 +92,19 @@ public class MongodbService {
Builder builder = MongoClientOptions.builder();
builder.serverSelectionTimeout(30000);//server selection timeout, in milliseconds
-
+
//http://mongodb.github.io/mongo-java-driver/3.0/driver/reference/connecting/ssl/
- builder.sslEnabled(Boolean.TRUE.equals(mongodb.getEncrypt()));// getEncrypt() can be null
+ if (config.isEnableSSL()) {
+ builder.sslEnabled(Boolean.TRUE.equals(mongodb.getEncrypt()));// getEncrypt() can be null
+ }
MongoClientOptions options = builder.build();
- mongoClient = new MongoClient(new ServerAddress(host, port), credential, options);
- database = mongoClient.getDatabase(mongodb.getDatabase());
+ if (credential == null) {
+ mongoClient = new MongoClient(new ServerAddress(host, port), options);
+ } else {
+ mongoClient = new MongoClient(new ServerAddress(host, port), credential, options);
+ }
+ database = mongoClient.getDatabase(databaseName);
}
@PreDestroy
diff --git a/components/datalake-handler/feeder/src/main/resources/application.properties b/components/datalake-handler/feeder/src/main/resources/application.properties
index ea94d004..42b13459 100644
--- a/components/datalake-handler/feeder/src/main/resources/application.properties
+++ b/components/datalake-handler/feeder/src/main/resources/application.properties
@@ -9,8 +9,8 @@ spring.jpa.show-sql=false
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mariadb://dl_mariadb:3306/datalake?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=UTF-8
-spring.datasource.username=nook
-spring.datasource.password=nook123
+spring.datasource.username=dl
+spring.datasource.password=dl1234
#For Beijing lab
@@ -35,6 +35,9 @@ kafkaConsumerCount=1
#tolerate inconsistency when system crash, see PullThread.run()
async=true
+#SSL global flag, if enabled, still need to check each individual DB SSL flag
+enableSSL=false
+
#Logging
logging.level.org.springframework.web=ERROR
logging.level.com.att.nsa.apiClient.http=ERROR
diff --git a/components/datalake-handler/pom.xml b/components/datalake-handler/pom.xml
index 45db09db..ee53ab3d 100644
--- a/components/datalake-handler/pom.xml
+++ b/components/datalake-handler/pom.xml
@@ -31,7 +31,7 @@
<springcouchbase.version>3.1.2.RELEASE</springcouchbase.version>
<jackson.version>2.9.6</jackson.version>
<kafka.version>2.0.0</kafka.version>
- <elasticsearchjava.version>7.0.0-rc2</elasticsearchjava.version>
+ <elasticsearchjava.version>7.0.0</elasticsearchjava.version>
</properties>