/** * Deletes a table. * @param tableName name of table to delete * @throws IOException if a remote or network exception occurs */ public void deleteTable(final String tableName) throws IOException { deleteTable(Bytes.toBytes(tableName)); }
/** * @param tableName name of table to check * @return true if all regions of the table are available * @throws IOException if a remote or network exception occurs */ public boolean isTableAvailable(String tableName) throws IOException { return isTableAvailable(Bytes.toBytes(tableName)); }
@Test public void testParsingClusterVersion() throws Exception { final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<ClusterVersion Version=\"2.0.0\"/>"; Client client = mock(Client.class); RemoteAdmin admin = new RemoteAdmin(client, HBaseConfiguration.create(), null); Response resp = new Response(200, null, Bytes.toBytes(xml)); when(client.get("/version/cluster", Constants.MIMETYPE_XML)).thenReturn(resp); StorageClusterVersionModel cv = admin.getClusterVersion(); assertEquals("2.0.0", cv.getVersion()); }
try { return (StorageClusterVersionModel) getUnmarsheller().unmarshal( getInputStream(response)); } catch (JAXBException jaxbe) {
private boolean checkTable(RemoteAdmin admin) throws IOException { HTableDescriptor tableDescriptor = getTableDescriptor(); if (this.presplitRegions > 0) { // presplit requested if (admin.isTableAvailable(tableDescriptor.getTableName().getName())) { admin.deleteTable(tableDescriptor.getTableName().getName()); } byte[][] splits = getSplits(); for (int i=0; i < splits.length; i++) { LOG.debug(" split " + i + ": " + Bytes.toStringBinary(splits[i])); } admin.createTable(tableDescriptor); LOG.info ("Table created with " + this.presplitRegions + " splits"); } else { boolean tableExists = admin.isTableAvailable(tableDescriptor.getTableName().getName()); if (!tableExists) { admin.createTable(tableDescriptor); LOG.info("Table " + tableDescriptor + " created"); } } boolean tableExists = admin.isTableAvailable(tableDescriptor.getTableName().getName()); return tableExists; }
@Before public void setup() throws Exception { client = mock(Client.class); Response response = new Response(509); when(client.get(anyString(), anyString())).thenReturn(response); when(client.delete(anyString())).thenReturn(response); when(client.put(anyString(), anyString(), any())).thenReturn(response); when(client.post(anyString(), anyString(), any())).thenReturn(response); Configuration configuration = TEST_UTIL.getConfiguration(); configuration.setInt("hbase.rest.client.max.retries", RETRIES); configuration.setInt("hbase.rest.client.sleep", SLEEP_TIME); remoteAdmin = new RemoteAdmin(client, TEST_UTIL.getConfiguration(), "MyTable"); }
@Override public void run() throws Exception { remoteAdmin.createTable(new HTableDescriptor(TableName.valueOf("TestTable"))); } });
@Override public void run() throws Exception { remoteAdmin.getTableList(); } });
@Override public void run() throws Exception { remoteAdmin.getClusterStatus(); } });
@Override public void run() throws Exception { remoteAdmin.getRestVersion(); } });
@Override public void run() throws Exception { remoteAdmin.getClusterVersion(); } });
private boolean checkTable(RemoteAdmin admin) throws IOException { HTableDescriptor tableDescriptor = getTableDescriptor(); if (this.presplitRegions > 0) { // presplit requested if (admin.isTableAvailable(tableDescriptor.getTableName().getName())) { admin.deleteTable(tableDescriptor.getTableName().getName()); } byte[][] splits = getSplits(); for (int i=0; i < splits.length; i++) { LOG.debug(" split " + i + ": " + Bytes.toStringBinary(splits[i])); } admin.createTable(tableDescriptor); LOG.info ("Table created with " + this.presplitRegions + " splits"); } else { boolean tableExists = admin.isTableAvailable(tableDescriptor.getTableName().getName()); if (!tableExists) { admin.createTable(tableDescriptor); LOG.info("Table " + tableDescriptor + " created"); } } boolean tableExists = admin.isTableAvailable(tableDescriptor.getTableName().getName()); return tableExists; }
private void runNIsOne(final Class<? extends Test> cmd) { Status status = new Status() { @Override public void setStatus(String msg) throws IOException { LOG.info(msg); } }; RemoteAdmin admin = null; try { Client client = new Client(cluster); admin = new RemoteAdmin(client, getConf()); checkTable(admin); runOneClient(cmd, 0, this.R, this.R, this.flushCommits, this.writeToWAL, this.useTags, this.noOfTags, this.connection, status); } catch (Exception e) { LOG.error("Failed", e); } }
try { return (StorageClusterVersionModel) getUnmarsheller().unmarshal( getInputStream(response)); } catch (JAXBException jaxbe) {
private void createTable(HTableDescriptor hTableDescriptor) { try { synchronized (mutex) { remoteAdmin.createTable(hTableDescriptor); } } catch (IOException e) { throw new CreateTableException(e); } }
@Override public void run() throws Exception { remoteAdmin.getTableList(); } });
@Override public void run() throws Exception { remoteAdmin.getClusterStatus(); } });
@Override public void run() throws Exception { remoteAdmin.getRestVersion(); } });
@Override public void run() throws Exception { remoteAdmin.getClusterVersion(); } });
@Override public void run() throws Exception { remoteAdmin.isTableAvailable(Bytes.toBytes("TestTable")); } });