List of usage examples for java.util.concurrent ExecutorService submit
Future<?> submit(Runnable task);
From source file:apiserver.services.pdf.service.RemovePdfHeaderFooterCFService.java
public Object execute(Message<?> message) throws ColdFusionException { OptimizePdfResult props = (OptimizePdfResult) message.getPayload(); try {/*from w ww .j a v a 2s. c o m*/ long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<ByteArrayResult> future = exec .submit(new RemoveHeaderFooterCallable(props.getFile().getFileBytes(), props.getOptions())); ByteArrayResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); props.setResult(_result.getBytes()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } }
From source file:apiserver.services.pdf.service.TransformPdfCFService.java
public Object execute(Message<?> message) throws ColdFusionException { TransformPdfResult props = (TransformPdfResult) message.getPayload(); try {/*from w w w . j av a 2 s .c o m*/ long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<ByteArrayResult> future = exec .submit(new TransformPdfCallable(props.getFile().getFileBytes(), props.getOptions())); ByteArrayResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); props.setResult(_result.getBytes()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } }
From source file:apiserver.services.pdf.service.ExtractPdfImagesCFService.java
public Object execute(Message<?> message) throws ColdFusionException { ExtractImageResult props = (ExtractImageResult) message.getPayload(); try {//from w w w . ja va2 s .c om long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<CollectionResult> future = exec .submit(new ExtractImageCallable(props.getFile().getFileBytes(), props.getOptions())); CollectionResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); props.setResult(_result.getCollection()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } }
From source file:apiserver.services.pdf.service.GenerateThumbnailPdfCFService.java
public Object execute(Message<?> message) throws ColdFusionException { SecurePdfResult props = (SecurePdfResult) message.getPayload(); try {// w w w. j a v a2 s .co m long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<CollectionResult> future = exec .submit(new GenerateThumbnailCallable(props.getFile().getFileBytes(), props.getOptions())); CollectionResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); //props.setResult(_result.getBytes()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } }
From source file:apiserver.services.pdf.service.MergePdfFilesCFService.java
public Object execute(Message<?> message) throws ColdFusionException { ExtractImageResult props = (ExtractImageResult) message.getPayload(); try {/* w w w. j a v a 2s. co m*/ long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<CollectionResult> future = exec .submit(new MergePdfCallable(props.getFile().getFileBytes(), props.getOptions())); CollectionResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); props.setResult(_result.getCollection()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } }
From source file:apiserver.services.pdf.service.PopulatePdfFormFieldsCFService.java
public Object execute(Message<?> message) throws ColdFusionException { PopulatePdfFormResult props = (PopulatePdfFormResult) message.getPayload(); try {/* www . j a v a 2 s. c om*/ long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<ByteArrayResult> future = exec .submit(new PopulateFormFieldsCallable(props.getFile().getFileBytes(), props.getFields(), ((String) props.getOptions().get("password")))); ByteArrayResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); props.setResult(_result.getBytes()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } }
From source file:br.com.mobclip.Application.java
public void submitTasks(int threads, Runnable runnable) { ExecutorService executor = Executors.newFixedThreadPool(threads); for (int i = 0; i < threads; i++) { executor.submit(runnable); }/*from ww w .j a va 2 s . c o m*/ }
From source file:maltcms.ui.fileHandles.serialized.JFCOpenSupport.java
@Override protected CloneableTopComponent createCloneableTopComponent() { final JFCDataObject dobj = (JFCDataObject) entry.getDataObject(); final JFCTopComponent tc = new JFCTopComponent(); tc.setDisplayName(dobj.getName());/*from w w w. ja v a 2 s .c o m*/ final ProgressHandle ph = ProgressHandleFactory .createHandle("Loading file " + dobj.getPrimaryFile().getName()); tc.setDisplayName(dobj.getPrimaryFile().getName()); final ExecutorService es = Executors.newSingleThreadExecutor(); final Future<JFreeChart> f = es.submit(new JFCLoader(dobj.getPrimaryFile().getPath(), ph)); try { tc.setChart(f.get()); } catch (InterruptedException | ExecutionException ex) { Exceptions.printStackTrace(ex); } finally { ph.finish(); } return tc; }
From source file:com.blacklocus.qs.worker.TestApplication.java
@Override public void run() { // simulated work ExecutorService executorService = Executors.newCachedThreadPool(); executorService.submit(new TaskGenerator()); // actual qs-worker API QSAssembly.newBuilder().taskServices(new BlockingQueueQSTaskService(numbersMan)) .logService(new SystemOutQSLogService()).workerIdService(new HostNameQSWorkerIdService()) .workers(new TestWorkerPrintIdentity(), new TestWorkerPrintSquare(), new TestWorkerPrintZero(), new TestWorkerUnmotivated()) .build().run();/*w ww. ja v a 2 s. c o m*/ }
From source file:apiserver.services.pdf.service.ProtectPdfCFService.java
public Object execute(Message<?> message) throws ColdFusionException { SecurePdfResult props = (SecurePdfResult) message.getPayload(); File tmpFile = null;//w w w .j av a 2 s.com try { long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<ByteArrayResult> future = exec .submit(new ProtectPdfCallable(props.getFile().getFileBytes(), props.getOptions())); ByteArrayResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); props.setResult(_result.getBytes()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } finally { if (tmpFile != null) tmpFile.delete(); } }