public interface Replicator extends Closeable
publish
Revision
s and consumers to
check for updates
. When a client needs to be
updated, it is given a SessionToken
through which it can
obtain
the files of that
revision. After the client has finished obtaining all the files, it should
release
the given session, so that the files can be
reclaimed if they are not needed anymore.
A client is always updated to the newest revision available. That is, if a client is on revision r1 and revisions r2 and r3 were published, then when the cllient will next check for update, it will receive r3.
Modifier and Type | Method and Description |
---|---|
SessionToken |
checkForUpdate(String currVersion)
Check whether the given version is up-to-date and returns a
SessionToken which can be used for fetching the revision files,
otherwise returns null . |
InputStream |
obtainFile(String sessionID,
String source,
String fileName)
Returns an
InputStream for the requested file and source in the
context of the given session . |
void |
publish(Revision revision)
Publish a new
Revision for consumption by clients. |
void |
release(String sessionID)
Notify that the specified
SessionToken is no longer needed by the
caller. |
void publish(Revision revision) throws IOException
Revision
for consumption by clients. It is the
caller's responsibility to verify that the revision files exist and can be
read by clients. When the revision is no longer needed, it will be
released
by the replicator.IOException
SessionToken checkForUpdate(String currVersion) throws IOException
SessionToken
which can be used for fetching the revision files,
otherwise returns null
.
NOTE: when the returned session token is no longer needed, you
should call release(String)
so that the session resources can be
reclaimed, including the revision files.
IOException
void release(String sessionID) throws IOException
SessionToken
is no longer needed by the
caller.IOException
InputStream obtainFile(String sessionID, String source, String fileName) throws IOException
InputStream
for the requested file and source in the
context of the given session
.
NOTE: it is the caller's responsibility to close the returned stream.
SessionExpiredException
- if the specified session has already
expiredIOException
Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.