com.weibo.api.motan.rpc.URL.getIntParameter()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(13.4k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中com.weibo.api.motan.rpc.URL.getIntParameter()方法的一些代码示例,展示了URL.getIntParameter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URL.getIntParameter()方法的具体详情如下:
包路径:com.weibo.api.motan.rpc.URL
类名称:URL
方法名:getIntParameter

URL.getIntParameter介绍

暂无

代码示例

代码示例来源:origin: weibocom/motan

public FailbackRegistry(URL url) {
  super(url);
  long retryPeriod = url.getIntParameter(URLParamType.registryRetryPeriod.getName(), URLParamType.registryRetryPeriod.getIntValue());
  retryExecutor.scheduleAtFixedRate(new Runnable() {
    @Override
    public void run() {
      try {
        retry();
      } catch (Exception e) {
        LoggerUtil.warn(String.format("[%s] False when retry in failback registry", registryClassName), e);
      }
    }
  }, retryPeriod, retryPeriod, TimeUnit.MILLISECONDS);
}

代码示例来源:origin: weibocom/motan

public AbstractSharedPoolClient(URL url) {
  super(url);
  connections = url.getIntParameter(URLParamType.minClientConnection.getName(), URLParamType.minClientConnection.getIntValue());
  if (connections <= 0) {
    connections = URLParamType.minClientConnection.getIntValue();
  }
}

代码示例来源:origin: weibocom/motan

public ConsulRegistry(URL url, MotanConsulClient client) {
  super(url);
  this.client = client;
  heartbeatManager = new ConsulHeartbeatManager(client);
  heartbeatManager.start();
  lookupInterval = getUrl().getIntParameter(URLParamType.registrySessionTimeout.getName(), ConsulConstants.DEFAULT_LOOKUP_INTERVAL);
  ArrayBlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<Runnable>(20000);
  notifyExecutor = new ThreadPoolExecutor(10, 30, 30 * 1000, TimeUnit.MILLISECONDS, workQueue);
  ShutDownHook.registerShutdownHook(this);
  LoggerUtil.info("ConsulRegistry init finish.");
}

代码示例来源:origin: weibocom/motan

/**
 * 默认策略当接口线程池占用达到3/4或者空闲小于150时,限制单个方法请求不能超过总线程数的1/2 需要自定义方法并发限制可以通过actives参数配置
 */
@Override
public void init(Caller<?> caller) {
  if (caller instanceof Provider) {
    String port = String.valueOf(caller.getUrl().getPort());
    totalCount = portTotalMap.get(port);
    if (totalCount == null) {
      portTotalMap.putIfAbsent(port, new AtomicInteger());
      totalCount = portTotalMap.get(port);
    }
    maxThread = caller.getUrl().getIntParameter(URLParamType.maxWorkerThread.getName(), URLParamType.maxWorkerThread.getIntValue());
    totalLimit = maxThread > 600 ? maxThread - 150 : maxThread * 3 / 4;
    int active = caller.getUrl().getIntParameter(URLParamType.actives.getName(), URLParamType.actives.getIntValue());
    if (active > 0) {
      methodLimit = active;
    } else {
      methodLimit = maxThread / 2;
    }
    isProvider = true;
  }
}

代码示例来源:origin: weibocom/motan

public NettyClient(URL url) {
  super(url);
  maxClientConnection = url.getIntParameter(URLParamType.maxClientConnection.getName(),
      URLParamType.maxClientConnection.getIntValue());
  timeMonitorFuture = scheduledExecutor.scheduleWithFixedDelay(
      new TimeoutMonitor("timeout_monitor_" + url.getHost() + "_" + url.getPort()),
      MotanConstants.NETTY_TIMEOUT_TIMER_PERIOD, MotanConstants.NETTY_TIMEOUT_TIMER_PERIOD,
      TimeUnit.MILLISECONDS);
}

代码示例来源:origin: weibocom/motan

url.getIntParameter(URLParamType.maxServerConnection.getName(), URLParamType.maxServerConnection.getIntValue());
int workerQueueSize = url.getIntParameter(URLParamType.workerQueueSize.getName(), 500);
  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);
