Skip to content

Commit

Permalink
Refactor:当filter数量为0时不去创建InvokerDelegate
Browse files Browse the repository at this point in the history
  • Loading branch information
songxinjianqwe committed Aug 24, 2018
1 parent 4c051b8 commit e398e4e
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public void run(int threads, int requestsTotal, int measurementIterations) {
this.executorService = Executors.newFixedThreadPool(threads);
this.measurementIterations = measurementIterations;
createUser();
existUser();
getUser();
listUser();
// existUser();
// getUser();
// listUser();
}

@Data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
rpc.application.name=benchmark_consumer
rpc.application.serialize=json
rpc.application.proxy=javassist
rpc.application.serialize=protostuff
rpc.application.proxy=jdk
rpc.protocol.type=toy
rpc.protocol.executor.server.type=threadpool
rpc.protocol.executor.client.type=threadpool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</appender>


<logger name="com.sinjinsong.benchmark" level="INFO" additivity="false">
<logger name="com.sinjinsong" level="INFO" additivity="false">
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
rpc.application.name=benchmark_provider
rpc.application.serialize=json
rpc.application.proxy=javassist
rpc.application.serialize=protostuff
rpc.application.proxy=jdk
rpc.protocol.type=toy
rpc.protocol.port=8000
rpc.protocol.executor.server.type=threadpool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</appender>


<logger name="com.sinjinsong.benchmark" level="INFO" additivity="false">
<logger name="com.sinjinsong" level="INFO" additivity="false">
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.sinjinsong.toy.common.exception.RPCException;
import com.sinjinsong.toy.config.ReferenceConfig;
import com.sinjinsong.toy.config.ServiceConfig;
import com.sinjinsong.toy.filter.Filter;
import com.sinjinsong.toy.protocol.api.Exporter;
import com.sinjinsong.toy.protocol.api.Invoker;
import com.sinjinsong.toy.protocol.api.support.AbstractRemoteProtocol;
Expand All @@ -16,6 +17,7 @@

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.List;

/**
* @author sinjinsong
Expand Down Expand Up @@ -49,7 +51,12 @@ public <T> Invoker<T> refer(ReferenceConfig<T> referenceConfig, ServiceURL servi
invoker.setInterfaceName(referenceConfig.getInterfaceName());
invoker.setClient(initClient(serviceURL));
invoker.setGlobalConfig(getGlobalConfig());
return invoker.buildFilterChain(referenceConfig.getFilters());
List<Filter> filters = referenceConfig.getFilters();
if(filters.size() == 0) {
return invoker;
}else {
return invoker.buildFilterChain(filters);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.sinjinsong.toy.common.exception.RPCException;
import com.sinjinsong.toy.config.ReferenceConfig;
import com.sinjinsong.toy.config.ServiceConfig;
import com.sinjinsong.toy.filter.Filter;
import com.sinjinsong.toy.protocol.api.Exporter;
import com.sinjinsong.toy.protocol.api.Invoker;
import com.sinjinsong.toy.protocol.api.support.AbstractRemoteProtocol;
Expand All @@ -16,6 +17,7 @@

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.List;

/**
* @author sinjinsong
Expand Down Expand Up @@ -47,7 +49,12 @@ public <T> Invoker<T> refer(ReferenceConfig<T> referenceConfig, ServiceURL servi
invoker.setInterfaceName(referenceConfig.getInterfaceName());
invoker.setGlobalConfig(getGlobalConfig());
invoker.setClient(initClient(serviceURL));
return invoker.buildFilterChain(referenceConfig.getFilters());
List<Filter> filters = referenceConfig.getFilters();
if (filters.size() == 0) {
return invoker;
} else {
return invoker.buildFilterChain(filters);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private Object handle(RPCRequest request) throws Throwable {

Method method = serviceClass.getMethod(methodName, parameterTypes);
method.setAccessible(true);

// 针对callback参数,要将其设置为代理对象
if (serviceConfig.isCallback()) {
Class<?> interfaceClass = parameterTypes[serviceConfig.getCallbackParamIndex()];
Expand Down

0 comments on commit e398e4e

Please sign in to comment.