private void checkReadOnlyMode() throws TIOError { if (isReadOnly()) { throw getTIOError(ioe); } }
@Override public List<TTableName> getTableNamesByPattern(String regex, boolean includeSysTables) throws TIOError, TException { try { Pattern pattern = (regex == null ? null : Pattern.compile(regex)); TableName[] tableNames = connectionCache.getAdmin() .listTableNames(pattern, includeSysTables); return tableNamesFromHBase(tableNames); } catch (IOException e) { throw getTIOError(e); } }
@Override public boolean isTableAvailable(TTableName tableName) throws TIOError, TException { try { TableName table = tableNameFromThrift(tableName); return connectionCache.getAdmin().isTableAvailable(table); } catch (IOException e) { throw getTIOError(e); } }
@Override public void truncateTable(TTableName tableName, boolean preserveSplits) throws TIOError, TException { try { TableName table = tableNameFromThrift(tableName); connectionCache.getAdmin().truncateTable(table, preserveSplits); } catch (IOException e) { throw getTIOError(e); } }
@Override public boolean isTableDisabled(TTableName tableName) throws TIOError, TException { try { TableName table = tableNameFromThrift(tableName); return connectionCache.getAdmin().isTableDisabled(table); } catch (IOException e) { throw getTIOError(e); } }
@Override public boolean tableExists(TTableName tTableName) throws TIOError, TException { try { TableName tableName = tableNameFromThrift(tTableName); return connectionCache.getAdmin().tableExists(tableName); } catch (IOException e) { throw getTIOError(e); } }
@Override public void modifyTable(TTableDescriptor desc) throws TIOError, TException { try { TableDescriptor descriptor = tableDescriptorFromThrift(desc); connectionCache.getAdmin().modifyTable(descriptor); } catch (IOException e) { throw getTIOError(e); } }
@Override public void createNamespace(TNamespaceDescriptor namespaceDesc) throws TIOError, TException { try { NamespaceDescriptor descriptor = namespaceDescriptorFromThrift(namespaceDesc); connectionCache.getAdmin().createNamespace(descriptor); } catch (IOException e) { throw getTIOError(e); } }
@Override public List<TTableName> getTableNamesByNamespace(String name) throws TIOError, TException { try { TableName[] tableNames = connectionCache.getAdmin().listTableNamesByNamespace(name); return tableNamesFromHBase(tableNames); } catch (IOException e) { throw getTIOError(e); } }
@Override public TTableDescriptor getTableDescriptor(TTableName table) throws TIOError, TException { try { TableName tableName = ThriftUtilities.tableNameFromThrift(table); TableDescriptor tableDescriptor = connectionCache.getAdmin().getDescriptor(tableName); return tableDescriptorFromHBase(tableDescriptor); } catch (IOException e) { throw getTIOError(e); } }
@Override public void addColumnFamily(TTableName tableName, TColumnFamilyDescriptor column) throws TIOError, TException { try { TableName table = tableNameFromThrift(tableName); ColumnFamilyDescriptor columnFamilyDescriptor = columnFamilyDescriptorFromThrift(column); connectionCache.getAdmin().addColumnFamily(table, columnFamilyDescriptor); } catch (IOException e) { throw getTIOError(e); } }
@Override public List<TTableDescriptor> getTableDescriptors(List<TTableName> tables) throws TIOError, TException { try { List<TableName> tableNames = ThriftUtilities.tableNamesFromThrift(tables); List<TableDescriptor> tableDescriptors = connectionCache.getAdmin() .listTableDescriptors(tableNames); return tableDescriptorsFromHBase(tableDescriptors); } catch (IOException e) { throw getTIOError(e); } }
@Override public void modifyColumnFamily(TTableName tableName, TColumnFamilyDescriptor column) throws TIOError, TException { try { TableName table = tableNameFromThrift(tableName); ColumnFamilyDescriptor columnFamilyDescriptor = columnFamilyDescriptorFromThrift(column); connectionCache.getAdmin().modifyColumnFamily(table, columnFamilyDescriptor); } catch (IOException e) { throw getTIOError(e); } }
@Override public boolean exists(ByteBuffer table, TGet get) throws TIOError, TException { Table htable = getTable(table); try { return htable.exists(getFromThrift(get)); } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
@Override public void createTable(TTableDescriptor desc, List<ByteBuffer> splitKeys) throws TIOError, TException { try { TableDescriptor descriptor = tableDescriptorFromThrift(desc); byte[][] split = splitKeyFromThrift(splitKeys); connectionCache.getAdmin().createTable(descriptor, split); } catch (IOException e) { throw getTIOError(e); } }
@Override public boolean isTableAvailableWithSplit(TTableName tableName, List<ByteBuffer> splitKeys) throws TIOError, TException { try { TableName table = tableNameFromThrift(tableName); byte[][] split = splitKeyFromThrift(splitKeys); return connectionCache.getAdmin().isTableAvailable(table, split); } catch (IOException e) { throw getTIOError(e); } }
@Override public List<TResult> getMultiple(ByteBuffer table, List<TGet> gets) throws TIOError, TException { Table htable = getTable(table); try { return resultsFromHBase(htable.get(getsFromThrift(gets))); } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
@Override public TResult get(ByteBuffer table, TGet get) throws TIOError, TException { Table htable = getTable(table); try { return resultFromHBase(htable.get(getFromThrift(get))); } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
@Override public void deleteSingle(ByteBuffer table, TDelete deleteSingle) throws TIOError, TException { checkReadOnlyMode(); Table htable = getTable(table); try { htable.delete(deleteFromThrift(deleteSingle)); } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
@Override public TResult append(ByteBuffer table, TAppend append) throws TIOError, TException { checkReadOnlyMode(); Table htable = getTable(table); try { return resultFromHBase(htable.append(appendFromThrift(append))); } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }