This is an automated email from the ASF dual-hosted git repository. ofuks pushed a commit to branch DLAB-1571 in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/DLAB-1571 by this push: new 435d3a1 Remote billing 435d3a1 is described below commit 435d3a1867cf0a7a5f5ae5aff3d7e481783293b6 Author: Oleh Fuks <olegfuk...@gmail.com> AuthorDate: Fri Mar 27 18:35:36 2020 +0200 Remote billing --- services/billing-aws/billing.yml | 1 + .../java/com/epam/dlab/mongo/AdapterMongoDb.java | 23 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/services/billing-aws/billing.yml b/services/billing-aws/billing.yml index 510411f..e90978c 100644 --- a/services/billing-aws/billing.yml +++ b/services/billing-aws/billing.yml @@ -57,6 +57,7 @@ adapterOut: database: dlabdb # bufferSize: 10000 upsert: true + serviceBaseName: <CONF_SERVICE_BASE_NAME> # Filter for source and converted data. filter: diff --git a/services/billing-aws/src/main/java/com/epam/dlab/mongo/AdapterMongoDb.java b/services/billing-aws/src/main/java/com/epam/dlab/mongo/AdapterMongoDb.java index e0af4e6..994522d 100644 --- a/services/billing-aws/src/main/java/com/epam/dlab/mongo/AdapterMongoDb.java +++ b/services/billing-aws/src/main/java/com/epam/dlab/mongo/AdapterMongoDb.java @@ -31,12 +31,17 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeName; import com.google.common.base.MoreObjects.ToStringHelper; import com.mongodb.client.MongoCollection; +import com.mongodb.client.model.UpdateOptions; import org.bson.Document; import java.util.ArrayList; import java.util.List; import java.util.TreeSet; +import static com.epam.dlab.mongo.MongoConstants.COLLECTION_SETTINGS; +import static com.epam.dlab.mongo.MongoConstants.FIELD_SERIVICE_BASE_NAME; +import static com.mongodb.client.model.Filters.eq; + /** * The adapter for file system. */ @@ -67,6 +72,17 @@ public class AdapterMongoDb extends DBAdapterBase { @JsonProperty private boolean upsert = false; + @JsonProperty + private String serviceBaseName; + + public String getServiceBaseName() { + return serviceBaseName; + } + + public void setServiceBaseName(String serviceBaseName) { + this.serviceBaseName = serviceBaseName; + } + /** * Return the size of buffer for bulk insert. */ @@ -142,6 +158,7 @@ public class AdapterMongoDb extends DBAdapterBase { throw new AdapterException("Mode of " + getType() + " adapter may be " + Mode.WRITE + " only."); } connection = new MongoDbConnection(getHost(), getPort(), getDatabase(), getUsername(), getPassword()); + setServiceBaseName(); collection = connection.getCollection(MongoConstants.COLLECTION_BILLING); try { resourceTypeDAO = new DlabResourceTypeDAO(connection); @@ -158,6 +175,12 @@ public class AdapterMongoDb extends DBAdapterBase { } } + private void setServiceBaseName() { + connection.getCollection(COLLECTION_SETTINGS) + .updateOne(eq("_id", FIELD_SERIVICE_BASE_NAME), new Document("$set", new Document("value", serviceBaseName)), + new UpdateOptions().upsert(true)); + } + @Override public void close() throws AdapterException { if (connection != null) { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@dlab.apache.org For additional commands, e-mail: commits-h...@dlab.apache.org