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


Java AsyncFuture类代码示例

本文整理汇总了Java中com.gigaspaces.async.AsyncFuture的典型用法代码示例。如果您正苦于以下问题:Java AsyncFuture类的具体用法?Java AsyncFuture怎么用?Java AsyncFuture使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AsyncFuture类属于com.gigaspaces.async包,在下文中一共展示了AsyncFuture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: asyncAddIndexes

import com.gigaspaces.async.AsyncFuture; //导入依赖的package包/类
public AsyncFuture<AddTypeIndexesResult> asyncAddIndexes(String typeName, SpaceIndex[] indexes,
        AsyncFutureListener<AddTypeIndexesResult> listener) {
    try {
        // Validate:
        if (typeName == null || typeName.length() == 0)
            throw new IllegalArgumentException("Argument cannot be null or empty - 'typeName'.");
        if (indexes == null || indexes.length == 0)
            throw new IllegalArgumentException("Argument cannot be null or empty - 'indexes'.");
        // Convert indexes:
        ISpaceIndex[] internalIndexes = new ISpaceIndex[indexes.length];
        for (int i=0 ; i < indexes.length ; i++) {              
            if (indexes[i] == null)
                throw new IllegalArgumentException("Index at position #" + i + " is null.");
            if (!(indexes[i] instanceof ISpaceIndex))
                throw new IllegalArgumentException("Index at position #" + i + " is of an unsupported type - " + indexes[i].getClass().getName());
            if (((ISpaceIndex)indexes[i]).isUnique())
            	throw new UnsupportedOperationException("invalid index at position #" + i + " dynamic index cannot be unique");
            internalIndexes[i] = (ISpaceIndex) indexes[i];
        }
        // Execute:
        return space.asyncAddIndexes(typeName, internalIndexes, listener);
    } catch (Exception e) {
        throw exTranslator.translate(e);
    }
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:26,代码来源:DefaultGigaSpaceTypeManager.java

示例2: testSimpleTransactionRollback1

import com.gigaspaces.async.AsyncFuture; //导入依赖的package包/类
@Test public void testSimpleTransactionRollback1() {
    TransactionTemplate txTemplate = new TransactionTemplate(localTxManager1);
    txTemplate.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            AsyncFuture<Integer> value = localGigaSpace1.execute(new SimpleTask1(), 0);
            try {
                assertEquals(1, (int) value.get(1000, TimeUnit.MILLISECONDS));
            } catch (Exception e) {
                e.printStackTrace();
                fail();
            }
            status.setRollbackOnly();
        }
    });
    assertEquals(0, localGigaSpace1.count(null));
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:17,代码来源:TransactionalExecutorTests.java

示例3: testExecute

import com.gigaspaces.async.AsyncFuture; //导入依赖的package包/类
@Test public void testExecute() throws InterruptedException, ExecutionException, UnusableEntryException{
    AsyncFuture<Integer> future = gigaSpace.execute(new MyTask());
    assertEquals(2, future.get().intValue());
    
    assertEquals(2, customFilter.getLastExecutions().size());

    Object[] params = customFilter.getLastExecutions().get(0);
    assertEquals(2, params.length);
    assertNotNull((Task<Integer>)((ISpaceFilterEntry)params[0]).getObject(gigaSpace.getSpace()));
    assertEquals(FilterOperationCodes.BEFORE_EXECUTE, params[1]);

    params = customFilter.getLastExecutions().get(1);
    assertEquals(2, params.length);
    assertEquals(2, ((ExecutionFilterEntry) params[0]).getObject(null));
    assertEquals(FilterOperationCodes.AFTER_EXECUTE, params[1]);
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:17,代码来源:AbstractSecurityAdapterCustomFilterTests.java

示例4: testListenerTransactionCommit

import com.gigaspaces.async.AsyncFuture; //导入依赖的package包/类
@Test public void testListenerTransactionCommit() throws Exception {
    TransactionTemplate txTemplate = new TransactionTemplate(localTxManager1);
    final Listener listener = new Listener();
    txTemplate.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            AsyncFuture<Integer> value = localGigaSpace1.execute(new DelayedSimpleTask1(), 0);
            value.setListener(listener);
        }
    });
    assertEquals(0, localGigaSpace1.count(null));
    while (listener.getResult() == null) {
        Thread.sleep(100);
    }
    // let it commit
    Thread.sleep(100);
    assertEquals(1, localGigaSpace1.count(null));
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:18,代码来源:TransactionalExecutorTests.java

