PrimaryNode (Lucene 10.5.1 replicator API)
Description: declaration: package: org.apache.lucene.replicator.nrt, class: PrimaryNode

Package org.apache.lucene.replicator.nrt

# Class PrimaryNode

java.lang.Object
org.apache.lucene.replicator.nrt.Node
org.apache.lucene.replicator.nrt.PrimaryNode

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

public abstract class PrimaryNode extends Node
Node that holds an IndexWriter, indexing documents into its local index.

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

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final long`
  `primaryGen`
  `protected final IndexWriter`
  `writer`

  ### Fields inherited from class org.apache.lucene.replicator.nrt.Node

  `dir, globalStartNS, id, lastFileMetaData, localStartNS, mgr, PRIMARY_GEN_KEY, printStream, searcherFactory, VERSION_KEY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PrimaryNode(IndexWriter writer, int id, long primaryGen, long forcePrimaryVersion, SearcherFactory searcherFactory, PrintStream printStream)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  `void`
  `commit()`
  `boolean`
  `flushAndRefresh()`
  Flush all index operations to disk and opens a new near-real-time reader.
  `CopyState`
  `getCopyState()`
  IncRef the current CopyState and return it
  `long`
  `getCopyStateVersion()`
  `long`
  `getLastCommitVersion()`
  `long`
  `getPrimaryGen()`
  Returns the current primary generation, which is incremented each time a new primary is started for this index
  `int`
  `getRemoteCloseTimeoutMs()`
  `boolean`
  `isClosed()`
  `protected abstract void`
  `preCopyMergedSegmentFiles(SegmentCommitInfo info, Map<String,FileMetaData> files)`
  Called when a merge has finished, but before IW switches to the merged segment
  `void`
  `releaseCopyState(CopyState copyState)`
  Called once replica is done (or failed) copying an NRT point
  `void`
  `setRemoteCloseTimeoutMs(int remoteCloseTimeoutMs)`
  Set the number of milliseconds to wait during shutdown for remote replicas to close.

  ### Methods inherited from class org.apache.lucene.replicator.nrt.Node

  `bytesToString, getCurrentSearchingVersion, getDirectory, getSearcherManager, isVerboseFiles, message, name, nodeMessage, nodeMessage, readLocalFileMetaData, setVerboseFiles, toString`

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

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

- ## Field Details

  - ### writer

    protected final IndexWriter writer

  - ### primaryGen

    protected final long primaryGen

- ## Constructor Details

  - ### PrimaryNode

    public PrimaryNode(IndexWriter writer, int id, long primaryGen, long forcePrimaryVersion, SearcherFactory searcherFactory, PrintStream printStream) throws IOException
    Throws:
      `IOException`

- ## Method Details

  - ### getPrimaryGen

    public long getPrimaryGen()
    Returns the current primary generation, which is incremented each time a new primary is started for this index

  - ### flushAndRefresh

    public boolean flushAndRefresh() throws IOException
    Flush all index operations to disk and opens a new near-real-time reader. new NRT point, to make the changes visible to searching. Returns true if there were changes.
    Throws:
      `IOException`

  - ### getCopyStateVersion

    public long getCopyStateVersion()

  - ### getLastCommitVersion

    public long getLastCommitVersion()

  - ### getRemoteCloseTimeoutMs

    public int getRemoteCloseTimeoutMs()
    Returns:
      the number of milliseconds to wait during shutdown for remote replicas to close

  - ### setRemoteCloseTimeoutMs

    public void setRemoteCloseTimeoutMs(int remoteCloseTimeoutMs)
    Set the number of milliseconds to wait during shutdown for remote replicas to close. `-1` (the default) means forever, and `0` means don't wait at all.

  - ### commit

    public void commit() throws IOException
    Specified by:
      `commit` in class `Node`
    Throws:
      `IOException`

  - ### getCopyState

    public CopyState getCopyState() throws IOException
    IncRef the current CopyState and return it
    Throws:
      `IOException`

  - ### releaseCopyState

    public void releaseCopyState(CopyState copyState) throws IOException
    Called once replica is done (or failed) copying an NRT point
    Throws:
      `IOException`

  - ### isClosed

    public boolean isClosed()
    Specified by:
      `isClosed` in class `Node`

  - ### close

    public void close() throws IOException
    Throws:
      `IOException`

  - ### preCopyMergedSegmentFiles

    protected abstract void preCopyMergedSegmentFiles(SegmentCommitInfo info, Map<String,FileMetaData> files) throws IOException
    Called when a merge has finished, but before IW switches to the merged segment
    Throws:
      `IOException`