final int maxContentLength = url.getIntParameter(URLParamType.maxContentLength.getName(), URLParamType.maxContentLength.getIntValue());
final NettyHttpRequestHandler handler =
    new NettyHttpRequestHandler(this, messageHandler, new ThreadPoolExecutor(minWorkerThread, maxWorkerThread, 15,

代码示例来源:origin: weibocom/motan

@Override
protected Registry createRegistry(URL registryUrl) {
  try {
    int timeout = registryUrl.getIntParameter(URLParamType.connectTimeout.getName(), URLParamType.connectTimeout.getIntValue());
    int sessionTimeout = registryUrl.getIntParameter(URLParamType.registrySessionTimeout.getName(), URLParamType.registrySessionTimeout.getIntValue());
    ZkClient zkClient = createInnerZkClient(registryUrl.getParameter("address"), sessionTimeout, timeout);
    return new ZookeeperRegistry(registryUrl, zkClient);
  } catch (ZkException e) {
    LoggerUtil.error("[ZookeeperRegistry] fail to connect zookeeper, cause: " + e.getMessage());
    throw e;
  }
}

代码示例来源: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

int timeout = getUrl().getIntParameter(URLParamType.connectTimeout.getName(), URLParamType.connectTimeout.getIntValue());
if (timeout <= 0) {
  throw new MotanFrameworkException("NettyClient init Error: timeout(" + timeout + ") <= 0 is forbid.", MotanErrorMsgConstant.FRAMEWORK_INIT_ERROR);
bootstrap.option(ChannelOption.SO_KEEPALIVE, true);
final int maxContentLength = url.getIntParameter(URLParamType.maxContentLength.getName(), URLParamType.maxContentLength.getIntValue());
bootstrap.group(nioEventLoopGroup)
    .channel(NioSocketChannel.class)

代码示例来源:origin: weibocom/motan

final int maxContentLength = url.getIntParameter(URLParamType.maxContentLength.getName(), URLParamType.maxContentLength.getIntValue());
int maxServerConnection = url.getIntParameter(URLParamType.maxServerConnection.getName(), URLParamType.maxServerConnection.getIntValue());
int workerQueueSize = url.getIntParameter(URLParamType.workerQueueSize.getName(), URLParamType.workerQueueSize.getIntValue());
  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);

代码示例来源:origin: weibocom/motan

@Override
protected RestServer innerCreateServer(URL url) {
  NettyJaxrsServer server = new NettyJaxrsServer();
  server.setMaxRequestSize(url.getIntParameter(URLParamType.maxContentLength.getName(),
      URLParamType.maxContentLength.getIntValue()));
  ResteasyDeployment deployment = new ResteasyDeployment();
  server.setDeployment(deployment);
  server.setExecutorThreadCount(url.getIntParameter(URLParamType.maxWorkerThread.getName(),
      URLParamType.maxWorkerThread.getIntValue()));
  server.setPort(url.getPort());
  server.setRootResourcePath("");
  server.setSecurityDomain(null);
  deployment.setInjectorFactoryClass(RestfulInjectorFactory.class.getName());
  deployment.getProviderClasses().add(RpcExceptionMapper.class.getName());
  return new EmbedRestServer(server);
}

代码示例来源: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(),
      URLParamType.maxContentLength.getIntValue());
  int maxServerConnection = url.getIntParameter(URLParamType.maxServerConnection.getName(),
      URLParamType.maxServerConnection.getIntValue());
  int workerQueueSize = url.getIntParameter(URLParamType.workerQueueSize.getName(),
      URLParamType.workerQueueSize.getIntValue());
    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);

代码示例来源:origin: weibocom/motan

long start = System.currentTimeMillis();
channelFuture = nettyClient.getBootstrap().connect(remoteAddress);
int timeout = nettyClient.getUrl().getIntParameter(URLParamType.connectTimeout.getName(), URLParamType.connectTimeout.getIntValue());
if (timeout <= 0) {
  throw new MotanFrameworkException("NettyClient init Error: timeout(" + timeout + ") <= 0 is forbid.", MotanErrorMsgConstant.FRAMEWORK_INIT_ERROR);

代码示例来源: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

@Override
public Response filter(Caller<?> caller, Request request) {
  int maxAcvitivyCount = caller.getUrl().getIntParameter(URLParamType.actives.getName(), URLParamType.actives.getIntValue());
  if (maxAcvitivyCount > 0) {
    int activeCount = RpcStats.getServiceStat(caller.getUrl()).getActiveCount();
    if (activeCount >= maxAcvitivyCount) {
      throw new MotanServiceException(String.format("Request(%s) active count exceed the limit (%s), referer:%s", request,
          maxAcvitivyCount, caller.getUrl()), MotanErrorMsgConstant.SERVICE_REJECT);
    }
  }
  long startTime = System.currentTimeMillis();
  RpcStats.beforeCall(caller.getUrl(), request);
  try {
    Response rs = caller.call(request);
    RpcStats.afterCall(caller.getUrl(), request, true, System.currentTimeMillis() - startTime);
    return rs;
  } catch (RuntimeException re) {
    RpcStats.afterCall(caller.getUrl(), request, false, System.currentTimeMillis() - startTime);
    throw re;
  }
}

代码示例来源:origin: weibocom/motan

int minGzSize = channel.getUrl().getIntParameter(URLParamType.mingzSize.getName(), URLParamType.mingzSize.getIntValue());
return encode(compress(body, usegz, minGzSize), flag, value.getRequestId());

代码示例来源:origin: weibocom/motan

int timeout = getUrl().getIntParameter(URLParamType.connectTimeout.getName(), URLParamType.connectTimeout.getIntValue());
if (timeout <= 0) {
  throw new MotanFrameworkException("NettyClient init Error: timeout(" + timeout + ") <= 0 is forbid.",
final int maxContentLength = url.getIntParameter(URLParamType.maxContentLength.getName(),
    URLParamType.maxContentLength.getIntValue());

代码示例来源:origin: weibocom/motan

@Override
protected Response call(Request request, Provider<?> provider) {
  // 支持的最大worker thread数
  int maxThread = provider.getUrl().getIntParameter(URLParamType.maxWorkerThread.getName(), URLParamType.maxWorkerThread.getIntValue());
  String requestKey = MotanFrameworkUtil.getFullMethodString(request);
  try {
    int requestCounter = incrRequestCounter(requestKey);
    int totalCounter = incrTotalCounter();
    if (isAllowRequest(requestCounter, totalCounter, maxThread, request)) {
      return super.call(request, provider);
    } else {
      // reject request
      return reject(request.getInterfaceName() + "." + request.getMethodName(), requestCounter, totalCounter, maxThread);
    }
  } finally {
    decrTotalCounter();
    decrRequestCounter(requestKey);
  }
}

代码示例来源:origin: weibocom/motan

int minGzSize = channel.getUrl().getIntParameter(URLParamType.mingzSize.getName(), URLParamType.mingzSize.getIntValue());
return encode(compress(body, usegz, minGzSize), flag, request.getRequestId());

代码示例来源:origin: weibocom/motan

int timeout = nettyClient.getUrl().getIntParameter(URLParamType.connectTimeout.getName(), URLParamType.connectTimeout.getIntValue());
if (timeout <= 0) {
  throw new MotanFrameworkException("NettyClient init Error: timeout(" + timeout + ") <= 0 is forbid.",

相关文章