Search in sources :

Example 1 with TablesList

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);
}
Also used : TableDataManager(com.linkedin.pinot.core.data.manager.offline.TableDataManager) ArrayList(java.util.ArrayList) InstanceDataManager(com.linkedin.pinot.core.data.manager.offline.InstanceDataManager) TablesList(com.linkedin.pinot.common.restlet.resources.TablesList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with TablesList

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));
}
Also used : Response(javax.ws.rs.core.Response) IndexSegment(com.linkedin.pinot.core.indexsegment.IndexSegment) TablesList(com.linkedin.pinot.common.restlet.resources.TablesList) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.testng.annotations.Test)

Aggregations

TablesList (com.linkedin.pinot.common.restlet.resources.TablesList)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 InstanceDataManager (com.linkedin.pinot.core.data.manager.offline.InstanceDataManager)1 TableDataManager (com.linkedin.pinot.core.data.manager.offline.TableDataManager)1 IndexSegment (com.linkedin.pinot.core.indexsegment.IndexSegment)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Response (javax.ws.rs.core.Response)1 Test (org.testng.annotations.Test)1