PoolAlignmentContext (Apache Hadoop HDFS-RBF 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.server.federation.router, class: PoolAlignmentContext

Package org.apache.hadoop.hdfs.server.federation.router

# Class PoolAlignmentContext

java.lang.Object
org.apache.hadoop.hdfs.server.federation.router.PoolAlignmentContext

All Implemented Interfaces:
  `org.apache.hadoop.ipc.AlignmentContext`

public class PoolAlignmentContext extends Object implements org.apache.hadoop.ipc.AlignmentContext
An alignment context shared by all connections in a `ConnectionPool`. There is a distinct connection pool for each [namespace,UGI] pairing.

`sharedGlobalStateId` is a reference to a shared `LongAccumulator` object in the `RouterStateIdContext`. `poolLocalStateId` is specific to each PoolAlignmentContext.

The shared `sharedGlobalStateId` is updated only using responses from NameNodes, so clients cannot poison it. `poolLocalStateId` is used to propagate client observed state into NameNode requests. A misbehaving client can poison this but the effect is only visible to other clients with the same UGI and accessing the same namespace.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `advanceClientStateId(Long clientStateId)`
  `long`
  `getLastSeenStateId()`
  `long`
  `getPoolLocalStateId()`
  `boolean`
  `isCoordinatedCall(String protocolName, String method)`
  `long`
  `receiveRequestState(org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcRequestHeaderProto header, long threshold)`
  Client side implementation only provides state alignment info in requests.
  `void`
  `receiveResponseState(org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcResponseHeaderProto header)`
  Router updates a globally shared value using response from namenodes.
  `void`
  `updateRequestState(org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcRequestHeaderProto.Builder header)`
  Client side implementation for routers to provide state info in requests to namenodes.
  `void`
  `updateResponseState(org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcResponseHeaderProto.Builder header)`
  Client side implementation only receives state alignment info.

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

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

- ## Method Details

  - ### updateResponseState

    public void updateResponseState(org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcResponseHeaderProto.Builder header)
    Client side implementation only receives state alignment info. It does not provide state alignment info therefore this does nothing.
    Specified by:
      `updateResponseState` in interface `org.apache.hadoop.ipc.AlignmentContext`

  - ### receiveResponseState

    public void receiveResponseState(org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcResponseHeaderProto header)
    Router updates a globally shared value using response from namenodes.
    Specified by:
      `receiveResponseState` in interface `org.apache.hadoop.ipc.AlignmentContext`

  - ### updateRequestState

    public void updateRequestState(org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcRequestHeaderProto.Builder header)
    Client side implementation for routers to provide state info in requests to namenodes.
    Specified by:
      `updateRequestState` in interface `org.apache.hadoop.ipc.AlignmentContext`

  - ### receiveRequestState

    public long receiveRequestState(org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcRequestHeaderProto header, long threshold) throws IOException
    Client side implementation only provides state alignment info in requests. Client does not receive RPC requests therefore this does nothing.
    Specified by:
      `receiveRequestState` in interface `org.apache.hadoop.ipc.AlignmentContext`
    Throws:
      `IOException`

  - ### getLastSeenStateId

    public long getLastSeenStateId()
    Specified by:
      `getLastSeenStateId` in interface `org.apache.hadoop.ipc.AlignmentContext`

  - ### isCoordinatedCall

    public boolean isCoordinatedCall(String protocolName, String method)
    Specified by:
      `isCoordinatedCall` in interface `org.apache.hadoop.ipc.AlignmentContext`

  - ### advanceClientStateId

    public void advanceClientStateId(Long clientStateId)

  - ### getPoolLocalStateId

    @VisibleForTesting public long getPoolLocalStateId()