diff options
author | Yan Yang <yangyanyj@chinamobile.com> | 2019-04-15 02:56:59 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-04-15 02:56:59 +0000 |
commit | f9b8345c99bdf176aa438e555f7f29003027b297 (patch) | |
tree | 01b17a83a8481f631604d8e071905c30cd2116dc /components | |
parent | a78b0157c60d8c03b87ca996a2d262f0e662487b (diff) | |
parent | dda9f177f0d04073d4b5a13753fdd4b652443df1 (diff) |
Merge "Introduce global SSL flag"
Diffstat (limited to 'components')
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&useUnicode=true&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> |