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;
}
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);
}
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;
}
Aggregations