/** * Creates or Replaces the object or value at the given path * with the supplied json document. * * @param path to the object or value to set * @param json value to set it to, can be a json primitive or struct */ default void set(String path, String json) { set(path, json.getBytes(StandardCharsets.UTF_8)); }
/** * Creates or Replaces the object or value at the given path * with the supplied json document. * * @param path to the object or value to set * @param json value to set it to, can be a json primitive or struct */ default void set(String path, String json) { set(path, json.getBytes(StandardCharsets.UTF_8)); }
default void set(String path, byte[] json) { set(path, new ByteArrayInputStream(json)); }
default void set(String path, byte[] json) { set(path, new ByteArrayInputStream(json)); }
@Path("/{path: .*}.json") @Consumes(APPLICATION_JSON) @PUT public void set(@PathParam("path") String path, InputStream body) { jsondb.set(path, body); }
@Path("/{path: .*}.json") @Consumes(APPLICATION_JSON) @PUT public void set(@PathParam("path") String path, InputStream body) { jsondb.set(path, body); }
public void setPodLogState(String podName, PodLogState state) throws IOException { jsonDB.set("/logs/pods/" + podName, Json.mapper().writeValueAsBytes(state)); }
@Override public void deleteAll() { try { String dbPath = getCollectionPath(); jsondb.set(dbPath, "{}"); } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") RuntimeException e) { throw SyndesisServerException.launderThrowable(e); } } }
@Override public void deleteAll() { try { String dbPath = getCollectionPath(); jsondb.set(dbPath, "{}"); } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") RuntimeException e) { throw SyndesisServerException.launderThrowable(e); } } }
@Override public T update(T entity) { try { T previousValue = this.fetch(entity.getId().get()); // Only update if the entity existed. if( previousValue !=null ) { String dbPath = getCollectionPath()+"/:"+entity.getId().get(); byte[] json = Json.mapper().writeValueAsBytes(entity); jsondb.set(dbPath, json); } return previousValue; } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") RuntimeException|IOException e) { throw SyndesisServerException.launderThrowable(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.mapper().writeValueAsBytes(entity); jsondb.set(dbPath, json); return entity; } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") RuntimeException|IOException e) { throw SyndesisServerException.launderThrowable(e); } }
@Override public void set(T entity) { try { String dbPath = getCollectionPath()+"/:"+entity.getId().get(); byte[] json = Json.writer().writeValueAsBytes(entity); jsondb.set(dbPath, json); } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") RuntimeException|IOException e) { throw SyndesisServerException.launderThrowable(e); } }
@Override public T update(T entity) { try { T previousValue = this.fetch(entity.getId().get()); // Only update if the entity existed. if( previousValue !=null ) { String dbPath = getCollectionPath()+"/:"+entity.getId().get(); byte[] json = Json.writer().writeValueAsBytes(entity); jsondb.set(dbPath, json); } return previousValue; } 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); } }
jsonDB.set(path(integrationId,historyKey), json);