Search in sources :

Example 1 with Description

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

the class LLCSegmentCommit method post.

@Override
@HttpVerb("post")
@Description("Uploads an LLC segment coming in from a server")
@Summary("Uploads an LLC segment coming in from a server")
@Paths({ "/" + SegmentCompletionProtocol.MSG_TYPE_COMMMIT })
public Representation post(Representation entity) {
    if (!extractParams()) {
        return new StringRepresentation(SegmentCompletionProtocol.RESP_FAILED.toJsonString());
    }
    LOGGER.info("segment={} offset={} instance={} ", _segmentNameStr, _offset, _instanceId);
    final SegmentCompletionManager segmentCompletionManager = getSegmentCompletionManager();
    final SegmentCompletionProtocol.Request.Params reqParams = new SegmentCompletionProtocol.Request.Params();
    reqParams.withInstanceId(_instanceId).withSegmentName(_segmentNameStr).withOffset(_offset);
    SegmentCompletionProtocol.Response response = segmentCompletionManager.segmentCommitStart(reqParams);
    if (response.equals(SegmentCompletionProtocol.RESP_COMMIT_CONTINUE)) {
        // Get the segment and put it in the right place.
        boolean success = uploadSegment(_instanceId, _segmentNameStr);
        response = segmentCompletionManager.segmentCommitEnd(reqParams, success);
    }
    LOGGER.info("Response: instance={}  segment={} status={} offset={}", _instanceId, _segmentNameStr, response.getStatus(), response.getOffset());
    return new StringRepresentation(response.toJsonString());
}
Also used : SegmentCompletionProtocol(com.linkedin.pinot.common.protocols.SegmentCompletionProtocol) StringRepresentation(org.restlet.representation.StringRepresentation) SegmentCompletionManager(com.linkedin.pinot.controller.helix.core.realtime.SegmentCompletionManager) 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)

Example 2 with Description

use of com.linkedin.pinot.common.restlet.swagger.Description 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)

Aggregations

Description (com.linkedin.pinot.common.restlet.swagger.Description)2 HttpVerb (com.linkedin.pinot.common.restlet.swagger.HttpVerb)2 Paths (com.linkedin.pinot.common.restlet.swagger.Paths)2 Summary (com.linkedin.pinot.common.restlet.swagger.Summary)2 StringRepresentation (org.restlet.representation.StringRepresentation)2 SegmentCompletionProtocol (com.linkedin.pinot.common.protocols.SegmentCompletionProtocol)1 Tags (com.linkedin.pinot.common.restlet.swagger.Tags)1 TenantRole (com.linkedin.pinot.common.utils.TenantRole)1 PinotResourceManagerResponse (com.linkedin.pinot.controller.helix.core.PinotResourceManagerResponse)1 SegmentCompletionManager (com.linkedin.pinot.controller.helix.core.realtime.SegmentCompletionManager)1