private TableName parseTable(String msg) { // ... TableNotFoundException: '<table>'/n... Pattern p = Pattern.compile("TableNotFoundException: '([\\S]*)'"); Matcher m = p.matcher(msg); if (m.find()) { String table = m.group(1); try { // double check that table is a valid table name TableName.valueOf(TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(table))); return TableName.valueOf(table); } catch (IllegalArgumentException ignore) { } } return null; }
@Override public void deleteSnapshot(final String snapshotName) throws IOException { // make sure the snapshot is possibly valid TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(snapshotName)); // do the delete executeCallable(new MasterCallable<Void>(getConnection(), getRpcControllerFactory()) { @Override protected Void rpcCall() throws Exception { master.deleteSnapshot(getRpcController(), DeleteSnapshotRequest.newBuilder().setSnapshot( SnapshotProtos.SnapshotDescription.newBuilder().setName(snapshotName).build()) .build() ); return null; } }); }
@Test public void testLegalTableNames() { for (String tn : legalTableNames) { TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); } }
@Test public void testLegalHTableNames() { for (String tn : legalTableNames) { TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); } }
@Test public void testLegalHTableNames() { for (String tn : legalTableNames) { TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); } }
@Test public void testIllegalZooKeeperName() { for (String name : Arrays.asList("zookeeper", "ns:zookeeper", "zookeeper:table")) { try { TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(name)); fail("invalid tablename " + name + " should have failed"); } catch (Exception e) { // expected } } }
@Test(expected = IllegalArgumentException.class) public void testInvalidNamespace() { for (String tn : invalidNamespace) { TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); fail("invalid namespace " + tn + " should have failed with IllegalArgumentException for namespace"); } }
@Test(expected = IllegalArgumentException.class) public void testEmptyTableName() { for (String tn : emptyNames) { TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); fail("invalid tablename " + tn + " should have failed with IllegalArgumentException"); } }
@Test public void testIllegalHTableNames() { for (String tn : illegalTableNames) { try { TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); fail("invalid tablename " + tn + " should have failed"); } catch (Exception e) { // expected } } }
@Test public void testIllegalTableNames() { for (String tn : illegalTableNames) { try { TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); fail("invalid tablename " + tn + " should have failed"); } catch (Exception e) { // expected } } }
@Test public void testIllegalHTableNames() { for (String tn : illegalTableNames) { try { TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); fail("invalid tablename " + tn + " should have failed"); } catch (Exception e) { // expected } } }
@Override public Future<Void> disableTableAsync(final TableName tableName) throws IOException { TableName.isLegalFullyQualifiedTableName(tableName.getName()); DisableTableResponse response = executeCallable( new MasterCallable<DisableTableResponse>(getConnection(), getRpcControllerFactory()) { Long nonceGroup = ng.getNonceGroup(); Long nonce = ng.newNonce(); @Override protected DisableTableResponse rpcCall() throws Exception { setPriority(tableName); LOG.info("Started disable of " + tableName); DisableTableRequest req = RequestConverter.buildDisableTableRequest( tableName, nonceGroup, nonce); return master.disableTable(getRpcController(), req); } }); return new DisableTableFuture(this, tableName, response); }
@Override public Future<Void> enableTableAsync(final TableName tableName) throws IOException { TableName.isLegalFullyQualifiedTableName(tableName.getName()); EnableTableResponse response = executeCallable( new MasterCallable<EnableTableResponse>(getConnection(), getRpcControllerFactory()) { Long nonceGroup = ng.getNonceGroup(); Long nonce = ng.newNonce(); @Override protected EnableTableResponse rpcCall() throws Exception { setPriority(tableName); LOG.info("Started enable of " + tableName); EnableTableRequest req = RequestConverter.buildEnableTableRequest(tableName, nonceGroup, nonce); return master.enableTable(getRpcController(),req); } }); return new EnableTableFuture(this, tableName, response); }
@Test public void testLegalHTableNames() { for (String tn : legalTableNames) { TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); } }
@Override public void deleteSnapshot(final String snapshotName) throws IOException { // make sure the snapshot is possibly valid TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(snapshotName)); // do the delete executeCallable(new MasterCallable<Void>(getConnection(), getRpcControllerFactory()) { @Override protected Void rpcCall() throws Exception { master.deleteSnapshot(getRpcController(), DeleteSnapshotRequest.newBuilder().setSnapshot( SnapshotProtos.SnapshotDescription.newBuilder().setName(snapshotName).build()) .build() ); return null; } }); }
@Test public void testLegalTableNames() { for (String tn : legalTableNames) { TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); } }
@Test public void testIllegalZooKeeperName() { for (String name : Arrays.asList("zookeeper", "ns:zookeeper", "zookeeper:table")) { try { TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(name)); fail("invalid tablename " + name + " should have failed"); } catch (Exception e) { // expected } } }
@Test public void testIllegalTableNames() { for (String tn : illegalTableNames) { try { TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); fail("invalid tablename " + tn + " should have failed"); } catch (Exception e) { // expected } } }
@Test public void testIllegalHTableNames() { for (String tn : illegalTableNames) { try { TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); fail("invalid tablename " + tn + " should have failed"); } catch (Exception e) { // expected } } }
@Override public Future<Void> enableTableAsync(final TableName tableName) throws IOException { TableName.isLegalFullyQualifiedTableName(tableName.getName()); EnableTableResponse response = executeCallable( new MasterCallable<EnableTableResponse>(getConnection(), getRpcControllerFactory()) { Long nonceGroup = ng.getNonceGroup(); Long nonce = ng.newNonce(); @Override protected EnableTableResponse rpcCall() throws Exception { setPriority(tableName); LOG.info("Started enable of " + tableName); EnableTableRequest req = RequestConverter.buildEnableTableRequest(tableName, nonceGroup, nonce); return master.enableTable(getRpcController(),req); } }); return new EnableTableFuture(this, tableName, response); }