/** * Be informed when one of the other methods futures is terminated. * Returns an initial result when this future is registered. * Is finished, when the terminate action of the other future was called. */ public IIntermediateFuture<Void> terminateCalled() { IntermediateFuture<Void> ret = new IntermediateFuture<Void>(); if(termfut!=null) { ret.setException(new RuntimeException("Must not be called twice before result is available")); } else { ret.addIntermediateResult(null); termfut = ret; } return ret; } }
public void exceptionOccurred(Exception exception) { // ret.setResult(new RemoteResultCommand(null, exception, callid, false)); ret.addIntermediateResult(new RemoteResultCommand(null, null, exception, callid, false, null, getNonFunctionalProperties())); ret.setFinished(); } });
/** * Add an result listener, which called on intermediate results. * * @param intermediateListener The intermediate listener. */ public void addIntermediateResultListener(IIntermediateResultListener<E> intermediateListener) { addResultListener(intermediateListener); }
/** * Declare that the future is finished. */ public void customFinished() { if(undone) { future.setFinishedIfUndone(); } else { future.setFinished(); } }
/** * Called when the result is available. * @param result The result. */ public void customResultAvailable(Collection<E> result) { if(undone) { future.setResultIfUndone(result); } else { future.setResult(result); } }
/** * Called when an exception occurred. * @param exception The exception. */ public void customExceptionOccurred(Exception exception) { if(undone) { future.setExceptionIfUndone(exception); } else { future.setException(exception); } }
final IntermediateFuture<IRemoteCommand> reply = new IntermediateFuture<IRemoteCommand>(); reply.addIntermediateResult(new RemoteResultCommand(null, null, new RuntimeException("RMS received broken message content: "+content), callid, false, null, null)); reply.setFinished(); reply.addIntermediateResult(new RemoteResultCommand(null, null, new RuntimeException("RMS received unexpected message content: "+content), callid, false, null, null)); reply.setFinished(); reply.addResultListener(createResultListener(new IIntermediateResultListener<IRemoteCommand>()
@Classname("convertPathToRelative") public IIntermediateFuture<String> execute(IInternalAccess ia) { IntermediateFuture<String> ret = new IntermediateFuture<String>(); try { for(String path: paths) { ret.addIntermediateResult(SUtil.convertPathToRelative(path)); } ret.setFinished(); } catch(Exception e) { // Protect remote platform from execution errors. Thread.dumpStack(); e.printStackTrace(); ret.setException(e); } return ret; } });
@Classname("listFiles") public IIntermediateFuture<FileData> execute(IInternalAccess ia) IntermediateFuture<FileData> ret = new IntermediateFuture<FileData>(); try ret.setResult(null); ret.setException(e);
public void exceptionOccurred(Exception exception) { ret.setException(exception); } })
/** * Create a new allocation data. */ public AllocationData(int open, boolean retry, Object user) { this.open = open; this.retry = retry; this.user = user; this.result = new IntermediateFuture(); }
public void terminated(Exception reason) { // System.out.println("termination command called2: "+termfut); if(termfut!=null) { if(!agent.getComponentFeature(IExecutionFeature.class).isComponentThread()) { System.err.println("adapter1: "+agent.getComponentIdentifier()); System.err.println("adapter1a: "+IInternalExecutionFeature.LOCAL.get()); Thread.dumpStack(); termfut.setException(new RuntimeException("Terminate called on wrong thread.")); } else { termfut.setFinished(); } termfut = null; } }
public void customIntermediateResultAvailable(Object result) { if(shutdowned) { fut.setException(new ComponentTerminatedException(id)); } else { fut.addIntermediateResult((T)BasicServiceInvocationHandler.createRequiredServiceProxy(instance, instance.getExternalAccess(), adapter, (IService)result, null, new RequiredServiceInfo(type), null, realtime)); } } });
/** * Example implementation of the method. */ public IIntermediateFuture<String> getIntermediateResults() { IntermediateFuture<String> ret = new IntermediateFuture<String>(); ret.addIntermediateResult("hello"); System.out.println("called method getIntermediateResults()"); return ret; }
final IntermediateFuture<TestReport> ret = new IntermediateFuture<TestReport>(); final IntermediateFuture<TestReport> res = new IntermediateFuture<TestReport>(); ret.addResultListener(new IntermediateDelegationResultListener<TestReport>(res)
public void intermediateResultAvailable(E result) { delegate.addIntermediateResultIfUndone(result); }
/** * Called when an intermediate result is available. * @param result The result. */ public void customIntermediateResultAvailable(E result) { if(undone) { future.addIntermediateResultIfUndone(result); } else { future.addIntermediateResult(result); } } /**
public void intermediateResultAvailable(Object result) { // System.out.println("inter: "+result); ret.addIntermediateResult(new RemoteIntermediateResultCommand(rec, result, callid, returnisref, methodname, false, nonfunc, (IFuture<?>)res, cnt++)); }
/** * Get a file filter according to current file type settings. */ protected IIntermediateFuture<FileData> listFiles() { final IntermediateFuture<FileData> ret = new IntermediateFuture<FileData>(); if(file instanceof RemoteJarFile) { RemoteJarFile myfile = (RemoteJarFile)file; Collection<FileData> files = myfile.listFiles(); ret.setResult(files); } else { SRemoteGui.listFiles(file, factory.getFileFilter(), exta) .addResultListener(new IntermediateDelegationResultListener<FileData>(ret)); } return ret; }
if(fini) ifut.setFinishedIfUndone(); ifut.addIntermediateResultIfUndone(res); if(nres==FINISHED) ifut.setFinishedIfUndone(); ifut.addIntermediateResultIfUndone(nres);