use of com.linkedin.pinot.common.restlet.swagger.Summary in project pinot by linkedin.
the class PinotTableIndexingConfigs method updateIndexingConfig.
@Deprecated
@HttpVerb("put")
@Summary("DEPRECATED: Updates the indexing configuration for a table")
@Tags({ "table" })
@Paths({ "/tables/{tableName}/indexingConfigs" })
private Representation updateIndexingConfig(@Parameter(name = "tableName", in = "path", description = "The name of the table for which to update the indexing configuration", required = true) String tableName, Representation entity) throws Exception {
AbstractTableConfig config = AbstractTableConfig.init(entity.getText());
_pinotHelixResourceManager.updateIndexingConfigFor(config.getTableName(), TableType.valueOf(config.getTableType().toUpperCase()), config.getIndexingConfig());
return new StringRepresentation("done");
}
use of com.linkedin.pinot.common.restlet.swagger.Summary in project pinot by linkedin.
the class PinotTableRestletResource method setTablestate.
@HttpVerb("get")
@Summary("Enable, disable or drop a table")
@Tags({ "table" })
@Paths({ "/tables/{tableName}", "/table/{tableName}/" })
private StringRepresentation setTablestate(@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 = false) String type, @Parameter(name = "state", in = "query", description = "The desired table state, either enable or disable", required = true) String state) throws JSONException {
JSONArray ret = new JSONArray();
boolean tableExists = false;
if ((type == null || TableType.OFFLINE.name().equalsIgnoreCase(type)) && _pinotHelixResourceManager.hasOfflineTable(tableName)) {
String offlineTableName = TableNameBuilder.OFFLINE_TABLE_NAME_BUILDER.forTable(tableName);
JSONObject offline = new JSONObject();
tableExists = true;
offline.put(TABLE_NAME, offlineTableName);
offline.put(STATE, toggleTableState(offlineTableName, state).toJSON().toString());
ret.put(offline);
}
if ((type == null || TableType.REALTIME.name().equalsIgnoreCase(type)) && _pinotHelixResourceManager.hasRealtimeTable(tableName)) {
String realTimeTableName = TableNameBuilder.REALTIME_TABLE_NAME_BUILDER.forTable(tableName);
JSONObject realTime = new JSONObject();
tableExists = true;
realTime.put(TABLE_NAME, realTimeTableName);
realTime.put(STATE, toggleTableState(realTimeTableName, state).toJSON().toString());
ret.put(realTime);
}
if (tableExists) {
return new StringRepresentation(ret.toString());
} else {
setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return new StringRepresentation("Error: Table " + tableName + " not found.");
}
}
use of com.linkedin.pinot.common.restlet.swagger.Summary in project pinot by linkedin.
the class PinotTableRestletResource method getAllTables.
@HttpVerb("get")
@Summary("Views all tables' configuration")
@Tags({ "table" })
@Paths({ "/tables", "/tables/" })
private Representation getAllTables() throws JSONException {
JSONObject object = new JSONObject();
JSONArray tableArray = new JSONArray();
Set<String> tableNames = new TreeSet<String>();
tableNames.addAll(_pinotHelixResourceManager.getAllUniquePinotRawTableNames());
for (String pinotTableName : tableNames) {
tableArray.put(pinotTableName);
}
object.put("tables", tableArray);
return new StringRepresentation(object.toString(2));
}
use of com.linkedin.pinot.common.restlet.swagger.Summary in project pinot by linkedin.
the class PinotTableSchema method getTableSchema.
@HttpVerb("get")
@Summary("Gets schema for a table")
@Tags({ "schema", "table" })
@Paths({ "/tables/{tableName}/schema", "/tables/{tableName}/schema/" })
private Representation getTableSchema(@Parameter(name = "tableName", in = "path", description = "Table name for which to get the schema", required = true) String tableName) {
if (_pinotHelixResourceManager.hasRealtimeTable(tableName)) {
try {
AbstractTableConfig config = _pinotHelixResourceManager.getTableConfig(tableName, TableType.REALTIME);
return new StringRepresentation(_pinotHelixResourceManager.getSchema(config.getValidationConfig().getSchemaName()).getJSONSchema().toString());
} catch (Exception e) {
LOGGER.error("Caught exception while fetching schema for a realtime table : {} ", tableName, e);
ControllerRestApplication.getControllerMetrics().addMeteredGlobalValue(ControllerMeter.CONTROLLER_TABLE_SCHEMA_GET_ERROR, 1L);
setStatus(Status.SERVER_ERROR_INTERNAL);
return PinotSegmentUploadRestletResource.exceptionToStringRepresentation(e);
}
} else {
AbstractTableConfig config;
try {
config = _pinotHelixResourceManager.getTableConfig(tableName, TableType.OFFLINE);
String schemaName = config.getValidationConfig().getSchemaName();
Schema schema = null;
if (schemaName != null && !schemaName.isEmpty()) {
schema = _pinotHelixResourceManager.getSchema(schemaName);
}
if (schema == null) {
setStatus(Status.CLIENT_ERROR_NOT_FOUND);
StringRepresentation repr = new StringRepresentation("{\"error\": \"Schema " + schemaName + " not found\"");
repr.setMediaType(MediaType.APPLICATION_JSON);
return repr;
}
return new StringRepresentation(schema.getJSONSchema().toString());
} catch (Exception e) {
LOGGER.error("Caught exception while fetching schema for a offline table : {} ", tableName, e);
ControllerRestApplication.getControllerMetrics().addMeteredGlobalValue(ControllerMeter.CONTROLLER_TABLE_SCHEMA_GET_ERROR, 1L);
setStatus(Status.SERVER_ERROR_INTERNAL);
return PinotSegmentUploadRestletResource.exceptionToStringRepresentation(e);
}
}
}
use of com.linkedin.pinot.common.restlet.swagger.Summary in project pinot by linkedin.
the class PinotInstanceRestletResource method getInstanceInformation.
/**
* Gets the information for an instance.
*
* @param instanceName The instance name
*/
@HttpVerb("get")
@Summary("Gets information for an instance")
@Tags({ "instance" })
@Paths({ "/instances/{instanceName}", "/instances/{instanceName}/" })
@Responses({ @Response(statusCode = "200", description = "Information about the specified instance"), @Response(statusCode = "404", description = "The specified instance does not exist"), @Response(statusCode = "500", description = "There was an error while fetching information for the given instance") })
private Representation getInstanceInformation(@Parameter(name = "instanceName", description = "The name of the instance (eg. Server_1.2.3.4_1234 or Broker_someHost.example.com_2345)", in = "path", required = true) String instanceName) {
try {
if (!_pinotHelixResourceManager.instanceExists(instanceName)) {
setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return new StringRepresentation("Error: Instance " + instanceName + " not found.");
}
InstanceConfig instanceConfig = _pinotHelixResourceManager.getHelixInstanceConfig(instanceName);
JSONObject response = new JSONObject();
response.put("instanceName", instanceConfig.getInstanceName());
response.put("hostName", instanceConfig.getHostName());
response.put("enabled", instanceConfig.getInstanceEnabled());
response.put("port", instanceConfig.getPort());
response.put("tags", new JSONArray(instanceConfig.getTags()));
return new StringRepresentation(response.toString());
} catch (Exception e) {
LOGGER.warn("Caught exception while fetching information for instance {}", instanceName, e);
setStatus(Status.SERVER_ERROR_INTERNAL);
return new StringRepresentation("{}");
}
}
Aggregations