/** * Retrieve information about platforms as they appear or vanish. * @param include_initial If true, information about initially known platforms will be immediately posted to the caller. * Otherwise only changes that happen after the subscription will be posted. * @return An intermediate future that is notified about any changes. */ public ISubscriptionIntermediateFuture<DiscoveryInfo> subscribeToPlatformList(boolean include_initial) { if(listeners==null) { listeners = new LinkedHashSet<SubscriptionIntermediateDelegationFuture<DiscoveryInfo>>(); } SubscriptionIntermediateDelegationFuture<DiscoveryInfo> ret = new SubscriptionIntermediateDelegationFuture<DiscoveryInfo>(); listeners.add(ret); if(include_initial) { for(DiscoveryInfo dif: discovered.values()) { ret.addIntermediateResult(dif); } } return ret; }
public void run() { ret.setException(e); } });
public void setException(Exception exception) { super.setExceptionIfUndone(exception); } };
final SubscriptionIntermediateDelegationFuture<Long> ret = new SubscriptionIntermediateDelegationFuture<Long>(); ret.setException(new RuntimeException("Must not be called twice."));
SubscriptionIntermediateDelegationFuture<Long> ret = new SubscriptionIntermediateDelegationFuture<Long>(); ret.addIntermediateResult(f.length()); FileInputStream fis = new FileInputStream(f); ISubscriptionIntermediateFuture<Long> fut = con.writeFromInputStream(fis, agent); ret.setException(new RuntimeException("File does not exist: "+name)); ret.setException(e);
final SubscriptionIntermediateDelegationFuture<IMonitoringEvent> ret = new SubscriptionIntermediateDelegationFuture<IMonitoringEvent>();
/** * Inform listeners about a changed discovery info. */ protected void informListeners(DiscoveryInfo dif) { if(listeners!=null) { for(Iterator<SubscriptionIntermediateDelegationFuture<DiscoveryInfo>> it=listeners.iterator(); it.hasNext() ; ) { SubscriptionIntermediateDelegationFuture<DiscoveryInfo> fut = it.next(); try { if(!fut.addIntermediateResultIfUndone(dif)) { // Future terminated, i.e., subscription cancelled. it.remove(); } } catch(Exception e) { e.printStackTrace(); } } } }
/** * Retrieve information about platforms as they appear or vanish. * @param include_initial If true, information about initially known platforms will be immediately posted to the caller. * Otherwise only changes that happen after the subscription will be posted. * @return An intermediate future that is notified about any changes. */ public ISubscriptionIntermediateFuture<DiscoveryInfo> subscribeToPlatformList(boolean include_initial) { // SubscriptionIntermediateDelegationFuture<DiscoveryInfo> ret = new SubscriptionIntermediateDelegationFuture<DiscoveryInfo>(); SubscriptionIntermediateDelegationFuture<DiscoveryInfo> ret = (SubscriptionIntermediateDelegationFuture<DiscoveryInfo>)SFuture.getNoTimeoutFuture(SubscriptionIntermediateDelegationFuture.class, agent); if(listeners==null) { listeners = new LinkedHashSet<SubscriptionIntermediateDelegationFuture<DiscoveryInfo>>(); } listeners.add(ret); if(include_initial) { for(DiscoveryInfo dif: discovered.values()) { ret.addIntermediateResult(dif); } } return ret; }
/** * Overwritten to change result, if necessary. */ @Override protected boolean doAddIntermediateResult(Object result, boolean undone) { try { result = func.handleIntermediateResult(result); return DelegatingSubscriptionIntermediateDelegationFuture.super.doAddIntermediateResult(result, func.isUndone(undone)); } catch(Exception e) { return doSetException(e, func.isUndone(undone)); } }
final SubscriptionIntermediateDelegationFuture<Long> ret = new SubscriptionIntermediateDelegationFuture<Long>(); ret.setException(new RuntimeException("Must not be called twice."));
SubscriptionIntermediateDelegationFuture<Long> ret = new SubscriptionIntermediateDelegationFuture<Long>(); ret.addIntermediateResult(f.length()); FileInputStream fis = new FileInputStream(f); ISubscriptionIntermediateFuture<Long> fut = con.writeFromInputStream(fis, agent); ret.setException(new RuntimeException("File does not exist: "+name)); ret.setException(e);
ret = new SubscriptionIntermediateDelegationFuture();
/** * Inform listeners about a changed discovery info. */ protected void informListeners(DiscoveryInfo dif) { if(listeners!=null) { for(Iterator<SubscriptionIntermediateDelegationFuture<DiscoveryInfo>> it=listeners.iterator(); it.hasNext() ; ) { SubscriptionIntermediateDelegationFuture<DiscoveryInfo> fut = it.next(); try { if(!fut.addIntermediateResultIfUndone(dif)) { // Future terminated, i.e., subscription cancelled. it.remove(); } } catch(Exception e) { e.printStackTrace(); } } } }
final SubscriptionIntermediateDelegationFuture<Long> ret = new SubscriptionIntermediateDelegationFuture<Long>(); ret.setException(new RuntimeException("Must not be called twice."));
final SubscriptionIntermediateDelegationFuture<IMonitoringEvent> ret = new SubscriptionIntermediateDelegationFuture<IMonitoringEvent>();
public void run() { ret.setException(e); } });
public void setException(Exception exception) { super.setExceptionIfUndone(exception); } };
final SubscriptionIntermediateDelegationFuture<Long> ret = new SubscriptionIntermediateDelegationFuture<Long>(); ret.setException(new RuntimeException("Must not be called twice."));
final SubscriptionIntermediateDelegationFuture<IMonitoringEvent> ret = new SubscriptionIntermediateDelegationFuture<IMonitoringEvent>();
public void run() { ret.setException(e); } });