List of usage examples for java.util.concurrent Future get
V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException;
From source file:net.solarnetwork.central.dras.biz.alert.test.SimpleAlertBizTest.java
@Test public void processEventCreatedAlert() throws Exception { Event event = setupEvent();//from www . ja v a 2s .c o m SimpleAlert alert = new SimpleAlert(); alert.setAlertType(AlertBiz.ALERT_TYPE_ENTITY_CREATED); alert.setRegardingIdentity(event); Future<AlertProcessingResult> future = alertBiz.postAlert(alert); assertNotNull(future); AlertProcessingResult result = future.get(1, TimeUnit.MINUTES); assertNotNull(result); assertNotNull(result.getAlert()); assertEquals(alert.getAlertType(), result.getAlert().getAlertType()); assertNotNull(result.getAlertedUsers()); assertEquals(1, result.getAlertedUsers().size()); assertTrue(result.getAlertedUsers().contains(new User(TEST_USER_ID))); }
From source file:apiserver.services.pdf.service.MergePdfFilesCFService.java
public Object execute(Message<?> message) throws ColdFusionException { ExtractImageResult props = (ExtractImageResult) message.getPayload(); try {//from ww w . j a v a 2 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 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.DeletePdfPagesCFService.java
public Object execute(Message<?> message) throws ColdFusionException { DeletePdfPagesResult props = (DeletePdfPagesResult) message.getPayload(); try {/*ww w . j ava 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 DeletePagesCallable(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.OptimizePdfCFService.java
public Object execute(Message<?> message) throws ColdFusionException { OptimizePdfResult props = (OptimizePdfResult) message.getPayload(); try {/*from w w w .ja va 2 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<ByteArrayResult> future = exec .submit(new OptimizePdfCallable(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.AddPdfWatermarkCFService.java
public Object execute(Message<?> message) throws ColdFusionException { WatermarkPdfResult props = (WatermarkPdfResult) message.getPayload(); try {/*w ww .ja va 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 AddWatermarkCallable(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 {//w w w. ja v a2 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 ww w . j a v a2s .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<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.RemotePdfWatermarkCFService.java
public Object execute(Message<?> message) throws ColdFusionException { WatermarkPdfResult props = (WatermarkPdfResult) message.getPayload(); try {/*from w ww . j a v 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 RemoveWatermarkCallable(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:org.activiti.extension.cache.MemcachedManager.java
/** * Delete, ??updateTimeout, ?false??.//from w w w .ja va2 s . com */ @ManagedOperation(description = "Delete, ??updateTimeout, ?false??.") @ManagedOperationParameters({ @ManagedOperationParameter(name = "key", description = "key") }) public boolean safeDelete(String key) { Future<Boolean> future = memcachedClient.delete(key); try { return future.get(updateTimeout, TimeUnit.MILLISECONDS); } catch (Exception e) { future.cancel(false); } return false; }
From source file:apiserver.services.pdf.controllers.InfoController.java
/** * Get information about document//from www.j a v a 2 s .c o m * @param file PDF to pull info from * @param password Password to open pdf * @return * @throws InterruptedException * @throws java.util.concurrent.ExecutionException * @throws java.util.concurrent.TimeoutException * @throws java.io.IOException * @throws Exception */ @ApiOperation(value = "TODO") @RequestMapping(value = "/info/get", method = RequestMethod.POST, produces = "application/pdf") public ResponseEntity<Object> getPdfInfo( @ApiParam(name = "file", required = true) @RequestPart("file") MultipartFile file, @ApiParam(name = "password", required = false) @RequestPart(value = "password", required = false) String password) throws InterruptedException, ExecutionException, TimeoutException, IOException, Exception { PdfInfoJob job = new PdfInfoJob(); job.setFile(new Document(file)); if (password != null) job.setPassword(password); Future<Map> future = gateway.pdfInfo(job); ObjectJob payload = (ObjectJob) future.get(defaultTimeout, TimeUnit.MILLISECONDS); return ResponseEntityHelper.processObject(payload.getResult()); }