Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright 2010-2014 Peter Klauser
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.dongliu.prettypb.rpc.server;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import net.dongliu.prettypb.rpc.common.MethodInfo;
import net.dongliu.prettypb.rpc.common.ServiceInfo;
import net.dongliu.prettypb.rpc.common.TaskCallBack;
import net.dongliu.prettypb.rpc.common.TaskSet;
import net.dongliu.prettypb.rpc.exception.ServiceException;
import net.dongliu.prettypb.rpc.protocol.RpcCancel;
import net.dongliu.prettypb.rpc.protocol.RpcRequest;
import net.dongliu.prettypb.rpc.protocol.WirePayload;
import net.dongliu.prettypb.runtime.ExtensionRegistry;
import net.dongliu.prettypb.runtime.ProtoBufDecoder;
import net.dongliu.prettypb.runtime.include.RpcCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadPoolExecutor;
/**
* A pipeline handler which handles incoming RpcRequest and RpcCancel payloads towards
*
* @author Peter Klauser
*/
public class RpcServerHandler extends MessageToMessageDecoder {
private static Logger logger = LoggerFactory.getLogger(RpcServerHandler.class);
private final RpcServerChannel rpcServerChannel;
private final RpcServiceRegistry rpcServiceRegistry;
private final ThreadPoolExecutor rpcServiceExecutor;
private final RpcServerChannelRegistry rpcServerChannelRegistry;
/**
* extension registry for rpc messages
*/
private final ExtensionRegistry extensionRegistry;
private final TaskSet taskSet = new TaskSet<>();
public RpcServerHandler(RpcServerChannel rpcServerChannel,
RpcServiceRegistry rpcServiceRegistry,
ThreadPoolExecutor rpcServiceExecutor,
RpcServerChannelRegistry rpcServerChannelRegistry,
ExtensionRegistry extensionRegistry) {
this.rpcServerChannelRegistry = rpcServerChannelRegistry;
this.rpcServerChannel = rpcServerChannel;
this.rpcServiceRegistry = rpcServiceRegistry;
this.rpcServiceExecutor = rpcServiceExecutor;
this.extensionRegistry = extensionRegistry;
}
@Override
protected void decode(ChannelHandlerContext ctx, WirePayload msg,
List