org.apache.flink.shaded.netty4.io.netty.util.ReferenceCountUtil Java Examples

The following examples show how to use org.apache.flink.shaded.netty4.io.netty.util.ReferenceCountUtil. 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: RoutedRequest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public ReferenceCounted touch() {
	if (requestAsReferenceCounted.isPresent()) {
		ReferenceCountUtil.touch(requestAsReferenceCounted.get());
	}
	return this;
}
 
Example #3
Source File: RoutedRequest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public ReferenceCounted touch(Object hint) {
	if (requestAsReferenceCounted.isPresent()) {
		ReferenceCountUtil.touch(requestAsReferenceCounted.get(), hint);
	}
	return this;
}
 
Example #4
Source File: RedirectingSslHandler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private void handleSsl(ChannelHandlerContext context) {
	SslHandler sslHandler = sslHandlerFactory.createNettySSLHandler();
	try {
		context.pipeline().replace(this, SSL_HANDLER_NAME, sslHandler);
	} catch (Throwable t) {
		ReferenceCountUtil.safeRelease(sslHandler.engine());
		throw t;
	}
}
 
Example #5
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 #6
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 #7
Source File: RoutedRequest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public ReferenceCounted touch() {
	if (requestAsReferenceCounted.isPresent()) {
		ReferenceCountUtil.touch(requestAsReferenceCounted.get());
	}
	return this;
}
 
Example #8
Source File: RoutedRequest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public ReferenceCounted touch(Object hint) {
	if (requestAsReferenceCounted.isPresent()) {
		ReferenceCountUtil.touch(requestAsReferenceCounted.get(), hint);
	}
	return this;
}
 
Example #9
Source File: RedirectingSslHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
private void handleSsl(ChannelHandlerContext context) {
	SslHandler sslHandler = sslHandlerFactory.createNettySSLHandler(context.alloc());
	try {
		context.pipeline().replace(this, SSL_HANDLER_NAME, sslHandler);
	} catch (Throwable t) {
		ReferenceCountUtil.safeRelease(sslHandler.engine());
		throw t;
	}
}
 
Example #10
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 #11
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 #12
Source File: RoutedRequest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public ReferenceCounted touch() {
	if (requestAsReferenceCounted.isPresent()) {
		ReferenceCountUtil.touch(requestAsReferenceCounted.get());
	}
	return this;
}
 
Example #13
Source File: RoutedRequest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public ReferenceCounted touch(Object hint) {
	if (requestAsReferenceCounted.isPresent()) {
		ReferenceCountUtil.touch(requestAsReferenceCounted.get(), hint);
	}
	return this;
}
 
Example #14
Source File: RedirectingSslHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
private void handleSsl(ChannelHandlerContext context) {
	SslHandler sslHandler = sslHandlerFactory.createNettySSLHandler(context.alloc());
	try {
		context.pipeline().replace(this, SSL_HANDLER_NAME, sslHandler);
	} catch (Throwable t) {
		ReferenceCountUtil.safeRelease(sslHandler.engine());
		throw t;
	}
}
 
Example #15
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);
	}
}