use of io.syndesis.common.util.SyndesisServerException in project syndesis by syndesisio.
the class PrometheusMetricsProviderImpl method getTotalIntegrationMetricsSummary.
@Override
public IntegrationMetricsSummary getTotalIntegrationMetricsSummary() {
final Optional<Long> totalMessages = getSummaryMetricValue(METRIC_TOTAL, Long.class, "sum");
final Optional<Long> failedMessages = getSummaryMetricValue(METRIC_FAILED, Long.class, "sum");
try {
final Optional<Date> startTime = Optional.of(dateFormat.parse(openShiftClient.pods().withLabelSelector(SELECTOR).list().getItems().get(0).getStatus().getStartTime()));
// compute last processed time
final Optional<Date> lastCompletedTime = getAggregateMetricValue(METRIC_COMPLETED_TIMESTAMP, Date.class, "max");
final Optional<Date> lastFailureTime = getAggregateMetricValue(METRIC_FAILURE_TIMESTAMP, Date.class, "max");
final Date lastProcessedTime = MAX_DATE.apply(lastCompletedTime.orElse(null), lastFailureTime.orElse(null));
return new IntegrationMetricsSummary.Builder().metricsProvider("prometheus").start(startTime).lastProcessed(Optional.ofNullable(lastProcessedTime)).messages(totalMessages.orElse(0L)).errors(failedMessages.orElse(0L)).build();
} catch (ParseException e) {
throw new SyndesisServerException(e.getMessage(), e);
}
}
use of io.syndesis.common.util.SyndesisServerException in project syndesis by syndesisio.
the class SalesforceMetadataRetrieval method handle.
@Override
public RuntimeException handle(final Exception e) {
Throwable current = e;
while (current != null && current != current.getCause() && !(current instanceof SalesforceException)) {
current = current.getCause();
}
if (current instanceof SalesforceException) {
final SalesforceException salesforceException = (SalesforceException) current;
final String message = salesforceException.getErrors().stream().map(error -> error.getErrorCode() + ": " + error.getMessage()).collect(Collectors.joining(". "));
return new SyndesisServerException("Salesforce: " + message, e);
}
if (e instanceof RuntimeException) {
return (RuntimeException) e;
}
return new SyndesisServerException("Salesforce", e);
}
use of io.syndesis.common.util.SyndesisServerException in project syndesis by syndesisio.
the class DefaultMigrator method performMigration.
private void performMigration(final JsonDB utilized, final int toVersion) {
final String path = migrationsScriptPrefix() + toVersion + ".js";
try {
final Resource resource = resourceLoader.getResource(path);
if (!resource.exists()) {
return;
}
final String migrationScript = IOStreams.readText(resource.getInputStream());
LOG.info("Migrating to schema: {}", toVersion);
final ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
engine.put("internal", map("jsondb", utilized));
engine.eval(Resources.getResourceAsText("migrations/common.js"));
engine.eval(migrationScript);
} catch (IOException | ScriptException e) {
throw new SyndesisServerException("Unable to perform database migration to version " + toVersion + ", using migration script at: " + path, e);
}
}
Aggregations