HBASE-3808 Implement Executor.toString for master handlers at least

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1132466 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2011-06-05 18:02:34 +00:00
parent 64f6fb52dc
commit 06eba7a579
14 changed files with 132 additions and 3 deletions

View File

@ -239,6 +239,8 @@ Release 0.91.0 - Unreleased
HBASE-2556 Add convenience method to HBaseAdmin to get a collection of
HRegionInfo objects for each table (Ming Ma)
HBASE-3592 Guava snuck back in as a dependency via hbase-3777
HBASE-3808 Implement Executor.toString for master handlers at least
(Brock Noland)
TASKS
HBASE-3559 Move report of split to master OFF the heartbeat channel

View File

@ -27,6 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -188,7 +189,7 @@ public class ExecutorService {
List<Runnable> wasRunning =
entry.getValue().threadPoolExecutor.shutdownNow();
if (!wasRunning.isEmpty()) {
LOG.info(entry.getKey() + " had " + wasRunning + " on shutdown");
LOG.info(entry.getValue() + " had " + wasRunning + " on shutdown");
}
}
this.executorMap.clear();
@ -255,9 +256,12 @@ public class ExecutorService {
final BlockingQueue<Runnable> q = new LinkedBlockingQueue<Runnable>();
private final String name;
private final Map<EventHandler.EventType, EventHandlerListener> eventHandlerListeners;
private static final AtomicLong seqids = new AtomicLong(0);
private final long id;
protected Executor(String name, int maxThreads,
final Map<EventHandler.EventType, EventHandlerListener> eventHandlerListeners) {
this.id = seqids.incrementAndGet();
this.name = name;
this.eventHandlerListeners = eventHandlerListeners;
// create the thread pool executor
@ -283,5 +287,9 @@ public class ExecutorService {
}
this.threadPoolExecutor.execute(event);
}
public String toString() {
return getClass().getSimpleName() + "-" + id + "-" + name;
}
}
}

View File

@ -78,6 +78,15 @@ public class ClosedRegionHandler extends EventHandler implements TotesHRegionInf
return this.regionInfo;
}
@Override
public String toString() {
String name = "UnknownServerName";
if(server != null && server.getServerName() != null) {
name = server.getServerName().toString();
}
return getClass().getSimpleName() + "-" + name + "-" + getSeqid();
}
@Override
public void process() {
LOG.debug("Handling CLOSED event for " + regionInfo.getEncodedName());

View File

@ -75,4 +75,13 @@ public class DeleteTableHandler extends TableEventHandler {
// Call to undisableTable does this. TODO: Make a more formal purge table.
am.getZKTable().setEnabledTable(Bytes.toString(tableName));
}
@Override
public String toString() {
String name = "UnknownServerName";
if(server != null && server.getServerName() != null) {
name = server.getServerName().toString();
}
return getClass().getSimpleName() + "-" + name + "-" + getSeqid() + "-" + tableNameStr;
}
}

View File

