Skip to content

Commit

Permalink
upgrade ngsi-ld sinks
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroVega committed Apr 16, 2024
1 parent 168fba3 commit a490093
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand All @@ -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);
}
}

Expand Down

0 comments on commit a490093

Please sign in to comment.