Search in sources :

Example 16 with Summary

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");
}
Also used : StringRepresentation(org.restlet.representation.StringRepresentation) AbstractTableConfig(com.linkedin.pinot.common.config.AbstractTableConfig) Summary(com.linkedin.pinot.common.restlet.swagger.Summary) HttpVerb(com.linkedin.pinot.common.restlet.swagger.HttpVerb) Paths(com.linkedin.pinot.common.restlet.swagger.Paths) Tags(com.linkedin.pinot.common.restlet.swagger.Tags)

Example 17 with Summary

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.");
    }
}
Also used : JSONObject(org.json.JSONObject) StringRepresentation(org.restlet.representation.StringRepresentation) JSONArray(org.json.JSONArray) Summary(com.linkedin.pinot.common.restlet.swagger.Summary) HttpVerb(com.linkedin.pinot.common.restlet.swagger.HttpVerb) Paths(com.linkedin.pinot.common.restlet.swagger.Paths) Tags(com.linkedin.pinot.common.restlet.swagger.Tags)

Example 18 with Summary

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));
}
Also used : JSONObject(org.json.JSONObject) StringRepresentation(org.restlet.representation.StringRepresentation) TreeSet(java.util.TreeSet) JSONArray(org.json.JSONArray) Summary(com.linkedin.pinot.common.restlet.swagger.Summary) HttpVerb(com.linkedin.pinot.common.restlet.swagger.HttpVerb) Paths(com.linkedin.pinot.common.restlet.swagger.Paths) Tags(com.linkedin.pinot.common.restlet.swagger.Tags)

Example 19 with Summary

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);
        }
    }
}
Also used : StringRepresentation(org.restlet.representation.StringRepresentation) Schema(com.linkedin.pinot.common.data.Schema) AbstractTableConfig(com.linkedin.pinot.common.config.AbstractTableConfig) IOException(java.io.IOException) Summary(com.linkedin.pinot.common.restlet.swagger.Summary) HttpVerb(com.linkedin.pinot.common.restlet.swagger.HttpVerb) Paths(com.linkedin.pinot.common.restlet.swagger.Paths) Tags(com.linkedin.pinot.common.restlet.swagger.Tags)

Example 20 with Summary

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("{}");
    }
}
Also used : InstanceConfig(org.apache.helix.model.InstanceConfig) JSONObject(org.json.JSONObject) StringRepresentation(org.restlet.representation.StringRepresentation) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) Summary(com.linkedin.pinot.common.restlet.swagger.Summary) HttpVerb(com.linkedin.pinot.common.restlet.swagger.HttpVerb) Paths(com.linkedin.pinot.common.restlet.swagger.Paths) Tags(com.linkedin.pinot.common.restlet.swagger.Tags) Responses(com.linkedin.pinot.common.restlet.swagger.Responses)

Aggregations

HttpVerb (com.linkedin.pinot.common.restlet.swagger.HttpVerb)32 Paths (com.linkedin.pinot.common.restlet.swagger.Paths)32 Summary (com.linkedin.pinot.common.restlet.swagger.Summary)32 Tags (com.linkedin.pinot.common.restlet.swagger.Tags)31 StringRepresentation (org.restlet.representation.StringRepresentation)30 Responses (com.linkedin.pinot.common.restlet.swagger.Responses)14 JSONObject (org.json.JSONObject)10 JSONArray (org.json.JSONArray)9 AbstractTableConfig (com.linkedin.pinot.common.config.AbstractTableConfig)7 Schema (com.linkedin.pinot.common.data.Schema)5 PinotResourceManagerResponse (com.linkedin.pinot.controller.helix.core.PinotResourceManagerResponse)5 File (java.io.File)5 IOException (java.io.IOException)4 JSONException (org.json.JSONException)4 FileRepresentation (org.restlet.representation.FileRepresentation)3 Representation (org.restlet.representation.Representation)3 Description (com.linkedin.pinot.common.restlet.swagger.Description)2 JSONArray (com.alibaba.fastjson.JSONArray)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 OfflineTableConfig (com.linkedin.pinot.common.config.OfflineTableConfig)1