options.prettyPrint(true); } else if ("silent".equals(print)) { if( jsondb.exists(path) ) { return Response.noContent().build();
options.prettyPrint(true); } else if ("silent".equals(print)) { if( jsondb.exists(path) ) { return Response.noContent().build();
@Override public T create(T entity) { try { String dbPath = getCollectionPath()+"/:"+entity.getId().get(); // Only create if it did not exist. if( jsondb.exists(dbPath) ) { return null; } byte[] json = Json.mapper().writeValueAsBytes(entity); jsondb.set(dbPath, json); return entity; } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") RuntimeException|IOException e) { throw SyndesisServerException.launderThrowable(e); } }
/** * Persists the latest metrics of a live pod to the database. */ @Override public void persist(RawMetrics rawMetrics) { try { //persist the latest rawMetrics String path = path(rawMetrics.getIntegrationId(), rawMetrics.getPod()); String json = Json.writer().writeValueAsString(rawMetrics); if (jsonDB.exists(path)) { //only update if not the same (don't cause unnecessary and expensive writes) if (! jsonDB.getAsString(path).equals(json)) { jsonDB.update(path, json); } } else { jsonDB.set(path, json); } } catch (JsonProcessingException e) { LOGGER.error("Error persisting metrics!", e); } }
@Override public T create(T entity) { try { String dbPath = getCollectionPath()+"/:"+entity.getId().get(); // Only create if it did not exist. if( jsondb.exists(dbPath) ) { return null; } byte[] json = Json.writer().writeValueAsBytes(entity); jsondb.set(dbPath, json); return entity; } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") RuntimeException|IOException e) { throw SyndesisServerException.launderThrowable(e); } }