use of com.linkedin.pinot.core.data.manager.offline.InstanceDataManager in project pinot by linkedin.
the class TableSizeResource method getTableSize.
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/tables/{tableName}/size")
@ApiOperation(value = "Show table storage size", notes = "Lists size of all the segments of the table")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"), @ApiResponse(code = 500, message = "Internal server error"), @ApiResponse(code = 404, message = "Table not found") })
public TableSizeInfo getTableSize(@ApiParam(value = "Table Name with type", required = true) @PathParam("tableName") String tableName, @ApiParam(value = "Provide detailed information", required = false) @DefaultValue("true") @QueryParam("detailed") boolean detailed) throws WebApplicationException {
InstanceDataManager dataManager = (InstanceDataManager) serverInstance.getInstanceDataManager();
if (dataManager == null) {
throw new WebApplicationException("Invalid server initialization", Response.Status.INTERNAL_SERVER_ERROR);
}
TableDataManager tableDataManager = dataManager.getTableDataManager(tableName);
if (tableDataManager == null) {
throw new WebApplicationException("Table: " + tableName + " is not found", Response.Status.NOT_FOUND);
}
TableSizeInfo tableSizeInfo = new TableSizeInfo();
tableSizeInfo.tableName = tableDataManager.getTableName();
tableSizeInfo.diskSizeInBytes = 0L;
ImmutableList<SegmentDataManager> segmentDataManagers = tableDataManager.acquireAllSegments();
try {
for (SegmentDataManager segmentDataManager : segmentDataManagers) {
IndexSegment segment = segmentDataManager.getSegment();
long segmentSizeBytes = segment.getDiskSizeBytes();
if (detailed) {
SegmentSizeInfo segmentSizeInfo = new SegmentSizeInfo(segment.getSegmentName(), segmentSizeBytes);
tableSizeInfo.segments.add(segmentSizeInfo);
}
tableSizeInfo.diskSizeInBytes += segmentSizeBytes;
}
} finally {
// executes fast so duration of holding segments is not a concern
for (SegmentDataManager segmentDataManager : segmentDataManagers) {
tableDataManager.releaseSegment(segmentDataManager);
}
}
//invalid to use the segmentDataManagers below
return tableSizeInfo;
}
use of com.linkedin.pinot.core.data.manager.offline.InstanceDataManager in project pinot by linkedin.
the class TablesResource method checkGetTableDataManager.
private TableDataManager checkGetTableDataManager(String tableName) {
InstanceDataManager dataManager = checkGetInstanceDataManager();
TableDataManager tableDataManager = dataManager.getTableDataManager(tableName);
if (tableDataManager == null) {
throw new WebApplicationException("Table " + tableName + " does not exist", Response.Status.NOT_FOUND);
}
return tableDataManager;
}
use of com.linkedin.pinot.core.data.manager.offline.InstanceDataManager 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);
}
Aggregations