Skip to content

Commit

Permalink
Merge pull request #2421 from telefonicaid/task/log_reuse_persistence…
Browse files Browse the repository at this point in the history
…Backend_arcgis

check if featureTable is connected before use it (arcgis)
  • Loading branch information
fgalan authored Oct 1, 2024
2 parents 1f0cd23 + 9461100 commit d03e685
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

- [cygnus-ngsi][arcgis] Check feature table is connected before use it (#2405)
- [cygnus-ngsi][arcgis] Set feature table to not connected after a connection error (#2405)
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.net.SocketException;

import com.telefonica.iot.cygnus.backends.arcgis.exceptions.ArcgisException;
import com.telefonica.iot.cygnus.backends.arcgis.model.Credential;
Expand Down Expand Up @@ -593,6 +594,9 @@ private void setError(Exception e) {
this.errorCode = agsEx.getCode();
} else {
if (e != null && e.getCause() != null) {
if (e.getCause() instanceof SocketException) {
connected = false;
}
LOGGER.error("Error Cause: " + e.getCause().getMessage());
}
LOGGER.error("Error Message: " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,12 @@ protected int featuresBatched() {
*/
protected ArcgisFeatureTable getPersistenceBackend(String featureServiceUrl) throws CygnusRuntimeError {

if (arcgisPersistenceBackend.containsKey(featureServiceUrl)) {
if (arcgisPersistenceBackend.containsKey(featureServiceUrl) &&
arcgisPersistenceBackend.get(featureServiceUrl).connected() ){
LOGGER.info("Using persistenceBackend which contains key for Feature table: " + featureServiceUrl);
return arcgisPersistenceBackend.get(featureServiceUrl);
} else {
LOGGER.debug("Creating new persistenceBackend for Feature table: " + featureServiceUrl);
LOGGER.info("Creating new persistenceBackend for Feature table: " + featureServiceUrl);
LOGGER.debug("Token url: " + getGetTokenUrl());
try {
NGSIArcgisFeatureTable newTable = new NGSIArcgisFeatureTable(featureServiceUrl, getUsername(),
Expand Down

0 comments on commit d03e685

Please sign in to comment.