/** * Test whether patch log exists or not. * Calling {@link #getDataSourceDescriptionByName} to get details,or null, is better than * calling {@code existsByName} if the description is needed. */ public default boolean existsByName(String name) { return getDataSourceDescriptionByName(name) != null; }
public Version append(RDFPatch patch) { return dLink.append(dsRef, patch); }
public RDFPatch fetch(Version version) { return dLink.fetch(dsRef, version); }
protected void create(String name, String url) { Objects.requireNonNull(name); Objects.requireNonNull(url); List <DataSourceDescription> all = dLink.listDescriptions(); boolean b = all.stream().anyMatch(dsd-> Objects.equals(dsd.getName(), name)); if ( b ) throw new CmdException("Source '"+name+"' already exists"); Id id = dLink.newDataSource(name, url); DataSourceDescription dsd = dLink.getDataSourceDescription(id); System.out.println("Created "+dsd); }
protected void exec1(String fn) { Id dsRef = getDescription().getId(); PatchLogInfo info = dLink.getPatchLogInfo(dsRef); Id prev = info.getLatestPatch(); RDFPatch body = toPatch(fn); // Header. PatchHeader header = RDFPatchOps.makeHeader(Id.create().asNode(), prev==null?null:prev.asNode()); RDFPatch patch = RDFPatchOps.withHeader(header, body); //RDFPatchOps.write(System.out, patch); // Add previous. Version version = dLink.append(dsRef, patch); System.out.printf("Version = %s\n", version.value()); }
@Test public void cmd_mk() { String LOG_NAME = "ABC_1"; cmdq("mk", "--server="+serverURL, LOG_NAME); DataSourceDescription dsd = dLink.getDataSourceDescriptionByName(LOG_NAME); assertNotNull(dsd); assertEquals(LOG_NAME, dsd.getName()); List<DataSourceDescription> list = dLink.listDescriptions(); assertEquals(1, list.size()); DeltaLog log = new DeltaLog(dLink, dsd.getId()); PatchLogInfo info = log.info(); assertEquals(0, log.getCurrentVersion().value()); }
deltaLink.ping(); DataSourceDescription dsd = deltaLink.getDataSourceDescriptionByName(logName); Id dsRef; if ( dsd == null )
/** * Test whether patch log exists or not. * Calling {@link #getDataSourceDescription} to get details,or null, is better than * calling {@code exists} if the description is needed. */ public default boolean exists(Id dsRef) { return getDataSourceDescription(dsRef) != null; }
public PatchLogInfo info() { return dLink.getPatchLogInfo(dsRef); }
@Override protected void execCmdURI(String uriStr) { Optional<Id> opt = findByURI(uriStr); if ( ! opt.isPresent() ) throw new CmdException("Source <"+uriStr+"> does not exist"); Id dsRef = opt.get(); dLink.removeDataSource(dsRef); } }
/** * No-op end-to-end operation. This operation succeeds or throws an exception. * This operation makes one attempt only to perform the ping. */ public void ping() { dLink.ping(); }
protected List<DataSourceDescription> getDescriptions() { if ( descriptions == null ) descriptions = dLink.listDescriptions(); return descriptions; }
public PatchLogInfo getPatchLogInfo() { checkDeltaConnection(); PatchLogInfo info = dLink.getPatchLogInfo(datasourceId); if ( info != null ) { if ( remote.get() != null ) { if ( Version.isValid(getRemoteVersionCached()) && info.getMaxVersion().value() < getRemoteVersionCached().value() ) { String dsName = dLink.getDataSourceName(datasourceId); FmtLog.warn(LOG, "[ds:%s %s] Remote version behind local tracking of remote version: [%d, %d]", datasourceId, dsName, info.getMaxVersion(), getRemoteVersionCached()); } } // Set the local copy whenever we get the remote latest. remote.set(info); } return info; }
/** Create a new data source. * This operation does not register the new {@code DataSource} to this {@code DeltaClient}; * call {@link #register(Id, LocalStorageType, SyncPolicy)}. */ public Id newDataSource(String name, String uri) { return dLink.newDataSource(name, uri); }
/** * Test whether patch log exists or not. * Calling {@link #getDataSourceDescriptionByURI} to get details,or null, is better than * calling {@code existsByURI} if the description is needed. */ public default boolean existsByURI(String uri) { return getDataSourceDescriptionByURI(uri) != null; }
static void create(DeltaLink dLink, String name, String url) { Objects.requireNonNull(dLink); Objects.requireNonNull(name); Objects.requireNonNull(url); List <DataSourceDescription> all = dLink.listDescriptions(); boolean b = all.stream().anyMatch(dsd-> Objects.equals(dsd.getName(), name)); if ( b ) throw new CmdException("Source '"+name+"' already exists"); Id id = dLink.newDataSource(name, url); DataSourceDescription dsd = dLink.getDataSourceDescription(id); System.out.println("Created "+dsd); }
/** Return details of a patch log, or null if not registered. */ public DataSourceDescription getDataSourceDescription() { return dLink.getDataSourceDescription(dsRef); } }
/** Get the current version: if this is an HTTP connection, this causes network traffic. */ public default Version getCurrentVersion(Id dsRef) { return getPatchLogInfo(dsRef).getMaxVersion(); }
static void hide(DeltaLink dLink, String name) { Optional<Id> opt = find(dLink, name); if ( ! opt.isPresent() ) throw new CmdException("Source '"+name+"' does not exist"); Id dsRef = opt.get(); dLink.removeDataSource(dsRef); }
@Override public void ping() { exec(()->get().ping()); }