Exemple #1
0
 @Override
 public void run() {
   while (running) {
     client.noop(context);
     counter.incrementAndGet();
   }
 }
Exemple #2
0
  public static void main(String[] args) throws InterruptedException {
    if (args.length < 2) {
      System.err.println(
          "Usage: RpcMain <client-name> <target host:port> [<clientExecutorPoolSize>]");
      System.exit(1);
    }
    name = args[0];
    String targetAddress = args[1];

    if (args.length > 2) {
      System.setProperty("cougar.client.socket.clientExecutor.maximumPoolSize", args[2]);
    }

    System.setProperty("server.address", targetAddress);

    CougarSpringCtxFactoryImpl cougarSpringCtxFactory = new CougarSpringCtxFactoryImpl();
    ClassPathXmlApplicationContext context = cougarSpringCtxFactory.create();

    final SocketPerfTestingSyncClient client =
        (SocketPerfTestingSyncClient) context.getBean("perfTestClient");
    final ExecutionContextImpl ctx = new ExecutionContextImpl();
    ctx.setGeoLocationDetails(
        new GeoLocationDetails() {
          @Override
          public String getRemoteAddr() {
            return "127.0.0.1";
          }

          @Override
          public List<String> getResolvedAddresses() {
            return Collections.singletonList("127.0.0.1");
          }

          @Override
          public String getCountry() {
            return "GB";
          }

          @Override
          public boolean isLowConfidenceGeoLocation() {
            return false;
          }

          @Override
          public String getLocation() {
            return "Somewhere over the rainbow";
          }

          @Override
          public String getInferredCountry() {
            return "GB";
          }
        });

    ConnectedResponse rpcControlResponse = client.getRpcControl(ctx);
    Heap rpcControlHeap = rpcControlResponse.getHeap();
    final RpcControlCO rpcControl = RpcControlClientCO.rootFrom(rpcControlHeap);

    rpcControlHeap.addListener(
        new HeapListener() {
          @Override
          public void applyUpdate(UpdateBlock update) {
            if (rpcControl.getRunning()) {
              startTest(rpcControl.getNumThreads(), client, ctx);
            } else {
              stopTest();
            }
          }
        },
        true);

    System.out.println("[" + name + "]: READY");
  }