Search in sources :

Example 6 with TableType

use of com.linkedin.pinot.common.utils.CommonConstants.Helix.TableType in project pinot by linkedin.

the class RetentionManager method retrieveSegmentMetadataForTable.

private List<SegmentZKMetadata> retrieveSegmentMetadataForTable(String tableName) {
    List<SegmentZKMetadata> segmentMetadataList = new ArrayList<>();
    ZkHelixPropertyStore<ZNRecord> propertyStore = _pinotHelixResourceManager.getPropertyStore();
    TableType tableType = TableNameBuilder.getTableTypeFromTableName(tableName);
    assert tableType != null;
    switch(tableType) {
        case OFFLINE:
            List<OfflineSegmentZKMetadata> offlineSegmentZKMetadatas = ZKMetadataProvider.getOfflineSegmentZKMetadataListForTable(propertyStore, tableName);
            for (OfflineSegmentZKMetadata offlineSegmentZKMetadata : offlineSegmentZKMetadatas) {
                segmentMetadataList.add(offlineSegmentZKMetadata);
            }
            break;
        case REALTIME:
            List<RealtimeSegmentZKMetadata> realtimeSegmentZKMetadatas = ZKMetadataProvider.getRealtimeSegmentZKMetadataListForTable(propertyStore, tableName);
            for (RealtimeSegmentZKMetadata realtimeSegmentZKMetadata : realtimeSegmentZKMetadatas) {
                segmentMetadataList.add(realtimeSegmentZKMetadata);
            }
            break;
        default:
            throw new IllegalArgumentException("No table type matches table name: " + tableName);
    }
    return segmentMetadataList;
}
Also used : SegmentZKMetadata(com.linkedin.pinot.common.metadata.segment.SegmentZKMetadata) RealtimeSegmentZKMetadata(com.linkedin.pinot.common.metadata.segment.RealtimeSegmentZKMetadata) OfflineSegmentZKMetadata(com.linkedin.pinot.common.metadata.segment.OfflineSegmentZKMetadata) RealtimeSegmentZKMetadata(com.linkedin.pinot.common.metadata.segment.RealtimeSegmentZKMetadata) TableType(com.linkedin.pinot.common.utils.CommonConstants.Helix.TableType) OfflineSegmentZKMetadata(com.linkedin.pinot.common.metadata.segment.OfflineSegmentZKMetadata) ArrayList(java.util.ArrayList) ZNRecord(org.apache.helix.ZNRecord)

Example 7 with TableType

use of com.linkedin.pinot.common.utils.CommonConstants.Helix.TableType in project pinot by linkedin.

the class TableViews method get.

@Get
@Override
public Representation get() {
    final String tableName = (String) getRequest().getAttributes().get("tableName");
    final int viewPositon = 3;
    String[] path = getReference().getPath().split("/");
    // first part is "" because paths start with /
    if (path.length < (viewPositon + 1) || (!path[viewPositon].equalsIgnoreCase(EXTERNALVIEW) && !path[viewPositon].equalsIgnoreCase(IDEALSTATE))) {
        // this is unexpected condition
        LOGGER.error("Invalid path: {} while reading views", path);
        return responseRepresentation(Status.SERVER_ERROR_INTERNAL, "{\"error\":\"Invalid reqeust path\"");
    }
    final String view = path[viewPositon];
    String tableTypeStr = getQuery().getValues("tableType");
    if (tableTypeStr == null) {
        tableTypeStr = "";
    }
    TableType tableType = null;
    if (!tableTypeStr.isEmpty()) {
        try {
            tableType = TableType.valueOf(tableTypeStr.toUpperCase());
        } catch (IllegalArgumentException e) {
            return responseRepresentation(Status.CLIENT_ERROR_BAD_REQUEST, "{\"error\":\"Illegal value for table type: " + tableTypeStr + "\"}");
        } catch (Exception e) {
            LOGGER.error("Error", e);
            return responseRepresentation(Status.SERVER_ERROR_INTERNAL, "error");
        }
    }
    if (tableName == null || view == null) {
        return responseRepresentation(Status.CLIENT_ERROR_BAD_REQUEST, "{\"error\" : \"Table name and view type are required\"}");
    }
    return getTableState(tableName, view, tableType);
}
Also used : TableType(com.linkedin.pinot.common.utils.CommonConstants.Helix.TableType) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Get(org.restlet.resource.Get)

Example 8 with TableType

use of com.linkedin.pinot.common.utils.CommonConstants.Helix.TableType in project pinot by linkedin.

