org.apache.hadoop.hbase.regionserver
Class SplitLogWorker

java.lang.Object
  extended by org.apache.hadoop.hbase.zookeeper.ZooKeeperListener
      extended by org.apache.hadoop.hbase.regionserver.SplitLogWorker
All Implemented Interfaces:
Runnable

@InterfaceAudience.Private
public class SplitLogWorker
extends ZooKeeperListener
implements Runnable

This worker is spawned in every regionserver (should we also spawn one in the master?). The Worker waits for log splitting tasks to be put up by the SplitLogManager running in the master and races with other workers in other serves to acquire those tasks. The coordination is done via zookeeper. All the action takes place at /hbase/splitlog znode.

If a worker has successfully moved the task from state UNASSIGNED to OWNED then it owns the task. It keeps heart beating the manager by periodically moving the task from UNASSIGNED to OWNED state. On success it moves the task to TASK_DONE. On unrecoverable error it moves task state to ERR. If it cannot continue but wants the master to retry the task then it moves the task state to RESIGNED.

The manager can take a task away from a worker by moving the task from OWNED to UNASSIGNED. In the absence of a global lock there is a unavoidable race here - a worker might have just finished its task when it is stripped of its ownership. Here we rely on the idempotency of the log splitting task for correctness


Nested Class Summary
static interface SplitLogWorker.TaskExecutor
          Objects implementing this interface actually do the task that has been acquired by a SplitLogWorker.
 
Field Summary
static int DEFAULT_MAX_SPLITTERS
           
protected  AtomicInteger tasksInProgress
           
 
Fields inherited from class org.apache.hadoop.hbase.zookeeper.ZooKeeperListener
watcher
 
Constructor Summary
SplitLogWorker(ZooKeeperWatcher watcher, org.apache.hadoop.conf.Configuration conf, RegionServerServices server, LastSequenceId sequenceIdChecker)
           
SplitLogWorker(ZooKeeperWatcher watcher, org.apache.hadoop.conf.Configuration conf, RegionServerServices server, SplitLogWorker.TaskExecutor splitTaskExecutor)
           
 
Method Summary
protected static int attemptToOwnTask(boolean isFirstTime, ZooKeeperWatcher zkw, ServerName server, String task, ZooKeeperProtos.SplitLogTask.RecoveryMode mode, int taskZKVersion)
          Try to own the task by transitioning the zk node data from UNASSIGNED to OWNED.
 void nodeChildrenChanged(String path)
          Called when an existing node has a child node added or removed.
 void nodeDataChanged(String path)
          Called when an existing node has changed data.
 void run()
           
 void start()
          start the SplitLogWorker thread
 void stop()
          stop the SplitLogWorker thread
 
Methods inherited from class org.apache.hadoop.hbase.zookeeper.ZooKeeperListener
getWatcher, nodeCreated, nodeDeleted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_SPLITTERS

public static final int DEFAULT_MAX_SPLITTERS
See Also:
Constant Field Values

tasksInProgress

protected final AtomicInteger tasksInProgress
Constructor Detail

SplitLogWorker

public SplitLogWorker(ZooKeeperWatcher watcher,
                      org.apache.hadoop.conf.Configuration conf,
                      RegionServerServices server,
                      SplitLogWorker.TaskExecutor splitTaskExecutor)

SplitLogWorker

public SplitLogWorker(ZooKeeperWatcher watcher,
                      org.apache.hadoop.conf.Configuration conf,
                      RegionServerServices server,
                      LastSequenceId sequenceIdChecker)
Method Detail

run

public void run()
Specified by:
run in interface Runnable

attemptToOwnTask

protected static int attemptToOwnTask(boolean isFirstTime,
                                      ZooKeeperWatcher zkw,
                                      ServerName server,
                                      String task,
                                      ZooKeeperProtos.SplitLogTask.RecoveryMode mode,
                                      int taskZKVersion)
Try to own the task by transitioning the zk node data from UNASSIGNED to OWNED.

This method is also used to periodically heartbeat the task progress by transitioning the node from OWNED to OWNED.

Parameters:
isFirstTime -
zkw -
server -
task -
taskZKVersion -
Returns:
non-negative integer value when task can be owned by current region server otherwise -1

nodeDataChanged

public void nodeDataChanged(String path)
Description copied from class: ZooKeeperListener
Called when an existing node has changed data.

Overrides:
nodeDataChanged in class ZooKeeperListener
Parameters:
path - full path of the updated node

nodeChildrenChanged

public void nodeChildrenChanged(String path)
Description copied from class: ZooKeeperListener
Called when an existing node has a child node added or removed.

Overrides:
nodeChildrenChanged in class ZooKeeperListener
Parameters:
path - full path of the node whose children have changed

start

public void start()
start the SplitLogWorker thread


stop

public void stop()
stop the SplitLogWorker thread



Copyright © 2007–2015 The Apache Software Foundation. All rights reserved.