@InterfaceAudience.Private @InterfaceStability.Evolving public class MasterProcedureScheduler extends Object implements ProcedureRunnableSet
Each procedure should implement an interface providing information for this queue. for example table related procedures should implement TableProcedureInterface. each procedure will be pushed in its own queue, and based on the operation type we may take smarter decision. e.g. we can abort all the operations preceding a delete table, or similar.
Modifier and Type | Class and Description |
---|---|
private static class |
MasterProcedureScheduler.AvlTree |
private static class |
MasterProcedureScheduler.FairQueue<T extends Comparable<T>> |
private static class |
MasterProcedureScheduler.IterableList |
static class |
MasterProcedureScheduler.ProcedureEvent |
private static class |
MasterProcedureScheduler.Queue<TKey extends Comparable<TKey>> |
private static class |
MasterProcedureScheduler.QueueImpl<TKey extends Comparable<TKey>> |
private static interface |
MasterProcedureScheduler.QueueInterface |
static class |
MasterProcedureScheduler.ServerQueue |
static class |
MasterProcedureScheduler.TableQueue |
Modifier and Type | Field and Description |
---|---|
private TableLockManager |
lockManager |
private static org.apache.commons.logging.Log |
LOG |
private int |
metaTablePriority |
private MasterProcedureScheduler.Queue<String> |
namespaceMap |
private long |
nullPollCalls |
private long |
pollCalls |
private int |
queueSize |
private ReentrantLock |
schedLock |
private Condition |
schedWaitCond |
private Object[] |
serverBuckets |
private MasterProcedureScheduler.FairQueue<ServerName> |
serverRunQueue |
private int |
sysTablePriority |
private MasterProcedureScheduler.Queue<TableName> |
tableMap |
private MasterProcedureScheduler.FairQueue<TableName> |
tableRunQueue |
private int |
userTablePriority |
Constructor and Description |
---|
MasterProcedureScheduler(org.apache.hadoop.conf.Configuration conf,
TableLockManager lockManager) |
Modifier and Type | Method and Description |
---|---|
void |
addBack(Procedure proc)
Inserts the specified element at the end of this queue.
|
void |
addFront(Procedure proc)
Inserts the specified element at the front of this queue.
|
private <T extends Comparable<T>> |
addToRunQueue(MasterProcedureScheduler.FairQueue<T> fairq,
MasterProcedureScheduler.Queue<T> queue) |
void |
clear()
Removes all of the elements from this collection.
|
private <T extends Comparable<T>> |
clear(MasterProcedureScheduler.Queue<T> treeMap,
MasterProcedureScheduler.FairQueue<T> fairq) |
void |
completionCleanup(Procedure proc)
The procedure in execution completed.
|
private <T extends Comparable<T>> |
doAdd(MasterProcedureScheduler.FairQueue<T> fairq,
MasterProcedureScheduler.Queue<T> queue,
Procedure proc,
boolean addFront) |
private void |
doAdd(Procedure proc,
boolean addFront) |
private <T extends Comparable<T>> |
doPoll(MasterProcedureScheduler.FairQueue<T> fairq) |
private static int |
getBucketIndex(Object[] buckets,
int hashCode) |
long |
getNullPollCalls() |
long |
getPollCalls() |
private static ServerName |
getServerName(Procedure proc) |
private MasterProcedureScheduler.ServerQueue |
getServerQueue(ServerName serverName) |
private MasterProcedureScheduler.ServerQueue |
getServerQueueWithLock(ServerName serverName) |
private static TableName |
getTableName(Procedure proc) |
private int |
getTablePriority(TableName tableName) |
private MasterProcedureScheduler.TableQueue |
getTableQueue(TableName tableName) |
private MasterProcedureScheduler.TableQueue |
getTableQueueWithLock(TableName tableName) |
private static <T extends Comparable<T>> |
getTreeRoot(Object[] buckets,
int index) |
private static boolean |
isServerProcedure(Procedure proc) |
private static boolean |
isTableProcedure(Procedure proc) |
protected boolean |
markTableAsDeleted(TableName table)
Tries to remove the queue and the table-lock of the specified table.
|
Procedure |
poll()
Fetch one Procedure from the queue
|
(package private) Procedure |
poll(long waitNsec) |
void |
releaseServerExclusiveLock(Procedure procedure,
ServerName serverName)
Release the exclusive lock
|
void |
releaseServerSharedLock(Procedure procedure,
ServerName serverName)
Release the shared lock taken
|
void |
releaseTableExclusiveLock(Procedure procedure,
TableName table)
Release the exclusive lock taken with tryAcquireTableWrite()
|
void |
releaseTableSharedLock(Procedure procedure,
TableName table)
Release the shared lock taken with tryAcquireTableRead()
|
private <T extends Comparable<T>> |
removeFromRunQueue(MasterProcedureScheduler.FairQueue<T> fairq,
MasterProcedureScheduler.Queue<T> queue) |
private void |
removeServerQueue(ServerName serverName) |
private void |
removeTableQueue(TableName tableName) |
void |
signalAll()
In case the class is blocking on poll() waiting for items to be added,
this method should awake poll() and poll() should return.
|
int |
size()
Returns the number of elements in this collection.
|
void |
suspend(MasterProcedureScheduler.ProcedureEvent event) |
private void |
suspendServerQueue(MasterProcedureScheduler.ProcedureEvent event,
ServerName serverName) |
private void |
suspendTableQueue(MasterProcedureScheduler.ProcedureEvent event,
TableName tableName) |
boolean |
tryAcquireServerExclusiveLock(Procedure procedure,
ServerName serverName)
Try to acquire the exclusive lock on the specified server.
|
boolean |
tryAcquireServerSharedLock(Procedure procedure,
ServerName serverName)
Try to acquire the shared lock on the specified server.
|
boolean |
tryAcquireTableExclusiveLock(Procedure procedure,
TableName table)
Try to acquire the exclusive lock on the specified table.
|
private MasterProcedureScheduler.TableQueue |
tryAcquireTableQueueSharedLock(Procedure procedure,
TableName table) |
boolean |
tryAcquireTableSharedLock(Procedure procedure,
TableName table)
Try to acquire the shared lock on the specified table.
|
boolean |
waitEvent(MasterProcedureScheduler.ProcedureEvent event,
Procedure procedure) |
boolean |
waitEvent(MasterProcedureScheduler.ProcedureEvent event,
Procedure procedure,
boolean suspendQueue) |
void |
wake(MasterProcedureScheduler.ProcedureEvent event) |
void |
yield(Procedure proc)
The procedure can't run at the moment.
|
private static final org.apache.commons.logging.Log LOG
private final TableLockManager lockManager
private final ReentrantLock schedLock
private final Condition schedWaitCond
private final MasterProcedureScheduler.FairQueue<ServerName> serverRunQueue
private final MasterProcedureScheduler.FairQueue<TableName> tableRunQueue
private int queueSize
private final Object[] serverBuckets
private MasterProcedureScheduler.Queue<String> namespaceMap
private MasterProcedureScheduler.Queue<TableName> tableMap
private final int metaTablePriority
private final int userTablePriority
private final int sysTablePriority
private long pollCalls
private long nullPollCalls
public MasterProcedureScheduler(org.apache.hadoop.conf.Configuration conf, TableLockManager lockManager)
public void addFront(Procedure proc)
ProcedureRunnableSet
addFront
in interface ProcedureRunnableSet
proc
- the Procedure to addpublic void addBack(Procedure proc)
ProcedureRunnableSet
addBack
in interface ProcedureRunnableSet
proc
- the Procedure to addpublic void yield(Procedure proc)
ProcedureRunnableSet
yield
in interface ProcedureRunnableSet
proc
- the Procedure to add back to the listprivate void doAdd(Procedure proc, boolean addFront)
private <T extends Comparable<T>> void doAdd(MasterProcedureScheduler.FairQueue<T> fairq, MasterProcedureScheduler.Queue<T> queue, Procedure proc, boolean addFront)
public Procedure poll()
ProcedureRunnableSet
poll
in interface ProcedureRunnableSet
Procedure poll(long waitNsec)
private <T extends Comparable<T>> Procedure doPoll(MasterProcedureScheduler.FairQueue<T> fairq)
public void clear()
ProcedureRunnableSet
clear
in interface ProcedureRunnableSet
private <T extends Comparable<T>> void clear(MasterProcedureScheduler.Queue<T> treeMap, MasterProcedureScheduler.FairQueue<T> fairq)
public void signalAll()
ProcedureRunnableSet
signalAll
in interface ProcedureRunnableSet
public int size()
ProcedureRunnableSet
size
in interface ProcedureRunnableSet
public void completionCleanup(Procedure proc)
ProcedureRunnableSet
completionCleanup
in interface ProcedureRunnableSet
proc
- the Procedure that completed the execution.private <T extends Comparable<T>> void addToRunQueue(MasterProcedureScheduler.FairQueue<T> fairq, MasterProcedureScheduler.Queue<T> queue)
private <T extends Comparable<T>> void removeFromRunQueue(MasterProcedureScheduler.FairQueue<T> fairq, MasterProcedureScheduler.Queue<T> queue)
public long getPollCalls()
public long getNullPollCalls()
public boolean waitEvent(MasterProcedureScheduler.ProcedureEvent event, Procedure procedure)
public boolean waitEvent(MasterProcedureScheduler.ProcedureEvent event, Procedure procedure, boolean suspendQueue)
private void suspendTableQueue(MasterProcedureScheduler.ProcedureEvent event, TableName tableName)
private void suspendServerQueue(MasterProcedureScheduler.ProcedureEvent event, ServerName serverName)
public void suspend(MasterProcedureScheduler.ProcedureEvent event)
public void wake(MasterProcedureScheduler.ProcedureEvent event)
private MasterProcedureScheduler.TableQueue getTableQueueWithLock(TableName tableName)
private MasterProcedureScheduler.TableQueue getTableQueue(TableName tableName)
private void removeTableQueue(TableName tableName)
private int getTablePriority(TableName tableName)
private static boolean isTableProcedure(Procedure proc)
private MasterProcedureScheduler.ServerQueue getServerQueueWithLock(ServerName serverName)
private MasterProcedureScheduler.ServerQueue getServerQueue(ServerName serverName)
private void removeServerQueue(ServerName serverName)
private static <T extends Comparable<T>> MasterProcedureScheduler.Queue<T> getTreeRoot(Object[] buckets, int index)
private static int getBucketIndex(Object[] buckets, int hashCode)
private static boolean isServerProcedure(Procedure proc)
private static ServerName getServerName(Procedure proc)
public boolean tryAcquireTableExclusiveLock(Procedure procedure, TableName table)
procedure
- the procedure trying to acquire the locktable
- Table to lockpublic void releaseTableExclusiveLock(Procedure procedure, TableName table)
procedure
- the procedure releasing the locktable
- the name of the table that has the exclusive lockpublic boolean tryAcquireTableSharedLock(Procedure procedure, TableName table)
procedure
- the procedure trying to acquire the locktable
- Table to lockprivate MasterProcedureScheduler.TableQueue tryAcquireTableQueueSharedLock(Procedure procedure, TableName table)
public void releaseTableSharedLock(Procedure procedure, TableName table)
procedure
- the procedure releasing the locktable
- the name of the table that has the shared lockprotected boolean markTableAsDeleted(TableName table)
table
- the name of the table that should be marked as deletedpublic boolean tryAcquireServerExclusiveLock(Procedure procedure, ServerName serverName)
procedure
- the procedure trying to acquire the lockserverName
- Server to lockreleaseServerExclusiveLock(Procedure,ServerName)
public void releaseServerExclusiveLock(Procedure procedure, ServerName serverName)
procedure
- the procedure releasing the lockserverName
- the server that has the exclusive locktryAcquireServerExclusiveLock(Procedure,ServerName)
public boolean tryAcquireServerSharedLock(Procedure procedure, ServerName serverName)
procedure
- the procedure releasing the lockserverName
- Server to lockreleaseServerSharedLock(Procedure,ServerName)
public void releaseServerSharedLock(Procedure procedure, ServerName serverName)
procedure
- the procedure releasing the lockserverName
- the server that has the shared locktryAcquireServerSharedLock(Procedure,ServerName)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.