本文整理了Java中com.weibo.api.motan.rpc.URL.getBooleanParameter()
方法的一些代码示例,展示了URL.getBooleanParameter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URL.getBooleanParameter()
方法的具体详情如下:
包路径:com.weibo.api.motan.rpc.URL
类名称:URL
方法名:getBooleanParameter
暂无
代码示例来源:origin: weibocom/motan
protected void initPool() {
factory = createChannelFactory();
channels = new ArrayList<>(connections);
for (int i = 0; i < connections; i++) {
channels.add((Channel) factory.makeObject());
}
initConnections(url.getBooleanParameter(URLParamType.asyncInitConnection.getName(), URLParamType.asyncInitConnection.getBooleanValue()));
}
代码示例来源:origin: weibocom/motan
private <T extends Endpoint> void safeReleaseResource(T endpoint, URL url, Map<String, T> ipPort2Endpoint,
ConcurrentMap<T, Set<String>> endpoint2Urls) {
boolean shareChannel = url.getBooleanParameter(URLParamType.shareChannel.getName(), URLParamType.shareChannel.getBooleanValue());
if (!shareChannel) {
destory(endpoint);
return;
}
synchronized (ipPort2Endpoint) {
String ipPort = url.getServerPortStr();
String protocolKey = MotanFrameworkUtil.getProtocolKey(url);
if (endpoint != ipPort2Endpoint.get(ipPort)) {
destory(endpoint);
return;
}
Set<String> urls = endpoint2Urls.get(endpoint);
urls.remove(protocolKey);
if (urls.isEmpty()) {
destory(endpoint);
ipPort2Endpoint.remove(ipPort);
endpoint2Urls.remove(endpoint);
}
}
}
代码示例来源:origin: weibocom/motan
@Override
public Response filter(Caller<?> caller, Request request) {
boolean needLog = caller.getUrl().getBooleanParameter(URLParamType.accessLog.getName(), URLParamType.accessLog.getBooleanValue());
if (needLog) {
long t1 = System.currentTimeMillis();
boolean success = false;
try {
Response response = caller.call(request);
success = true;
return response;
} finally {
long consumeTime = System.currentTimeMillis() - t1;
logAccess(caller, request, consumeTime, success);
}
} else {
return caller.call(request);
}
}
代码示例来源:origin: weibocom/motan
boolean accessLog = url.getBooleanParameter(URLParamType.accessLog.getName(), URLParamType.accessLog.getBooleanValue());
if (accessLog) {
addIfAbsent(filters, AccessLogFilter.class.getAnnotation(SpiMeta.class).name());
代码示例来源:origin: weibocom/motan
@SuppressWarnings("rawtypes")
public void addExporter(Exporter<?> exporter) throws Exception{
Provider provider = exporter.getProvider();
ServerServiceDefinition serviceDefine = GrpcUtil.getServiceDefByAnnotation(provider.getInterface());
boolean urlShareChannel = exporter.getUrl().getBooleanParameter(URLParamType.shareChannel.getName(),
URLParamType.shareChannel.getBooleanValue());
synchronized (serviceDefinetions) {
if(!(shareChannel && urlShareChannel) && !serviceDefinetions.isEmpty()){
URL url = serviceDefinetions.keySet().iterator().next();
throw new MotanFrameworkException("url:" + exporter.getUrl() + " cannot share channel with url:" + url);
}
registry.addService(serviceDefine, provider);
if(httpHandler != null){
httpHandler.addProvider(provider);
}
serviceDefinetions.put(exporter.getUrl(), serviceDefine);
}
}
代码示例来源:origin: weibocom/motan
workerGroup = new NioEventLoopGroup();
boolean shareChannel = url.getBooleanParameter(URLParamType.shareChannel.getName(), URLParamType.shareChannel.getBooleanValue());
代码示例来源:origin: weibocom/motan
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public Listener startCall(ServerCall call, Metadata headers) {
if (!inited) {
throw new MotanFrameworkException("grpc ServerCallHandler not inited!");
}
// TODO check header
if (provider.getUrl().getBooleanParameter(URLParamType.usegz.getName(), URLParamType.usegz.getBooleanValue())){
call.setCompression("gzip");
}
return requestStream ? streamCall(call, headers) : unaryCall(call, headers);
}
代码示例来源:origin: weibocom/motan
Boolean usegz = channel.getUrl().getBooleanParameter(URLParamType.usegz.getName(), URLParamType.usegz.getBooleanValue());
int minGzSize = channel.getUrl().getIntParameter(URLParamType.mingzSize.getName(), URLParamType.mingzSize.getIntValue());
return encode(compress(body, usegz, minGzSize), flag, value.getRequestId());
代码示例来源:origin: weibocom/motan
url.getBooleanParameter(URLParamType.shareChannel.getName(), URLParamType.shareChannel.getBooleanValue());
代码示例来源:origin: weibocom/motan
boolean transExceptionStack = this.url.getBooleanParameter(URLParamType.transExceptionStack.getName(), defaultThrowExceptionStack);
if (!transExceptionStack) {//不传输业务异常栈
ExceptionUtil.setMockStackTrace(response.getException().getCause());
代码示例来源:origin: weibocom/motan
protected void initPool() {
poolConfig = new GenericObjectPool.Config();
poolConfig.minIdle =
url.getIntParameter(URLParamType.minClientConnection.getName(), URLParamType.minClientConnection.getIntValue());
poolConfig.maxIdle =
url.getIntParameter(URLParamType.maxClientConnection.getName(), URLParamType.maxClientConnection.getIntValue());
poolConfig.maxActive = poolConfig.maxIdle;
poolConfig.maxWait = url.getIntParameter(URLParamType.requestTimeout.getName(), URLParamType.requestTimeout.getIntValue());
poolConfig.lifo = url.getBooleanParameter(URLParamType.poolLifo.getName(), URLParamType.poolLifo.getBooleanValue());
poolConfig.minEvictableIdleTimeMillis = defaultMinEvictableIdleTimeMillis;
poolConfig.softMinEvictableIdleTimeMillis = defaultSoftMinEvictableIdleTimeMillis;
poolConfig.timeBetweenEvictionRunsMillis = defaultTimeBetweenEvictionRunsMillis;
factory = createChannelFactory();
pool = new GenericObjectPool(factory, poolConfig);
boolean lazyInit = url.getBooleanParameter(URLParamType.lazyInit.getName(), URLParamType.lazyInit.getBooleanValue());
if (!lazyInit) {
initConnection(true);
}
}
代码示例来源:origin: weibocom/motan
boolean shareChannel = url.getBooleanParameter(URLParamType.shareChannel.getName(), URLParamType.shareChannel.getBooleanValue());
final int maxContentLength = url.getIntParameter(URLParamType.maxContentLength.getName(), URLParamType.maxContentLength.getIntValue());
int maxServerConnection = url.getIntParameter(URLParamType.maxServerConnection.getName(), URLParamType.maxServerConnection.getIntValue());
代码示例来源:origin: weibocom/motan
@Override
protected <T> Exporter<T> createExporter(Provider<T> provider, URL url) {
String ipPort = url.getServerPortStr();
GrpcServer server = serverMap.get(ipPort);
if (server == null) {
boolean shareChannel =
url.getBooleanParameter(URLParamType.shareChannel.getName(), URLParamType.shareChannel.getBooleanValue());
int workerQueueSize = url.getIntParameter(URLParamType.workerQueueSize.getName(), URLParamType.workerQueueSize.getIntValue());
int minWorkerThread = 0, maxWorkerThread = 0;
if (shareChannel) {
minWorkerThread =
url.getIntParameter(URLParamType.minWorkerThread.getName(), MotanConstants.NETTY_SHARECHANNEL_MIN_WORKDER);
maxWorkerThread =
url.getIntParameter(URLParamType.maxWorkerThread.getName(), MotanConstants.NETTY_SHARECHANNEL_MAX_WORKDER);
} else {
minWorkerThread =
url.getIntParameter(URLParamType.minWorkerThread.getName(), MotanConstants.NETTY_NOT_SHARECHANNEL_MIN_WORKDER);
maxWorkerThread =
url.getIntParameter(URLParamType.maxWorkerThread.getName(), MotanConstants.NETTY_NOT_SHARECHANNEL_MAX_WORKDER);
}
ExecutorService executor =
new StandardThreadExecutor(minWorkerThread, maxWorkerThread, workerQueueSize, new DefaultThreadFactory("GrpcServer-"
+ url.getServerPortStr(), true));
server = new GrpcServer(url.getPort(), shareChannel, executor);
serverMap.putIfAbsent(ipPort, server);
server = serverMap.get(ipPort);
}
return new GrpcExporter<T>(provider, url, server);
}
代码示例来源:origin: weibocom/motan
Boolean usegz = channel.getUrl().getBooleanParameter(URLParamType.usegz.getName(), URLParamType.usegz.getBooleanValue());
int minGzSize = channel.getUrl().getIntParameter(URLParamType.mingzSize.getName(), URLParamType.mingzSize.getIntValue());
return encode(compress(body, usegz, minGzSize), flag, request.getRequestId());
代码示例来源:origin: weibocom/motan
if (channel.getUrl().getBooleanParameter(URLParamType.usegz.getName(), URLParamType.usegz.getBooleanValue())
&& body.length > channel.getUrl().getIntParameter(URLParamType.mingzSize.getName(), URLParamType.mingzSize.getIntValue())) {
try {
代码示例来源:origin: weibocom/motan
private synchronized void initServerBootstrap() {
boolean shareChannel = url.getBooleanParameter(URLParamType.shareChannel.getName(),
URLParamType.shareChannel.getBooleanValue());
final int maxContentLength = url.getIntParameter(URLParamType.maxContentLength.getName(),
代码示例来源:origin: com.weibo/motan-transport-netty4
boolean shareChannel = url.getBooleanParameter(URLParamType.shareChannel.getName(), URLParamType.shareChannel.getBooleanValue());
final int maxContentLength = url.getIntParameter(URLParamType.maxContentLength.getName(), URLParamType.maxContentLength.getIntValue());
int maxServerConnection = url.getIntParameter(URLParamType.maxServerConnection.getName(), URLParamType.maxServerConnection.getIntValue());
内容来源于网络,如有侵权,请联系作者删除!