Search in sources :

Example 26 with Paths

use of com.linkedin.pinot.common.restlet.swagger.Paths in project pinot by linkedin.

the class PinotSchemaRestletResource method getAllSchemas.

@HttpVerb("get")
@Summary("Get a list of all schemas")
@Tags({ "schema" })
@Paths({ "/schemas", "/schemas/" })
@Responses({ @Response(statusCode = "200", description = "A list of all schemas") })
private Representation getAllSchemas() {
    List<String> schemaNames = _pinotHelixResourceManager.getSchemaNames();
    JSONArray ret = new JSONArray();
    if (schemaNames == null) {
        return new StringRepresentation(ret.toString());
    }
    for (String schema : schemaNames) {
        ret.put(schema);
    }
    return new StringRepresentation(ret.toString());
}
Also used : 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) Responses(com.linkedin.pinot.common.restlet.swagger.Responses)

Example 27 with Paths

use of com.linkedin.pinot.common.restlet.swagger.Paths in project pinot by linkedin.

the class PinotSchemaRestletResource method uploadNewSchema.

@HttpVerb("post")
@Summary("Adds a new schema")
@Tags({ "schema" })
@Paths({ "/schemas", "/schemas/" })
@Responses({ @Response(statusCode = "200", description = "The schema was added"), @Response(statusCode = "500", description = "There was an error while adding the schema") })
private Representation uploadNewSchema() throws Exception {
    File dataFile = getUploadContents();
    if (dataFile != null) {
        Schema schema = Schema.fromFile(dataFile);
        try {
            if (!schema.validate(LOGGER)) {
                throw new RuntimeException("Schema validation failed");
            }
            _pinotHelixResourceManager.addOrUpdateSchema(schema);
            return new StringRepresentation(dataFile + " sucessfully added", MediaType.TEXT_PLAIN);
        } catch (Exception e) {
            LOGGER.error("error adding schema ", e);
            LOGGER.error("Caught exception in file upload", e);
            setStatus(Status.SERVER_ERROR_INTERNAL);
            ControllerRestApplication.getControllerMetrics().addMeteredGlobalValue(ControllerMeter.CONTROLLER_SCHEMA_UPLOAD_ERROR, 1L);
            return PinotSegmentUploadRestletResource.exceptionToStringRepresentation(e);
        }
    } else {
        // Some problem occurs, send back a simple line of text.
        LOGGER.warn("No file was uploaded");
        ControllerRestApplication.getControllerMetrics().addMeteredGlobalValue(ControllerMeter.CONTROLLER_SCHEMA_UPLOAD_ERROR, 1L);
        setStatus(Status.SERVER_ERROR_INTERNAL);
        return new StringRepresentation("schema not added", MediaType.TEXT_PLAIN);
    }
}
Also used : StringRepresentation(org.restlet.representation.StringRepresentation) Schema(com.linkedin.pinot.common.data.Schema) File(java.io.File) JSONException(org.json.JSONException) 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) Responses(com.linkedin.pinot.common.restlet.swagger.Responses)

Example 28 with Paths

use of com.linkedin.pinot.common.restlet.swagger.Paths in project pinot by linkedin.

the class PinotTableSegmentConfigs method updateSegmentConfig.

@Deprecated
@HttpVerb("put")
@Summary("DEPRECATED: Updates the segment configuration (validation and retention) for a table")
@Tags({ "table" })
@Paths({ "/tables/{tableName}/segmentConfigs" })
private Representation updateSegmentConfig(@Parameter(name = "tableName", in = "path", description = "The name of the table for which to update the segment configuration", required = true) String tableName, Representation entity) throws Exception {
    AbstractTableConfig config = AbstractTableConfig.init(entity.getText());
    _pinotHelixResourceManager.updateSegmentsValidationAndRetentionConfigFor(config.getTableName(), TableType.valueOf(config.getTableType().toUpperCase()), config.getValidationConfig());
    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 29 with Paths

use of com.linkedin.pinot.common.restlet.swagger.Paths in project pinot by linkedin.

the class PinotTenantRestletResource method getTenant.

@HttpVerb("get")
@Summary("Gets information about a tenant")
@Tags({ "tenant" })
@Paths({ "/tenants/{tenantName}/metadata", "/tenants/{tenantName}/metadata/" })
private StringRepresentation getTenant(@Parameter(name = "tenantName", in = "path", description = "The tenant name") String tenantName, @Parameter(name = "type", in = "query", description = "The type of tenant, either SERVER or BROKER") String type) throws JSONException {
    // Return instances related to given tenant name.
    StringRepresentation presentation;
    JSONObject resourceGetRet = new JSONObject();
    if (type == null) {
        resourceGetRet.put("ServerInstances", _pinotHelixResourceManager.getAllInstancesForServerTenant(tenantName));
        resourceGetRet.put("BrokerInstances", _pinotHelixResourceManager.getAllInstancesForBrokerTenant(tenantName));
    } else {
        if (type.equalsIgnoreCase("server")) {
            resourceGetRet.put("ServerInstances", _pinotHelixResourceManager.getAllInstancesForServerTenant(tenantName));
        }
        if (type.equalsIgnoreCase("broker")) {
            resourceGetRet.put("BrokerInstances", _pinotHelixResourceManager.getAllInstancesForBrokerTenant(tenantName));
        }
    }
    resourceGetRet.put(TENANT_NAME, tenantName);
    presentation = new StringRepresentation(resourceGetRet.toString(), MediaType.APPLICATION_JSON);
    return presentation;
}
Also used : JSONObject(org.json.JSONObject) StringRepresentation(org.restlet.representation.StringRepresentation) 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 30 with Paths

use of com.linkedin.pinot.common.restlet.swagger.Paths in project pinot by linkedin.

the class PinotTenantRestletResource method updateTenant.

@HttpVerb("put")
@Summary("Updates a tenant")
@Tags({ "tenant" })
@Paths({ "/tenants", "/tenants/" })
private StringRepresentation updateTenant(Tenant tenant) {
    PinotResourceManagerResponse response;
    StringRepresentation presentation;
    switch(tenant.getTenantRole()) {
        case BROKER:
            response = _pinotHelixResourceManager.updateBrokerTenant(tenant);
            presentation = new StringRepresentation(response.toString());
            break;
        case SERVER:
            response = _pinotHelixResourceManager.updateServerTenant(tenant);
            presentation = new StringRepresentation(response.toString());
            break;
        default:
            throw new RuntimeException("Not a valid tenant update call");
    }
    return presentation;
}
Also used : StringRepresentation(org.restlet.representation.StringRepresentation) PinotResourceManagerResponse(com.linkedin.pinot.controller.helix.core.PinotResourceManagerResponse) 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)

Aggregations

Paths (com.linkedin.pinot.common.restlet.swagger.Paths)33 HttpVerb (com.linkedin.pinot.common.restlet.swagger.HttpVerb)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 TreeSet (java.util.TreeSet)2 JSONArray (com.alibaba.fastjson.JSONArray)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1