示例5: testListenerAsParameterTransactionCommit

import com.gigaspaces.async.AsyncFuture; //导入依赖的package包/类
@Test public void testListenerAsParameterTransactionCommit() throws Exception {
    TransactionTemplate txTemplate = new TransactionTemplate(localTxManager1);
    final Listener listener = new Listener();
    txTemplate.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            AsyncFuture<Integer> value = localGigaSpace1.execute(new DelayedSimpleTask1(), 0, listener);
        }
    });
    assertEquals(0, localGigaSpace1.count(null));
    while (listener.getResult() == null) {
        Thread.sleep(100);
    }
    // let it commit
    Thread.sleep(100);
    assertEquals(1, localGigaSpace1.count(null));
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:17,代码来源:TransactionalExecutorTests.java

示例6: testListenerTransactionRollback

import com.gigaspaces.async.AsyncFuture; //导入依赖的package包/类
@Test public void testListenerTransactionRollback() throws Exception {
    TransactionTemplate txTemplate = new TransactionTemplate(localTxManager1);
    final Listener listener = new Listener();
    txTemplate.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            AsyncFuture<Integer> value = localGigaSpace1.execute(new DelayedSimpleTask1(), 0);
            value.setListener(listener);
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            status.setRollbackOnly();
        }
    });
    assertEquals(0, localGigaSpace1.count(null));
    while (listener.getResult() == null) {
        Thread.sleep(100);
    }
    // let it "commit"
    Thread.sleep(100);
    assertEquals(0, localGigaSpace1.count(null));
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:24,代码来源:TransactionalExecutorTests.java

示例7: testListenerAsParameterTransactionRollback

import com.gigaspaces.async.AsyncFuture; //导入依赖的package包/类
@Test public void testListenerAsParameterTransactionRollback() throws Exception {
    TransactionTemplate txTemplate = new TransactionTemplate(localTxManager1);
    final Listener listener = new Listener();
    txTemplate.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            AsyncFuture<Integer> value = localGigaSpace1.execute(new DelayedSimpleTask1(), 0, listener);
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            status.setRollbackOnly();
        }
    });
    assertEquals(0, localGigaSpace1.count(null));
    while (listener.getResult() == null) {
        Thread.sleep(100);
    }
    // let it "commit"
    Thread.sleep(100);
    assertEquals(0, localGigaSpace1.count(null));
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:23,代码来源:TransactionalExecutorTests.java

示例8: testListenerTransactionException

import com.gigaspaces.async.AsyncFuture; //导入依赖的package包/类
@Test public void testListenerTransactionException() throws Exception {
    TransactionTemplate txTemplate = new TransactionTemplate(localTxManager1);
    final ExceptionListener listener = new ExceptionListener();
    txTemplate.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            AsyncFuture<Integer> value = localGigaSpace1.execute(new DelayedSimpleTask1(), 0);
            value.setListener(listener);
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            status.setRollbackOnly();
        }
    });
    assertEquals(0, localGigaSpace1.count(null));
    while (!listener.isCalled()) {
        Thread.sleep(100);
    }
    // let it "commit"
    Thread.sleep(100);
    assertEquals(0, localGigaSpace1.count(null));
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:24,代码来源:TransactionalExecutorTests.java

示例9: testDistributedTransactionRollback

import com.gigaspaces.async.AsyncFuture; //导入依赖的package包/类
@Test public void testDistributedTransactionRollback() throws Exception {
    TransactionTemplate txTemplate = new TransactionTemplate(distTxManager);
    txTemplate.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            AsyncFuture<Integer> value = distGigaSpace.execute(new SimpleDistributedTask1());
            try {
                assertEquals(2, (int) value.get(1000, TimeUnit.MILLISECONDS));
            } catch (Exception e) {
                e.printStackTrace();
                fail();
            }
            status.setRollbackOnly();
        }
    });
    assertEquals(0, distGigaSpace.count(null));
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:17,代码来源:TransactionalExecutorTests.java

示例10: 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

示例11: supportsMethodsReturningAsyncFuture

import com.gigaspaces.async.AsyncFuture; //导入依赖的package包/类
@Test
public void supportsMethodsReturningAsyncFuture() throws Exception {
	configurer.setSubsystem("lunch-system");
	astrix = autoClosables.add(configurer.configure());
	GigaSpace proxy = astrix.waitForBean(GigaSpace.class, "lunch-space", 10000);
	AsyncFuture<Integer> result = proxy.execute(new ReturnOneTask(), 1);
	assertEquals(1, (int) result.get());
}
 
开发者ID:AvanzaBank,项目名称:astrix,代码行数:9,代码来源:ClusteredProxyLibraryTest.java

示例12: testExecute

import com.gigaspaces.async.AsyncFuture; //导入依赖的package包/类
@Test public void testExecute() throws InterruptedException, ExecutionException{
    beforeTest(); 
    
    AsyncFuture<Integer> future = gigaSpace.execute(new MyTask());
    assertEquals(2, future.get().intValue());
    AllOperationsFilterUtil.assertAfterExecuteWithAuthentication(securityFilterCodeName.getStats() , "simpleFilterCodeName");
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:8,代码来源:SecurityOperationCodeFilterTest.java

示例13: execute

import com.gigaspaces.async.AsyncFuture; //导入依赖的package包/类
/**
 * Executes all the given tasks (asynchronously) based on their execution mode and returns a future
 * allowing to retrieve the reduced operation of all the tasks.
 *
 * <p>The future actual result will be the reduced result of the execution, or the exception thrown during
 * during the reduce operation. The moderator (assuming the reducer provided implements
 * {@link com.gigaspaces.async.AsyncResultFilter}) can be used as a mechanism to listen for results as they arrive.
 *
 * @return a Future representing pending completion of the task,
 *         and whose <code>get()</code> method will return the task value upon completion.
 */
public AsyncFuture<R> execute() {
    if (holders.size() == 0) {
        throw new IllegalArgumentException("No tasks to execute");
    }
    AsyncFuture[] futures = new AsyncFuture[holders.size()];
    for (int i = 0; i < futures.length; i++) {
        Holder holder = holders.get(i);
        if (holder.task instanceof DistributedTask) {
            if (holder.routing != null) {
                futures[i] = gigaSpace.execute((DistributedTask) holder.task, (Object[]) holder.routing);
            } else {
                futures[i] = gigaSpace.execute((DistributedTask) holder.task);
            }
        } else {
            if (holder.routing != null) {
                futures[i] = gigaSpace.execute(holder.task, holder.routing);
            } else {
                futures[i] = gigaSpace.execute(holder.task);
            }
        }
    }
    AsyncFuture<R> result;
    if (reducer instanceof AsyncResultFilter) {
        result = FutureFactory.create(futures, reducer, (AsyncResultFilter<T>) reducer);
    } else {
        result = FutureFactory.create(futures, reducer);
    }
    return gigaSpace.wrapFuture(result, gigaSpace.getCurrentTransaction());
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:41,代码来源:ExecutorBuilder.java

示例14: submit

import com.gigaspaces.async.AsyncFuture; //导入依赖的package包/类
public <T> AsyncFuture<T> submit(Callable<T> task) {
    AsyncFuture<T> result;
    if (task instanceof AsyncResultsReducer) {
        result = gigaSpace.execute(new CallableDistributedTaskAdapter(task));
    } else {
        result = gigaSpace.execute(new CallableTaskAdapter(task));
    }
    return result;
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:10,代码来源:DefaultTaskExecutorService.java

示例15: submitDistributedTaskExecution

import com.gigaspaces.async.AsyncFuture; //导入依赖的package包/类
private <R, T extends Serializable> void submitDistributedTaskExecution(final DistributedTask<T, R> distributedTask, Subscriber<? super R> t1) {
	usingErrorReporter(t1, serviceUnavailable()).accept(() -> {
		// Submit task on current thread in executorService
		AsyncFuture<R> taskResult = gigaSpace.execute(distributedTask);
		GsUtil.subscribe(taskResult, t1);
	});
}
 
开发者ID:AvanzaBank,项目名称:astrix,代码行数:8,代码来源:SpaceTaskDispatcher.java


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