当前位置: 首页>>代码示例>>Java>>正文


Java AsyncFuture.get方法代码示例

本文整理汇总了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());
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:18,代码来源:EventContainerExecutorTestsX.java

示例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);
    }
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:37,代码来源:StoreManagerSQLQuery.java

示例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);
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:8,代码来源:TaskTests.java

示例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);
    }
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:10,代码来源:SimpleExecutorTests.java


注:本文中的com.gigaspaces.async.AsyncFuture.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。