@Override public void execute(Executor executor) { setActive(); /* currentRequestor = null; Check if there is a valid host to which return the task output for(int i=0; i<delegationChain.size() && currentRequestor == null; i++){ if(myRouter.getPresenceCollector().isHostInRange(delegationChain.get(i))){ currentRequestor = delegationChain.get(i); } } */ if ( /*currentRequestor != null*/ myRouter.getPresenceCollector().isHostInRange(requestor) && executor.moreCommunicatorsAvailable()) { int[] missingRestOfMap = ((M2MShareRouter) requestor.getRouter()).getIntervalsForDownloadFwd(getID()); if (missingRestOfMap == null) { setCompleted(); return; } System.err.println( myRouter.getHost() + " - in DTNDownloadFwd.execute comincio a trasferire a " + requestor); executor.addCommunicator( myRouter.getPresenceCollector().getConnectionFor(requestor), myRouter.getHost(), filehash, missingRestOfMap); /* keep state = ACTIVE */ return; } // no communicator started setIncomplete(); }
@Override public void setCompleted() { super.setCompleted(); myRouter.notifyDownloadFWDReturned(myRouter.getHost(), requestor, filehash); myRouter.notifyDataRedundancyUpdated(myRouter.getHost(), map.mapBytesSize() * -1); ((M2MShareRouter) requestor.getRouter()).notifyDownloadFwdCompleted(myRouter.getHost()); }
@Override public void addTransferredData(int[] intervals, DTNHost from) { ((M2MShareRouter) requestor.getRouter()) .dataFromDownloadFwd(getID(), intervals, myRouter.getHost()); if (((M2MShareRouter) requestor.getRouter()).getIntervalsForDownloadFwd(getID()) == null) { setCompleted(); } }