HBASE-17965 Canary tool should print the regionserver name on failure
Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
parent
eb6ded4849
commit
880db3eee4
|
@ -116,15 +116,15 @@ public final class Canary implements Tool {
|
|||
public interface Sink {
|
||||
public long getReadFailureCount();
|
||||
public long incReadFailureCount();
|
||||
public void publishReadFailure(HRegionInfo region, Exception e);
|
||||
public void publishReadFailure(HRegionInfo region, HColumnDescriptor column, Exception e);
|
||||
public void publishReadFailure(ServerName serverName, HRegionInfo region, Exception e);
|
||||
public void publishReadFailure(ServerName serverName, HRegionInfo region, HColumnDescriptor column, Exception e);
|
||||
public void updateReadFailedHostList(HRegionInfo region, String serverName);
|
||||
public Map<String,String> getReadFailures();
|
||||
public void publishReadTiming(HRegionInfo region, HColumnDescriptor column, long msTime);
|
||||
public void publishReadTiming(ServerName serverName, HRegionInfo region, HColumnDescriptor column, long msTime);
|
||||
public long getWriteFailureCount();
|
||||
public void publishWriteFailure(HRegionInfo region, Exception e);
|
||||
public void publishWriteFailure(HRegionInfo region, HColumnDescriptor column, Exception e);
|
||||
public void publishWriteTiming(HRegionInfo region, HColumnDescriptor column, long msTime);
|
||||
public void publishWriteFailure(ServerName serverName, HRegionInfo region, Exception e);
|
||||
public void publishWriteFailure(ServerName serverName, HRegionInfo region, HColumnDescriptor column, Exception e);
|
||||
public void publishWriteTiming(ServerName serverName, HRegionInfo region, HColumnDescriptor column, long msTime);
|
||||
public void updateWriteFailedHostList(HRegionInfo region, String serverName);
|
||||
public Map<String,String> getWriteFailures();
|
||||
}
|
||||
|
@ -155,16 +155,16 @@ public final class Canary implements Tool {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void publishReadFailure(HRegionInfo region, Exception e) {
|
||||
public void publishReadFailure(ServerName serverName, HRegionInfo region, Exception e) {
|
||||
readFailureCount.incrementAndGet();
|
||||
LOG.error(String.format("read from region %s failed", region.getRegionNameAsString()), e);
|
||||
LOG.error(String.format("read from region %s on regionserver %s failed", region.getRegionNameAsString(), serverName), e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishReadFailure(HRegionInfo region, HColumnDescriptor column, Exception e) {
|
||||
public void publishReadFailure(ServerName serverName, HRegionInfo region, HColumnDescriptor column, Exception e) {
|
||||
readFailureCount.incrementAndGet();
|
||||
LOG.error(String.format("read from region %s column family %s failed",
|
||||
region.getRegionNameAsString(), column.getNameAsString()), e);
|
||||
LOG.error(String.format("read from region %s on regionserver %s column family %s failed",
|
||||
region.getRegionNameAsString(), serverName, column.getNameAsString()), e);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -173,9 +173,9 @@ public final class Canary implements Tool {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void publishReadTiming(HRegionInfo region, HColumnDescriptor column, long msTime) {
|
||||
LOG.info(String.format("read from region %s column family %s in %dms",
|
||||
region.getRegionNameAsString(), column.getNameAsString(), msTime));
|
||||
public void publishReadTiming(ServerName serverName, HRegionInfo region, HColumnDescriptor column, long msTime) {
|
||||
LOG.info(String.format("read from region %s on regionserver %s column family %s in %dms",
|
||||
region.getRegionNameAsString(), serverName, column.getNameAsString(), msTime));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -194,22 +194,22 @@ public final class Canary implements Tool {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void publishWriteFailure(HRegionInfo region, Exception e) {
|
||||
public void publishWriteFailure(ServerName serverName, HRegionInfo region, Exception e) {
|
||||
writeFailureCount.incrementAndGet();
|
||||
LOG.error(String.format("write to region %s failed", region.getRegionNameAsString()), e);
|
||||
LOG.error(String.format("write to region %s on regionserver %s failed", region.getRegionNameAsString(), serverName), e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishWriteFailure(HRegionInfo region, HColumnDescriptor column, Exception e) {
|
||||
public void publishWriteFailure(ServerName serverName, HRegionInfo region, HColumnDescriptor column, Exception e) {
|
||||
writeFailureCount.incrementAndGet();
|
||||
LOG.error(String.format("write to region %s column family %s failed",
|
||||
region.getRegionNameAsString(), column.getNameAsString()), e);
|
||||
LOG.error(String.format("write to region %s on regionserver %s column family %s failed",
|
||||
region.getRegionNameAsString(), serverName, column.getNameAsString()), e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishWriteTiming(HRegionInfo region, HColumnDescriptor column, long msTime) {
|
||||
LOG.info(String.format("write to region %s column family %s in %dms",
|
||||
region.getRegionNameAsString(), column.getNameAsString(), msTime));
|
||||
public void publishWriteTiming(ServerName serverName, HRegionInfo region, HColumnDescriptor column, long msTime) {
|
||||
LOG.info(String.format("write to region %s on regionserver %s column family %s in %dms",
|
||||
region.getRegionNameAsString(), serverName, column.getNameAsString(), msTime));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -332,7 +332,7 @@ public final class Canary implements Tool {
|
|||
tableDesc = table.getTableDescriptor();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("sniffRegion failed", e);
|
||||
sink.publishReadFailure(region, e);
|
||||
sink.publishReadFailure(serverName, region, e);
|
||||
if (table != null) {
|
||||
try {
|
||||
table.close();
|
||||
|
@ -386,9 +386,9 @@ public final class Canary implements Tool {
|
|||
rs.next();
|
||||
}
|
||||
stopWatch.stop();
|
||||
sink.publishReadTiming(region, column, stopWatch.getTime());
|
||||
sink.publishReadTiming(serverName, region, column, stopWatch.getTime());
|
||||
} catch (Exception e) {
|
||||
sink.publishReadFailure(region, column, e);
|
||||
sink.publishReadFailure(serverName, region, column, e);
|
||||
sink.updateReadFailedHostList(region, serverName.getHostname());
|
||||
} finally {
|
||||
if (rs != null) {
|
||||
|
@ -438,14 +438,14 @@ public final class Canary implements Tool {
|
|||
long startTime = System.currentTimeMillis();
|
||||
table.put(put);
|
||||
long time = System.currentTimeMillis() - startTime;
|
||||
sink.publishWriteTiming(region, column, time);
|
||||
sink.publishWriteTiming(serverName, region, column, time);
|
||||
} catch (Exception e) {
|
||||
sink.publishWriteFailure(region, column, e);
|
||||
sink.publishWriteFailure(serverName, region, column, e);
|
||||
}
|
||||
}
|
||||
table.close();
|
||||
} catch (IOException e) {
|
||||
sink.publishWriteFailure(region, e);
|
||||
sink.publishWriteFailure(serverName, region, e);
|
||||
sink.updateWriteFailedHostList(region, serverName.getHostname());
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
*
|
||||
q *
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -19,10 +19,7 @@
|
|||
|
||||
package org.apache.hadoop.hbase.tool;
|
||||
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.*;
|
||||
import org.apache.hadoop.hbase.client.Put;
|
||||
import org.apache.hadoop.hbase.client.Table;
|
||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||
|
@ -32,7 +29,6 @@ import org.apache.log4j.Appender;
|
|||
import org.apache.log4j.LogManager;
|
||||
import org.apache.log4j.spi.LoggingEvent;
|
||||
import com.google.common.collect.Iterables;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
|
@ -120,7 +116,7 @@ public class TestCanaryTool {
|
|||
ToolRunner.run(testingUtility.getConfiguration(), canary, args);
|
||||
assertEquals("verify no read error count", 0, canary.getReadFailures().size());
|
||||
assertEquals("verify no write error count", 0, canary.getWriteFailures().size());
|
||||
verify(sink, atLeastOnce()).publishReadTiming(isA(HRegionInfo.class), isA(HColumnDescriptor.class), anyLong());
|
||||
verify(sink, atLeastOnce()).publishReadTiming(isA(ServerName.class), isA(HRegionInfo.class), isA(HColumnDescriptor.class), anyLong());
|
||||
}
|
||||
|
||||
//no table created, so there should be no regions
|
||||
|
@ -168,7 +164,7 @@ public class TestCanaryTool {
|
|||
conf.setBoolean(HConstants.HBASE_CANARY_READ_RAW_SCAN_KEY, true);
|
||||
ToolRunner.run(conf, canary, args);
|
||||
verify(sink, atLeastOnce())
|
||||
.publishReadTiming(isA(HRegionInfo.class), isA(HColumnDescriptor.class), anyLong());
|
||||
.publishReadTiming(isA(ServerName.class), isA(HRegionInfo.class), isA(HColumnDescriptor.class), anyLong());
|
||||
assertEquals("verify no read error count", 0, canary.getReadFailures().size());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue