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

Package org.apache.lucene.replicator.nrt

# Class Node

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

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

Direct Known Subclasses:
  `PrimaryNode`, `ReplicaNode`

public abstract class Node extends Object implements Closeable
Common base class for `PrimaryNode` and `ReplicaNode`.

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 Directory`
  `dir`
  `static long`
  `globalStartNS`
  Startup time of original test, carefully propagated to all nodes to produce consistent "seconds since start time" in messages
  `protected final int`
  `id`
  Compact ordinal for this node
  `protected Map<String,FileMetaData>`
  `lastFileMetaData`
  File metadata for last sync that succeeded; we use this as a cache
  `static final long`
  `localStartNS`
  When this node was started
  `protected ReferenceManager<IndexSearcher>`
  `mgr`
  `static final String`
  `PRIMARY_GEN_KEY`
  Key to store the primary gen in the commit data, which increments every time we promote a new primary, so replicas can detect when the primary they were talking to is changed
  `protected final PrintStream`
  `printStream`
  For debug logging
  `protected final SearcherFactory`
  `searcherFactory`
  `static final String`
  `VERSION_KEY`
  Key to store the version in the commit data, which increments every time we open a new NRT reader

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Node(int id, Directory dir, SearcherFactory searcherFactory, PrintStream printStream)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String`
  `bytesToString(long bytes)`
  `abstract void`
  `commit()`
  `long`
  `getCurrentSearchingVersion()`
  `Directory`
  `getDirectory()`
  Returns the `Directory` this node is writing to
  `ReferenceManager<IndexSearcher>`
  `getSearcherManager()`
  Returns the `ReferenceManager` to use for acquiring and releasing searchers
  `abstract boolean`
  `isClosed()`
  `boolean`
  `isVerboseFiles()`
  `void`
  `message(String message)`
  `String`
  `name()`
  `static void`
  `nodeMessage(PrintStream printStream, int id, String message)`
  `static void`
  `nodeMessage(PrintStream printStream, String message)`
  `FileMetaData`
  `readLocalFileMetaData(String fileName)`
  Opens the specified file, reads its identifying information, including file length, full index header (includes the unique segment ID) and the full footer (includes checksum), and returns the resulting `FileMetaData`.
  `void`
  `setVerboseFiles(boolean verboseFiles)`
  `String`
  `toString()`

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

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

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

  `close`

- ## Field Details

  - ### PRIMARY_GEN_KEY

    public static final String PRIMARY_GEN_KEY
    Key to store the primary gen in the commit data, which increments every time we promote a new primary, so replicas can detect when the primary they were talking to is changed
    See Also:
      - Constant Field Values

  - ### VERSION_KEY

    public static final String VERSION_KEY
    Key to store the version in the commit data, which increments every time we open a new NRT reader
    See Also:
      - Constant Field Values

  - ### id

    protected final int id
    Compact ordinal for this node

  - ### dir

    protected final Directory dir

  - ### searcherFactory

    protected final SearcherFactory searcherFactory

  - ### mgr

    protected ReferenceManager<IndexSearcher> mgr

  - ### globalStartNS

    public static long globalStartNS
    Startup time of original test, carefully propagated to all nodes to produce consistent "seconds since start time" in messages

  - ### localStartNS

    public static final long localStartNS
    When this node was started

  - ### printStream

    protected final PrintStream printStream
    For debug logging

  - ### lastFileMetaData

    protected volatile Map<String,FileMetaData> lastFileMetaData
    File metadata for last sync that succeeded; we use this as a cache

- ## Constructor Details

  - ### Node

    public Node(int id, Directory dir, SearcherFactory searcherFactory, PrintStream printStream)

- ## Method Details

  - ### getSearcherManager

    public ReferenceManager<IndexSearcher> getSearcherManager()
    Returns the `ReferenceManager` to use for acquiring and releasing searchers

  - ### getDirectory

    public Directory getDirectory()
    Returns the `Directory` this node is writing to

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### commit

    public abstract void commit() throws IOException
    Throws:
      `IOException`

  - ### nodeMessage

    public static void nodeMessage(PrintStream printStream, String message)

  - ### nodeMessage

    public static void nodeMessage(PrintStream printStream, int id, String message)

  - ### message

    public void message(String message)

  - ### name

    public String name()

  - ### isClosed

    public abstract boolean isClosed()

  - ### getCurrentSearchingVersion

    public long getCurrentSearchingVersion() throws IOException
    Throws:
      `IOException`

  - ### bytesToString

    public static String bytesToString(long bytes)

  - ### readLocalFileMetaData

    public FileMetaData readLocalFileMetaData(String fileName) throws IOException
    Opens the specified file, reads its identifying information, including file length, full index header (includes the unique segment ID) and the full footer (includes checksum), and returns the resulting `FileMetaData`.

    This returns null, logging a message, if there are any problems (the file does not exist, is corrupt, truncated, etc.).

    Throws:
      `IOException`

  - ### isVerboseFiles

    public boolean isVerboseFiles()

  - ### setVerboseFiles

    public void setVerboseFiles(boolean verboseFiles)