本文整理汇总了Java中com.gigaspaces.async.AsyncFuture.get方法的典型用法代码示例。如果您正苦于以下问题:Java AsyncFuture.get方法的具体用法?Java AsyncFuture.get怎么用?Java AsyncFuture.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.gigaspaces.async.AsyncFuture
的用法示例。
在下文中一共展示了AsyncFuture.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDynamicRegistrationOfEvents
import com.gigaspaces.async.AsyncFuture; //导入方法依赖的package包/类
@Test public void testDynamicRegistrationOfEvents() throws Exception {
DynamicEventListener listener = new DynamicEventListener();
gigaSpace1.write(new Object());
Thread.sleep(200);
assertFalse(listener.isReceivedEvent());
AsyncFuture future = distGigaSpace.execute(new RegisterEventContainerTask(listener), 0);
future.get(500, TimeUnit.MILLISECONDS);
Thread.sleep(500);
assertTrue(listener.isReceivedEvent());
listener.setReceivedEvent(false);
future = distGigaSpace.execute(new UnregisterEventContainerTask("test"), 0);
future.get(500, TimeUnit.MILLISECONDS);
gigaSpace1.write(new Object());
Thread.sleep(500);
assertFalse(listener.isReceivedEvent());
}
示例2: executeTask
import com.gigaspaces.async.AsyncFuture; //导入方法依赖的package包/类
/**
* Executes the provided GigaSpaces {@link Task}.
* This operation must be under a {@link StoreManager} transaction.
*
* @param task The {@link Task} to execute.
* @param query The query which execute was called for.
* @return {@link Task} execution returned value.
*/
private ResultObjectProvider executeTask(Task<?> task, final StoreManagerSQLQuery query) {
// Make sure there's an active store transaction
// since we assume the task is changing data within the space
final StoreContext context = query.getStore().getContext();
context.getBroker().assertActiveTransaction();
context.beginStore();
final ISpaceProxy space = (ISpaceProxy) query.getStore().getConfiguration().getSpace();
// Get routing from annotation
final Object routing = _executorMetaDataProvider.findRouting(task);
try {
SpaceTask<?> spaceTask;
if( task instanceof DistributedTask)
spaceTask = new InternalDistributedSpaceTaskWrapper((DistributedTask) task);
else
spaceTask = new InternalSpaceTaskWrapper(task, routing);
AsyncFuture<?> future = space.execute(spaceTask, routing, query.getStore().getCurrentTransaction(), null);
Object taskResult = future.get();
List resultList = new LinkedList();
resultList.add(taskResult);
return new ListResultObjectProvider(resultList);
} catch (Exception e) {
throw new GeneralException(e);
}
}
示例3: testSimpleTaskExecution
import com.gigaspaces.async.AsyncFuture; //导入方法依赖的package包/类
@Test
public void testSimpleTaskExecution() throws Exception {
GigaSpace gigaSpace = (GigaSpace) applicationContext.getBean("clusteredGigaSpace");
AsyncFuture<Long> future = gigaSpace.execute(new MyTask());
long result = future.get();
Assert.assertEquals(1, result);
}
示例4: testException1
import com.gigaspaces.async.AsyncFuture; //导入方法依赖的package包/类
@Test public void testException1() throws Exception {
AsyncFuture<Integer> result = clusteredGigaSpace1.execute(new TaskException(), 1);
try {
result.get(1000, TimeUnit.MILLISECONDS);
fail();
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof IllegalArgumentException);
}
}