/** Called after writing the patch to the {@link PatchLog}. */ protected void afterWrite(DataSource source, RDFPatch rdfPatch, Version version, long timeElapsed) { // FmtLog.info(LOG, "append: finish: Patch=%s[ver=%d] ds=%s", // str(rdfPatch.getId()), version, source); //FmtLog.info(LOG, "append (%.3fs): Patch=%s[%s] ds=%s", (timeElapsed / 1000.0), str(rdfPatch.getId()), version, source); FmtLog.info(LOG, "append : Patch=%s(>%s)[%s] ds=%s", str(rdfPatch.getId()), str(rdfPatch.getPrevious()), version, source); }
/** Called after writing the patch to the {@link PatchLog}. */ protected void badWrite(DataSource source, PatchLog patchLog, RDFPatch rdfPatch, RuntimeException ex) { FmtLog.info(LOG, "Bad write: patch=%s ds=%s : msg=%s", str(rdfPatch.getId()), source, ex.getMessage()); }
@Override protected void execOne(String source, InputStream input) { //System.err.println("Source = "+source); RDFPatch patch = RDFPatchOps.read(input); // if ( patch.getId() == null ) // System.err.printf("No patch source=%s\n", source); //RDFChanges changes = RDFPatchOps.changesPrinter(); RDFChanges changes = RDFPatchOps.textWriter(System.out); patch.apply(changes); System.out.flush(); if ( isVerbose() ) { System.err.printf("# Patch id=%s", Id.str(patch.getId())); if ( patch.getPrevious() != null ) System.err.printf(" prev=%s", Id.str(patch.getPrevious())); System.err.println(); } RDFChangesCounter counter = new RDFChangesCounter(); patch.apply(counter); PatchSummary summary = counter.summary(); if ( summary.countTxnCommit == 0 && summary.countTxnAbort == 0 ) System.err.printf("# No commit source=%s, id=%s\n", source, Id.str(patch.getId())); } }
idStr = Id.str(patchId); else idStr = Long.toString(number);
@Override public Version append(Id dsRef, RDFPatch rdfPatch) { checkLink(); DataSource source = getDataSource(dsRef); // Patch not known to be valid yet. // Patch not safe in the Patch Log yet. PatchLog patchLog = source.getPatchLog(); try { beforeWrite(source, patchLog, rdfPatch); // FmtLog.info(LOG, "append: start: Patch=%s ds=%s", str(rdfPatch.getId()), // source); long t1 = System.currentTimeMillis(); Version version = patchLog.append(rdfPatch); long t2 = System.currentTimeMillis(); afterWrite(source, rdfPatch, version, (t2 - t1)); return version; } catch (RuntimeException ex) { badWrite(source, patchLog, rdfPatch, ex); FmtLog.info(LOG, "append: Failed: Dest=%s Patch=%s ; %s", source, str(rdfPatch.getId()), ex.getMessage()); // Stack trace logged higher up if relevant. throw ex; } }