Commit d9fe6359 authored by neop's avatar neop
Browse files

integrate influxdb client

parent 2294427d
......@@ -13,6 +13,7 @@ dependencies {
implementation 'org.neo4j.driver:neo4j-java-driver:4.3.5'
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'com.squareup.okhttp3:okhttp:4.9.2'
implementation 'com.influxdb:influxdb-client-java:3.4.0'
}
compileJava {
......
package sensor2graph;
import com.influxdb.client.*;
import org.neo4j.driver.*;
import org.neo4j.driver.Config.*;
......@@ -31,6 +33,8 @@ public class Main {
public static int process_timeout_minutes;
private static String http_agent;
private static String neo4j_uri;
private static String influxdb_uri;
private static String influxdb_database_name;
private static File neo4j_server_certificate_file;
private static String archive_uri;
private static String sensor_type_info;
......@@ -41,6 +45,7 @@ public class Main {
// }
public static Driver driver;
public static InfluxDBClient influxDBClient;
public static String handle_registry_session_id;
public static java.util.logging.Logger glogger;
private static java.util.logging.Logger logger;
......@@ -49,7 +54,7 @@ public class Main {
logger = java.util.logging.Logger.getLogger(Main.class.getName());
}
private static void initialize_driver() {
private static void initialize_neo4j_driver() {
driver = GraphDatabase.driver(
neo4j_uri,
AuthTokens.basic(System.getenv("SENSOR2GRAPH_GRAPHDB_USER"), System.getenv("SENSOR2GRAPH_GRAPHDB_PASS")),
......@@ -67,6 +72,16 @@ public class Main {
);
}
private static void initialize_influxdb_driver() {
influxDBClient = InfluxDBClientFactory.createV1(
Main.influxdb_uri,
System.getenv("SENSOR2GRAPH_INFLUXDB_USER"),
System.getenv("SENSOR2GRAPH_INFLUXDB_PASS").toCharArray(),
influxdb_database_name,
null
);
}
private static Set<String> parse_line_separated_values_file(String fname) throws Exception {
File file = new File(fname);
if (file.createNewFile()) {
......@@ -80,13 +95,12 @@ public class Main {
}
}
private static void run() throws Exception {
try_uploading_failed_sensors();
upload_all_days();
try_uploading_failed_sensors();
}
// try_uploading_failed_sensors();
// upload_all_days();
// try_uploading_failed_sensors();
}
private static void try_uploading_failed_sensors() throws Exception {
Main.logger.info("Trying again to upload failed csv files in case of transient errors");
......@@ -166,8 +180,10 @@ public class Main {
System.setProperty("http.agent", http_agent);
Main.logger.fine("initializing neo4j driver.");
initialize_driver();
initialize_neo4j_driver();
Main.logger.fine("initializing influxdb driver.");
initialize_influxdb_driver();
try {
......@@ -204,6 +220,8 @@ public class Main {
pid_reg_server_cert = config.getProperty("pid_reg_server_cert" );
pid_reg_keystore = config.getProperty("pid_reg_keystore" );
process_timeout_minutes = Integer.parseInt(config.getProperty("process_timeout_minutes" ));
influxdb_uri = config.getProperty("influxdb_uri" );
influxdb_database_name = config.getProperty("influxdb_database_name" );
}
......@@ -232,6 +250,9 @@ public class Main {
defaults.setProperty("pid_reg_server_cert", "pid_reg_server_cert.pem" );
defaults.setProperty("pid_reg_keystore", "pid_reg_keystore.p12" );
defaults.setProperty("process_timeout_minutes", "60" );
defaults.setProperty("influxdb_uri", "https://metrics.gwdg.de:8086" );
defaults.setProperty("influxdb_database_name", "openforecast" );
return defaults;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment