下面列出了org.apache.hadoop.hbase.client.NoServerForRegionException#org.apache.hadoop.hbase.MasterNotRunningException 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public long createSystemTable(final TableDescriptor tableDescriptor) throws IOException {
if (isStopped()) {
throw new MasterNotRunningException();
}
TableName tableName = tableDescriptor.getTableName();
if (!(tableName.isSystemTable())) {
throw new IllegalArgumentException(
"Only system table creation can use this createSystemTable API");
}
RegionInfo[] newRegions = ModifyRegionUtils.createRegionInfos(tableDescriptor, null);
LOG.info(getClientIdAuditPrefix() + " create " + tableDescriptor);
// This special create table is called locally to master. Therefore, no RPC means no need
// to use nonce to detect duplicated RPC call.
long procId = this.procedureExecutor.submitProcedure(
new CreateTableProcedure(procedureExecutor.getEnvironment(), tableDescriptor, newRegions));
return procId;
}
CompletableFuture<MasterService.Interface> getMasterStub() {
return ConnectionUtils.getOrFetch(masterStub, masterStubMakeFuture, false, () -> {
CompletableFuture<MasterService.Interface> future = new CompletableFuture<>();
addListener(registry.getActiveMaster(), (addr, error) -> {
if (error != null) {
future.completeExceptionally(error);
} else if (addr == null) {
future.completeExceptionally(new MasterNotRunningException(
"ZooKeeper available but no active master location found"));
} else {
LOG.debug("The fetched master address is {}", addr);
try {
future.complete(createMasterStub(addr));
} catch (IOException e) {
future.completeExceptionally(e);
}
}
});
return future;
}, stub -> true, "master stub");
}
public static void main(String[] args) throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
Configuration conf = HBaseConfiguration.create();
HBaseAdmin admin = new HBaseAdmin(conf);
// tag::CREATE2[]
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf("pages"));
byte[][] splits = {Bytes.toBytes("b"), Bytes.toBytes("f"),
Bytes.toBytes("k"), Bytes.toBytes("n"), Bytes.toBytes("t")};
desc.setValue(Bytes.toBytes("comment"), Bytes.toBytes("Create 10012014"));
HColumnDescriptor family = new HColumnDescriptor("c");
family.setCompressionType(Algorithm.GZ);
family.setMaxVersions(52);
family.setBloomFilterType(BloomType.ROW);
desc.addFamily(family);
admin.createTable(desc, splits);
// end::CREATE2[]
admin.close();
}
public static void main(String[] args) throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
// Instantiate default HBase configuration object.
// Configuration file must be in the classpath
Configuration conf = HBaseConfiguration.create();
// tag::DESCRIBE
HBaseAdmin admin = new HBaseAdmin(conf);
HTableDescriptor desc = admin.getTableDescriptor(TableName.valueOf("crc"));
Collection<HColumnDescriptor> families = desc.getFamilies();
System.out.println("Table " + desc.getTableName() + " has " + families.size() + " family(ies)");
for (Iterator<HColumnDescriptor> iterator = families.iterator(); iterator.hasNext();) {
HColumnDescriptor family = iterator.next();
System.out.println("Family details: " + family);
}
// end::DESCRIBE
admin.close();
}
public static void main(String[] args) throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
// tag::MERGE1[]
Configuration conf = HBaseConfiguration.create();
Connection connection = ConnectionFactory.createConnection(conf);
HBaseAdmin admin = (HBaseAdmin)connection.getAdmin();
List<HRegionInfo> regions = admin.getTableRegions(TableName.valueOf("t1")); //<1>
LOG.info("testtable contains " + regions.size() + " regions.");
for (int index = 0; index < regions.size() / 2; index++) {
HRegionInfo region1 = regions.get(index*2);
HRegionInfo region2 = regions.get(index*2+1);
LOG.info("Merging regions " + region1 + " and " + region2);
admin.mergeRegions(region1.getEncodedNameAsBytes(),
region2.getEncodedNameAsBytes(), false); //<2>
}
admin.close();
// end::MERGE1[]
}
public static void main(String[] args) throws MasterNotRunningException,
ZooKeeperConnectionException, IOException {
try (Connection connection = ConnectionFactory.createConnection();
Admin admin = connection.getAdmin();) {
LOG.info("Starting table creation");
// tag::CREATE[]
TableName documents = TableName.valueOf("documents");
HTableDescriptor desc = new HTableDescriptor(documents);
HColumnDescriptor family = new HColumnDescriptor("c");
family.setCompressionType(Algorithm.GZ);
family.setBloomFilterType(BloomType.NONE);
desc.addFamily(family);
UniformSplit uniformSplit = new UniformSplit();
admin.createTable(desc, uniformSplit.split(8));
// end::CREATE[]
LOG.info("Table successfuly created");
}
}
public HBaseAdminMultiCluster(Configuration c)
throws MasterNotRunningException, ZooKeeperConnectionException,
IOException {
super(HBaseMultiClusterConfigUtil.splitMultiConfigFile(c).get(
HBaseMultiClusterConfigUtil.PRIMARY_NAME));
Map<String, Configuration> configs = HBaseMultiClusterConfigUtil
.splitMultiConfigFile(c);
for (Entry<String, Configuration> entry : configs.entrySet()) {
if (!entry.getKey().equals(HBaseMultiClusterConfigUtil.PRIMARY_NAME)) {
HBaseAdmin admin = new HBaseAdmin(entry.getValue());
LOG.info("creating HBaseAdmin for : " + entry.getKey());
failoverAdminMap.put(entry.getKey(), admin);
LOG.info(" - successfully creating HBaseAdmin for : " + entry.getKey());
}
}
LOG.info("Successful loaded all HBaseAdmins");
}
private void connect() throws IOException, ServiceException {
Configuration config = HBaseConfiguration.create();
String path = this.getClass().getClassLoader().getResource("hbase-site.xml").getPath();
config.addResource(new Path(path));
try {
HBaseAdmin.checkHBaseAvailable(config);
} catch (MasterNotRunningException e) {
System.out.println("HBase is not running." + e.getMessage());
return;
}
HBaseClientOperations HBaseClientOperations = new HBaseClientOperations();
HBaseClientOperations.run(config);
}
private boolean causeIsPleaseHold(Throwable e) {
if (e instanceof PleaseHoldException)
return true;
if (e instanceof TableNotEnabledException)
return true;
if (e instanceof RegionOfflineException)
return true;
if (e instanceof RetriesExhaustedException || e instanceof SocketTimeoutException) {
if (e.getCause() instanceof RemoteException) {
RemoteException re = (RemoteException) e.getCause();
if (PleaseHoldException.class.getName().equals(re.getClassName()))
return true;
} else if (e.getCause() instanceof MasterNotRunningException) {
return true;
}
return (e.getCause() instanceof IOException && e.getCause().getCause() instanceof CallTimeoutException) ||
(e.getCause() instanceof RemoteWithExtrasException && e.getMessage().equals(
"Table Namespace Manager not fully initialized, try again later"));
}
return false;
}
private static void validateAuthentication() throws ZooKeeperConnectionException {
try {
// Is there something better?
admin.isMasterRunning();
} catch (MasterNotRunningException e) {
System.out.println("Maybe you are connecting to the secured cluster without kerberos config.\n");
}
}
private static void validateAuthentication() throws ZooKeeperConnectionException {
try {
// Is there something better?
admin.isMasterRunning();
} catch (MasterNotRunningException e) {
System.out.println("Maybe you are connecting to the secured cluster without kerberos config.\n");
}
}
private static void validateAuthentication() throws ZooKeeperConnectionException {
try {
// Is there something better?
admin.isMasterRunning();
} catch (MasterNotRunningException e) {
System.out.println("Maybe you are connecting to the secured cluster without kerberos config.\n");
}
}
private static void validateAuthentication() throws ZooKeeperConnectionException {
try {
// Is there something better?
admin.isMasterRunning();
} catch (MasterNotRunningException e) {
System.out.println("Maybe you are connecting to the secured cluster without kerberos config.\n");
}
}
private static void validateAuthentication() throws ZooKeeperConnectionException {
try {
// Is there something better?
admin.isMasterRunning();
} catch (MasterNotRunningException e) {
System.out.println("Maybe you are connecting to the secured cluster without kerberos config.\n");
}
}
void checkInitialized() throws PleaseHoldException, ServerNotRunningYetException,
MasterNotRunningException, MasterStoppedException {
checkServiceStarted();
if (!isInitialized()) {
throw new PleaseHoldException("Master is initializing");
}
if (isStopped()) {
throw new MasterStoppedException();
}
}
/**
* return the index of the active master in the cluster
*
* @throws org.apache.hadoop.hbase.MasterNotRunningException
* if no active master found
*/
private int getActiveMasterIndex(MiniHBaseCluster cluster) throws MasterNotRunningException {
// get all the master threads
List<JVMClusterUtil.MasterThread> masterThreads = cluster.getMasterThreads();
for (int i = 0; i < masterThreads.size(); i++) {
if (masterThreads.get(i).getMaster().isActiveMaster()) {
return i;
}
}
throw new MasterNotRunningException();
}
public static void main(String[] args)
throws MasterNotRunningException, ZooKeeperConnectionException,
IOException {
// tag::CREATE1[]
Configuration conf = HBaseConfiguration.create();
HBaseAdmin admin = new HBaseAdmin(conf);
HTableDescriptor desc =
new HTableDescriptor(TableName.valueOf("testtable_create1"));
HColumnDescriptor family = new HColumnDescriptor("f1");
desc.addFamily(family);
admin.createTable(desc);
// end::CREATE1[]
admin.close();
}
public static void main(String[] args) throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
Configuration conf = HBaseConfiguration.create();
HBaseAdmin admin = new HBaseAdmin(conf);
// tag::CREATE3[]
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf("crc"));
desc.setMaxFileSize((long)20*1024*1024*1024);
desc.setConfiguration("hbase.hstore.compaction.min", "5");
HColumnDescriptor family = new HColumnDescriptor("c");
family.setInMemory(true);
desc.addFamily(family);
UniformSplit uniformSplit = new UniformSplit();
admin.createTable(desc, uniformSplit.split(64));
// end::CREATE3[]
admin.close();
}
public static void main(String[] args) throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
Configuration conf = HBaseConfiguration.create();
HBaseAdmin admin = new HBaseAdmin(conf);
// tag::CREATE4[]
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf("access"));
HColumnDescriptor family = new HColumnDescriptor("d");
family.setValue("comment", "Last user access date");
family.setMaxVersions(10);
family.setMinVersions(2);
family.setTimeToLive(2678400);
desc.addFamily(family);
admin.createTable(desc);
// end::CREATE4[]
admin.close();
}
private GetProcedureResultResponse.State getState(long procId)
throws MasterNotRunningException, IOException, ServiceException {
GetProcedureResultResponse resp = UTIL.getMiniHBaseCluster().getMaster().getMasterRpcServices()
.getProcedureResult(null, GetProcedureResultRequest.newBuilder().setProcId(procId).build());
return resp.getState();
}
/**
* Ensure single table region is not on same server as the single hbase:meta table
* region.
* @return Index of the server hosting the single table region
* @throws UnknownRegionException
* @throws MasterNotRunningException
* @throws org.apache.hadoop.hbase.ZooKeeperConnectionException
* @throws InterruptedException
*/
private int ensureTableRegionNotOnSameServerAsMeta(final Admin admin,
final RegionInfo hri)
throws IOException, MasterNotRunningException,
ZooKeeperConnectionException, InterruptedException {
// Now make sure that the table region is not on same server as that hosting
// hbase:meta We don't want hbase:meta replay polluting our test when we later crash
// the table region serving server.
int metaServerIndex = cluster.getServerWithMeta();
boolean tablesOnMaster = LoadBalancer.isTablesOnMaster(TESTING_UTIL.getConfiguration());
if (tablesOnMaster) {
// Need to check master is supposed to host meta... perhaps it is not.
throw new UnsupportedOperationException();
// TODO: assertTrue(metaServerIndex == -1); // meta is on master now
}
HRegionServer metaRegionServer = tablesOnMaster?
cluster.getMaster(): cluster.getRegionServer(metaServerIndex);
int tableRegionIndex = cluster.getServerWith(hri.getRegionName());
assertTrue(tableRegionIndex != -1);
HRegionServer tableRegionServer = cluster.getRegionServer(tableRegionIndex);
LOG.info("MetaRegionServer=" + metaRegionServer.getServerName() +
", other=" + tableRegionServer.getServerName());
if (metaRegionServer.getServerName().equals(tableRegionServer.getServerName())) {
HRegionServer hrs = getOtherRegionServer(cluster, metaRegionServer);
assertNotNull(hrs);
assertNotNull(hri);
LOG.info("Moving " + hri.getRegionNameAsString() + " from " +
metaRegionServer.getServerName() + " to " +
hrs.getServerName() + "; metaServerIndex=" + metaServerIndex);
admin.move(hri.getEncodedNameAsBytes(), hrs.getServerName());
}
// Wait till table region is up on the server that is NOT carrying hbase:meta.
for (int i = 0; i < 100; i++) {
tableRegionIndex = cluster.getServerWith(hri.getRegionName());
if (tableRegionIndex != -1 && tableRegionIndex != metaServerIndex) break;
LOG.debug("Waiting on region move off the hbase:meta server; current index " +
tableRegionIndex + " and metaServerIndex=" + metaServerIndex);
Thread.sleep(100);
}
assertTrue("Region not moved off hbase:meta server, tableRegionIndex=" + tableRegionIndex,
tableRegionIndex != -1 && tableRegionIndex != metaServerIndex);
// Verify for sure table region is not on same server as hbase:meta
tableRegionIndex = cluster.getServerWith(hri.getRegionName());
assertTrue(tableRegionIndex != -1);
assertNotSame(metaServerIndex, tableRegionIndex);
return tableRegionIndex;
}
protected void createSchema() throws IOException {
Configuration conf = getConf();
TableName tableName = getTableName(conf);
try (Connection conn = ConnectionFactory.createConnection(conf);
Admin admin = conn.getAdmin()) {
if (!admin.tableExists(tableName)) {
TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
new TableDescriptorBuilder.ModifyableTableDescriptor(getTableName(getConf()));
ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor =
new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(FAMILY_NAME);
// if -DuseMob=true force all data through mob path.
setMobProperties(conf, familyDescriptor);
tableDescriptor.setColumnFamily(familyDescriptor);
// Always add these families. Just skip writing to them when we do not test per CF flush.
familyDescriptor =
new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(BIG_FAMILY_NAME);
setMobProperties(conf, familyDescriptor);
tableDescriptor.setColumnFamily(familyDescriptor);
familyDescriptor =
new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(TINY_FAMILY_NAME);
setMobProperties(conf, familyDescriptor);
tableDescriptor.setColumnFamily(familyDescriptor);
// If we want to pre-split compute how many splits.
if (conf.getBoolean(HBaseTestingUtility.PRESPLIT_TEST_TABLE_KEY,
HBaseTestingUtility.PRESPLIT_TEST_TABLE)) {
int numberOfServers = admin.getRegionServers().size();
if (numberOfServers == 0) {
throw new IllegalStateException("No live regionservers");
}
int regionsPerServer = conf.getInt(HBaseTestingUtility.REGIONS_PER_SERVER_KEY,
HBaseTestingUtility.DEFAULT_REGIONS_PER_SERVER);
int totalNumberOfRegions = numberOfServers * regionsPerServer;
LOG.info("Number of live regionservers: " + numberOfServers + ", " +
"pre-splitting table into " + totalNumberOfRegions + " regions " +
"(default regions per server: " + regionsPerServer + ")");
byte[][] splits = new RegionSplitter.UniformSplit().split(totalNumberOfRegions);
admin.createTable(tableDescriptor, splits);
} else {
// Looks like we're just letting things play out.
// Create a table with on region by default.
// This will make the splitting work hard.
admin.createTable(tableDescriptor);
}
}
} catch (MasterNotRunningException e) {
LOG.error("Master not running", e);
throw new IOException(e);
}
}
public static boolean isAccessControllerRunning(Connection connection)
throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
try (Admin admin = connection.getAdmin()) {
return admin.isTableAvailable(ACL_TABLE_NAME);
}
}
public byte[] getPcaps(String startKey, String endKey, long maxResultSize,
long startTime, long endTime) throws IOException {
Assert.hasText(startKey, "startKey must no be null or empty");
byte[] cf = Bytes.toBytes(ConfigurationUtil.getConfiguration()
.getString("hbase.table.column.family"));
byte[] cq = Bytes.toBytes(ConfigurationUtil.getConfiguration()
.getString("hbase.table.column.qualifier"));
// create scan request
Scan scan = createScanRequest(cf, cq, startKey, endKey, maxResultSize,
startTime, endTime);
List<byte[]> pcaps = new ArrayList<byte[]>();
HTable table = null;
try {
pcaps = scanPcaps(pcaps, table, scan, cf, cq);
} catch (IOException e) {
LOGGER.error(
"Exception occurred while fetching Pcaps for the key range : startKey="
+ startKey + ", endKey=" + endKey, e);
if (e instanceof ZooKeeperConnectionException
|| e instanceof MasterNotRunningException
|| e instanceof NoServerForRegionException) {
int maxRetryLimit = getConnectionRetryLimit();
for (int attempt = 1; attempt <= maxRetryLimit; attempt++) {
try {
HBaseConfigurationUtil.closeConnection(); // closing the existing
// connection and retry,
// it will create a new
// HConnection
pcaps = scanPcaps(pcaps, table, scan, cf, cq);
break;
} catch (IOException ie) {
if (attempt == maxRetryLimit) {
System.out.println("Throwing the exception after retrying "
+ maxRetryLimit + " times.");
throw e;
}
}
}
} else {
throw e;
}
} finally {
if (table != null) {
table.close();
}
}
if (pcaps.size() == 1) {
return pcaps.get(0);
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PcapMerger.merge(baos, pcaps);
byte[] response = baos.toByteArray();
return response;
}
/**
* Process key.
*
* @param pcapsResponse
* the pcaps response
* @param key
* the key
* @param startTime
* the start time
* @param endTime
* the end time
* @param isPartialResponse
* the is partial response
* @param includeDuplicateLastRow
* the include duplicate last row
* @param maxResultSize
* the max result size
* @return the pcaps response
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@VisibleForTesting
PcapsResponse processKey(PcapsResponse pcapsResponse, String key,
long startTime, long endTime, boolean isPartialResponse,
boolean includeDuplicateLastRow, long maxResultSize) throws IOException {
HTable table = null;
Scan scan = null;
List<Cell> scannedCells = null;
try {
// 1. Create start and stop row for the key;
Map<String, String> keysMap = createStartAndStopRowKeys(key,
isPartialResponse, includeDuplicateLastRow);
// 2. if the input key contains all fragments (7) and it is not part
// of previous partial response (isPartialResponse),
// 'keysMap' will be null; do a Get; currently not doing any
// response size related checks for Get;
// by default all cells from a specific row are sorted by timestamp
if (keysMap == null) {
Get get = createGetRequest(key, startTime, endTime);
List<Cell> cells = executeGetRequest(table, get);
for (Cell cell : cells) {
pcapsResponse.addPcaps(CellUtil.cloneValue(cell));
}
return pcapsResponse;
}
// 3. Create and execute Scan request
scan = createScanRequest(pcapsResponse, keysMap, startTime, endTime,
maxResultSize);
scannedCells = executeScanRequest(table, scan);
LOGGER.info("scannedCells size :" + scannedCells.size());
addToResponse(pcapsResponse, scannedCells, maxResultSize);
} catch (IOException e) {
LOGGER.error("Exception occurred while fetching Pcaps for the keys :"
+ key, e);
if (e instanceof ZooKeeperConnectionException
|| e instanceof MasterNotRunningException
|| e instanceof NoServerForRegionException) {
int maxRetryLimit = ConfigurationUtil.getConnectionRetryLimit();
System.out.println("maxRetryLimit =" + maxRetryLimit);
for (int attempt = 1; attempt <= maxRetryLimit; attempt++) {
System.out.println("attempting =" + attempt);
try {
HBaseConfigurationUtil.closeConnection(); // closing the
// existing
// connection
// and retry,
// it will
// create a new
// HConnection
scannedCells = executeScanRequest(table, scan);
addToResponse(pcapsResponse, scannedCells, maxResultSize);
break;
} catch (IOException ie) {
if (attempt == maxRetryLimit) {
LOGGER.error("Throwing the exception after retrying "
+ maxRetryLimit + " times.");
throw e;
}
}
}
}
} finally {
if (table != null) {
table.close();
}
}
return pcapsResponse;
}
public byte[] getPcaps(String startKey, String endKey, long maxResultSize,
long startTime, long endTime) throws IOException {
Assert.hasText(startKey, "startKey must no be null or empty");
byte[] cf = Bytes.toBytes(ConfigurationUtil.getConfiguration()
.getString("hbase.table.column.family"));
byte[] cq = Bytes.toBytes(ConfigurationUtil.getConfiguration()
.getString("hbase.table.column.qualifier"));
// create scan request
Scan scan = createScanRequest(cf, cq, startKey, endKey, maxResultSize,
startTime, endTime);
List<byte[]> pcaps = new ArrayList<byte[]>();
HTable table = null;
try {
pcaps = scanPcaps(pcaps, table, scan, cf, cq);
} catch (IOException e) {
LOGGER.error(
"Exception occurred while fetching Pcaps for the key range : startKey="
+ startKey + ", endKey=" + endKey, e);
if (e instanceof ZooKeeperConnectionException
|| e instanceof MasterNotRunningException
|| e instanceof NoServerForRegionException) {
int maxRetryLimit = getConnectionRetryLimit();
for (int attempt = 1; attempt <= maxRetryLimit; attempt++) {
try {
HBaseConfigurationUtil.closeConnection(); // closing the existing
// connection and retry,
// it will create a new
// HConnection
pcaps = scanPcaps(pcaps, table, scan, cf, cq);
break;
} catch (IOException ie) {
if (attempt == maxRetryLimit) {
System.out.println("Throwing the exception after retrying "
+ maxRetryLimit + " times.");
throw e;
}
}
}
} else {
throw e;
}
} finally {
if (table != null) {
table.close();
}
}
if (pcaps.size() == 1) {
return pcaps.get(0);
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PcapMerger.merge(baos, pcaps);
byte[] response = baos.toByteArray();
return response;
}
/**
* Process key.
*
* @param pcapsResponse
* the pcaps response
* @param key
* the key
* @param startTime
* the start time
* @param endTime
* the end time
* @param isPartialResponse
* the is partial response
* @param includeDuplicateLastRow
* the include duplicate last row
* @param maxResultSize
* the max result size
* @return the pcaps response
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@VisibleForTesting
PcapsResponse processKey(PcapsResponse pcapsResponse, String key,
long startTime, long endTime, boolean isPartialResponse,
boolean includeDuplicateLastRow, long maxResultSize) throws IOException {
HTable table = null;
Scan scan = null;
List<Cell> scannedCells = null;
try {
// 1. Create start and stop row for the key;
Map<String, String> keysMap = createStartAndStopRowKeys(key,
isPartialResponse, includeDuplicateLastRow);
// 2. if the input key contains all fragments (7) and it is not part
// of previous partial response (isPartialResponse),
// 'keysMap' will be null; do a Get; currently not doing any
// response size related checks for Get;
// by default all cells from a specific row are sorted by timestamp
if (keysMap == null) {
Get get = createGetRequest(key, startTime, endTime);
List<Cell> cells = executeGetRequest(table, get);
for (Cell cell : cells) {
pcapsResponse.addPcaps(CellUtil.cloneValue(cell));
}
return pcapsResponse;
}
// 3. Create and execute Scan request
scan = createScanRequest(pcapsResponse, keysMap, startTime, endTime,
maxResultSize);
scannedCells = executeScanRequest(table, scan);
LOGGER.info("scannedCells size :" + scannedCells.size());
addToResponse(pcapsResponse, scannedCells, maxResultSize);
} catch (IOException e) {
LOGGER.error("Exception occurred while fetching Pcaps for the keys :"
+ key, e);
if (e instanceof ZooKeeperConnectionException
|| e instanceof MasterNotRunningException
|| e instanceof NoServerForRegionException) {
int maxRetryLimit = ConfigurationUtil.getConnectionRetryLimit();
System.out.println("maxRetryLimit =" + maxRetryLimit);
for (int attempt = 1; attempt <= maxRetryLimit; attempt++) {
System.out.println("attempting =" + attempt);
try {
HBaseConfigurationUtil.closeConnection(); // closing the
// existing
// connection
// and retry,
// it will
// create a new
// HConnection
scannedCells = executeScanRequest(table, scan);
addToResponse(pcapsResponse, scannedCells, maxResultSize);
break;
} catch (IOException ie) {
if (attempt == maxRetryLimit) {
LOGGER.error("Throwing the exception after retrying "
+ maxRetryLimit + " times.");
throw e;
}
}
}
}
} finally {
if (table != null) {
table.close();
}
}
return pcapsResponse;
}
/**
* Constructor
*
* @param conf
* Configuration object
* @throws MasterNotRunningException
* if the master is not running
* @throws ZooKeeperConnectionException
* if unable to connect to ZooKeeper
*/
public HBaseFsck(Configuration conf, ExecutorService exec) throws MasterNotRunningException,
ZooKeeperConnectionException, IOException, ClassNotFoundException {
super(conf);
errors = getErrorReporter(getConf());
this.executor = exec;
lockFileRetryCounterFactory = createLockRetryCounterFactory(getConf());
createZNodeRetryCounterFactory = createZnodeRetryCounterFactory(getConf());
zkw = createZooKeeperWatcher();
}
/**
* Constructor
*
* @param conf Configuration object
* @throws MasterNotRunningException
* @throws ZooKeeperConnectionException
*/
public IndexedTableAdmin(final Configuration conf) throws MasterNotRunningException, ZooKeeperConnectionException {
super(conf);
}