org.apache.hadoop.hbase.monitoring
Class MonitoredRPCHandlerImpl

java.lang.Object
  extended by org.apache.hadoop.hbase.monitoring.MonitoredRPCHandlerImpl
All Implemented Interfaces:
Cloneable, MonitoredRPCHandler, MonitoredTask

@InterfaceAudience.Private
public class MonitoredRPCHandlerImpl
extends Object
implements MonitoredRPCHandler

A MonitoredTask implementation designed for use with RPC Handlers handling frequent, short duration tasks. String concatenations and object allocations are avoided in methods that will be hit by every RPC call.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.monitoring.MonitoredTask
MonitoredTask.State
 
Field Summary
protected  MonitoredTask.State state
           
 
Constructor Summary
MonitoredRPCHandlerImpl()
           
 
Method Summary
 void abort(String msg)
           
 void cleanup()
          Explicitly mark this status as able to be cleaned up, even though it might not be complete.
 MonitoredRPCHandlerImpl clone()
          Public exposure of Object.clone() in order to allow clients to easily capture current state.
 void expireNow()
          Force the completion timestamp backwards so that it expires now.
 String getClient()
          If an RPC call is currently running, produces a String representation of the connection from which it was received.
 long getCompletionTimestamp()
           
 String getDescription()
           
 String getRPC()
          Produces a string representation of the method currently being serviced by this Handler.
 String getRPC(boolean withParams)
          Produces a string representation of the method currently being serviced by this Handler.
 long getRPCPacketLength()
          Produces a string representation of the method currently being serviced by this Handler.
 long getRPCQueueTime()
          Accesses the queue time for the currently running RPC on the monitored Handler.
 long getRPCStartTime()
          Accesses the start time for the currently running RPC on the monitored Handler.
 long getStartTime()
           
 MonitoredTask.State getState()
           
 long getStateTime()
           
 String getStatus()
          Gets the status of this handler; if it is currently servicing an RPC, this status will include the RPC information.
 long getStatusTime()
           
 boolean isOperationRunning()
          Indicates to the client whether this task is monitoring a currently active RPC call to a database command.
 boolean isRPCRunning()
          Indicates to the client whether this task is monitoring a currently active RPC call.
 void markComplete(String status)
           
 void pause(String msg)
           
 void resume(String msg)
           
 void setConnection(String clientAddress, int remotePort)
          Registers current handler client details.
 void setDescription(String description)
           
 void setRPC(String methodName, Object[] params, long queueTime)
          Tells this instance that it is monitoring a new RPC call.
 void setRPCPacket(com.google.protobuf.Message param)
          Gives this instance a reference to the protobuf received by the RPC, so that it can later compute its size if asked for it.
protected  void setState(MonitoredTask.State state)
           
 void setStatus(String status)
           
 String toJSON()
          Creates a JSON object for parseable exposure of monitored tasks.
 Map<String,Object> toMap()
          Creates a string map of internal details for extensible exposure of monitored tasks.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.hbase.monitoring.MonitoredTask
abort, cleanup, expireNow, getCompletionTimestamp, getDescription, getStartTime, getState, getStateTime, getStatusTime, pause, resume, setDescription, setStatus, toJSON
 

Field Detail

state

protected volatile MonitoredTask.State state
Constructor Detail

MonitoredRPCHandlerImpl

public MonitoredRPCHandlerImpl()
Method Detail

clone

public MonitoredRPCHandlerImpl clone()
Description copied from interface: MonitoredTask
Public exposure of Object.clone() in order to allow clients to easily capture current state.

Specified by:
clone in interface MonitoredTask
Returns:
a copy of the object whose references will not change

getStatus

public String getStatus()
Gets the status of this handler; if it is currently servicing an RPC, this status will include the RPC information.

Specified by:
getStatus in interface MonitoredTask
Returns:
a String describing the current status.

getRPCQueueTime

public long getRPCQueueTime()
Accesses the queue time for the currently running RPC on the monitored Handler.

Specified by:
getRPCQueueTime in interface MonitoredRPCHandler
Returns:
the queue timestamp or -1 if there is no RPC currently running.

getRPCStartTime

public long getRPCStartTime()
Accesses the start time for the currently running RPC on the monitored Handler.

Specified by:
getRPCStartTime in interface MonitoredRPCHandler
Returns:
the start timestamp or -1 if there is no RPC currently running.

getRPC

