use of org.apache.hadoop.hbase.MasterNotRunningException in project hbase by apache.
the class AsyncConnectionImpl method makeMasterStub.
private void makeMasterStub(CompletableFuture<MasterService.Interface> future) {
registry.getMasterAddress().whenComplete((sn, error) -> {
if (sn == null) {
String msg = "ZooKeeper available but no active master location found";
LOG.info(msg);
this.masterStubMakeFuture.getAndSet(null).completeExceptionally(new MasterNotRunningException(msg));
return;
}
try {
MasterService.Interface stub = createMasterStub(sn);
HBaseRpcController controller = getRpcController();
stub.isMasterRunning(controller, RequestConverter.buildIsMasterRunningRequest(), new RpcCallback<IsMasterRunningResponse>() {
@Override
public void run(IsMasterRunningResponse resp) {
if (controller.failed() || resp == null || (resp != null && !resp.getIsMasterRunning())) {
masterStubMakeFuture.getAndSet(null).completeExceptionally(new MasterNotRunningException("Master connection is not running anymore"));
} else {
masterStub.set(stub);
masterStubMakeFuture.set(null);
future.complete(stub);
}
}
});
} catch (IOException e) {
this.masterStubMakeFuture.getAndSet(null).completeExceptionally(new IOException("Failed to create async master stub", e));
}
});
}
use of org.apache.hadoop.hbase.MasterNotRunningException in project hbase by apache.
the class TestHBaseAdminNoCluster method testMasterOperationIsRetried.
private void testMasterOperationIsRetried(MethodCaller caller) throws Exception {
Configuration configuration = HBaseConfiguration.create();
// Set the pause and retry count way down.
configuration.setLong(HConstants.HBASE_CLIENT_PAUSE, 1);
final int count = 10;
configuration.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, count);
ClusterConnection connection = mock(ClusterConnection.class);
when(connection.getConfiguration()).thenReturn(configuration);
MasterKeepAliveConnection masterAdmin = Mockito.mock(MasterKeepAliveConnection.class, new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
if (invocation.getMethod().getName().equals("close")) {
return null;
}
// all methods will throw an exception
throw new MasterNotRunningException();
}
});
Mockito.when(connection.getKeepAliveMasterService()).thenReturn(masterAdmin);
RpcControllerFactory rpcControllerFactory = Mockito.mock(RpcControllerFactory.class);
Mockito.when(connection.getRpcControllerFactory()).thenReturn(rpcControllerFactory);
Mockito.when(rpcControllerFactory.newController()).thenReturn(Mockito.mock(HBaseRpcController.class));
// we need a real retrying caller
RpcRetryingCallerFactory callerFactory = new RpcRetryingCallerFactory(configuration);
Mockito.when(connection.getRpcRetryingCallerFactory()).thenReturn(callerFactory);
Admin admin = null;
try {
admin = Mockito.spy(new HBaseAdmin(connection));
// mock the call to getRegion since in the absence of a cluster (which means the meta
// is not assigned), getRegion can't function
Mockito.doReturn(null).when(((HBaseAdmin) admin)).getRegion(Matchers.<byte[]>any());
try {
// invoke the HBaseAdmin method
caller.call(admin);
fail();
} catch (RetriesExhaustedException e) {
LOG.info("Expected fail", e);
}
// Assert we were called 'count' times.
caller.verify(masterAdmin, count);
} finally {
if (admin != null) {
admin.close();
}
}
}
use of org.apache.hadoop.hbase.MasterNotRunningException in project hbase by apache.
the class HMasterCommandLine method stopMaster.
@SuppressWarnings("resource")
private int stopMaster() {
Configuration conf = getConf();
// Don't try more than once
conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 0);
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Admin admin = connection.getAdmin()) {
admin.shutdown();
} catch (Throwable t) {
LOG.error("Failed to stop master", t);
return 1;
}
} catch (MasterNotRunningException e) {
LOG.error("Master not running");
return 1;
} catch (ZooKeeperConnectionException e) {
LOG.error("ZooKeeper not available");
return 1;
} catch (IOException e) {
LOG.error("Got IOException: " + e.getMessage(), e);
return 1;
}
return 0;
}
use of org.apache.hadoop.hbase.MasterNotRunningException in project hbase by apache.
the class HMaster method createSystemTable.
@Override
public long createSystemTable(final HTableDescriptor hTableDescriptor) throws IOException {
if (isStopped()) {
throw new MasterNotRunningException();
}
TableName tableName = hTableDescriptor.getTableName();
if (!(tableName.isSystemTable())) {
throw new IllegalArgumentException("Only system table creation can use this createSystemTable API");
}
HRegionInfo[] newRegions = ModifyRegionUtils.createHRegionInfos(hTableDescriptor, null);
LOG.info(getClientIdAuditPrefix() + " create " + hTableDescriptor);
// 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(), hTableDescriptor, newRegions));
return procId;
}
use of org.apache.hadoop.hbase.MasterNotRunningException in project Solbase by Photobucket.
the class SolbaseIndexerTool method setupTables.
private void setupTables() {
HBaseAdmin admin;
try {
// should be running on the cluster that has zoo.cfg or hbase-site.xml on hadoop/hbase classpath already.
Configuration conf = HBaseConfiguration.create();
admin = new HBaseAdmin(conf);
if (!admin.isTableAvailable(SolbaseUtil.termVectorTable)) {
SolbaseUtil.createTermVectorTable(null, null, null);
} else {
//SolbaseUtil.truncateTable(admin, SolbaseUtil.termVectorTable);
}
if (!admin.isTableAvailable(SolbaseUtil.termVectorVersionIDTable)) {
SolbaseUtil.createTermVectorVersionIDTable();
} else {
//SolbaseUtil.truncateTable(admin, SolbaseUtil.termVectorVersionIDTable);
}
if (!admin.isTableAvailable(SolbaseUtil.docKeyIdMapTable)) {
SolbaseUtil.createDocKeyIdMapTable(null, null, null);
} else {
//SolbaseUtil.truncateTable(admin, SolbaseUtil.docKeyIdMapTable);
}
if (!admin.isTableAvailable(SolbaseUtil.docTable)) {
SolbaseUtil.createDocTable(null, null, null);
} else {
//SolbaseUtil.truncateTable(admin, SolbaseUtil.docTable);
}
if (!admin.isTableAvailable(SolbaseUtil.sequenceTable)) {
SolbaseUtil.createSequenceTable();
} else {
//SolbaseUtil.truncateTable(admin, SolbaseUtil.sequenceTable);
}
if (!admin.isTableAvailable(SolbaseUtil.uniqChecksumUserMediaTable)) {
SolbaseUtil.createUniqChecksumUserMediaTable(null, null, null);
} else {
//SolbaseUtil.truncateTable(admin, SolbaseUtil.uniqChecksumUserMediaTable);
}
} catch (MasterNotRunningException e) {
e.printStackTrace();
} catch (ZooKeeperConnectionException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations