use of com.linkedin.pinot.common.config.AbstractTableConfig in project pinot by linkedin.
the class PinotTableRestletResource method updateTableConfig.
/*
* NOTE: There is inconsistency in these APIs. GET returns OFFLINE + REALTIME configuration
* in a single response but POST and this PUT request only operate on either offline or realtime
* table configuration. If we make this API take both realtime and offline table configuration
* then the update is not guaranteed to be transactional for both table types. This is more of a PATCH request
* than PUT.
*/
@HttpVerb("put")
@Summary("Update table configuration. Request body is offline or realtime table configuration")
@Tags({ "Table" })
@Paths({ "/tables/{tableName}" })
public Representation updateTableConfig(@Parameter(name = "tableName", in = "path", description = "Table name (without type)") String tableName, Representation entity) {
AbstractTableConfig config = null;
try {
config = AbstractTableConfig.init(entity.getText());
} catch (JSONException e) {
errorResponseRepresentation(Status.CLIENT_ERROR_BAD_REQUEST, "Invalid json in table configuration");
} catch (IOException e) {
LOGGER.error("Failed to read request body while updating configuration for table: {}", tableName, e);
errorResponseRepresentation(Status.SERVER_ERROR_INTERNAL, "Failed to read request");
}
try {
String tableTypeStr = config.getTableType();
TableType tableType = TableType.valueOf(tableTypeStr.toUpperCase());
String configTableName = config.getTableName();
if (!configTableName.equals(tableName)) {
errorResponseRepresentation(Status.CLIENT_ERROR_BAD_REQUEST, "Request table name does not match table name in the body");
}
String tableNameWithType = null;
if (config.getTableType().equalsIgnoreCase(TableType.OFFLINE.name())) {
tableNameWithType = TableNameBuilder.OFFLINE_TABLE_NAME_BUILDER.forTable(tableName);
} else if (config.getTableType().equalsIgnoreCase(TableType.REALTIME.name())) {
tableNameWithType = TableNameBuilder.REALTIME_TABLE_NAME_BUILDER.forTable(tableName);
}
_pinotHelixResourceManager.setTableConfig(config, tableNameWithType, tableType);
return responseRepresentation(Status.SUCCESS_OK, "{\"status\" : \"Success\"}");
} catch (IOException e) {
LOGGER.error("Failed to update table configuration for table: {}", tableName, e);
return errorResponseRepresentation(Status.SERVER_ERROR_INTERNAL, "Internal error while updating table configuration");
}
}
use of com.linkedin.pinot.common.config.AbstractTableConfig in project pinot by linkedin.
the class PinotTableRestletResource method getTable.
@HttpVerb("get")
@Summary("Views a table's configuration")
@Tags({ "table" })
@Paths({ "/tables/{tableName}", "/tables/{tableName}/" })
private Representation getTable(@Parameter(name = "tableName", in = "path", description = "The name of the table for which to toggle its state", required = true) String tableName, @Parameter(name = "type", in = "query", description = "Type of table, Offline or Realtime", required = true) String tableType) throws JSONException, JsonParseException, JsonMappingException, JsonProcessingException, IOException {
JSONObject ret = new JSONObject();
if ((tableType == null || TableType.OFFLINE.name().equalsIgnoreCase(tableType)) && _pinotHelixResourceManager.hasOfflineTable(tableName)) {
AbstractTableConfig config = _pinotHelixResourceManager.getTableConfig(tableName, TableType.OFFLINE);
ret.put(TableType.OFFLINE.name(), config.toJSON());
}
if ((tableType == null || TableType.REALTIME.name().equalsIgnoreCase(tableType)) && _pinotHelixResourceManager.hasRealtimeTable(tableName)) {
AbstractTableConfig config = _pinotHelixResourceManager.getTableConfig(tableName, TableType.REALTIME);
ret.put(TableType.REALTIME.name(), config.toJSON());
}
return new StringRepresentation(ret.toString(2));
}
use of com.linkedin.pinot.common.config.AbstractTableConfig in project pinot by linkedin.
the class PinotHelixResourceManager method getTableConfig.
public AbstractTableConfig getTableConfig(String tableName, TableType type) throws JsonParseException, JsonMappingException, JsonProcessingException, JSONException, IOException {
String actualTableName = new TableNameBuilder(type).forTable(tableName);
AbstractTableConfig config = null;
if (type == TableType.REALTIME) {
config = ZKMetadataProvider.getRealtimeTableConfig(getPropertyStore(), actualTableName);
} else {
config = ZKMetadataProvider.getOfflineTableConfig(getPropertyStore(), actualTableName);
}
return config;
}
use of com.linkedin.pinot.common.config.AbstractTableConfig in project pinot by linkedin.
the class PinotHelixResourceManager method updateSegmentsValidationAndRetentionConfigFor.
public void updateSegmentsValidationAndRetentionConfigFor(String tableName, TableType type, SegmentsValidationAndRetentionConfig newConfigs) throws Exception {
String actualTableName = new TableNameBuilder(type).forTable(tableName);
AbstractTableConfig config;
if (type == TableType.REALTIME) {
config = ZKMetadataProvider.getRealtimeTableConfig(getPropertyStore(), actualTableName);
} else {
config = ZKMetadataProvider.getOfflineTableConfig(getPropertyStore(), actualTableName);
}
if (config == null) {
throw new RuntimeException("tableName : " + tableName + " of type : " + type + " not found");
}
config.setValidationConfig(newConfigs);
setTableConfig(config, actualTableName, type);
}
use of com.linkedin.pinot.common.config.AbstractTableConfig in project pinot by linkedin.
the class PinotHelixResourceManager method shouldSendMessage.
// Check to see if the table has been explicitly configured to NOT use messageBasedRefresh.
private boolean shouldSendMessage(OfflineSegmentZKMetadata segmentZKMetadata) {
final String rawTableName = segmentZKMetadata.getTableName();
AbstractTableConfig tableConfig = ZKMetadataProvider.getOfflineTableConfig(_propertyStore, rawTableName);
TableCustomConfig customConfig = tableConfig.getCustomConfigs();
if (customConfig != null) {
Map<String, String> customConfigMap = customConfig.getCustomConfigs();
if (customConfigMap != null) {
if (customConfigMap.containsKey(TableCustomConfig.MESSAGE_BASED_REFRESH_KEY) && !Boolean.valueOf(customConfigMap.get(TableCustomConfig.MESSAGE_BASED_REFRESH_KEY))) {
return false;
}
}
}
return true;
}
Aggregations