/** * Set the fast startup awareness flag */ public void setFastAwareness(final boolean fast) { this.fast = fast; IIntermediateFuture<IDiscoveryService> disfut = getRequiredServices("discoveries"); disfut.addResultListener(new IntermediateDefaultResultListener<IDiscoveryService>() { public void intermediateResultAvailable(IDiscoveryService ds) { ds.setFast(fast); } public void exceptionOccurred(Exception exception) { getLogger().warning("Could not find discoveries: "+exception); } }); }
final TestReport tr1 = new TestReport("#1", "Test if blocking get works."); String res1 = fut.getNextIntermediateResult(); // if broken, this hangs fut.addIntermediateResultListener(new IFunctionalIntermediateResultListener<String>() { @Override public void intermediateResultAvailable(String result) {
public IFuture<Void> execute(IInternalAccess ia) { while(fut.hasNextIntermediateResult()) { Integer res = fut.getNextIntermediateResult(); steps1.add(res); stepsall.add(res); } return IFuture.DONE; } });
first.addResultListener(lis); second.addResultListener(lis); first.get(); second.get();
Collection<?> results = services.get(this);
/** * Get next result. */ public E next() { return fut.getNextIntermediateResult(); }
/** * Check for more results. */ public boolean hasNext() { return fut.hasNextIntermediateResult(); }
/** * Creates a delegation from source to target, respecting future types. * @param source Delegation source. * @param target Delegation target. */ public static <E> void delegateFromTo(IFuture<E> source, Future<E> target) { // if (source instanceof ITuple2Future && target instanceof Tuple2Future) // { // // need special case for tuple? // ((ITuple2Future) source).addResultListener(delegate((Tuple2Future)target)); // } if (source instanceof IIntermediateFuture && target instanceof IntermediateFuture) { ((IIntermediateFuture) source).addIntermediateResultListener(delegate((IntermediateFuture)target)); } else { source.addResultListener(delegate(target)); } // TODO: needed for other *DelegationResultListeners ? }
Collection<IService> forces = (Collection<IService>)fut.get(); int number = ((Integer)disaster.getProperty(typename)).intValue();
public IFuture<Void> execute(IInternalAccess ia) { for(int i=0; i<3; i++) { Integer res = fut.getNextIntermediateResult(); steps2.add(res); stepsall.add(res); } return IFuture.DONE; } });
/** * Set the fast startup awareness flag * @param fast The fast awareness flag. */ public void setFastAwareness(final boolean fast) { this.fast = fast; IIntermediateFuture<IDiscoveryService> disfut = getRequiredServices("discoveries"); disfut.addResultListener(new IntermediateDefaultResultListener<IDiscoveryService>() { public void intermediateResultAvailable(IDiscoveryService ds) { ds.setFast(fast); } public void exceptionOccurred(Exception exception) { // No discoveries: ignore } }); }
public IFuture<Void> execute(IInternalAccess ia) { for(int i=0; i<3 && fut.hasNextIntermediateResult(); i++) { Integer res = fut.getNextIntermediateResult(); steps1.add(res); stepsall.add(res); } return IFuture.DONE; } });
public IFuture<Void> execute(IInternalAccess ia) { try { while(true) { Integer res = fut.getNextIntermediateResult(); steps2.add(res); stepsall.add(res); } } catch(NoSuchElementException e) { // got all results } return IFuture.DONE; } });
public void actionPerformed(ActionEvent e) { bsearchinfo.setEnabled(false); getInformation(tfname.getText(), cbremoteinfo.isSelected()).addResultListener(new SwingDefaultResultListener() { public void customResultAvailable(Object result) { infolist.clear(); if(result!=null) infolist.addAll((Collection)result); infomodel.fireTableDataChanged(); bsearchinfo.setEnabled(true); } public void customExceptionOccurred(Exception exception) { super.customExceptionOccurred(exception); bsearchinfo.setEnabled(true); } }); } });
/** * Set the excludes. * @param excludes The excludes to set. */ public void setExcludes(final String[] excludes) { synchronized(this) { this.excludes = new ArrayList<String>(Arrays.asList(excludes)); } IIntermediateFuture<IDiscoveryService> disfut = getRequiredServices("discoveries"); disfut.addResultListener(new IntermediateDefaultResultListener<IDiscoveryService>() { public void intermediateResultAvailable(IDiscoveryService ds) { ds.setExcludes(excludes); } public void exceptionOccurred(Exception exception) { // No discoveries: ignore } }); }
/** * Set the includes. * @param includes The includes to set. */ public void setIncludes(final String[] includes) { synchronized(this) { this.includes = new ArrayList<String>(Arrays.asList(includes)); } IIntermediateFuture<IDiscoveryService> disfut = getRequiredServices("discoveries"); disfut.addResultListener(new IntermediateDefaultResultListener<IDiscoveryService>() { public void intermediateResultAvailable(IDiscoveryService ds) { ds.setIncludes(includes); } public void exceptionOccurred(Exception exception) { getLogger().warning("Could not find discoveries: "+exception); } }); }
/** * Set the includes. * @param includes The includes to set. */ public void setIncludes(final String[] includes) { synchronized(this) { this.includes = new ArrayList<String>(Arrays.asList(includes)); } IIntermediateFuture<IDiscoveryService> disfut = getRequiredServices("discoveries"); disfut.addResultListener(new IntermediateDefaultResultListener<IDiscoveryService>() { public void intermediateResultAvailable(IDiscoveryService ds) { ds.setIncludes(includes); } public void exceptionOccurred(Exception exception) { // No discoveries: ignore } }); }
/** * Set the excludes. * @param excludes The excludes to set. */ public void setExcludes(final String[] excludes) { synchronized(this) { this.excludes = new ArrayList<String>(Arrays.asList(excludes)); } IIntermediateFuture<IDiscoveryService> disfut = getRequiredServices("discoveries"); disfut.addResultListener(new IntermediateDefaultResultListener<IDiscoveryService>() { public void intermediateResultAvailable(IDiscoveryService ds) { ds.setExcludes(excludes); } public void exceptionOccurred(Exception exception) { getLogger().warning("Could not find discoveries: "+exception); } }); }
/** * This method is called after agent startup. */ @AgentBody public void body() { // Subscribe to all found time services. timeservices.addResultListener(new IntermediateDefaultResultListener<ITimeService>() { public void intermediateResultAvailable(final ITimeService timeservice) { ISubscriptionIntermediateFuture<String> subscription = timeservice.subscribe(); subscription.addResultListener(new IntermediateDefaultResultListener<String>() { /** * This method gets called for each received time submission. */ public void intermediateResultAvailable(String time) { String platform = ((IService)timeservice).getServiceIdentifier().getProviderId().getPlatformName(); System.out.println("New time received from "+platform+" at "+timeservice.getLocation()+": "+time); } }); } }); } }
/** * Set the delay. * @param delay The delay to set. */ public synchronized void setDelay(final long delay) { // System.out.println("setDelay: "+delay+" "+getComponentIdentifier()); // if(this.delay>=0 && delay>0) // scheduleStep(send); if(this.delay!=delay) { this.delay = delay; // startSendBehaviour(); } IIntermediateFuture<IDiscoveryService> disfut = getRequiredServices("discoveries"); disfut.addResultListener(new IntermediateDefaultResultListener<IDiscoveryService>() { public void intermediateResultAvailable(IDiscoveryService ds) { ds.setDelay(delay); } public void exceptionOccurred(Exception exception) { getLogger().warning("Could not find discoveries: "+exception); } }); }