the class TableDataManagerConfig method getDefaultHelixTableDataManagerConfig.

public static TableDataManagerConfig getDefaultHelixTableDataManagerConfig(InstanceDataManagerConfig instanceDataManagerConfig, String tableName) throws ConfigurationException {
    TableType tableType = TableNameBuilder.getTableTypeFromTableName(tableName);
    assert tableType != null;
    Configuration defaultConfig = new PropertiesConfiguration();
    defaultConfig.addProperty(TABLE_DATA_MANAGER_NAME, tableName);
    String dataDir = instanceDataManagerConfig.getInstanceDataDir() + "/" + tableName;
    defaultConfig.addProperty(TABLE_DATA_MANAGER_DATA_DIRECTORY, dataDir);
    defaultConfig.addProperty(IndexLoadingConfigMetadata.KEY_OF_COLUMN_MIN_MAX_VALUE_GENERATOR_MODE, ColumnMinMaxValueGeneratorMode.TIME.toString());
    if (instanceDataManagerConfig.getReadMode() != null) {
        defaultConfig.addProperty(READ_MODE, instanceDataManagerConfig.getReadMode().toString());
    } else {
        defaultConfig.addProperty(READ_MODE, ReadMode.heap);
    }
    int avgMultiValueCount = DEFAULT_REALTIME_AVG_MULTI_VALUE_COUNT;
    if (instanceDataManagerConfig.getAvgMultiValueCount() != null) {
        try {
            avgMultiValueCount = Integer.valueOf(instanceDataManagerConfig.getAvgMultiValueCount());
        } catch (NumberFormatException e) {
        // Ignore
        }
    }
    defaultConfig.addProperty(REALTIME_AVG_MULTI_VALUE_COUNT, new Integer(avgMultiValueCount));
    if (instanceDataManagerConfig.getSegmentFormatVersion() != null) {
        defaultConfig.addProperty(IndexLoadingConfigMetadata.KEY_OF_SEGMENT_FORMAT_VERSION, instanceDataManagerConfig.getSegmentFormatVersion());
    }
    if (instanceDataManagerConfig.isEnableDefaultColumns()) {
        defaultConfig.addProperty(IndexLoadingConfigMetadata.KEY_OF_ENABLE_DEFAULT_COLUMNS, true);
    }
    TableDataManagerConfig tableDataManagerConfig = new TableDataManagerConfig(defaultConfig);
    switch(tableType) {
        case OFFLINE:
            defaultConfig.addProperty(TABLE_DATA_MANAGER_TYPE, "offline");
            break;
        case REALTIME:
            defaultConfig.addProperty(TABLE_DATA_MANAGER_TYPE, "realtime");
            break;
        default:
            throw new UnsupportedOperationException("Not supported table type for - " + tableName);
    }
    return tableDataManagerConfig;
}
Also used : TableType(com.linkedin.pinot.common.utils.CommonConstants.Helix.TableType) Configuration(org.apache.commons.configuration.Configuration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Aggregations

TableType (com.linkedin.pinot.common.utils.CommonConstants.Helix.TableType)8 ZNRecord (org.apache.helix.ZNRecord)4 AbstractTableConfig (com.linkedin.pinot.common.config.AbstractTableConfig)3 IdealState (org.apache.helix.model.IdealState)3 TenantConfig (com.linkedin.pinot.common.config.TenantConfig)2 OfflineSegmentZKMetadata (com.linkedin.pinot.common.metadata.segment.OfflineSegmentZKMetadata)2 RealtimeSegmentZKMetadata (com.linkedin.pinot.common.metadata.segment.RealtimeSegmentZKMetadata)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HelixAdmin (org.apache.helix.HelixAdmin)2 JSONException (org.json.JSONException)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 BiMap (com.google.common.collect.BiMap)1 HashBiMap (com.google.common.collect.HashBiMap)1 IndexingConfig (com.linkedin.pinot.common.config.IndexingConfig)1 SegmentsValidationAndRetentionConfig (com.linkedin.pinot.common.config.SegmentsValidationAndRetentionConfig)1 SegmentZKMetadata (com.linkedin.pinot.common.metadata.segment.SegmentZKMetadata)1 KafkaStreamMetadata (com.linkedin.pinot.common.metadata.stream.KafkaStreamMetadata)1 HttpVerb (com.linkedin.pinot.common.restlet.swagger.HttpVerb)1 Paths (com.linkedin.pinot.common.restlet.swagger.Paths)1