use of com.linkedin.pinot.core.data.manager.offline.TableDataManager 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.core.data.manager.offline.TableDataManager in project pinot by linkedin.
the class TablesResource method getSegmentMetadata.
@GET
@Path("/tables/{tableName}/segments/{segmentName}/metadata")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Provide segment metadata", notes = "Provide segments metadata for the segment on server")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"), @ApiResponse(code = 500, message = "Internal server error", response = ErrorInfo.class), @ApiResponse(code = 404, message = "Table or segment not found", response = ErrorInfo.class) })
public String getSegmentMetadata(@ApiParam(value = "Table name including type", required = true, example = "myTable_OFFLINE") @PathParam("tableName") String tableName, @ApiParam(value = "Segment Name", required = true) @PathParam("segmentName") String segmentName, @ApiParam(value = "column name", required = false, allowMultiple = true, defaultValue = "") @QueryParam("columns") @DefaultValue("") List<String> columns) {
TableDataManager tableDataManager = checkGetTableDataManager(tableName);
SegmentDataManager segmentDataManager = null;
try {
segmentDataManager = tableDataManager.acquireSegment(segmentName);
if (segmentDataManager == null) {
throw new WebApplicationException(String.format("Table %s segments %s does not exist", tableName, segmentName), Response.Status.NOT_FOUND);
}
SegmentMetadataImpl segmentMetadata = (SegmentMetadataImpl) segmentDataManager.getSegment().getSegmentMetadata();
Set<String> columnSet;
if (columns.size() == 1 && columns.get(0).equals("*")) {
columnSet = null;
} else {
columnSet = new HashSet<>(columns);
}
try {
return segmentMetadata.toJson(columnSet).toString();
} catch (JSONException e) {
LOGGER.error("Failed to convert table {} segment {} to json", tableName, segmentMetadata);
throw new WebApplicationException("Failed to convert segment metadata to json", Response.Status.INTERNAL_SERVER_ERROR);
}
} finally {
if (segmentDataManager != null) {
tableDataManager.releaseSegment(segmentDataManager);
}
}
}
use of com.linkedin.pinot.core.data.manager.offline.TableDataManager in project pinot by linkedin.
the class HelixInstanceDataManager method getSegmentMetadata.
@Override
public SegmentMetadata getSegmentMetadata(String table, String segmentName) {
SegmentDataManager segmentDataManager = null;
TableDataManager tableDataManager = _tableDataManagerMap.get(table);
try {
if (tableDataManager != null) {
segmentDataManager = tableDataManager.acquireSegment(segmentName);
if (segmentDataManager != null) {
return segmentDataManager.getSegment().getSegmentMetadata();
}
}
return null;
} finally {
if (segmentDataManager != null) {
tableDataManager.releaseSegment(segmentDataManager);
}
}
}
use of com.linkedin.pinot.core.data.manager.offline.TableDataManager in project pinot by linkedin.
the class HelixInstanceDataManager method start.
@Override
public synchronized void start() {
for (TableDataManager tableDataManager : _tableDataManagerMap.values()) {
tableDataManager.start();
}
_isStarted = true;
// LOGGER.info("InstanceDataManager is started! " + getServerInfo());
LOGGER.info("{} started!", this.getClass().getName());
}
use of com.linkedin.pinot.core.data.manager.offline.TableDataManager in project pinot by linkedin.
the class HelixInstanceDataManager method addTableIfNeed.
public synchronized void addTableIfNeed(AbstractTableConfig tableConfig, String tableName, String serverInstance) throws ConfigurationException {
TableDataManagerConfig tableDataManagerConfig = getDefaultHelixTableDataManagerConfig(tableName);
if (tableConfig != null) {
tableDataManagerConfig.overrideConfigs(tableName, tableConfig);
}
TableDataManager tableDataManager = TableDataManagerProvider.getTableDataManager(tableDataManagerConfig, serverInstance);
tableDataManager.start();
addTableDataManager(tableName, tableDataManager);
}
Aggregations