flink 获取上传的Jar源码



package org.apache.flink.runtime.webmonitor.handlers;

/**
* Handles .jar file uploads.
*/
public class JarUploadHandler extends
AbstractRestHandler<RestfulGateway, EmptyRequestBody, JarUploadResponseBody, EmptyMessageParameters> {


package org.apache.flink.runtime.rest;

public abstract class AbstractHandler<T extends RestfulGateway, R extends RequestBody, M extends MessageParameters> extends RedirectHandler<T> {
protected final Logger log = LoggerFactory.getLogger(getClass());
protected static final ObjectMapper MAPPER = RestMapperUtils.getStrictObjectMapper();
private final UntypedResponseMessageHeaders<R, M> untypedResponseMessageHeaders;
protected AbstractHandler(
@Nonnull CompletableFuture<String> localAddressFuture,
@Nonnull GatewayRetriever<? extends T> leaderRetriever,
@Nonnull Time timeout,
@Nonnull Map<String, String> responseHeaders,
@Nonnull UntypedResponseMessageHeaders<R, M> untypedResponseMessageHeaders) {
super(localAddressFuture, leaderRetriever, timeout, responseHeaders);

this.untypedResponseMessageHeaders = Preconditions.checkNotNull(untypedResponseMessageHeaders);
}

@Override
protected void respondAsLeader(ChannelHandlerContext ctx, RoutedRequest routedRequest, T gateway) {
HttpRequest httpRequest = routedRequest.getRequest();
if (log.isTraceEnabled()) {
log.trace("Received request " + httpRequest.uri() + '.');
}

FileUploads uploadedFiles = null;
try {
if (!(httpRequest instanceof FullHttpRequest)) {
// The RestServerEndpoint defines a HttpObjectAggregator in the pipeline that always returns
// FullHttpRequests.
log.error("Implementation error: Received a request that wasn't a FullHttpRequest.");
throw new RestHandlerException("Bad request received.", HttpResponseStatus.BAD_REQUEST);
}

final ByteBuf msgContent = ((FullHttpRequest) httpRequest).content();

uploadedFiles = FileUploadHandler.getMultipartFileUploads(ctx);

posted on 2018-10-12 17:54  暖风的风  阅读(256)  评论(0编辑  收藏  举报

导航