public String getRPC()
Produces a string representation of the method currently being serviced by this Handler.

Specified by:
getRPC in interface MonitoredRPCHandler
Returns:
a string representing the method call without parameters

getRPC

public String getRPC(boolean withParams)
Produces a string representation of the method currently being serviced by this Handler.

Specified by:
getRPC in interface MonitoredRPCHandler
Parameters:
withParams - toggle inclusion of parameters in the RPC String
Returns:
A human-readable string representation of the method call.

getRPCPacketLength

public long getRPCPacketLength()
Produces a string representation of the method currently being serviced by this Handler.

Specified by:
getRPCPacketLength in interface MonitoredRPCHandler
Returns:
A human-readable string representation of the method call.

getClient

public String getClient()
If an RPC call is currently running, produces a String representation of the connection from which it was received.

Specified by:
getClient in interface MonitoredRPCHandler
Returns:
A human-readable string representation of the address and port of the client.

isRPCRunning

public boolean isRPCRunning()
Indicates to the client whether this task is monitoring a currently active RPC call.

Specified by:
isRPCRunning in interface MonitoredRPCHandler
Returns:
true if the monitored handler is currently servicing an RPC call.

isOperationRunning

public boolean isOperationRunning()
Indicates to the client whether this task is monitoring a currently active RPC call to a database command. (as defined by o.a.h.h.client.Operation)

Specified by:
isOperationRunning in interface MonitoredRPCHandler
Returns:
true if the monitored handler is currently servicing an RPC call to a database command.

setRPC

public void setRPC(String methodName,
                   Object[] params,
                   long queueTime)
Tells this instance that it is monitoring a new RPC call.

Specified by:
setRPC in interface MonitoredRPCHandler
Parameters:
methodName - The name of the method that will be called by the RPC.
params - The parameters that will be passed to the indicated method.

setRPCPacket

public void setRPCPacket(com.google.protobuf.Message param)
Gives this instance a reference to the protobuf received by the RPC, so that it can later compute its size if asked for it.

Specified by:
setRPCPacket in interface MonitoredRPCHandler
Parameters:
param - The protobuf received by the RPC for this call

setConnection

public void setConnection(String clientAddress,
                          int remotePort)
Registers current handler client details.

Specified by:
setConnection in interface MonitoredRPCHandler
Parameters:
clientAddress - the address of the current client
remotePort - the port from which the client connected

markComplete

public void markComplete(String status)
Specified by:
markComplete in interface MonitoredTask

toMap

public Map<String,Object> toMap()
Description copied from interface: MonitoredTask
Creates a string map of internal details for extensible exposure of monitored tasks.

Specified by:
toMap in interface MonitoredTask
Returns:
A Map containing information for this task.

toString

public String toString()

getStartTime

public long getStartTime()
Specified by:
getStartTime in interface MonitoredTask

getDescription

public String getDescription()
Specified by:
getDescription in interface MonitoredTask

getStatusTime

public long getStatusTime()
Specified by:
getStatusTime in interface MonitoredTask

getState

public MonitoredTask.State getState()
Specified by:
getState in interface MonitoredTask

getStateTime

public long getStateTime()
Specified by:
getStateTime in interface MonitoredTask

getCompletionTimestamp

public long getCompletionTimestamp()
Specified by:
getCompletionTimestamp in interface MonitoredTask

pause

public void pause(String msg)
Specified by:
pause in interface MonitoredTask

resume

public void resume(String msg)
Specified by:
resume in interface MonitoredTask

abort

public void abort(String msg)
Specified by:
abort in interface MonitoredTask

setStatus

public void setStatus(String status)
Specified by:
setStatus in interface MonitoredTask

setState

protected void setState(MonitoredTask.State state)

setDescription

public void setDescription(String description)
Specified by:
setDescription in interface MonitoredTask

cleanup

public void cleanup()
Description copied from interface: MonitoredTask
Explicitly mark this status as able to be cleaned up, even though it might not be complete.

Specified by:
cleanup in interface MonitoredTask

expireNow

public void expireNow()
Force the completion timestamp backwards so that it expires now.

Specified by:
expireNow in interface MonitoredTask

toJSON

public String toJSON()
              throws IOException
Description copied from interface: MonitoredTask
Creates a JSON object for parseable exposure of monitored tasks.

Specified by:
toJSON in interface MonitoredTask
Returns:
An encoded JSON object containing information for this task.
Throws:
IOException


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.