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 HBASE-2556 Add convenience method to HBaseAdmin to get a collection of
HRegionInfo objects for each table (Ming Ma) HRegionInfo objects for each table (Ming Ma)
HBASE-3592 Guava snuck back in as a dependency via hbase-3777 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 TASKS
HBASE-3559 Move report of split to master OFF the heartbeat channel 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.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -188,7 +189,7 @@ public class ExecutorService {
List<Runnable> wasRunning = List<Runnable> wasRunning =
entry.getValue().threadPoolExecutor.shutdownNow(); entry.getValue().threadPoolExecutor.shutdownNow();
if (!wasRunning.isEmpty()) { if (!wasRunning.isEmpty()) {
LOG.info(entry.getKey() + " had " + wasRunning + " on shutdown"); LOG.info(entry.getValue() + " had " + wasRunning + " on shutdown");
} }
} }
this.executorMap.clear(); this.executorMap.clear();
@ -255,9 +256,12 @@ public class ExecutorService {
final BlockingQueue<Runnable> q = new LinkedBlockingQueue<Runnable>(); final BlockingQueue<Runnable> q = new LinkedBlockingQueue<Runnable>();
private final String name; private final String name;
private final Map<EventHandler.EventType, EventHandlerListener> eventHandlerListeners; 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, protected Executor(String name, int maxThreads,
final Map<EventHandler.EventType, EventHandlerListener> eventHandlerListeners) { final Map<EventHandler.EventType, EventHandlerListener> eventHandlerListeners) {
this.id = seqids.incrementAndGet();
this.name = name; this.name = name;
this.eventHandlerListeners = eventHandlerListeners; this.eventHandlerListeners = eventHandlerListeners;
// create the thread pool executor // create the thread pool executor
@ -283,5 +287,9 @@ public class ExecutorService {
} }
this.threadPoolExecutor.execute(event); 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; 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 @Override
public void process() { public void process() {
LOG.debug("Handling CLOSED event for " + regionInfo.getEncodedName()); 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. // Call to undisableTable does this. TODO: Make a more formal purge table.
am.getZKTable().setEnabledTable(Bytes.toString(tableName)); 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 @Override
public void process() { public void process() {
try { 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 @Override
public void process() { public void process() {
try { try {

View File

@ -50,4 +50,13 @@ public class MetaServerShutdownHandler extends ServerShutdownHandler {
boolean isCarryingMeta() { boolean isCarryingMeta() {
return this.carryingMeta; 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); 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

@ -78,7 +78,16 @@ public class OpenedRegionHandler extends EventHandler implements TotesHRegionInf
public HRegionInfo getHRegionInfo() { public HRegionInfo getHRegionInfo() {
return this.regionInfo; 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 @Override
public void process() { public void process() {
LOG.debug("Handling OPENED event for " + this.regionInfo.getEncodedName() + 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 { public class ServerShutdownHandler extends EventHandler {
private static final Log LOG = LogFactory.getLog(ServerShutdownHandler.class); private static final Log LOG = LogFactory.getLog(ServerShutdownHandler.class);
private final ServerName serverName; private final ServerName serverName;
private final Server server;
private final MasterServices services; private final MasterServices services;
private final DeadServer deadServers; private final DeadServer deadServers;
@ -107,6 +106,15 @@ public class ServerShutdownHandler extends EventHandler {
return false; 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 @Override
public void process() throws IOException { public void process() throws IOException {
final ServerName serverName = this.serverName; final ServerName serverName = this.serverName;

View File

@ -59,6 +59,19 @@ public class SplitRegionHandler extends EventHandler implements TotesHRegionInfo
public HRegionInfo getHRegionInfo() { public HRegionInfo getHRegionInfo() {
return this.parent; 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 @Override
public void process() { public void process() {

View File

@ -63,4 +63,16 @@ public class TableAddFamilyHandler extends TableEventHandler {
this.masterServices.getMasterFileSystem().updateRegionInfo(hri); 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); 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); 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;
}
} }