From a49009302e30f2a28fe4109dc0d0a480b0e018de Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 16 Apr 2024 14:36:48 +0200 Subject: [PATCH] upgrade ngsi-ld sinks --- .../iot/cygnus/sinks/NGSIPostgisSink.java | 14 +++++++------- .../iot/cygnus/sinks/NGSIPostgreSQLSink.java | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cygnus-ngsi-ld/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIPostgisSink.java b/cygnus-ngsi-ld/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIPostgisSink.java index d5fa24066..f866bb954 100644 --- a/cygnus-ngsi-ld/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIPostgisSink.java +++ b/cygnus-ngsi-ld/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIPostgisSink.java @@ -59,7 +59,7 @@ public class NGSIPostgisSink extends NGSILDSink { private static final int DEFAULT_MAX_POOL_SIZE = 3; private static final int DEFAULT_MAX_POOL_IDLE = 2; private static final int DEFAULT_MIN_POOL_IDLE = 0; - private static final int DEFAULT_MAX_POOL_WAIT = 10000; + private static final int DEFAULT_MIN_POOL_IDLE_TIME_MILLIS = 10000; private static final String DEFAULT_POSTGIS_TYPE = "geometry"; private static final String DEFAULT_ATTR_NATIVE_TYPES = "false"; private static final String POSTGIS_DRIVER_NAME = "org.postgresql.Driver"; @@ -75,7 +75,7 @@ public class NGSIPostgisSink extends NGSILDSink { private int maxPoolSize; private int maxPoolIdle; private int minPoolIdle; - private int maxPoolWait; + private int minPoolIdleTimeMillis; private SQLBackendImpl postgisPersistenceBackend; private boolean enableCache; private boolean swapCoordinates; @@ -218,8 +218,8 @@ public void configure(Context context) { minPoolIdle = context.getInteger("postgis_minPoolIdle", DEFAULT_MIN_POOL_IDLE); LOGGER.debug("[" + this.getName() + "] Reading configuration (postgis_minPoolIdle=" + minPoolIdle + ")"); - maxPoolWait = context.getInteger("postgis_maxPoolWait", DEFAULT_MAX_POOL_WAIT); - LOGGER.debug("[" + this.getName() + "] Reading configuration (postgis_maxPoolWait=" + maxPoolWait + ")"); + minPoolIdleTimeMillis = context.getInteger("postgis_minPoolIdleTimeMillis", DEFAULT_MIN_POOL_IDLE_TIME_MILLIS); + LOGGER.debug("[" + this.getName() + "] Reading configuration (postgis_minPoolIdleTimeMillis=" + minPoolIdleTimeMillis + ")"); rowAttrPersistence = context.getString("attr_persistence", DEFAULT_ROW_ATTR_PERSISTENCE).equals("row"); String persistence = context.getString("attr_persistence", DEFAULT_ROW_ATTR_PERSISTENCE); @@ -284,7 +284,7 @@ public void stop() { @Override public void start() { try { - createPersistenceBackend(postgisHost, postgisPort, postgisUsername, postgisPassword, maxPoolSize, maxPoolIdle, minPoolIdle, maxPoolWait, postgisOptions); + createPersistenceBackend(postgisHost, postgisPort, postgisUsername, postgisPassword, maxPoolSize, maxPoolIdle, minPoolIdle, minPoolIdleTimeMillis, postgisOptions); } catch (Exception e) { LOGGER.error("Error while creating the Postgis persistence backend. Details=" + e.getMessage()); @@ -297,9 +297,9 @@ public void start() { /** * Initialices a lazy singleton to share among instances on JVM */ - private void createPersistenceBackend(String sqlHost, String sqlPort, String sqlUsername, String sqlPassword, int maxPoolSize, int maxPoolIdle, int minPoolIdle, int maxPoolWait, String sqlOptions) { + private void createPersistenceBackend(String sqlHost, String sqlPort, String sqlUsername, String sqlPassword, int maxPoolSize, int maxPoolIdle, int minPoolIdle, int minPoolIdleTimeMillis, String sqlOptions) { if (postgisPersistenceBackend == null) { - postgisPersistenceBackend = new SQLBackendImpl(sqlHost, sqlPort, sqlUsername, sqlPassword, maxPoolSize, maxPoolIdle, minPoolIdle, maxPoolWait, POSTGIS_INSTANCE_NAME, POSTGIS_DRIVER_NAME, sqlOptions); + postgisPersistenceBackend = new SQLBackendImpl(sqlHost, sqlPort, sqlUsername, sqlPassword, maxPoolSize, maxPoolIdle, minPoolIdle, minPoolIdleTimeMillis, POSTGIS_INSTANCE_NAME, POSTGIS_DRIVER_NAME, sqlOptions); } } diff --git a/cygnus-ngsi-ld/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIPostgreSQLSink.java b/cygnus-ngsi-ld/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIPostgreSQLSink.java index b5be024d5..f210cb091 100644 --- a/cygnus-ngsi-ld/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIPostgreSQLSink.java +++ b/cygnus-ngsi-ld/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIPostgreSQLSink.java @@ -50,7 +50,7 @@ public class NGSIPostgreSQLSink extends NGSILDSink { private static final int DEFAULT_MAX_POOL_SIZE = 3; private static final int DEFAULT_MAX_POOL_IDLE = 2; private static final int DEFAULT_MIN_POOL_IDLE = 0; - private static final int DEFAULT_MAX_POOL_WAIT = 10000; + private static final int DEFAULT_MIN_POOL_IDLE_TIME_MILLIS = 10000; private static final String POSTGRESQL_DRIVER_NAME = "org.postgresql.Driver"; private static final SQLInstance POSTGRESQL_INSTANCE_NAME = SQLInstance.POSTGRESQL; @@ -63,7 +63,7 @@ public class NGSIPostgreSQLSink extends NGSILDSink { private int maxPoolSize; private int maxPoolIdle; private int minPoolIdle; - private int maxPoolWait; + private int minPoolIdleTimeMillis; private boolean rowAttrPersistence; private SQLBackendImpl postgreSQLPersistenceBackend; private boolean enableCache; @@ -196,8 +196,8 @@ public void configure(Context context) { minPoolIdle = context.getInteger("postgresql_minPoolIdle", DEFAULT_MIN_POOL_IDLE); LOGGER.debug("[" + this.getName() + "] Reading configuration (postgresql_minPoolIdle=" + minPoolIdle + ")"); - maxPoolWait = context.getInteger("postgresql_maxPoolWait", DEFAULT_MAX_POOL_WAIT); - LOGGER.debug("[" + this.getName() + "] Reading configuration (postgresql_maxPoolWait=" + maxPoolWait + ")"); + minPoolIdleTimeMillis = context.getInteger("postgresql_minPoolIdleTimeMillis", DEFAULT_MAX_POOL_WAIT); + LOGGER.debug("[" + this.getName() + "] Reading configuration (postgresql_minPoolIdleTimeMillis=" + minPoolIdleTimeMillis + ")"); rowAttrPersistence = context.getString("attr_persistence", DEFAULT_ROW_ATTR_PERSISTENCE).equals("row"); String persistence = context.getString("attr_persistence", DEFAULT_ROW_ATTR_PERSISTENCE); @@ -228,7 +228,7 @@ public void configure(Context context) { @Override public void start() { try { - createPersistenceBackend(postgresqlHost, postgresqlPort, postgresqlUsername, postgresqlPassword, maxPoolSize, maxPoolIdle, minPoolIdle, maxPoolWait, postgresqlOptions); + createPersistenceBackend(postgresqlHost, postgresqlPort, postgresqlUsername, postgresqlPassword, maxPoolSize, maxPoolIdle, minPoolIdle, minPoolIdleTimeMillis, postgresqlOptions); } catch (Exception e) { LOGGER.error("Error while creating the PostgreSQL persistence backend. Details=" + e.getMessage()); @@ -241,9 +241,9 @@ public void start() { /** * Initialices a lazy singleton to share among instances on JVM */ - private void createPersistenceBackend(String sqlHost, String sqlPort, String sqlUsername, String sqlPassword, int maxPoolSize, int maxPoolIdle, int minPoolIdle, int maxPoolWait, String sqlOptions) { + private void createPersistenceBackend(String sqlHost, String sqlPort, String sqlUsername, String sqlPassword, int maxPoolSize, int maxPoolIdle, int minPoolIdle, int minPoolIdleTimeMillis, String sqlOptions) { if (postgreSQLPersistenceBackend == null) { - postgreSQLPersistenceBackend = new SQLBackendImpl(sqlHost, sqlPort, sqlUsername, sqlPassword, maxPoolSize, maxPoolIdle, minPoolIdle, maxPoolWait, POSTGRESQL_INSTANCE_NAME, POSTGRESQL_DRIVER_NAME, sqlOptions); + postgreSQLPersistenceBackend = new SQLBackendImpl(sqlHost, sqlPort, sqlUsername, sqlPassword, maxPoolSize, maxPoolIdle, minPoolIdle, minPoolIdleTimeMillis, POSTGRESQL_INSTANCE_NAME, POSTGRESQL_DRIVER_NAME, sqlOptions); } }