public void setException(Exception exception) { super.setExceptionIfUndone(exception); } };
/** * Notify the results, */ protected void notifyResults(List<Tuple2<S, Double>> results) { if(!isFinished()) { finished = Boolean.TRUE; TerminableIntermediateDelegationFuture<Tuple2<S, Double>> fut = (TerminableIntermediateDelegationFuture<Tuple2<S, Double>>)future; for(Tuple2<S, Double> res: results) { fut.addIntermediateResult(res); } fut.setFinished(); } } }
/** * Add a listener which is only informed about new results, * i.e. the initial results are not posted to this listener, * even if it is the first listener to be added to this future. */ public void addQuietListener(IResultListener<Collection<E>> listener) { if(!(listener instanceof IIntermediateResultListener)) { throw new IllegalArgumentException("Subscription futures require intermediate listeners."); } super.addResultListener(listener); }
/** * Rank the services of a search with a specific ranker and emit the scores. */ public static <S> ITerminableIntermediateFuture<Tuple2<S, Double>> rankServicesWithScores(ITerminableIntermediateFuture<S> searchfut, IServiceRanker<S> ranker, IRankingSearchTerminationDecider<S> decider) { TerminableIntermediateDelegationFuture<Tuple2<S, Double>> ret = new TerminableIntermediateDelegationFuture<Tuple2<S, Double>>(); searchfut.addResultListener(new ServiceRankingDelegationResultListener2<S>(ret, searchfut, ranker, decider)); return ret; }
final TerminableIntermediateDelegationFuture ret = new TerminableIntermediateDelegationFuture(); ret.setException(e);
/** * Rank the results and announce them */ protected void rankResults() { if(!isFinished()) { // Terminate the source ((TerminableIntermediateDelegationFuture<S>)future).getSource().terminate(); ranker.rankWithScores(results).addResultListener(new IResultListener<List<Tuple2<S, Double>>>() { public void resultAvailable(List<Tuple2<S, Double>> result) { notifyResults(result); } public void exceptionOccurred(Exception exception) { notifyException(exception); } }); } }
/** * Set the source. */ public void setSource(ITerminableIntermediateFuture<?> src) { assert this.src==null; this.src = src; doNotify(); }
/** * Add a result. * @param result The result. */ protected void addResult(E result) { // Store results only if necessary for first listener. if(storeforfirst) super.addResult(result); if(ownresults!=null) { for(List<E> res: ownresults.values()) { res.add(result); } } resumeIntermediate(); }
/** * Overwritten to change result, if necessary. */ @Override protected boolean doAddIntermediateResult(Object result, boolean undone) { try { result = func.handleIntermediateResult(result); return DelegatingTerminableIntermediateDelegationFuture.super.doAddIntermediateResult(result, func.isUndone(undone)); } catch(Exception e) { return doSetException(e, func.isUndone(undone)); } }
/** * Rank the services of a search with a specific ranker and emit the scores. */ public static <S> ITerminableIntermediateFuture<Tuple2<S, Double>> rankServicesWithScores(ITerminableIntermediateFuture<S> searchfut, IServiceRanker<S> ranker, IRankingSearchTerminationDecider<S> decider) { TerminableIntermediateDelegationFuture<Tuple2<S, Double>> ret = new TerminableIntermediateDelegationFuture<Tuple2<S, Double>>(); searchfut.addResultListener(new ServiceRankingDelegationResultListener2<S>(ret, searchfut, ranker, decider)); return ret; }
/** * Rank the results and announce them */ protected void rankResults() { if(!isFinished()) { // Terminate the source ((TerminableIntermediateDelegationFuture<S>)future).getSource().terminate(); ranker.rankWithScores(results).addResultListener(new IResultListener<List<Tuple2<S, Double>>>() { public void resultAvailable(List<Tuple2<S, Double>> result) { notifyResults(result); } public void exceptionOccurred(Exception exception) { notifyException(exception); } }); } }
/** * Possibly notify the termination source. */ protected void doNotify() { super.doNotify(); int mynotifycnt = 0; synchronized(this) { mynotifycnt = notifycnt; notifycnt = 0; } for(int i=0; i<mynotifycnt; i++) ((IPullIntermediateFuture<E>)src).pullIntermediateResult(); }
public void setException(Exception exception) { super.setExceptionIfUndone(exception); } };
/** * Rank the services of a search with a specific ranker. */ public static <S> ITerminableIntermediateFuture<S> rankServices(ITerminableIntermediateFuture<S> searchfut, IServiceRanker<S> ranker, IRankingSearchTerminationDecider<S> decider) { TerminableIntermediateDelegationFuture<S> ret = new TerminableIntermediateDelegationFuture<S>(); searchfut.addResultListener(new ServiceRankingDelegationResultListener<S>(ret, searchfut, ranker, decider)); return ret; }
/** * Notify the results, */ protected void notifyResults(List<Tuple2<S, Double>> results) { if(!isFinished()) { finished = Boolean.TRUE; TerminableIntermediateDelegationFuture<Tuple2<S, Double>> fut = (TerminableIntermediateDelegationFuture<Tuple2<S, Double>>)future; for(Tuple2<S, Double> res: results) { fut.addIntermediateResult(res); } fut.setFinished(); } } }
storeforfirst = false; super.addResultListener(listener);
public void setException(Exception exception) { super.setExceptionIfUndone(exception); } };
/** * Rank the services of a search with a specific ranker. */ public static <S> ITerminableIntermediateFuture<S> rankServices(ITerminableIntermediateFuture<S> searchfut, IServiceRanker<S> ranker, IRankingSearchTerminationDecider<S> decider) { TerminableIntermediateDelegationFuture<S> ret = new TerminableIntermediateDelegationFuture<S>(); searchfut.addResultListener(new ServiceRankingDelegationResultListener<S>(ret, searchfut, ranker, decider)); return ret; }
public void setException(Exception exception) { super.setExceptionIfUndone(exception); } };
final TerminableIntermediateDelegationFuture<T> ret = new TerminableIntermediateDelegationFuture<T>();