Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check if featureTable is connected before use it (arcgis) #2421

Merged
merged 6 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading