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

Fix/arcgis exception to cygnus persistence error to allow batch retries #2444

Merged
merged 6 commits into from
Nov 20, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix persistBatch catch
AlvaroVega committed Nov 18, 2024
commit c4b1338ea6495d50044e6944d5fe3874492a957b
Original file line number Diff line number Diff line change
@@ -167,7 +167,7 @@ protected int featuresBatched() {
* @return The persistence backend
* @throws CygnusRuntimeError
*/
protected ArcgisFeatureTable getPersistenceBackend(String featureServiceUrl) throws CygnusRuntimeError {
protected ArcgisFeatureTable getPersistenceBackend(String featureServiceUrl) throws CygnusPersistenceError, CygnusRuntimeError {

LOGGER.debug("Current persistenceBackend has " + arcgisPersistenceBackend.size() +" tables ");

@@ -187,7 +187,7 @@ protected ArcgisFeatureTable getPersistenceBackend(String featureServiceUrl) thr

if (newTable.hasError() || !newTable.connected()) {
LOGGER.error("Error creating new persistence Backend. " + newTable.getErrorDesc());
throw new CygnusRuntimeError("[" + this.getName() + "Error creating Persistence backend: "
throw new CygnusPersistenceError("[" + this.getName() + "Error creating Persistence backend: "
+ newTable.getErrorCode() + " - " + newTable.getErrorDesc());
} else {
arcgisPersistenceBackend.put(featureServiceUrl, newTable);
@@ -199,7 +199,7 @@ protected ArcgisFeatureTable getPersistenceBackend(String featureServiceUrl) thr
LOGGER.error("Error creating new persistence Backend. " +e.getClass().getSimpleName());
LOGGER.debug(stackTrace);

throw new CygnusRuntimeError("Error creating new persistence Backend. ", e.getClass().getName(),
throw new CygnusPersistenceError("Error creating new persistence Backend. ", e.getClass().getName(),
e.getMessage());
}
}
@@ -306,34 +306,29 @@ void persistBatch(NGSIBatch batch)
return;
} // if

try {
// Iterate on the destinations
batch.startIterator();
// Iterate on the destinations
batch.startIterator();

while (batch.hasNext()) {
String destination = batch.getNextDestination();
LOGGER.debug(
"[" + this.getName() + "] Processing sub-batch regarding the " + destination + " destination");
while (batch.hasNext()) {
String destination = batch.getNextDestination();
LOGGER.debug(
"[" + this.getName() + "] Processing sub-batch regarding the " + destination + " destination");

// Get the events within the current sub-batch
ArrayList<NGSIEvent> events = batch.getNextEvents();
// Get the events within the current sub-batch
ArrayList<NGSIEvent> events = batch.getNextEvents();

// Get an aggregator for this destination and initialize it
NGSIArcgisAggregator aggregator = new NGSIArcgisAggregator(getrAcgisServicesUrl(), enableNameMappings);

for (NGSIEvent event : events) {
aggregator.aggregate(event);
} // for
// Get an aggregator for this destination and initialize it
NGSIArcgisAggregator aggregator = new NGSIArcgisAggregator(getrAcgisServicesUrl(), enableNameMappings);

// Persist the aggregation
persistAggregation(aggregator);
batch.setNextPersisted(true);
for (NGSIEvent event : events) {
aggregator.aggregate(event);
} // for

} // while
} catch (Exception e) {
LOGGER.error("[" + this.getName() + "] Error persisting batch, " + e.getClass().getSimpleName() + "." + e.getMessage());
throw new CygnusRuntimeError(e.getMessage());
}
// Persist the aggregation
persistAggregation(aggregator);
batch.setNextPersisted(true);

} // while
} // persistBatch

/*
@@ -422,7 +417,11 @@ public void persistAggregation(NGSIArcgisAggregator aggregator) throws CygnusPer
}
} catch (CygnusRuntimeError e) {
String stackTrace = ExceptionUtils.getFullStackTrace(e);
LOGGER.debug(" PersistAggregation Error: " + stackTrace);
LOGGER.debug(" PersistAggregation CygnusRuntimeError: " + stackTrace);
throw (e);
} catch (CygnusPersistenceError e) {
String stackTrace = ExceptionUtils.getFullStackTrace(e);
LOGGER.debug(" PersistAggregation CygnusPersistenceError: " + stackTrace);
throw (e);
} catch (ArcgisException e) {
LOGGER.error("[" + this.getName() + "] Error persisting batch, " + e.getClass().getSimpleName() + " - "