private void log(String fmt, Object... args) { if ( TRACKING ) FmtLog.debug(log, fmt, args); } }
private void log(String fmt, Object... args) { if ( TRACKING ) FmtLog.debug(log, fmt, args); } }
static void log(Logger log, String fmt, Object... args) { if ( logging(log) ) { FmtLog.debug(log, fmt, args); } }
public static void debug(Class<?> cls, Throwable th, String fmt, Object...args) { debug(log(cls), th, fmt, args) ; }
public static void debug(Class<?> cls, String fmt, Object...args) { debug(log(cls), fmt, args) ; }
@Override public Version nextVersion() { Version ver = Version.create(version+1); FmtLog.debug(LOG, "Alloc version %d", ver); return ver; }
static void log(Logger log, String fmt, Object... args) { if ( logging(log) ) { FmtLog.debug(log, fmt, args); } }
static void log(Logger log, String fmt, Object... args) { if ( logging(log) ) { FmtLog.debug(log, fmt, args); } }
public static void debug(Class<?> cls, String fmt, Object...args) { debug(log(cls), fmt, args) ; }
public static void debug(Class<?> cls, Throwable th, String fmt, Object...args) { debug(log(cls), th, fmt, args) ; }
private void initState() { runWithLock(()->{ FmtLog.debug(LOG, "initState %s", logName); if ( current == null ) earliestVersion = Version.INIT; version = DeltaConst.VERSION_INIT; save(version, current, previous); }); }
@Override public List<DataSourceDescription> listDataSources() { FmtLog.debug(LOGZK, "[%d] listDataSources", instance); sync(); return super.listDataSources(); // List<DataSourceDescription> sources = listDataSourcesZk(); // // Would need to atomically set the data registry. // return sources; }
/** The initial state object of a patch log */ /*package*/ static JsonObject initialStateJson() { FmtLog.debug(LOG, "initialStateJson"); return JSONX.buildObject(b->{ b.pair(fVersion, DeltaConst.VERSION_INIT); }); }
private void newState(long newVersion, Id patch, Id prev) { synchronized(lock) { FmtLog.debug(LOG, "newVersion %d -> %d", version, newVersion); //FmtLog.info(LOG, "[%s] newState %s -> %s", instance, Version.str(version), Version.str(newVersion)); if ( newVersion <= version ) { if ( newVersion == version ) { if ( ! Objects.equals(patch, current) || ! Objects.equals(prev,previous) ) FmtLog.error(LOG, "Same version but different ids: current=(%s,%s), proposed=(%s,%s)", current, previous, patch, prev); } return ; } //FmtLog.debug(LOG, "-- [%d] State: [%s] (%s, %s, %s)", instance, dsd.getName(), version, current, previous); if ( newVersion == DeltaConst.VERSION_FIRST && ! earliestVersion.isValid() ) { // If going no patch -> patch, set the start. earliestVersion = Version.FIRST; earliestId = patch; } // newVersion > version this.version = newVersion; this.current = patch; this.previous = prev; } }
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); } }
if ( in == null ) FmtLog.debug(log, "Failed to locate '%s'", mappedURI); throw new NotFoundException("Not found: "+filenameOrURI) ;
private static JsonObject stateToJson(long version, Id patch, Id prev) { FmtLog.debug(LOG, "stateToJson ver=%d", version); return JSONX.buildObject(b->{ b.pair(fVersion, version); if ( patch != null ) b.pair(fId, patch.asPlainString()); if ( prev != null ) b.pair(fPrevious, patch.asPlainString()); }); }
@Override protected Model readModelWorker(Model model, String filenameOrURI, String baseURI, String syntax) { // Doesn't call open() - we want to make the syntax guess // based on the mapped URI. String mappedURI = mapURI(filenameOrURI) ; if ( log.isDebugEnabled() && !mappedURI.equals(filenameOrURI) ) log.debug("Map: " + filenameOrURI + " => " + mappedURI) ; Lang lang = (syntax != null) ? RDFLanguages.nameToLang(syntax) : RDFLanguages.resourceNameToLang(mappedURI, Lang.RDFXML) ; // Not : RDFDataMgr.read(model, mappedURI, baseURI, lang); // Allow model.read to be overridden e.g. by OntModel which does import processing. if ( baseURI == null ) baseURI = SysRIOT.chooseBaseIRI(filenameOrURI) ; try(TypedInputStream in = streamManager.openNoMapOrNull(mappedURI)) { if ( in == null ) { FmtLog.debug(log, "Failed to locate '%s'", mappedURI); throw new NotFoundException("Not found: "+filenameOrURI) ; } Lang lang2 = RDFDataMgr.determineLang(mappedURI, in.getContentType(), lang); // May be overridden by model implementation. model.read(in, baseURI, lang2.getName()) ; } return model ; }
/** Sync until some version */ private void syncToVersion(Version version) { //long remoteVer = getRemoteVersionLatestOrDefault(VERSION_UNSET); if ( ! Version.isValid(version) ) { FmtLog.debug(LOG, "Sync: Asked for no patches to sync"); return; } Version localVer = getLocalVersion(); // // -1 ==> no entries, uninitialized. // if ( DeltaConst.versionUninitialized(localVer) ) { // FmtLog.info(LOG, "Sync: No log entries"); // localVer = DeltaConst.VERSION_INIT; // setLocalState(localVer, (Node)null); // return; // } if ( localVer.value() > version.value() ) FmtLog.info(LOG, "[%s] Local version ahead of remote : [local=%d, remote=%d]", datasourceId, getLocalVersion(), getRemoteVersionCached()); if ( localVer.value() >= version.value() ) return; // bring up-to-date. FmtLog.info(LOG, "Sync: Versions [%s, %s]", localVer, version); playPatches(localVer.value()+1, version.value()) ; //FmtLog.info(LOG, "Now: Versions [%d, %d]", getLocalVersion(), remoteVer); }