Search in sources :

Example 46 with StringRepresentation

use of org.restlet.representation.StringRepresentation 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 47 with StringRepresentation

use of org.restlet.representation.StringRepresentation 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 48 with StringRepresentation

use of org.restlet.representation.StringRepresentation 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)

Example 49 with StringRepresentation

use of org.restlet.representation.StringRepresentation in project pinot by linkedin.

the class PinotTenantRestletResource method deleteTenant.

@HttpVerb("delete")
@Summary("Deletes a tenant")
@Tags({ "tenant" })
@Description("Deletes a tenant from the cluster")
@Paths({ "/tenants/{tenantName}", "/tenants/{tenantName}/" })
private StringRepresentation deleteTenant(@Parameter(name = "tenantName", in = "path", description = "The tenant id") String tenantName, @Parameter(name = "type", in = "query", description = "The type of tenant, either SERVER or BROKER", required = true) String type) {
    StringRepresentation presentation;
    if (type == null) {
        presentation = new StringRepresentation("Not specify the type for the tenant name. Please try to append:" + "/?type=SERVER or /?type=BROKER ");
    } else {
        TenantRole tenantRole = TenantRole.valueOf(type.toUpperCase());
        PinotResourceManagerResponse res = null;
        switch(tenantRole) {
            case BROKER:
                if (_pinotHelixResourceManager.isBrokerTenantDeletable(tenantName)) {
                    res = _pinotHelixResourceManager.deleteBrokerTenantFor(tenantName);
                } else {
                    res = new PinotResourceManagerResponse();
                    res.status = ResponseStatus.failure;
                    res.message = "Broker Tenant is not null, cannot delete it.";
                }
                break;
            case SERVER:
                if (_pinotHelixResourceManager.isServerTenantDeletable(tenantName)) {
                    res = _pinotHelixResourceManager.deleteOfflineServerTenantFor(tenantName);
                    if (res.isSuccessful()) {
                        res = _pinotHelixResourceManager.deleteRealtimeServerTenantFor(tenantName);
                    }
                } else {
                    res = new PinotResourceManagerResponse();
                    res.status = ResponseStatus.failure;
                    res.message = "Server Tenant is not null, cannot delete it.";
                }
                break;
            default:
                break;
        }
        presentation = new StringRepresentation(res.toString());
    }
    return presentation;
}
Also used : StringRepresentation(org.restlet.representation.StringRepresentation) TenantRole(com.linkedin.pinot.common.utils.TenantRole) PinotResourceManagerResponse(com.linkedin.pinot.controller.helix.core.PinotResourceManagerResponse) Description(com.linkedin.pinot.common.restlet.swagger.Description) 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 50 with StringRepresentation

use of org.restlet.representation.StringRepresentation in project pinot by linkedin.

the class PinotTenantRestletResource method createTenant.

@HttpVerb("post")
@Summary("Creates a tenant")
@Tags({ "tenant" })
@Paths({ "/tenants", "/tenants/" })
private StringRepresentation createTenant(Tenant tenant) {
    PinotResourceManagerResponse response;
    StringRepresentation presentation;
    switch(tenant.getTenantRole()) {
        case BROKER:
            response = _pinotHelixResourceManager.createBrokerTenant(tenant);
            presentation = new StringRepresentation(response.toString());
            break;
        case SERVER:
            response = _pinotHelixResourceManager.createServerTenant(tenant);
            presentation = new StringRepresentation(response.toString());
            break;
        default:
            throw new RuntimeException("Not a valid tenant creation 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

StringRepresentation (org.restlet.representation.StringRepresentation)63 HttpVerb (com.linkedin.pinot.common.restlet.swagger.HttpVerb)30 Paths (com.linkedin.pinot.common.restlet.swagger.Paths)30 Summary (com.linkedin.pinot.common.restlet.swagger.Summary)30 Tags (com.linkedin.pinot.common.restlet.swagger.Tags)29 JSONException (org.json.JSONException)17 JSONObject (org.json.JSONObject)16 Responses (com.linkedin.pinot.common.restlet.swagger.Responses)14 IOException (java.io.IOException)12 JSONArray (org.json.JSONArray)12 Representation (org.restlet.representation.Representation)12 File (java.io.File)8 MediaType (org.restlet.data.MediaType)8 AbstractTableConfig (com.linkedin.pinot.common.config.AbstractTableConfig)7 PinotResourceManagerResponse (com.linkedin.pinot.controller.helix.core.PinotResourceManagerResponse)6 WriterRepresentation (org.restlet.representation.WriterRepresentation)6 ResourceException (org.restlet.resource.ResourceException)6 Schema (com.linkedin.pinot.common.data.Schema)5 Writer (java.io.Writer)5 Get (org.restlet.resource.Get)5