Search in sources :

Example 1 with SegmentCompletionManager

use of com.linkedin.pinot.controller.helix.core.realtime.SegmentCompletionManager 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)

Aggregations

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