org.apache.lucene.replicator.http

## Class HttpReplicator

- java.lang.Object
- - org.apache.lucene.replicator.http.HttpClientBase
  - - org.apache.lucene.replicator.http.HttpReplicator

- All Implemented Interfaces:
    Closeable, AutoCloseable, Replicator

      public class HttpReplicator
      extends HttpClientBase
      implements Replicator

  An HTTP implementation of `Replicator`. Assumes the API supported by `ReplicationService`.
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Field Summary

    - ### Fields inherited from class org.apache.lucene.replicator.http.HttpClientBase

      `DEFAULT_CONNECTION_TIMEOUT, DEFAULT_SO_TIMEOUT, url`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpReplicator(String host, int port, String path, org.apache.http.conn.HttpClientConnectionManager conMgr)` Construct with specified connection manager.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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.

    - ### Methods inherited from class org.apache.lucene.replicator.http.HttpClientBase

      `close, doAction, doAction, ensureOpen, executeGET, executePOST, isClosed, responseInputStream, responseInputStream, throwKnownError, verifyStatus`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.io.Closeable

      `close`

- - ### Constructor Detail

    - #### HttpReplicator

          public HttpReplicator(String host,
                                int port,
                                String path,
                                org.apache.http.conn.HttpClientConnectionManager conMgr)

      Construct with specified connection manager.

  - ### Method Detail

    - #### checkForUpdate

          public SessionToken checkForUpdate(String currVersion)
                                      throws IOException

      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`
      Throws:
        `IOException`

    - #### 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`

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