Package com.google.common.util.concurrent

Examples of com.google.common.util.concurrent.ListeningExecutorService.submit()


            ListeningExecutorService executorService = MoreExecutors.listeningDecorator(
                    Executors.newCachedThreadPool());

            List<ListenableFuture<?>> futures = Lists.newArrayList();
            for (int k = 0; k < 20; k ++) {
                futures.add(executorService.submit(new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        for (int k = 0; k < 10000; k++) {
                            session.refresh(false);
                            NodeIterator children = testRoot.getNodes();
View Full Code Here


            ListeningExecutorService executorService = MoreExecutors.listeningDecorator(
                    Executors.newCachedThreadPool());

            List<ListenableFuture<?>> futures = Lists.newArrayList();
            for (int k = 0; k < 20; k ++) {
                futures.add(executorService.submit(new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        for (int k = 0; k < 100000; k++) {
                            session.refresh(false);
                            PropertyIterator properties = testRoot.getProperties();
View Full Code Here

         for (int i = 0; i < 2; i++) {
            final int groupNum = i;
            final String group = "twin" + groupNum;
            groups.add(group);

            ListenableFuture<NodeMetadata> future = userExecutor.submit(new Callable<NodeMetadata>() {
               public NodeMetadata call() throws Exception {
                  NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1, inboundPorts(22, 8080)
                           .blockOnPort(22, 300 + groupNum)));
                  getAnonymousLogger().info("Started node " + node.getId());
                  return node;
View Full Code Here

   public void testAwaitCompletionTimeout() throws Exception {
      final long timeoutMs = 1000;
      ListeningExecutorService userExecutor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
      Map<Void, ListenableFuture<?>> responses = newHashMap();
      try {
         responses.put(null, userExecutor.submit(new Runnable() {
            @Override
            public void run() {
               try {
                  Thread.sleep(2 * timeoutMs);
               } catch (InterruptedException ie) {
View Full Code Here

      final SshClient client = setupClient();
      ListeningExecutorService userExecutor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
      List<ListenableFuture<ExecResponse>> futures = Lists.newArrayList();
      try {
         for (int i = 0; i < 100; i++) {
            futures.add(userExecutor.submit(new Callable<ExecResponse>() {
               @Override
               public ExecResponse call() {
                  ExecResponse response = client.exec("hostname");
                  //System.out.println("completed (concurrently) "+count.incrementAndGet());
                  return response;
View Full Code Here

    public ListenableFuture<SyncTask.Outcome> start(Config config) {

        final ListeningExecutorService exec = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(
                config.numConcurrent + 3));

        ListenableFuture<SyncTask.Outcome> syncOutcomeFuture = exec.submit(new SyncTask(bus,
                exec,
                config));

        // Shut down executor on completion
        Futures.addCallback(syncOutcomeFuture, new FutureCallback<Outcome>() {
View Full Code Here

        ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(ITERATIONS));
        List<ListenableFuture<ECKey.ECDSASignature>> sigFutures = Lists.newArrayList();
        final ECKey key = new ECKey();
        for (byte i = 0; i < ITERATIONS; i++) {
            final byte[] hash = HashUtil.sha3(new byte[]{i});
            sigFutures.add(executor.submit(new Callable<ECKey.ECDSASignature>() {
                @Override
                public ECKey.ECDSASignature call() throws Exception {
                    return key.doSign(hash);
                }
            }));
View Full Code Here

    List<ListenableFuture<List<RemoteCommandResult>>> futures = Lists.newArrayList();
    ListeningExecutorService executor = MoreExecutors.
        listeningDecorator(Executors.newFixedThreadPool(hostExecutors.size()));
    try {
      for(final HostExecutor hostExecutor : hostExecutors) {
        futures.add(executor.submit(new Callable<List<RemoteCommandResult>>() {
          @Override
          public List<RemoteCommandResult> call() throws Exception {
            return initalizeHost(hostExecutor);
          }
        }));
View Full Code Here

            ListeningExecutorService executorService = MoreExecutors.listeningDecorator(
                    Executors.newCachedThreadPool());

            List<ListenableFuture<?>> futures = Lists.newArrayList();
            for (int k = 0; k < 20; k ++) {
                futures.add(executorService.submit(new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        for (int k = 0; k < 100000; k++) {
                            session.refresh(false);
                            NodeIterator children = testRoot.getNodes();
View Full Code Here

            ListeningExecutorService executorService = MoreExecutors.listeningDecorator(
                    Executors.newCachedThreadPool());

            List<ListenableFuture<?>> futures = Lists.newArrayList();
            for (int k = 0; k < 20; k ++) {
                futures.add(executorService.submit(new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        for (int k = 0; k < 100000; k++) {
                            session.refresh(false);
                            PropertyIterator properties = testRoot.getProperties();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.