Java Code Examples for org.apache.flink.shaded.netty4.io.netty.util.ReferenceCountUtil#release()

The following examples show how to use org.apache.flink.shaded.netty4.io.netty.util.ReferenceCountUtil#release() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileUploadHandler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private void handleError(ChannelHandlerContext ctx, String errorMessage, HttpResponseStatus responseStatus, @Nullable Throwable e) {
	HttpRequest tmpRequest = currentHttpRequest;
	deleteUploadedFiles();
	reset();
	LOG.warn(errorMessage, e);
	HandlerUtils.sendErrorResponse(
		ctx,
		tmpRequest,
		new ErrorResponseBody(errorMessage),
		responseStatus,
		Collections.emptyMap()
	);
	ReferenceCountUtil.release(tmpRequest);
}
 
Example 2
Source File: ClientHandler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
	try {
		ByteBuf buf = (ByteBuf) msg;
		MessageType msgType = MessageSerializer.deserializeHeader(buf);

		if (msgType == MessageType.REQUEST_RESULT) {
			long requestId = MessageSerializer.getRequestId(buf);
			RESP result = serializer.deserializeResponse(buf);
			callback.onRequestResult(requestId, result);
		} else if (msgType == MessageType.REQUEST_FAILURE) {
			RequestFailure failure = MessageSerializer.deserializeRequestFailure(buf);
			callback.onRequestFailure(failure.getRequestId(), failure.getCause());
		} else if (msgType == MessageType.SERVER_FAILURE) {
			throw MessageSerializer.deserializeServerFailure(buf);
		} else {
			throw new IllegalStateException("Unexpected response type '" + msgType + "'");
		}
	} catch (Throwable t1) {
		try {
			callback.onFailure(t1);
		} catch (Throwable t2) {
			LOG.error("Failed to notify callback about failure", t2);
		}
	} finally {
		ReferenceCountUtil.release(msg);
	}
}
 
Example 3
Source File: FileUploadHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
private void handleError(ChannelHandlerContext ctx, String errorMessage, HttpResponseStatus responseStatus, @Nullable Throwable e) {
	HttpRequest tmpRequest = currentHttpRequest;
	deleteUploadedFiles();
	reset();
	LOG.warn(errorMessage, e);
	HandlerUtils.sendErrorResponse(
		ctx,
		tmpRequest,
		new ErrorResponseBody(errorMessage),
		responseStatus,
		Collections.emptyMap()
	);
	ReferenceCountUtil.release(tmpRequest);
}
 
Example 4
Source File: ClientHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
	try {
		ByteBuf buf = (ByteBuf) msg;
		MessageType msgType = MessageSerializer.deserializeHeader(buf);

		if (msgType == MessageType.REQUEST_RESULT) {
			long requestId = MessageSerializer.getRequestId(buf);
			RESP result = serializer.deserializeResponse(buf);
			callback.onRequestResult(requestId, result);
		} else if (msgType == MessageType.REQUEST_FAILURE) {
			RequestFailure failure = MessageSerializer.deserializeRequestFailure(buf);
			callback.onRequestFailure(failure.getRequestId(), failure.getCause());
		} else if (msgType == MessageType.SERVER_FAILURE) {
			throw MessageSerializer.deserializeServerFailure(buf);
		} else {
			throw new IllegalStateException("Unexpected response type '" + msgType + "'");
		}
	} catch (Throwable t1) {
		try {
			callback.onFailure(t1);
		} catch (Throwable t2) {
			LOG.error("Failed to notify callback about failure", t2);
		}
	} finally {
		ReferenceCountUtil.release(msg);
	}
}
 
Example 5
Source File: FileUploadHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
private void handleError(ChannelHandlerContext ctx, String errorMessage, HttpResponseStatus responseStatus, @Nullable Throwable e) {
	HttpRequest tmpRequest = currentHttpRequest;
	deleteUploadedFiles();
	reset();
	LOG.warn(errorMessage, e);
	HandlerUtils.sendErrorResponse(
		ctx,
		tmpRequest,
		new ErrorResponseBody(errorMessage),
		responseStatus,
		Collections.emptyMap()
	);
	ReferenceCountUtil.release(tmpRequest);
}
 
Example 6
Source File: ClientHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
	try {
		ByteBuf buf = (ByteBuf) msg;
		MessageType msgType = MessageSerializer.deserializeHeader(buf);

		if (msgType == MessageType.REQUEST_RESULT) {
			long requestId = MessageSerializer.getRequestId(buf);
			RESP result = serializer.deserializeResponse(buf);
			callback.onRequestResult(requestId, result);
		} else if (msgType == MessageType.REQUEST_FAILURE) {
			RequestFailure failure = MessageSerializer.deserializeRequestFailure(buf);
			callback.onRequestFailure(failure.getRequestId(), failure.getCause());
		} else if (msgType == MessageType.SERVER_FAILURE) {
			throw MessageSerializer.deserializeServerFailure(buf);
		} else {
			throw new IllegalStateException("Unexpected response type '" + msgType + "'");
		}
	} catch (Throwable t1) {
		try {
			callback.onFailure(t1);
		} catch (Throwable t2) {
			LOG.error("Failed to notify callback about failure", t2);
		}
	} finally {
		ReferenceCountUtil.release(msg);
	}
}