use of com.linkedin.pinot.common.restlet.resources.TablesList in project pinot by linkedin.
the class TablesResource method listTables.
@GET
@Path("/tables")
@Produces(MediaType.APPLICATION_JSON)
//swagger annotations
@ApiOperation(value = "List tables", notes = "List all the tables on this server")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = TablesList.class), @ApiResponse(code = 500, message = "Server initialization error", response = ErrorInfo.class) })
public TablesList listTables() {
InstanceDataManager dataManager = checkGetInstanceDataManager();
Collection<TableDataManager> tableDataManagers = dataManager.getTableDataManagers();
List<String> tables = new ArrayList<>(tableDataManagers.size());
for (TableDataManager tableDataManager : tableDataManagers) {
tables.add(tableDataManager.getTableName());
}
return new TablesList(tables);
}
use of com.linkedin.pinot.common.restlet.resources.TablesList in project pinot by linkedin.
the class TablesResourceTest method getTables.
@Test
public void getTables() throws Exception {
Response response = testHelper.target.path("/tables").request().get(Response.class);
String responseBody = response.readEntity(String.class);
TablesList tablesList = new ObjectMapper().readValue(responseBody, TablesList.class);
assertNotNull(tablesList);
List<String> tables = tablesList.getTables();
assertNotNull(tables);
assertEquals(tables.size(), 1);
assertEquals(tables.get(0), ResourceTestHelper.DEFAULT_TABLE_NAME);
final String secondTable = "secondTable";
testHelper.addTable(secondTable);
IndexSegment secondSegment = testHelper.setupSegment(secondTable, ResourceTestHelper.DEFAULT_AVRO_DATA_FILE, "2");
tablesList = testHelper.target.path("/tables").request().get(TablesList.class);
assertNotNull(tablesList);
assertNotNull(tablesList.getTables());
assertEquals(tablesList.getTables().size(), 2);
assertTrue(tablesList.getTables().contains(ResourceTestHelper.DEFAULT_TABLE_NAME));
assertTrue(tablesList.getTables().contains(secondTable));
}
Aggregations