Examples of ExecutorService


Examples of com.alibaba.wasp.executor.ExecutorService

     * below after we determine if cluster startup or failover.
     */
    this.masterActiveTime = System.currentTimeMillis();

    if (!masterRecovery) {
      this.executorService = new ExecutorService(getServerName().toString());
      this.serverManager = createServerManager(this, this);
    }

    // check the FMeta if we should create and init it
    FMetaUtil.checkAndInit(conf);
View Full Code Here

Examples of com.starflow.wf.engine.ExecutorService

  private static void action(ProcessEngine processEngine, final ActivityElement activityXml, final ActivityInst activityInst,
      EventElement eventXml, final IAction action) {
    String invokePattern = eventXml.getInvokePattern();
    final String transactionType = eventXml.getTransactionType();
   
    ExecutorService executor = processEngine.getExecutorService();
    if(Constants.ACT_AUTO_CALL_SYN.equalsIgnoreCase(invokePattern)) {
      //同步调用可以返回运行结果,前提是要设置返回运行结果。
      try {
        executor.execute(new Callable<Object>() {
          public Object call() throws Exception {
            if(Constants.ACT_TRANSACTION_JOIN.equalsIgnoreCase(transactionType)) {
              action.execute(activityXml, activityInst);
            } else {
              executeLogicInNewTransaction(activityXml, activityInst, action);
            }
            return null;
          }
        }, invokePattern);
      } catch (Exception e) {
        handleException(e, eventXml);
      }
     
    } else {
      //异步执行使用suspend事务。忽略异常
      try {
        executor.execute(new Callable<Object>() {
          public Object call() throws Exception {
            executeLogicInNewTransaction(activityXml, activityInst, action);
            return null;
          }
        }, invokePattern);
View Full Code Here

Examples of com.starflow.wf.engine.ExecutorService

   */
  public void action(final ActivityStartEvent event, final ActivityInst activityInst, ActivityElement activityXml, final IAction action) {
    String invokePattern = activityXml.getInvokePattern();
    final String transactionType = activityXml.getTransactionType();
   
    ExecutorService executor = event.getProcessEngine().getExecutorService();
   
    if(Constants.ACT_AUTO_CALL_SYN.equalsIgnoreCase(invokePattern)) {
      Object result = null;
      //同步调用可以返回运行结果,前提是要设置返回运行结果。
      try {
        result = executor.execute(new Callable<Object>() {
          @Override
          public Object call() throws Exception {
            if(Constants.ACT_TRANSACTION_JOIN.equalsIgnoreCase(transactionType)) {
              return action.execute(event, activityInst);
            } else {
              return executeLogicInNewTransaction(event, activityInst, action);
            }
          }
        }, invokePattern);
       
      } catch (Exception e) {
        handleException(e, event, activityXml);
      }
     
      //执行结果放入相关数据区。
      saveResultRelaData(event, result, activityXml);
    } else {
      //异步执行使用suspend事务。忽略异常
     
      try {
        executor.execute(new Callable<Object>() {
          public Object call() throws Exception {
            return executeLogicInNewTransaction(event, activityInst, action);
          }
        }, invokePattern);
      } catch (Exception e) {
View Full Code Here

Examples of com.starflow.wf.engine.ExecutorService

  private static void action(ProcessEngine processEngine, final ProcessDefine processDefine,
      final ProcessInstance processInstance, EventElement eventXml, final IAction action) {
    String invokePattern = eventXml.getInvokePattern();
    final String transactionType = eventXml.getTransactionType();
   
    ExecutorService executor = processEngine.getExecutorService();
    if(Constants.ACT_AUTO_CALL_SYN.equalsIgnoreCase(invokePattern)) {
      //同步调用可以返回运行结果,前提是要设置返回运行结果。
      try {
        executor.execute(new Callable<Object>() {
          public Object call() throws Exception {
            if(Constants.ACT_TRANSACTION_JOIN.equalsIgnoreCase(transactionType)) {
              action.execute(processDefine, processInstance);
            } else {
              executeLogicInNewTransaction(processDefine, processInstance, action);
            }
            return null;
          }
        }, invokePattern);
      } catch (Exception e) {
        handleException(e, eventXml);
      }
    } else {
      //异步执行使用suspend事务。忽略异常
      try {
        executor.execute(new Callable<Object>() {
          public Object call() throws Exception {
            executeLogicInNewTransaction(processDefine, processInstance, action);
            return null;
          }
        }, invokePattern);
View Full Code Here

Examples of edu.emory.mathcs.backport.java.util.concurrent.ExecutorService

            int th = 30;
            if (args.length > 1) {
                th = Integer.parseInt(args[1]);
            }
            latch = new CountDownLatch(nb);
            ExecutorService threadPool = Executors.newFixedThreadPool(th);
            for (int i = 0; i < nb; i++) {
                threadPool.submit(new JMSClient());
            }
            latch.await();
        }
        System.out.println("Closing.");
        requestor.close();
View Full Code Here

Examples of java.util.concurrent.ExecutorService

    }
   
    protected  void testhelper(boolean useDispatcher) throws Throwable {
        final int count=8;

        final ExecutorService executor=Executors.newFixedThreadPool(count);
        final CountDownLatch latch=new CountDownLatch(count);
        final JChannel[] channels=new JChannel[count];
        final Task[] tasks=new Task[count];

        final long start=System.currentTimeMillis();
        for(int i=0;i < count;i++) {
            if(i == 0)
                channels[i]=createChannel(true, count);
            else
                channels[i]=createChannel(channels[0]);
           
            tasks[i]=new Task(latch, channels[i],useDispatcher);
            changeMergeInterval(channels[i]);
            changeViewBundling(channels[i]);
            replaceDiscoveryProtocol(channels[i]);
        }

        for(final Task t:tasks) {
            executor.execute(t);
        }

        int timeoutToConverge=120;
        boolean successConnecting  = false;
        try {
            // Wait for all channels to finish connecting
            successConnecting=latch.await(timeoutToConverge, TimeUnit.SECONDS);           
            if(successConnecting) {
                log.info("All connected. Converging...");
                for(Task t:tasks) {
                    Throwable ex=t.getException();
                    if(ex != null)
                        throw ex;
                }

                // Wait for all channels to have the correct number of members in their
                // current view
                boolean converged=false;
                for(int counter=0;counter < timeoutToConverge && !converged;SECONDS.sleep(1),counter++) {
                    for(final JChannel channel:channels) {
                        converged=channel.getView() != null && channel.getView().size() == count;
                        if(!converged)
                            break;
                    }
                }

                final long duration=System.currentTimeMillis() - start;
                log.info("Converged to a single group after " + duration
                                   + " ms; group is:\n");
                for(int i=0;i < channels.length;i++) {
                    log.info("#" + (i + 1)
                                       + ": "
                                       + channels[i].getAddress()
                                       + ": "
                                       + channels[i].getView());
                }               
            }        

            for(final JChannel channel:channels) {
                assertEquals("View ok for channel " + channel.getAddress(), count, channel.getView().size());
            }
            assertTrue("All channels were succefully connected",successConnecting);    
        }
        finally {
            Util.sleep(2500);
            executor.shutdownNow();
            log.info("closing channels: ");           
            for(JChannel ch:channels) {
                ch.close();                              
                //there are sometimes big delays until entire cluster shuts down
                //use sleep to make a smoother shutdown so we avoid false positives
View Full Code Here

Examples of java.util.concurrent.ExecutorService

                + ", invocations: " + total + ", scanPercentage: " + percent + ", scanLength: "
                + scanLength);

        final FixedSegments pager = makeTempSegments(pageSize);

        final ExecutorService exec = Executors.newFixedThreadPool(threads);
        try {
            for(int i = 0; i < threads; i++) {
                exec.submit(new Runnable() {
                    public void run() {
                        try {
                            if(lock == null) {
                                runBenchmarkWithZipfDistributionSync(pager, cache, capacity, round, percent, scanLength, reader);
                            } else {
                                runBenchmarkWithZipfDistributionLock(lock, pager, cache, capacity, round, percent, scanLength, reader);
                            }
                        } catch (Throwable e) {
                            e.printStackTrace();
                        }
                    }
                });
            }
        } finally {
            exec.shutdown();
            try {
                exec.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
            } catch (InterruptedException e) {
                ;
            }
        }
View Full Code Here

Examples of java.util.concurrent.ExecutorService

                + ", invocations: " + total + ", scanPercentage: " + percent + ", scanLength: "
                + scanLength);

        final FixedSegments pager = makeTempSegments(pageSize);

        final ExecutorService exec = Executors.newFixedThreadPool(threads);
        try {
            for(int i = 0; i < threads; i++) {
                exec.submit(new Runnable() {
                    public void run() {
                        try {
                            if(lock == null) {
                                runBenchmarkWithZipfDistributionLongHashSync(pager, hash, capacity, round, percent, scanLength, reader);
                            } else {
                                runBenchmarkWithZipfDistributionLongHashLock(lock, pager, hash, capacity, round, percent, scanLength, reader);
                            }
                        } catch (Throwable e) {
                            e.printStackTrace();
                        }
                    }
                });
            }
        } finally {
            exec.shutdown();
            try {
                exec.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
            } catch (InterruptedException e) {
                ;
            }
        }
View Full Code Here

Examples of java.util.concurrent.ExecutorService

                + ", invocations: " + total + ", scanPercentage: " + percent + ", scanLength: "
                + scanLength + ", pageSize: " + pageSize);

        final FixedSegments pager = makeTempSegments(pageSize);

        final ExecutorService exec = Executors.newFixedThreadPool(threads);
        try {
            for(int i = 0; i < threads; i++) {
                final int threadId = i;
                exec.submit(new Runnable() {
                    public void run() {
                        try {
                            if(lock == null) {
                                runBenchmarkWithZipfDistributionSync(pager, cache, capacity, round, percent, scanLength, dist[threadId]);
                            } else {
                                runBenchmarkWithZipfDistributionLock(lock, pager, cache, capacity, round, percent, scanLength, dist[threadId]);
                            }
                        } catch (Throwable e) {
                            e.printStackTrace();
                        }
                    }
                });
            }
        } finally {
            exec.shutdown();
            try {
                exec.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
            } catch (InterruptedException e) {
                ;
            }
        }
View Full Code Here

Examples of java.util.concurrent.ExecutorService

                + ", invocations: " + total + ", scanPercentage: " + percent + ", scanLength: "
                + scanLength + ", pageSize: " + pageSize);

        final FixedSegments pager = makeTempSegments(pageSize);

        final ExecutorService exec = Executors.newFixedThreadPool(threads);
        try {
            for(int i = 0; i < threads; i++) {
                final int threadId = i;
                exec.submit(new Runnable() {
                    public void run() {
                        try {
                            if(lock == null) {
                                runBenchmarkWithZipfDistributionLongHashSync(pager, hash, capacity, round, percent, scanLength, dist[threadId]);
                            } else {
                                runBenchmarkWithZipfDistributionLongHashLock(lock, pager, hash, capacity, round, percent, scanLength, dist[threadId]);
                            }
                        } catch (Throwable e) {
                            e.printStackTrace();
                        }
                    }
                });
            }
        } finally {
            exec.shutdown();
            try {
                exec.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
            } catch (InterruptedException e) {
                ;
            }
        }
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.