You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by fj...@apache.org on 2020/09/22 10:34:58 UTC
[incubator-streampipes] branch datalake-rest-extension updated:
Change/View Retention Policies
This is an automated email from the ASF dual-hosted git repository.
fjohn pushed a commit to branch datalake-rest-extension
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
The following commit(s) were added to refs/heads/datalake-rest-extension by this push:
new 7f31d20 Change/View Retention Policies
7f31d20 is described below
commit 7f31d208a13fc6ea0af01529438a028baf8c5175
Author: Felix John <jo...@axantu.com>
AuthorDate: Tue Sep 22 12:34:43 2020 +0200
Change/View Retention Policies
---
.../rest/impl/datalake/DataLakeManagementV3.java | 40 ++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeManagementV3.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeManagementV3.java
index dece402..f58b638 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeManagementV3.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeManagementV3.java
@@ -229,6 +229,46 @@ public class DataLakeManagementV3 {
return new PageResult(dataResult.getTotal(), dataResult.getHeaders(), dataResult.getRows(), page, pageSum);
}
+ public DataResult getRetentionPoliciesOfDatabase() {
+ InfluxDB influxDB = getInfluxDBClient();
+ Query query = new Query("SHOW RETENTION POLICIES ON sp");
+ QueryResult influx_result = influxDB.query(query);
+ DataResult dataResult = convertResult(influx_result);
+ influxDB.close();
+ return dataResult;
+ }
+
+
+ public void alterRetentionPolicy(String policyName, String duration, String shardDuration, int replication, boolean defaultPolicy) {
+ InfluxDB influxDB = getInfluxDBClient();
+
+ String defaultPolicyString = "";
+ if (defaultPolicy)
+ defaultPolicyString = " DEFAULT";
+
+ Query query = new Query("ALTER RETENTION POLICY "
+ + policyName
+ + " ON sp DURATION "
+ + duration
+ + " REPLICATION "
+ + replication
+ + " SHARD DURATION "
+ + shardDuration
+ + defaultPolicyString,
+ BackendConfig.INSTANCE.getInfluxDatabaseName());
+
+ QueryResult influx_result = influxDB.query(query);
+ if (influx_result.hasError() || influx_result.getResults().get(0).getError() != null) {
+ System.out.println("Error!");
+ }
+ }
+
+ public static void main(String [] args) {
+ DataLakeManagementV3 dlmv3 = new DataLakeManagementV3();
+ DataResult result = dlmv3.getRetentionPoliciesOfDatabase();
+ dlmv3.alterRetentionPolicy("rp2", "1h", "1h", 3, Boolean.FALSE);
+ }
+
public void deleteMeasurement(String index) {
InfluxDB influxDB = getInfluxDBClient();