@@ -0,0 +1,2710 @@
+/*%0A * Copyright 2016 okumin%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage sample;%0A%0Aimport influent.forward.ForwardCallback;%0Aimport influent.forward.ForwardServer;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.util.concurrent.CompletableFuture;%0Aimport java.util.concurrent.atomic.AtomicLong;%0A%0Apublic class TLSCounter %7B%0A  private static final class Reporter implements Runnable %7B%0A    private final AtomicLong counter = new AtomicLong();%0A%0A    void add(final int up) %7B%0A      counter.addAndGet(up);%0A    %7D%0A%0A    @Override%0A    public void run() %7B%0A      long lastChecked = System.currentTimeMillis();%0A      while (true) %7B%0A        try %7B%0A          Thread.sleep(100);%0A        %7D catch (final InterruptedException e) %7B%0A          break;%0A        %7D%0A        final long now = System.currentTimeMillis();%0A        if (now - lastChecked %3E= 1000) %7B%0A          lastChecked = now;%0A          final long current = counter.getAndSet(0);%0A          logger.info(%22%7B%7D requests/sec%22, current);%0A        %7D%0A      %7D%0A    %7D%0A  %7D%0A%0A  private static final Logger logger = LoggerFactory.getLogger(TLSCounter.class);%0A%0A  public static void main(final String%5B%5D args) %7B%0A    if (args.length != 4) %7B%0A      usage();%0A      return;%0A    %7D%0A    final int workerPoolSize = Integer.parseInt(args%5B0%5D);%0A    final String keystorePath = args%5B1%5D;%0A    final String keystorePassword = args%5B2%5D;%0A    final String keyPassword = args%5B3%5D;%0A%0A    final Reporter reporter = new Reporter();%0A%0A    final ForwardCallback callback = ForwardCallback.of(stream -%3E %7B%0A      reporter.add(stream.getEntries().size());%0A      return CompletableFuture.completedFuture(null);%0A    %7D);%0A%0A    final ForwardServer server = new ForwardServer%0A        .Builder(callback)%0A        .workerPoolSize(workerPoolSize)%0A        .sslEnabled(true)%0A        .tlsVersions(%22TLSv1.2%22)%0A        .keystorePath(keystorePath)%0A        .keystorePassword(keystorePassword)%0A        .keyPassword(keyPassword)%0A        .build();%0A    server.start();%0A    new Thread(reporter).start();%0A  %7D%0A%0A  private static void usage() %7B%0A    System.out.println(%22Must specify 4 arguments.%22);%0A    System.out.println();%0A    System.out.println(%22e.g. 4 /path/to/server.jks keystorePassowrd keyPassword%22);%0A  %7D%0A%7D%0A

Add TLSCounter for benchmark same as Counter