private JsonValue rpcToValue(String opName, JsonObject arg) { JsonObject argx = ( arg == null ) ? emptyObject : arg; // [NET] Network point return retry(()->DRPC.rpc(remoteServer + DeltaConst.EP_RPC, opName, argx), ()->true, ()->format("Retry : %s",opName), ()->format("Failed : %s %s",opName,JSON.toStringFlat(argx)) ); }
Version version = Version.fromJson(sourceObj, F_VERSION, Version.UNSET); if ( ! Version.isValid(version) ) { LOG.warn("No version: "+JSON.toStringFlat(sourceObj)); dataState.datasource = Id.fromString(dsStr); else { LOG.error("No datasource: "+JSON.toStringFlat(sourceObj)); throw new DeltaException("No datasource: "+JSON.toStringFlat(sourceObj)); dataState.name = name; else { LOG.error("No datasource name: "+JSON.toStringFlat(sourceObj)); throw new DeltaException("No datasource name: "+JSON.toStringFlat(sourceObj));
public static Version create(JsonValue version) { Objects.requireNonNull(version, "version"); if ( version.isNumber() ) { long ver = JSONX.getLong(version, -2); if ( ver < -1 ) throw new DeltaException("Bad version number: '"+JSON.toStringFlat(version)+"'"); return create(ver); } if ( version.isString() ) { try { String s = version.getAsString().value(); long ver = Long.parseLong(s); return create(ver); } catch (NumberFormatException ex) { throw new DeltaException("Bad format for version: '"+JSON.toStringFlat(version)+"'"); } } throw new DeltaException("Unrecognized JSON version: '"+JSON.toStringFlat(version)+"'"); }
private JsonObject rpc(String opName, JsonObject arg) { JsonValue r = rpcToValue(opName, arg); if ( ! r.isObject() ) throw new DeltaException("Bad result to '"+opName+"': "+JSON.toStringFlat(r)); return r.getAsObject(); }
public static Version fromJson(JsonObject obj, String field) { long ver = JSONX.getLong(obj, field, -99) ; if ( ver < -1 ) throw new DeltaException("Bad version number: '"+JSON.toStringFlat(obj.get(field))+"'"); return create(ver); }
private JsonObject rpcOnce(String opName, JsonObject arg) { JsonValue r = rpcOnceToValue(opName, arg); if ( ! r.isObject() ) throw new DeltaException("Bad result to '"+opName+"': "+JSON.toStringFlat(r)); return r.getAsObject(); }
private void jsonSetState(JsonObject obj) { try { FmtLog.debug(LOG, "jsonToState %s",JSON.toStringFlat(obj)); long ver = obj.get(fVersion).getAsNumber().value().longValue(); if ( ver == version ) return ; Id newCurrent = getIdOrNull(obj, fId); Id newPrevious = getIdOrNull(obj, fPrevious); newState(ver, newCurrent, newPrevious); } catch (RuntimeException ex) { FmtLog.error(this.getClass(), "Failed to load the patch log index state", ex); } }
LOG.info(JSON.toStringFlat(obj)); try (OutputStream out = Files.newOutputStream(sourcePath.resolve(FileNames.DS_CONFIG))) { JSON.write(out, obj);