org.apache.hadoop.hbase.TableNotFoundException Java Examples
The following examples show how to use
org.apache.hadoop.hbase.TableNotFoundException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HBaseRowInputFormat.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private void connectToTable() { if (this.conf == null) { this.conf = HBaseConfiguration.create(); } try { Connection conn = ConnectionFactory.createConnection(conf); super.table = (HTable) conn.getTable(TableName.valueOf(tableName)); } catch (TableNotFoundException tnfe) { LOG.error("The table " + tableName + " not found ", tnfe); throw new RuntimeException("HBase table '" + tableName + "' not found.", tnfe); } catch (IOException ioe) { LOG.error("Exception while creating connection to HBase.", ioe); throw new RuntimeException("Cannot create connection to HBase.", ioe); } }
Example #2
Source File: HBaseInterClusterReplicationEndpoint.java From hbase with Apache License 2.0 | 6 votes |
/** * Check if there's an {@link TableNotFoundException} in the caused by stacktrace. */ @VisibleForTesting public static boolean isTableNotFoundException(Throwable io) { if (io instanceof RemoteException) { io = ((RemoteException) io).unwrapRemoteException(); } if (io != null && io.getMessage().contains("TableNotFoundException")) { return true; } for (; io != null; io = io.getCause()) { if (io instanceof TableNotFoundException) { return true; } } return false; }
Example #3
Source File: SnapshotScannerHDFSAclController.java From hbase with Apache License 2.0 | 6 votes |
@Override public void postStartMaster(ObserverContext<MasterCoprocessorEnvironment> c) throws IOException { if (!initialized) { return; } try (Admin admin = c.getEnvironment().getConnection().getAdmin()) { if (admin.tableExists(PermissionStorage.ACL_TABLE_NAME)) { // Check if acl table has 'm' CF, if not, add 'm' CF TableDescriptor tableDescriptor = admin.getDescriptor(PermissionStorage.ACL_TABLE_NAME); boolean containHdfsAclFamily = Arrays.stream(tableDescriptor.getColumnFamilies()).anyMatch( family -> Bytes.equals(family.getName(), SnapshotScannerHDFSAclStorage.HDFS_ACL_FAMILY)); if (!containHdfsAclFamily) { TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableDescriptor) .setColumnFamily(ColumnFamilyDescriptorBuilder .newBuilder(SnapshotScannerHDFSAclStorage.HDFS_ACL_FAMILY).build()); admin.modifyTable(builder.build()); } aclTableInitialized = true; } else { throw new TableNotFoundException("Table " + PermissionStorage.ACL_TABLE_NAME + " is not created yet. Please check if " + getClass().getName() + " is configured after " + AccessController.class.getName()); } } }
Example #4
Source File: HBaseLookupFunction.java From flink with Apache License 2.0 | 6 votes |
@Override public void open(FunctionContext context) { LOG.info("start open ..."); org.apache.hadoop.conf.Configuration config = prepareRuntimeConfiguration(); try { hConnection = ConnectionFactory.createConnection(config); table = (HTable) hConnection.getTable(TableName.valueOf(hTableName)); } catch (TableNotFoundException tnfe) { LOG.error("Table '{}' not found ", hTableName, tnfe); throw new RuntimeException("HBase table '" + hTableName + "' not found.", tnfe); } catch (IOException ioe) { LOG.error("Exception while creating connection to HBase.", ioe); throw new RuntimeException("Cannot create connection to HBase.", ioe); } this.readHelper = new HBaseReadWriteHelper(hbaseTableSchema); LOG.info("end open."); }
Example #5
Source File: HBaseRowDataLookupFunction.java From flink with Apache License 2.0 | 6 votes |
@Override public void open(FunctionContext context) { LOG.info("start open ..."); Configuration config = prepareRuntimeConfiguration(); try { hConnection = ConnectionFactory.createConnection(config); table = (HTable) hConnection.getTable(TableName.valueOf(hTableName)); } catch (TableNotFoundException tnfe) { LOG.error("Table '{}' not found ", hTableName, tnfe); throw new RuntimeException("HBase table '" + hTableName + "' not found.", tnfe); } catch (IOException ioe) { LOG.error("Exception while creating connection to HBase.", ioe); throw new RuntimeException("Cannot create connection to HBase.", ioe); } this.serde = new HBaseSerde(hbaseTableSchema, nullStringLiteral); LOG.info("end open."); }
Example #6
Source File: TestAccessController3.java From hbase with Apache License 2.0 | 6 votes |
private static void cleanUp() throws Exception { // Clean the _acl_ table // TODO: Skipping delete because of access issues w/ AMv2. // AMv1 seems to crash servers on exit too for same lack of // auth perms but it gets hung up. try { deleteTable(TEST_UTIL, TEST_TABLE); } catch (TableNotFoundException ex) { // Test deleted the table, no problem LOG.info("Test deleted table " + TEST_TABLE); } // Verify all table/namespace permissions are erased assertEquals(0, PermissionStorage.getTablePermissions(conf, TEST_TABLE).size()); assertEquals(0, PermissionStorage.getNamespacePermissions(conf, TEST_TABLE.getNamespaceAsString()).size()); }
Example #7
Source File: ExportHBaseTableToDelimiteredTxt.java From HBase-ToHDFS with Apache License 2.0 | 6 votes |
@Override public void setup(Context context) throws TableNotFoundException, IOException { fs = FileSystem.get(context.getConfiguration()); taskId = context.getTaskAttemptID().getTaskID().getId(); schemaFileLocation = context.getConfiguration().get(SCHEMA_FILE_LOCATION_CONF); columns = generateColumnsFromSchemaFile(fs, schemaFileLocation); String outputPath = context.getConfiguration().get(OUTPUT_PATH_CONF); boolean shouldCompress = context.getConfiguration().getBoolean(SHOULD_COMPRESSION_CONF, false); OutputStream outputStream = fs.create(new Path(outputPath + "/part-m-" + StringUtils.leftPad(Integer.toString(taskId), 5, "0")), true); if (shouldCompress) { outputStream = new GZIPOutputStream(outputStream); } writer = new BufferedWriter(new OutputStreamWriter(outputStream)); delimiter = context.getConfiguration().get(DELIMITER_CONF); rowKeyColumn = context.getConfiguration().get(ROW_KEY_COLUMN_CONF); }
Example #8
Source File: RawAsyncHBaseAdmin.java From hbase with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<Void> disableTableReplication(TableName tableName) { if (tableName == null) { return failedFuture(new IllegalArgumentException("Table name is null")); } CompletableFuture<Void> future = new CompletableFuture<>(); addListener(tableExists(tableName), (exist, err) -> { if (err != null) { future.completeExceptionally(err); return; } if (!exist) { future.completeExceptionally(new TableNotFoundException( "Table '" + tableName.getNameAsString() + "' does not exists.")); return; } addListener(setTableReplication(tableName, false), (result, err2) -> { if (err2 != null) { future.completeExceptionally(err2); } else { future.complete(result); } }); }); return future; }
Example #9
Source File: RSGroupAdminClient.java From hbase with Apache License 2.0 | 6 votes |
/** * Move given set of servers and tables to the specified target RegionServer group. * @param servers set of servers to move * @param tables set of tables to move * @param targetGroup the target group name * @throws IOException if moving the server and tables fail */ public void moveServersAndTables(Set<Address> servers, Set<TableName> tables, String targetGroup) throws IOException { MoveServersAndTablesRequest.Builder builder = MoveServersAndTablesRequest.newBuilder().setTargetGroup(targetGroup); for (Address el : servers) { builder.addServers(HBaseProtos.ServerName.newBuilder().setHostName(el.getHostname()) .setPort(el.getPort()).build()); } for (TableName tableName : tables) { builder.addTableName(ProtobufUtil.toProtoTableName(tableName)); if (!admin.tableExists(tableName)) { throw new TableNotFoundException(tableName); } } try { stub.moveServersAndTables(null, builder.build()); } catch (ServiceException e) { throw ProtobufUtil.handleRemoteException(e); } }
Example #10
Source File: TableOutputFormat.java From hbase with Apache License 2.0 | 6 votes |
/** * Checks if the output table exists and is enabled. * * @param context The current context. * @throws IOException When the check fails. * @throws InterruptedException When the job is aborted. * @see OutputFormat#checkOutputSpecs(JobContext) */ @Override public void checkOutputSpecs(JobContext context) throws IOException, InterruptedException { Configuration hConf = getConf(); if (hConf == null) { hConf = context.getConfiguration(); } try (Admin admin = ConnectionFactory.createConnection(hConf).getAdmin()) { TableName tableName = TableName.valueOf(hConf.get(OUTPUT_TABLE)); if (!admin.tableExists(tableName)) { throw new TableNotFoundException("Can't write, table does not exist:" + tableName.getNameAsString()); } if (!admin.isTableEnabled(tableName)) { throw new TableNotEnabledException("Can't write, table is not enabled: " + tableName.getNameAsString()); } } }
Example #11
Source File: HBaseRowInputFormat.java From flink with Apache License 2.0 | 6 votes |
private void connectToTable() { if (this.conf == null) { this.conf = HBaseConfiguration.create(); } try { Connection conn = ConnectionFactory.createConnection(conf); super.table = (HTable) conn.getTable(TableName.valueOf(tableName)); } catch (TableNotFoundException tnfe) { LOG.error("The table " + tableName + " not found ", tnfe); throw new RuntimeException("HBase table '" + tableName + "' not found.", tnfe); } catch (IOException ioe) { LOG.error("Exception while creating connection to HBase.", ioe); throw new RuntimeException("Cannot create connection to HBase.", ioe); } }
Example #12
Source File: TestTruncateTableProcedure.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testTruncateNotExistentTable() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); // HBASE-20178 has us fail-fast, in the constructor, so add try/catch for this case. // Keep old way of looking at procedure too. Throwable cause = null; try { long procId = ProcedureTestingUtility.submitAndWait(procExec, new TruncateTableProcedure(procExec.getEnvironment(), tableName, true)); // Second delete should fail with TableNotFound Procedure<?> result = procExec.getResult(procId); assertTrue(result.isFailed()); cause = ProcedureTestingUtility.getExceptionCause(result); } catch (Throwable t) { cause = t; } LOG.debug("Truncate failed with exception: " + cause); assertTrue(cause instanceof TableNotFoundException); }
Example #13
Source File: HBaseLookupFunction.java From flink with Apache License 2.0 | 6 votes |
@Override public void open(FunctionContext context) { LOG.info("start open ..."); org.apache.hadoop.conf.Configuration config = prepareRuntimeConfiguration(); try { hConnection = ConnectionFactory.createConnection(config); table = (HTable) hConnection.getTable(TableName.valueOf(hTableName)); } catch (TableNotFoundException tnfe) { LOG.error("Table '{}' not found ", hTableName, tnfe); throw new RuntimeException("HBase table '" + hTableName + "' not found.", tnfe); } catch (IOException ioe) { LOG.error("Exception while creating connection to HBase.", ioe); throw new RuntimeException("Cannot create connection to HBase.", ioe); } this.readHelper = new HBaseReadWriteHelper(hbaseTableSchema); LOG.info("end open."); }
Example #14
Source File: RawAsyncHBaseAdmin.java From hbase with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<Void> enableTableReplication(TableName tableName) { if (tableName == null) { return failedFuture(new IllegalArgumentException("Table name is null")); } CompletableFuture<Void> future = new CompletableFuture<>(); addListener(tableExists(tableName), (exist, err) -> { if (err != null) { future.completeExceptionally(err); return; } if (!exist) { future.completeExceptionally(new TableNotFoundException( "Table '" + tableName.getNameAsString() + "' does not exists.")); return; } addListener(getTableSplits(tableName), (splits, err1) -> { if (err1 != null) { future.completeExceptionally(err1); } else { addListener(checkAndSyncTableToPeerClusters(tableName, splits), (result, err2) -> { if (err2 != null) { future.completeExceptionally(err2); } else { addListener(setTableReplication(tableName, true), (result3, err3) -> { if (err3 != null) { future.completeExceptionally(err3); } else { future.complete(result3); } }); } }); } }); }); return future; }
Example #15
Source File: TestImportTsv.java From hbase with Apache License 2.0 | 5 votes |
/** * If table is not present in bulk mode and create.table is not set to yes, * import should fail with TableNotFoundException. */ @Test public void testDryModeWithBulkOutputAndTableDoesNotExistsCreateTableSetToNo() throws Exception { // Prepare the arguments required for the test. Path hfiles = new Path(util.getDataTestDirOnTestFS(tn.getNameAsString()), "hfiles"); args.put(ImportTsv.BULK_OUTPUT_CONF_KEY, hfiles.toString()); args.put(ImportTsv.DRY_RUN_CONF_KEY, "true"); args.put(ImportTsv.CREATE_TABLE_CONF_KEY, "no"); exception.expect(TableNotFoundException.class); doMROnTableTest(null, 1); }
Example #16
Source File: TestRestoreSnapshotProcedure.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testRestoreSnapshotToDifferentTable() throws Exception { final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); final TableName restoredTableName = TableName.valueOf(name.getMethodName()); final TableDescriptor tableDescriptor = createHTableDescriptor(restoredTableName, CF1, CF2); long procId = ProcedureTestingUtility.submitAndWait( procExec, new RestoreSnapshotProcedure(procExec.getEnvironment(), tableDescriptor, snapshot)); Procedure<?> result = procExec.getResult(procId); assertTrue(result.isFailed()); LOG.debug("Restore snapshot failed with exception: " + result.getException()); assertTrue( ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotFoundException); }
Example #17
Source File: TestDeleteTableProcedure.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testDeleteDeletedTable() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); RegionInfo[] regions = MasterProcedureTestingUtility.createTable( procExec, tableName, null, "f"); UTIL.getAdmin().disableTable(tableName); // delete the table (that exists) long procId1 = procExec.submitProcedure( new DeleteTableProcedure(procExec.getEnvironment(), tableName)); // delete the table (that will no longer exist) long procId2 = procExec.submitProcedure( new DeleteTableProcedure(procExec.getEnvironment(), tableName)); // Wait the completion ProcedureTestingUtility.waitProcedure(procExec, procId1); ProcedureTestingUtility.waitProcedure(procExec, procId2); // First delete should succeed ProcedureTestingUtility.assertProcNotFailed(procExec, procId1); MasterProcedureTestingUtility.validateTableDeletion(getMaster(), tableName); // Second delete should fail with TableNotFound Procedure<?> result = procExec.getResult(procId2); assertTrue(result.isFailed()); LOG.debug("Delete failed with exception: " + result.getException()); assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotFoundException); }
Example #18
Source File: TestDeleteTableProcedure.java From hbase with Apache License 2.0 | 5 votes |
@Test(expected=TableNotFoundException.class) public void testDeleteNotExistentTable() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); ProcedurePrepareLatch latch = new ProcedurePrepareLatch.CompatibilityLatch(); long procId = ProcedureTestingUtility.submitAndWait(procExec, new DeleteTableProcedure(procExec.getEnvironment(), tableName, latch)); latch.await(); }
Example #19
Source File: TestRSGroupsWithACL.java From hbase with Apache License 2.0 | 5 votes |
private static void cleanUp() throws Exception { // Clean the _acl_ table try { deleteTable(TEST_UTIL, TEST_TABLE); } catch (TableNotFoundException ex) { // Test deleted the table, no problem LOG.info("Test deleted table " + TEST_TABLE); } // Verify all table/namespace permissions are erased assertEquals(0, PermissionStorage.getTablePermissions(conf, TEST_TABLE).size()); assertEquals(0, PermissionStorage.getNamespacePermissions(conf, TEST_TABLE.getNamespaceAsString()).size()); }
Example #20
Source File: TruncateTableProcedure.java From hbase with Apache License 2.0 | 5 votes |
private boolean prepareTruncate(final MasterProcedureEnv env) throws IOException { try { env.getMasterServices().checkTableModifiable(getTableName()); } catch (TableNotFoundException|TableNotDisabledException e) { setFailure("master-truncate-table", e); return false; } return true; }
Example #21
Source File: TestAsyncReplicationAdminApiWithClusters.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testDisableReplicationForNonExistingTable() throws Exception { try { admin.disableTableReplication(tableName).join(); } catch (CompletionException e) { assertTrue(e.getCause() instanceof TableNotFoundException); } }
Example #22
Source File: RawAsyncHBaseAdmin.java From hbase with Apache License 2.0 | 5 votes |
/** * Utility for completing passed TableState {@link CompletableFuture} <code>future</code> * using passed parameters. Sets error or boolean result ('true' if table matches * the passed-in targetState). */ private static CompletableFuture<Boolean> completeCheckTableState( CompletableFuture<Boolean> future, TableState tableState, Throwable error, TableState.State targetState, TableName tableName) { if (error != null) { future.completeExceptionally(error); } else { if (tableState != null) { future.complete(tableState.inStates(targetState)); } else { future.completeExceptionally(new TableNotFoundException(tableName)); } } return future; }
Example #23
Source File: TestAccessController.java From hbase with Apache License 2.0 | 5 votes |
private static void cleanUp() throws Exception { // Clean the _acl_ table try { deleteTable(TEST_UTIL, TEST_TABLE); } catch (TableNotFoundException ex) { // Test deleted the table, no problem LOG.info("Test deleted table " + TEST_TABLE); } // Verify all table/namespace permissions are erased assertEquals(0, PermissionStorage.getTablePermissions(conf, TEST_TABLE).size()); assertEquals(0, PermissionStorage.getNamespacePermissions(conf, TEST_TABLE.getNamespaceAsString()).size()); }
Example #24
Source File: TestCellACLs.java From hbase with Apache License 2.0 | 5 votes |
@After public void tearDown() throws Exception { // Clean the _acl_ table try { TEST_UTIL.deleteTable(testTable.getTableName()); } catch (TableNotFoundException ex) { // Test deleted the table, no problem LOG.info("Test deleted table " + testTable.getTableName()); } assertEquals(0, PermissionStorage.getTablePermissions(conf, testTable.getTableName()).size()); }
Example #25
Source File: EnableTableProcedure.java From hbase with Apache License 2.0 | 5 votes |
/** * Action before any real action of enabling table. Set the exception in the procedure instead * of throwing it. This approach is to deal with backward compatible with 1.0. * @param env MasterProcedureEnv * @return whether the table passes the necessary checks * @throws IOException */ private boolean prepareEnable(final MasterProcedureEnv env) throws IOException { boolean canTableBeEnabled = true; // Check whether table exists if (!MetaTableAccessor.tableExists(env.getMasterServices().getConnection(), tableName)) { setFailure("master-enable-table", new TableNotFoundException(tableName)); canTableBeEnabled = false; } else { // There could be multiple client requests trying to disable or enable // the table at the same time. Ensure only the first request is honored // After that, no other requests can be accepted until the table reaches // DISABLED or ENABLED. // // Note: in 1.0 release, we called TableStateManager.setTableStateIfInStates() to set // the state to ENABLING from DISABLED. The implementation was done before table lock // was implemented. With table lock, there is no need to set the state here (it will // set the state later on). A quick state check should be enough for us to move forward. TableStateManager tsm = env.getMasterServices().getTableStateManager(); TableState ts = tsm.getTableState(tableName); if(!ts.isDisabled()){ LOG.info("Not DISABLED tableState={}; skipping enable; {}", ts.getState(), this); setFailure("master-enable-table", new TableNotDisabledException(ts.toString())); canTableBeEnabled = false; } } // We are done the check. Future actions in this procedure could be done asynchronously. releaseSyncLatch(); return canTableBeEnabled; }
Example #26
Source File: DeleteTableProcedure.java From hbase with Apache License 2.0 | 5 votes |
private boolean prepareDelete(final MasterProcedureEnv env) throws IOException { try { env.getMasterServices().checkTableModifiable(tableName); } catch (TableNotFoundException|TableNotDisabledException e) { setFailure("master-delete-table", e); return false; } return true; }
Example #27
Source File: TestAccessController2.java From hbase with Apache License 2.0 | 5 votes |
@After public void tearDown() throws Exception { // Clean the _acl_ table try { deleteTable(TEST_UTIL, tableName); } catch (TableNotFoundException ex) { // Test deleted the table, no problem LOG.info("Test deleted table " + tableName); } deleteNamespace(TEST_UTIL, namespace); // Verify all table/namespace permissions are erased assertEquals(0, PermissionStorage.getTablePermissions(conf, tableName).size()); assertEquals(0, PermissionStorage.getNamespacePermissions(conf, namespace).size()); }
Example #28
Source File: TestWithDisabledAuthorization.java From hbase with Apache License 2.0 | 5 votes |
@After public void tearDown() throws Exception { // Clean the _acl_ table try { deleteTable(TEST_UTIL, testTable.getTableName()); } catch (TableNotFoundException ex) { // Test deleted the table, no problem LOG.info("Test deleted table " + testTable.getTableName()); } // Verify all table/namespace permissions are erased assertEquals(0, PermissionStorage .getTablePermissions(TEST_UTIL.getConfiguration(), testTable.getTableName()).size()); assertEquals(0, PermissionStorage.getNamespacePermissions(TEST_UTIL.getConfiguration(), testTable.getTableName().getNamespaceAsString()).size()); }
Example #29
Source File: TestScanEarlyTermination.java From hbase with Apache License 2.0 | 5 votes |
@After public void tearDown() throws Exception { // Clean the _acl_ table try { TEST_UTIL.deleteTable(testTable.getTableName()); } catch (TableNotFoundException ex) { // Test deleted the table, no problem LOG.info("Test deleted table " + testTable.getTableName()); } assertEquals(0, PermissionStorage.getTablePermissions(conf, testTable.getTableName()).size()); }
Example #30
Source File: TableStateManager.java From hbase with Apache License 2.0 | 5 votes |
@NonNull public TableState getTableState(TableName tableName) throws IOException { ReadWriteLock lock = tnLock.getLock(tableName); lock.readLock().lock(); try { TableState currentState = readMetaState(tableName); if (currentState == null) { throw new TableNotFoundException("No state found for " + tableName); } return currentState; } finally { lock.readLock().unlock(); } }