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
`protected long` `primaryGen`
`protected IndexWriter` `writer`

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

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

### Constructor Summary

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

### Method Summary

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

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

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

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

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

### Field Detail

#### writer

    protected final IndexWriter writer

#### primaryGen

    protected final long primaryGen

### Constructor Detail

#### PrimaryNode

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

Throws:
  `IOException`

### Method Detail

#### 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()

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