Class Node

java.lang.Object
com.aerospike.client.cluster.Node
All Implemented Interfaces:
Closeable, AutoCloseable

public class Node extends Object implements Closeable
Server node representation. This class manages server node connections and health status.
  • Field Details

  • Constructor Details

    • Node

      public Node(com.aerospike.client.cluster.Cluster cluster, com.aerospike.client.cluster.NodeValidator nv)
      Initialize server node with connection parameters.
      Parameters:
      cluster - collection of active server nodes
      nv - connection parameters
  • Method Details

    • createMinConnections

      public final void createMinConnections()
    • refresh

      public final void refresh(com.aerospike.client.cluster.Peers peers)
      Request current status from server node.
    • signalLogin

      public final void signalLogin()
    • getConnection

      public final com.aerospike.client.cluster.Connection getConnection(int timeoutMillis)
      Get a socket connection from connection pool to the server node.
    • getConnection

      public final com.aerospike.client.cluster.Connection getConnection(int connectTimeout, int socketTimeout)
      Get a socket connection from connection pool to the server node.
    • getConnection

      public final com.aerospike.client.cluster.Connection getConnection(com.aerospike.client.command.SyncCommand cmd, int connectTimeout, int socketTimeout, int timeoutDelay)
      Get a socket connection from connection pool to the server node.
    • putConnection

      public final void putConnection(com.aerospike.client.cluster.Connection conn)
      Put connection back into connection pool.
      Parameters:
      conn - socket connection
    • closeConnection

      public final void closeConnection(com.aerospike.client.cluster.Connection conn)
      Close pooled connection on error and decrement connection count.
    • closeConnectionOnError

      public final void closeConnectionOnError(com.aerospike.client.cluster.Connection conn)
      Close any connection on error.
    • closeIdleConnection

      public final void closeIdleConnection(com.aerospike.client.cluster.Connection conn)
      Close connection without incrementing error count.
    • getConnectionStats

      public final ConnectionStats getConnectionStats()
    • getAsyncConnection

      public final com.aerospike.client.async.AsyncConnection getAsyncConnection(int index, ByteBuffer byteBuffer)
    • reserveAsyncConnectionSlot

      public final boolean reserveAsyncConnectionSlot(int index)
    • connectionOpened

      public final void connectionOpened(int index)
    • putAsyncConnection

      public final boolean putAsyncConnection(com.aerospike.client.async.AsyncConnection conn, int index)
    • closeAsyncConnection

      public final void closeAsyncConnection(com.aerospike.client.async.AsyncConnection conn, int index)
      Close async connection on error.
    • closeAsyncIdleConnection

      public final void closeAsyncIdleConnection(com.aerospike.client.async.AsyncConnection conn, int index)
      Close async connection without incrementing error count.
    • decrAsyncConnection

      public final void decrAsyncConnection(int index)
    • getAsyncPool

      public final Node.AsyncPool getAsyncPool(int index)
    • balanceAsyncConnections

      public final void balanceAsyncConnections(EventLoop eventLoop)
    • getAsyncConnectionStats

      public final ConnectionStats getAsyncConnectionStats()
    • enableMetrics

      public final void enableMetrics(com.aerospike.client.metrics.MetricsPolicy policy)
    • getMetrics

      public final com.aerospike.client.metrics.NodeMetrics getMetrics()
    • addLatency

      public final void addLatency(com.aerospike.client.metrics.LatencyType type, long elapsed)
      Add elapsed time in nanoseconds to latency buckets corresponding to latency type.
    • incrErrorRate

      public final void incrErrorRate()
    • resetErrorRate

      public final void resetErrorRate()
    • errorRateWithinLimit

      public final boolean errorRateWithinLimit()
    • validateErrorCount

      public final void validateErrorCount()
    • addError

      public void addError()
      Increment transaction error count. If the error is retryable, multiple errors per transaction may occur.
    • addTimeout

      public void addTimeout()
      Increment transaction timeout count. If the timeout is retryable (ie socketTimeout), multiple timeouts per transaction may occur.
    • getErrorCount

      public long getErrorCount()
      Return transaction error count. The value is cumulative and not reset per metrics interval.
    • getTimeoutCount

      public long getTimeoutCount()
      Return transaction timeout count. The value is cumulative and not reset per metrics interval.
    • getHost

      public final Host getHost()
      Return server node IP address and port.
    • isActive

      public final boolean isActive()
      Return whether node is currently active.
    • getName

      public final String getName()
      Return server node name.
    • getAddress

      public final InetSocketAddress getAddress()
      Return node IP address.
    • getSessionToken

      public final byte[] getSessionToken()
      Return node session token.
    • getPeersGeneration

      public final int getPeersGeneration()
      Return current generation of cluster peers.
    • getPartitionGeneration

      public final int getPartitionGeneration()
      Return current generation of partition maps.
    • getRebalanceGeneration

      public final int getRebalanceGeneration()
      Return current generation of racks.
    • hasRack

      public final boolean hasRack(String namespace, int rackId)
      Return if this node has the same rack as the client for the given namespace.
    • hasQueryShow

      public final boolean hasQueryShow()
    • hasBatchAny

      public final boolean hasBatchAny()
    • hasPartitionQuery

      public final boolean hasPartitionQuery()
    • toString

      public final String toString()
      Does server support partition scans.
      Overrides:
      toString in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • close

      public final void close()
      Close all socket connections.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • closeConnections

      public final void closeConnections(AtomicInteger eventLoopCount, int index)
      Close all node socket connections from event loop. Must be called from event loop thread.
    • closeAsyncConnections

      public final void closeAsyncConnections(int index)
      Close asynchronous connections. Must be called from event loop thread.
    • closeSyncConnections

      public final void closeSyncConnections()
      Close synchronous connections.