@ -61,6 +61,15 @@ public class DisableTableHandler extends EventHandler {
}
}
@Override
public String toString() {
String name = "UnknownServerName";
if(server != null && server.getServerName() != null) {
name = server.getServerName().toString();
}
return getClass().getSimpleName() + "-" + name + "-" + getSeqid() + "-" + tableNameStr;
}
@Override
public void process() {
try {

View File

@ -60,6 +60,15 @@ public class EnableTableHandler extends EventHandler {
}
}
@Override
public String toString() {
String name = "UnknownServerName";
if(server != null && server.getServerName() != null) {
name = server.getServerName().toString();
}
return getClass().getSimpleName() + "-" + name + "-" + getSeqid() + "-" + tableNameStr;
}
@Override
public void process() {
try {

View File

@ -50,4 +50,13 @@ public class MetaServerShutdownHandler extends ServerShutdownHandler {
boolean isCarryingMeta() {
return this.carryingMeta;
}
@Override
public String toString() {
String name = "UnknownServerName";
if(server != null && server.getServerName() != null) {
name = server.getServerName().toString();
}
return getClass().getSimpleName() + "-" + name + "-" + getSeqid();
}
}

View File

@ -49,4 +49,12 @@ public class ModifyTableHandler extends TableEventHandler {
this.masterServices.getMasterFileSystem().updateRegionInfo(hri);
}
}
@Override
public String toString() {
String name = "UnknownServerName";
if(server != null && server.getServerName() != null) {
name = server.getServerName().toString();
}
return getClass().getSimpleName() + "-" + name + "-" + getSeqid() + "-" + tableNameStr;
}
}

View File

@ -79,6 +79,15 @@ public class OpenedRegionHandler extends EventHandler implements TotesHRegionInf
return this.regionInfo;
}
@Override
public String toString() {
String name = "UnknownServerName";
if(server != null && server.getServerName() != null) {
name = server.getServerName().toString();
}
return getClass().getSimpleName() + "-" + name + "-" + getSeqid();
}
@Override
public void process() {
LOG.debug("Handling OPENED event for " + this.regionInfo.getEncodedName() +

View File

@ -52,7 +52,6 @@ import org.apache.zookeeper.KeeperException;
public class ServerShutdownHandler extends EventHandler {
private static final Log LOG = LogFactory.getLog(ServerShutdownHandler.class);
private final ServerName serverName;
private final Server server;
private final MasterServices services;
private final DeadServer deadServers;
@ -107,6 +106,15 @@ public class ServerShutdownHandler extends EventHandler {
return false;
}
@Override
public String toString() {
String name = "UnknownServerName";
if(server != null && server.getServerName() != null) {
name = server.getServerName().toString();
}
return getClass().getSimpleName() + "-" + name + "-" + getSeqid();
}
@Override
public void process() throws IOException {
final ServerName serverName = this.serverName;

View File

@ -60,6 +60,19 @@ public class SplitRegionHandler extends EventHandler implements TotesHRegionInfo
return this.parent;
}
@Override
public String toString() {
String name = "UnknownServerName";
if(server != null && server.getServerName() != null) {
name = server.getServerName().toString();
}
String parentRegion = "UnknownRegion";
if(parent != null) {
parentRegion = parent.getRegionNameAsString();
}
return getClass().getSimpleName() + "-" + name + "-" + getSeqid() + "-" + parentRegion;
}
@Override
public void process() {
LOG.debug("Handling SPLIT event for " + this.parent.getEncodedName() +

View File

@ -63,4 +63,16 @@ public class TableAddFamilyHandler extends TableEventHandler {
this.masterServices.getMasterFileSystem().updateRegionInfo(hri);
}
}
@Override
public String toString() {
String name = "UnknownServerName";
if(server != null && server.getServerName() != null) {
name = server.getServerName().toString();
}
String family = "UnknownFamily";
if(familyDesc != null) {
family = familyDesc.getNameAsString();
}
return getClass().getSimpleName() + "-" + name + "-" + getSeqid() + "-" + tableNameStr + "-" + family;
}
}

View File

@ -66,4 +66,16 @@ public class TableDeleteFamilyHandler extends TableEventHandler {
this.masterServices.getMasterFileSystem().updateRegionInfo(hri);
}
}
@Override
public String toString() {
String name = "UnknownServerName";
if(server != null && server.getServerName() != null) {
name = server.getServerName().toString();
}
String family = "UnknownFamily";
if(familyName != null) {
family = Bytes.toString(familyName);
}
return getClass().getSimpleName() + "-" + name + "-" + getSeqid() + "-" + tableNameStr + "-" + family;
}
}

View File

@ -62,4 +62,16 @@ public class TableModifyFamilyHandler extends TableEventHandler {
this.masterServices.getMasterFileSystem().updateRegionInfo(hri);
}
}
@Override
public String toString() {
String name = "UnknownServerName";
if(server != null && server.getServerName() != null) {
name = server.getServerName().toString();
}
String family = "UnknownFamily";
if(familyDesc != null) {
family = familyDesc.getNameAsString();
}
return getClass().getSimpleName() + "-" + name + "-" + getSeqid() + "-" + tableNameStr + "-" + family;
}
}