diff --git a/Billing/README.md b/Billing/README.md index 6a169d7..306d974 100644 --- a/Billing/README.md +++ b/Billing/README.md @@ -1,6 +1,9 @@ -## Billing micro service +## Billing micro service +[![Reliability Rating](http://kafka.cloudlab.zhaw.ch:9000/api/project_badges/measure?project=ch.icclab.cyclops.billing%3Acyclops-billing&metric=reliability_rating)](http://kafka.cloudlab.zhaw.ch:9000/dashboard?id=ch.icclab.cyclops.billing%3Acyclops-billing) +[![Maintainability Rating](http://kafka.cloudlab.zhaw.ch:9000/api/project_badges/measure?project=ch.icclab.cyclops.billing%3Acyclops-billing&metric=sqale_rating)](http://kafka.cloudlab.zhaw.ch:9000/dashboard?id=ch.icclab.cyclops.billing%3Acyclops-billing) + Billing micro service as part of RCB Cyclops. ### Configuration @@ -10,14 +13,14 @@ For Billing micro service to function properly you will need to edit confi To have the logging system enabled you need to run the following: ./scripts/logging.sh - + Then all Billing micro service logs will be stored in /var/log/cyclops/billing/ directory. ### Run the JAR file In order to run Billing micro service as embedded JAR you need to have Java 8 installed and execute: java -jar bin/billing.jar config/billing.conf [port] - + If you don't want to use the default port from configuration file, you can optionally specify one by adding it as parameter. ### Compile from the source code @@ -25,22 +28,22 @@ If you want to compile the code on your own and your environment already has Jav cd scripts ./compile.sh - + You will find the compiled JAR embedded file in the bin subdirectory. - + ### Documentation You can find the API reference and developer's guide, as well as troubleshooting page in the Wiki section. ### License - + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations - under the License. \ No newline at end of file + under the License. diff --git a/Billing/pom.xml b/Billing/pom.xml index b93f5bd..bac5872 100644 --- a/Billing/pom.xml +++ b/Billing/pom.xml @@ -75,6 +75,11 @@ + + org.sonarsource.scanner.maven + sonar-maven-plugin + 3.6.0.1398 + @@ -256,5 +261,24 @@ okhttp 3.8.1 + + org.sonarsource.scanner.maven + sonar-maven-plugin + 3.6.0.1398 + + + + sonar + + true + + + + + http://kafka.cloudlab.zhaw.ch:9000 + + + + \ No newline at end of file diff --git a/Billing/src/main/java/ch/icclab/cyclops/consume/command/DeleteBills.java b/Billing/src/main/java/ch/icclab/cyclops/consume/command/DeleteBills.java index 82c4314..e26613b 100644 --- a/Billing/src/main/java/ch/icclab/cyclops/consume/command/DeleteBills.java +++ b/Billing/src/main/java/ch/icclab/cyclops/consume/command/DeleteBills.java @@ -44,11 +44,12 @@ public class DeleteBills extends Command{ @Override Status execute() { Status status = new Status(); + DeleteQuery delete = null; try { DbAccess db = new DbAccess(); // select time_from Bill table - DeleteQuery delete = db.createDeleteFrom(Bill.TABLE); + delete = db.createDeleteFrom(Bill.TABLE); // time window selection delete.addConditions(Bill.TIME_FROM_FIELD.ge(inline(new Timestamp(time_from)))); @@ -68,6 +69,9 @@ Status execute() { } catch (Exception e) { CommandLogger.log(e.getMessage()); status.setServerError(e.getMessage()); + } finally{ + assert delete != null; + delete.close(); } return status; diff --git a/CDR/README.md b/CDR/README.md index 0a8e7b3..cff6c10 100644 --- a/CDR/README.md +++ b/CDR/README.md @@ -1,6 +1,9 @@ -## CDR micro service +## CDR micro service +[![Reliability Rating](http://kafka.cloudlab.zhaw.ch:9000/api/project_badges/measure?project=ch.icclab.cyclops.cdr%3Acyclops-cdr&metric=reliability_rating)](http://kafka.cloudlab.zhaw.ch:9000/dashboard?id=ch.icclab.cyclops.cdr%3Acyclops-cdr) +[![Maintainability Rating](http://kafka.cloudlab.zhaw.ch:9000/api/project_badges/measure?project=ch.icclab.cyclops.cdr%3Acyclops-cdr&metric=sqale_rating)](http://kafka.cloudlab.zhaw.ch:9000/dashboard?id=ch.icclab.cyclops.cdr%3Acyclops-cdr) + Charge Data Records micro service as part of RCB Cyclops. ### Configuration @@ -10,14 +13,14 @@ For CDR micro service to function properly you will need to edit config/cd To have the logging system enabled you need to run the following: ./scripts/logging.sh - + Then all cdr micro service logs will be stored in /var/log/cyclops/cdr/ directory. ### Run the JAR file In order to run CDR micro service as embedded JAR you need to have Java 8 installed and execute: java -jar bin/cdr.jar config/cdr.conf [port] - + If you don't want to use the default port from configuration file, you can optionally specify one by adding it as parameter. ### Compile from the source code @@ -25,22 +28,22 @@ If you want to compile the code on your own and your environment already has Jav cd scripts ./compile.sh - + You will find the compiled JAR embedded file in the bin subdirectory. - + ### Documentation You can find the API reference and developer's guide, as well as troubleshooting page in the Wiki section. ### License - + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations - under the License. \ No newline at end of file + under the License. diff --git a/CDR/pom.xml b/CDR/pom.xml index 835e16f..d52768e 100644 --- a/CDR/pom.xml +++ b/CDR/pom.xml @@ -75,6 +75,11 @@ + + org.sonarsource.scanner.maven + sonar-maven-plugin + 3.6.0.1398 + @@ -246,5 +251,29 @@ disruptor ${lmax-version} + + org.sonarsource.scanner.maven + sonar-maven-plugin + 3.6.0.1398 + + + + + + + + + sonar + + true + + + + + http://kafka.cloudlab.zhaw.ch:9000 + + + + \ No newline at end of file diff --git a/CDR/src/main/java/ch/icclab/cyclops/consume/command/DeleteCDRs.java b/CDR/src/main/java/ch/icclab/cyclops/consume/command/DeleteCDRs.java index 1400478..da8cb8a 100644 --- a/CDR/src/main/java/ch/icclab/cyclops/consume/command/DeleteCDRs.java +++ b/CDR/src/main/java/ch/icclab/cyclops/consume/command/DeleteCDRs.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.List; +import static org.jooq.impl.DSL.delete; import static org.jooq.impl.DSL.inline; public class DeleteCDRs extends Command { @@ -43,11 +44,12 @@ public class DeleteCDRs extends Command { @Override Status execute() { Status status = new Status(); + DeleteQuery delete = null; try { DbAccess db = new DbAccess(); // select time_from CDR table - DeleteQuery delete = db.createDeleteFrom(CDR.TABLE); + delete = db.createDeleteFrom(CDR.TABLE); // time window selection delete.addConditions(CDR.TIME_FROM_FIELD.ge(inline(new Timestamp(time_from)))); @@ -67,6 +69,9 @@ Status execute() { } catch (Exception e) { CommandLogger.log(e.getMessage()); status.setServerError(e.getMessage()); + } finally{ + assert delete != null; + delete.close(); } return status; diff --git a/CDR/src/main/java/ch/icclab/cyclops/consume/command/FlushCDRRuns.java b/CDR/src/main/java/ch/icclab/cyclops/consume/command/FlushCDRRuns.java index 6f3a5d1..f13b153 100644 --- a/CDR/src/main/java/ch/icclab/cyclops/consume/command/FlushCDRRuns.java +++ b/CDR/src/main/java/ch/icclab/cyclops/consume/command/FlushCDRRuns.java @@ -90,7 +90,7 @@ public List getAccounts() { @Override Status execute(){ Status status = new Status(); - + SelectQuery select = null; try { // sanity checks first Condition accountCondition = sanityCheckAndWhereAccounts(); @@ -98,7 +98,7 @@ Status execute(){ DbAccess db = new DbAccess(); // select time_from CDR table - SelectQuery select = db.createSelectFrom(CDR.TABLE, inline(run).as("run"), CDR.METRIC_FIELD, CDR.ACCOUNT_FIELD, CDR.TIME_FROM_FIELD, CDR.TIME_TO_FIELD, + select = db.createSelectFrom(CDR.TABLE, inline(run).as("run"), CDR.METRIC_FIELD, CDR.ACCOUNT_FIELD, CDR.TIME_FROM_FIELD, CDR.TIME_TO_FIELD, CDR.CHARGE_FIELD, CDR.CURRENCY_FIELD, CDR.DATA_FIELD); // time window selection @@ -149,6 +149,9 @@ Status execute(){ } catch (Exception e) { CommandLogger.log(e.getMessage()); status.setServerError(e.getMessage()); + } finally { + assert select != null; + select.close(); } return status; diff --git a/CDR/src/main/java/ch/icclab/cyclops/consume/command/FlushCDRs.java b/CDR/src/main/java/ch/icclab/cyclops/consume/command/FlushCDRs.java index 7f94e8c..3b12731 100644 --- a/CDR/src/main/java/ch/icclab/cyclops/consume/command/FlushCDRs.java +++ b/CDR/src/main/java/ch/icclab/cyclops/consume/command/FlushCDRs.java @@ -83,7 +83,7 @@ public List getAccounts() { @Override Status execute(){ Status status = new Status(); - + SelectQuery select = null; try { // sanity checks first Condition accountCondition = sanityCheckAndWhereAccounts(); @@ -91,7 +91,7 @@ Status execute(){ DbAccess db = new DbAccess(); // select time_from CDR table - SelectQuery select = db.createSelectFrom(CDR.TABLE, CDR.METRIC_FIELD, CDR.ACCOUNT_FIELD, CDR.TIME_FROM_FIELD, CDR.TIME_TO_FIELD, + select = db.createSelectFrom(CDR.TABLE, CDR.METRIC_FIELD, CDR.ACCOUNT_FIELD, CDR.TIME_FROM_FIELD, CDR.TIME_TO_FIELD, CDR.CHARGE_FIELD, CDR.CURRENCY_FIELD, CDR.DATA_FIELD); // time window selection @@ -142,6 +142,9 @@ Status execute(){ } catch (Exception e) { CommandLogger.log(e.getMessage()); status.setServerError(e.getMessage()); + } finally{ + assert select != null; + select.close(); } return status; diff --git a/Coin/README.md b/Coin/README.md index b4363c6..8b4ff1e 100644 --- a/Coin/README.md +++ b/Coin/README.md @@ -1,6 +1,9 @@ ## Rule engine micro service +[![Reliability Rating](http://kafka.cloudlab.zhaw.ch:9000/api/project_badges/measure?project=ch.icclab.cyclops.coin%3Acyclops-coin&metric=reliability_rating)](http://kafka.cloudlab.zhaw.ch:9000/dashboard?id=ch.icclab.cyclops.coin%3Acyclops-coin) +[![Reliability Rating](http://kafka.cloudlab.zhaw.ch:9000/api/project_badges/measure?project=ch.icclab.cyclops.coin%3Acyclops-coin&metric=reliability_rating)](http://kafka.cloudlab.zhaw.ch:9000/dashboard?id=ch.icclab.cyclops.coin%3Acyclops-coin) + This micro service (aka Coin) is a generic business rule system that is internally utilising Drools, an inference engine, for its rule execution. The micro service itself exposes template instantiation, as well as truth maintenance over RESTful APIs, and therefore allow developers to write their own business rules and provide graphical user interfaces for people from sales to work with. The most prominent features: @@ -21,21 +24,21 @@ The most prominent features: - Stream processing - Alarm notifications - Batch processing - - Easy debugging + - Easy debugging - State recovery ### Logging To have the logging system enabled you need to run the following: ./scripts/logging.sh - + Then all Rule engine service logs will be stored in /var/log/cyclops/coin/ directory. ### Run the JAR file In order to run Rule ngine micro service as embedded JAR you need to have Java 8 installed and execute: java -jar bin/coin.jar config/coin.conf [port] - + If you don't want to use the default port from configuration file, you can optionally specify one by adding it as parameter. ### Compile from the source code @@ -43,7 +46,7 @@ If you want to compile the code on your own and your environment already has Jav cd scripts ./compile.sh - + You will find the compiled JAR embedded file in the bin subdirectory. ### Scripting @@ -62,15 +65,15 @@ If you decide to automate deployment of the Rule engine micro service, please no For API reference guide, as well as documentation please consult documentation folder. ### License - + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations - under the License. \ No newline at end of file + under the License. diff --git a/Coin/pom.xml b/Coin/pom.xml index 9d6bdf5..a24fb79 100644 --- a/Coin/pom.xml +++ b/Coin/pom.xml @@ -92,6 +92,11 @@ + + org.sonarsource.scanner.maven + sonar-maven-plugin + 3.6.0.1398 + @@ -315,10 +320,29 @@ gitlab4j-api 4.8.45 + + org.sonarsource.scanner.maven + sonar-maven-plugin + 3.6.0.1398 + + + + sonar + + true + + + + + http://kafka.cloudlab.zhaw.ch:9000 + + + + diff --git a/UDR/README.md b/UDR/README.md index c67699c..4af5958 100644 --- a/UDR/README.md +++ b/UDR/README.md @@ -1,6 +1,9 @@ -## UDR micro service +## UDR micro service +[![Reliability Rating](http://kafka.cloudlab.zhaw.ch:9000/api/project_badges/measure?project=ch.icclab.cyclops.udr%3Acyclops-udr&metric=reliability_rating)](http://kafka.cloudlab.zhaw.ch:9000/dashboard?id=ch.icclab.cyclops.udr%3Acyclops-udr) +[![Maintainability Rating](http://kafka.cloudlab.zhaw.ch:9000/api/project_badges/measure?project=ch.icclab.cyclops.udr%3Acyclops-udr&metric=sqale_rating)](http://kafka.cloudlab.zhaw.ch:9000/dashboard?id=ch.icclab.cyclops.udr%3Acyclops-udr) + Usage Data Records micro service as part of RCB Cyclops. ### Configuration @@ -10,14 +13,14 @@ For UDR micro service to function properly you will need to edit config/ud To have the logging system enabled you need to run the following: ./scripts/logging.sh - + Then all UDR micro service logs will be stored in /var/log/cyclops/udr/ directory. ### Run the JAR file In order to run UDR micro service as embedded JAR you need to have Java 8 installed and execute: java -jar bin/udr.jar config/udr.conf [port] - + If you don't want to use the default port from configuration file, you can optionally specify one by adding it as parameter. ### Compile from the source code @@ -25,22 +28,22 @@ If you want to compile the code on your own and your environment already has Jav cd scripts ./compile.sh - + You will find the compiled JAR embedded file in the bin subdirectory. - + ### Documentation You can find the API reference and developer's guide, as well as troubleshooting page in the Wiki section. ### License - + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations - under the License. \ No newline at end of file + under the License. diff --git a/UDR/pom.xml b/UDR/pom.xml index 6b1e43f..68b47ac 100644 --- a/UDR/pom.xml +++ b/UDR/pom.xml @@ -76,6 +76,11 @@ + + org.sonarsource.scanner.maven + sonar-maven-plugin + 3.6.0.1398 + @@ -252,5 +257,24 @@ timeseries-forecast ${timeseries-forecast-version} + + org.sonarsource.scanner.maven + sonar-maven-plugin + 3.6.0.1398 + + + + sonar + + true + + + + + http://kafka.cloudlab.zhaw.ch:9000 + + + + \ No newline at end of file diff --git a/UDR/src/main/java/ch/icclab/cyclops/consume/command/Forecast.java b/UDR/src/main/java/ch/icclab/cyclops/consume/command/Forecast.java index 5bc06ab..d547cc1 100644 --- a/UDR/src/main/java/ch/icclab/cyclops/consume/command/Forecast.java +++ b/UDR/src/main/java/ch/icclab/cyclops/consume/command/Forecast.java @@ -95,10 +95,11 @@ public static Status compute(String user, String model, long length){ Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); + Thread.currentThread().interrupt(); } //Generate Bill estimates - GenerateBill generateBill = new GenerateBill(time_from, time_to, user + "-arima-" + model); + GenerateBill generateBill = new GenerateBill(time_from, time_to, user + "-forecast-" + model); Messenger.publish(generateBill, "Billing"); status.setSuccessful("Forecast estimation for account " + user + " complete"); } @@ -148,7 +149,7 @@ private static int generateForecastFromUsage(List usages, int num, String DbAccess dbn = new DbAccess(); InsertQuery insert = dbn.createInsertInto(Usage.TABLE); insert.addValue(Usage.DATA_FIELD, String.format("{\"target\":\"%s\"}", model)); - insert.addValue(Usage.ACCOUNT_FIELD, user + "-arima-" + model); + insert.addValue(Usage.ACCOUNT_FIELD, user + "-forecast-" + model); insert.addValue(Usage.METRIC_FIELD, metric); insert.addValue(Usage.TIME_FIELD, System.currentTimeMillis() + k * 3600000); insert.addValue(Usage.USAGE_FIELD, entry); diff --git a/UDR/src/main/java/ch/icclab/cyclops/consume/command/GenerateMaxUDRs.java b/UDR/src/main/java/ch/icclab/cyclops/consume/command/GenerateMaxUDRs.java index 85ab051..30eb069 100644 --- a/UDR/src/main/java/ch/icclab/cyclops/consume/command/GenerateMaxUDRs.java +++ b/UDR/src/main/java/ch/icclab/cyclops/consume/command/GenerateMaxUDRs.java @@ -64,44 +64,55 @@ Status execute() { } DbAccess db = new DbAccess(); - - // create INSERT INTO statement - InsertQuery insert = db.createInsertInto(UDR.TABLE); - - // prepare fields - Field[] fields = {UDR.METRIC_FIELD, UDR.ACCOUNT_FIELD, UDR.USAGE_FIELD, - UDR.TIME_FROM_FIELD, UDR.TIME_TO_FIELD, UDR.UNIT_FIELD, UDR.DATA_FIELD}; - - // prepare select command - SelectQuery select = db.createSelectFrom(Usage.TABLE, Usage.METRIC_FIELD, Usage.ACCOUNT_FIELD, Usage.USAGE_FIELD, - inline(new Timestamp(time_from)), inline(new Timestamp(time_to)), Usage.UNIT_FIELD, Usage.DATA_FIELD); - - // add where predicate for TIME and WHERE METRICS - select.addConditions(Usage.TIME_FIELD.between(inline(new Timestamp(time_from)), inline(new Timestamp(time_to)))); - select.addConditions(onlySelectTheseMetrics(metrics)); - - // aggregate based on group by - select.addGroupBy(Usage.METRIC_FIELD, Usage.ACCOUNT_FIELD, Usage.USAGE_FIELD, Usage.UNIT_FIELD, Usage.DATA_FIELD); - - // modify insert command with list of fields and select statement - insert.setSelect(fields, select); - - // execute the insert - int ret = db.executeInsertStatement(insert); - - String message; - - // and handle the status - if (ret < 0) { - message = "Problem with the database access, could not generate UDRs"; - status.setServerError(message); - } else { - message = String.format("%d UDRs generated for period %s and %s", ret, new Timestamp(time_from), new Timestamp(time_to)); - status.setSuccessful(message); + InsertQuery insert = null; + SelectQuery select = null; + try { + // create INSERT INTO statement + insert = db.createInsertInto(UDR.TABLE); + + // prepare fields + Field[] fields = {UDR.METRIC_FIELD, UDR.ACCOUNT_FIELD, UDR.USAGE_FIELD, + UDR.TIME_FROM_FIELD, UDR.TIME_TO_FIELD, UDR.UNIT_FIELD, UDR.DATA_FIELD}; + + // prepare select command + select = db.createSelectFrom(Usage.TABLE, Usage.METRIC_FIELD, Usage.ACCOUNT_FIELD, Usage.USAGE_FIELD, + inline(new Timestamp(time_from)), inline(new Timestamp(time_to)), Usage.UNIT_FIELD, Usage.DATA_FIELD); + + // add where predicate for TIME and WHERE METRICS + select.addConditions(Usage.TIME_FIELD.between(inline(new Timestamp(time_from)), inline(new Timestamp(time_to)))); + select.addConditions(onlySelectTheseMetrics(metrics)); + + // aggregate based on group by + select.addGroupBy(Usage.METRIC_FIELD, Usage.ACCOUNT_FIELD, Usage.USAGE_FIELD, Usage.UNIT_FIELD, Usage.DATA_FIELD); + + // modify insert command with list of fields and select statement + insert.setSelect(fields, select); + + // execute the insert + int ret = db.executeInsertStatement(insert); + + String message; + + // and handle the status + if (ret < 0) { + message = "Problem with the database access, could not generate UDRs"; + status.setServerError(message); + } else { + message = String.format("%d UDRs generated for period %s and %s", ret, new Timestamp(time_from), new Timestamp(time_to)); + status.setSuccessful(message); + } + + CommandLogger.log(message); + } catch (Exception e) { + CommandLogger.log(e.getMessage()); + status.setClientError(e.getMessage()); + } finally{ + assert insert != null; + insert.close(); + assert select != null; + select.close(); } - CommandLogger.log(message); - return status; } diff --git a/forecast_dashboard/dashboard/src/pages/Forecasting.vue b/forecast_dashboard/dashboard/src/pages/Forecasting.vue index b1d50fc..567a50a 100644 --- a/forecast_dashboard/dashboard/src/pages/Forecasting.vue +++ b/forecast_dashboard/dashboard/src/pages/Forecasting.vue @@ -237,12 +237,12 @@ methods:{ for (var i=0; i