Search in sources :

Example 6 with TableDataManager

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);
}
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 7 with TableDataManager

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);
        }
    }
}
Also used : SegmentDataManager(com.linkedin.pinot.core.data.manager.offline.SegmentDataManager) WebApplicationException(javax.ws.rs.WebApplicationException) TableDataManager(com.linkedin.pinot.core.data.manager.offline.TableDataManager) JSONException(org.json.JSONException) SegmentMetadataImpl(com.linkedin.pinot.core.segment.index.SegmentMetadataImpl) 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 8 with TableDataManager

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);
        }
    }
}
Also used : SegmentDataManager(com.linkedin.pinot.core.data.manager.offline.SegmentDataManager) TableDataManager(com.linkedin.pinot.core.data.manager.offline.TableDataManager)

Example 9 with TableDataManager

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());
}
Also used : TableDataManager(com.linkedin.pinot.core.data.manager.offline.TableDataManager)

Example 10 with TableDataManager

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);
}
Also used : TableDataManager(com.linkedin.pinot.core.data.manager.offline.TableDataManager) TableDataManagerConfig(com.linkedin.pinot.core.data.manager.config.TableDataManagerConfig)

Aggregations

TableDataManager (com.linkedin.pinot.core.data.manager.offline.TableDataManager)11 SegmentDataManager (com.linkedin.pinot.core.data.manager.offline.SegmentDataManager)5 ApiOperation (io.swagger.annotations.ApiOperation)4 ApiResponses (io.swagger.annotations.ApiResponses)4 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 InstanceDataManager (com.linkedin.pinot.core.data.manager.offline.InstanceDataManager)3 WebApplicationException (javax.ws.rs.WebApplicationException)3 ArrayList (java.util.ArrayList)2 QueryException (com.linkedin.pinot.common.exception.QueryException)1 TimerContext (com.linkedin.pinot.common.query.context.TimerContext)1 BrokerRequest (com.linkedin.pinot.common.request.BrokerRequest)1 InstanceRequest (com.linkedin.pinot.common.request.InstanceRequest)1 SegmentSizeInfo (com.linkedin.pinot.common.restlet.resources.SegmentSizeInfo)1 TableSegments (com.linkedin.pinot.common.restlet.resources.TableSegments)1 TableSizeInfo (com.linkedin.pinot.common.restlet.resources.TableSizeInfo)1 TablesList (com.linkedin.pinot.common.restlet.resources.TablesList)1 DataTable (com.linkedin.pinot.common.utils.DataTable)1 DataTableImplV2 (com.linkedin.pinot.core.common.datatable.DataTableImplV2)1