Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.replicator
Class LocalReplicator

    java.lang.Object
      org.apache.lucene.replicator.LocalReplicator

All Implemented Interfaces:
  Closeable, Replicator

    public class LocalReplicator

extends Object
implements Replicator

A `Replicator` implementation for use by the side that publishes `Revision`s, as well for clients to `check for updates`. When a client needs to be updated, it is returned a `SessionToken` through which it can `obtain` the files of that revision. As long as a revision is being replicated, this replicator guarantees that it will not be `released`.

Replication sessions expire by default after `DEFAULT_SESSION_EXPIRATION_THRESHOLD`, and the threshold can be configured through `setExpirationThreshold(long)`.

WARNING: This API is experimental and might change in incompatible ways in the next release.

Field Summary
`static long` | `DEFAULT_SESSION_EXPIRATION_THRESHOLD` Threshold for expiring inactive sessions.

Constructor Summary
`LocalReplicator()`

Method Summary
`SessionToken` | `checkForUpdate(String currentVersion)` 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`.
`void` | `close()`
`protected void` | `ensureOpen()` Ensure that replicator is still open, or throw `AlreadyClosedException` otherwise.
`long` | `getExpirationThreshold()` Returns the expiration threshold.
`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` | `setExpirationThreshold(long expirationThreshold)` Modify session expiration time - if a replication session is inactive that long it is automatically expired, and further attempts to operate within this session will throw a `SessionExpiredException`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_SESSION_EXPIRATION_THRESHOLD

    public static final long DEFAULT_SESSION_EXPIRATION_THRESHOLD

  Threshold for expiring inactive sessions. Defaults to 30 minutes.

  See Also:
    Constant Field Values

Constructor Detail

### LocalReplicator

    public LocalReplicator()

Method Detail

### ensureOpen

    protected final void ensureOpen()

  Ensure that replicator is still open, or throw `AlreadyClosedException` otherwise.

### checkForUpdate

    public SessionToken checkForUpdate(String currentVersion)

  Description copied from interface: `Replicator`
  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`.

  NOTE: when the returned session token is no longer needed, you should call `Replicator.release(String)` so that the session resources can be reclaimed, including the revision files.

  Specified by:
    `checkForUpdate` in interface `Replicator`

### close

    public void close()
               throws IOException

  Specified by:
    `close` in interface `Closeable`
  Throws:
    `IOException`

### getExpirationThreshold

    public long getExpirationThreshold()

  Returns the expiration threshold.

  See Also:
    `setExpirationThreshold(long)`

### obtainFile

    public InputStream obtainFile(String sessionID,
                                  String source,
                                  String fileName)
                           throws IOException

  Description copied from interface: `Replicator`
  Returns an `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.

  Specified by:
    `obtainFile` in interface `Replicator`
  Throws:
    `SessionExpiredException` - if the specified session has already expired
    `IOException`

### publish

    public void publish(Revision revision)
                 throws IOException

  Description copied from interface: `Replicator`
  Publish a new `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.

  Specified by:
    `publish` in interface `Replicator`
  Throws:
    `IOException`

### release

    public void release(String sessionID)
                 throws IOException

  Description copied from interface: `Replicator`
  Notify that the specified `SessionToken` is no longer needed by the caller.

  Specified by:
    `release` in interface `Replicator`
  Throws:
    `IOException`

### setExpirationThreshold

    public void setExpirationThreshold(long expirationThreshold)
                                throws IOException

  Modify session expiration time - if a replication session is inactive that long it is automatically expired, and further attempts to operate within this session will throw a `SessionExpiredException`.

  Throws:
    `IOException`

Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.