@BeforeClass public static void setUpBeforeClass() throws Exception { conf = TEST_UTIL.getConfiguration(); TEST_UTIL.startMiniCluster(); REST_TEST_UTIL.startServletContainer(conf); client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort())); testNamespacesInstanceModel = new TestNamespacesInstanceModel(); context = JAXBContext.newInstance(NamespacesInstanceModel.class, TableListModel.class); jsonMapper = new JacksonProvider() .locateMapper(NamespacesInstanceModel.class, MediaType.APPLICATION_JSON_TYPE); NAMESPACE1_PROPS.put("key1", "value1"); NAMESPACE2_PROPS.put("key2a", "value2a"); NAMESPACE2_PROPS.put("key2b", "value2b"); NAMESPACE3_PROPS.put("key3", "value3"); NAMESPACE4_PROPS.put("key4a", "value4a"); NAMESPACE4_PROPS.put("key4b", "value4b"); }
@BeforeClass public static void setUpBeforeClass() throws Exception { conf = TEST_UTIL.getConfiguration(); TEST_UTIL.startMiniCluster(); REST_TEST_UTIL.startServletContainer(conf); client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort())); testNamespacesInstanceModel = new TestNamespacesInstanceModel(); context = JAXBContext.newInstance(NamespacesInstanceModel.class, TableListModel.class); jsonMapper = new JacksonJaxbJsonProvider() .locateMapper(NamespacesInstanceModel.class, MediaType.APPLICATION_JSON_TYPE); NAMESPACE1_PROPS.put("key1", "value1"); NAMESPACE2_PROPS.put("key2a", "value2a"); NAMESPACE2_PROPS.put("key2b", "value2b"); NAMESPACE3_PROPS.put("key3", "value3"); NAMESPACE4_PROPS.put("key4a", "value4a"); NAMESPACE4_PROPS.put("key4b", "value4b"); }
/** * @return string representing the cluster's version * @throws IOException * if the endpoint does not exist, there is a timeout, or some other * general failure mode */ public TableListModel getTableList() throws IOException { StringBuilder path = new StringBuilder(); path.append('/'); if (accessToken != null) { path.append(accessToken); path.append('/'); } int code = 0; for (int i = 0; i < maxRetries; i++) { // Response response = client.get(path.toString(), // Constants.MIMETYPE_XML); Response response = client.get(path.toString(), Constants.MIMETYPE_PROTOBUF); code = response.getCode(); switch (code) { case 200: TableListModel t = new TableListModel(); return (TableListModel) t.getObjectFromMessage(response.getBody()); case 404: throw new IOException("Table list not found"); case 509: try { Thread.sleep(sleepTime); } catch (InterruptedException e) { throw (InterruptedIOException)new InterruptedIOException().initCause(e); } break; default: throw new IOException("get request to " + path.toString() + " request returned " + code); } } throw new IOException("get request to " + path.toString() + " request timed out"); }
private final TableListModel getTableList() throws IOException { TableListModel tableList = new TableListModel(); TableName[] tableNames = servlet.getAdmin().listTableNames(); for (TableName name: tableNames) { tableList.add(new TableModel(name.getNameAsString())); } return tableList; }
private static void checkTableList(TableListModel model) { boolean found = false; Iterator<TableModel> tables = model.getTables().iterator(); assertTrue(tables.hasNext()); while (tables.hasNext()) { TableModel table = tables.next(); if (table.getName().equals(TABLE.getNameAsString())) { found = true; break; } } assertTrue(found); }
@Test public void testTableListXML() throws IOException, JAXBException { Response response = client.get("/", Constants.MIMETYPE_XML); assertEquals(response.getCode(), 200); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); TableListModel model = (TableListModel) context.createUnmarshaller() .unmarshal(new ByteArrayInputStream(response.getBody())); checkTableList(model); }
/** * @return string representing the cluster's version * @throws IOEXception * if the endpoint does not exist, there is a timeout, or some other * general failure mode */ public TableListModel getTableList() throws IOException { StringBuilder path = new StringBuilder(); path.append('/'); if (accessToken != null) { path.append(accessToken); path.append('/'); } int code = 0; for (int i = 0; i < maxRetries; i++) { // Response response = client.get(path.toString(), // Constants.MIMETYPE_XML); Response response = client.get(path.toString(), Constants.MIMETYPE_PROTOBUF); code = response.getCode(); switch (code) { case 200: TableListModel t = new TableListModel(); return (TableListModel) t.getObjectFromMessage(response.getBody()); case 404: throw new IOException("Table list not found"); case 509: try { Thread.sleep(sleepTime); } catch (InterruptedException e) { } break; default: throw new IOException("get request to " + path.toString() + " request returned " + code); } } throw new IOException("get request to " + path.toString() + " request timed out"); }
private final TableListModel getTableList() throws IOException { TableListModel tableList = new TableListModel(); String[] tableNames = servlet.getAdmin().getTableNames(); for (String name: tableNames) { tableList.add(new TableModel(name)); } return tableList; }
private static void checkTableList(TableListModel model) { boolean found = false; Iterator<TableModel> tables = model.getTables().iterator(); assertTrue(tables.hasNext()); while (tables.hasNext()) { TableModel table = tables.next(); if (table.getName().equals(TABLE)) { found = true; break; } } assertTrue(found); }
@Test public void testTableListXML() throws IOException, JAXBException { Response response = client.get("/", Constants.MIMETYPE_XML); assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); TableListModel model = (TableListModel) context.createUnmarshaller() .unmarshal(new ByteArrayInputStream(response.getBody())); checkTableList(model); }
private final TableListModel getTableList() throws IOException { TableListModel tableList = new TableListModel(); HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration()); HTableDescriptor[] list = admin.listTables(); for (HTableDescriptor htd: list) { tableList.add(new TableModel(htd.getNameAsString())); } return tableList; }
/** * @return string representing the cluster's version * @throws IOEXception * if the endpoint does not exist, there is a timeout, or some other * general failure mode */ public TableListModel getTableList() throws IOException { StringBuilder path = new StringBuilder(); path.append('/'); if (accessToken != null) { path.append(accessToken); path.append('/'); } int code = 0; for (int i = 0; i < maxRetries; i++) { // Response response = client.get(path.toString(), // Constants.MIMETYPE_XML); Response response = client.get(path.toString(), Constants.MIMETYPE_PROTOBUF); code = response.getCode(); switch (code) { case 200: TableListModel t = new TableListModel(); return (TableListModel) t.getObjectFromMessage(response.getBody()); case 404: throw new IOException("Table list not found"); case 509: try { Thread.sleep(sleepTime); } catch (InterruptedException e) { throw (InterruptedIOException)new InterruptedIOException().initCause(e); } break; default: throw new IOException("get request to " + path.toString() + " request returned " + code); } } throw new IOException("get request to " + path.toString() + " request timed out"); }
private final TableListModel getTableList() throws IOException { TableListModel tableList = new TableListModel(); HTableDescriptor[] list = servlet.getAdmin().listTables(); for (HTableDescriptor htd: list) { tableList.add(new TableModel(htd.getNameAsString())); } return tableList; }