private void addReplicas(Collection<Task> Tasks, int numberOfReplicas) {
   for (int i = 0; i < numberOfReplicas; i++) {
     for (Task Task : Tasks) {
       this.getSubmittedTasks().add(Task.makeReplica());
     }
   }
 }
 @Override
 public final void schedule() {
   for (Iterator<Task> iterator = this.getSubmittedTasks().iterator(); iterator.hasNext(); ) {
     Task Task = iterator.next();
     Task.getSourcePeer().prioritizePeersToConsume(this.getPeers());
     for (Peer provider : this.getPeers()) {
       boolean isTaskRunning = provider.executeTask(Task);
       if (isTaskRunning) {
         // System.out.println("Is Running: " + task.getStartTime() +
         // " : " + task.getId() + " : " + task.getReplicaId());
         iterator.remove();
         break;
       }
     }
   }
 }
  private void stopRemainingReplicas(Task Task) {

    for (Task replica : Task.getReplicas()) {
      // para as replicas que ainda estiverem rodando
      if (replica.isRunning()) {
        assert this.getRunningTasks().contains(replica) : replica;
        if (replica.getEstimatedFinishTime() > Task.getFinishTime()) {
          // ocorria problema quando a task tinha acabado de iniciar
          assert this.getRunningTasks().contains(replica)
                  || replica.getStartTime() == getCurrentTime()
              : getCurrentTime() + ": " + replica;
          assert !replica.isFinished();
          replica.getTargetPeer().cancelTask(replica);
        } else if (replica.getEstimatedFinishTime() == Task.getFinishTime()) {
          // Pode estar no caso "=" o warning apresentado
          replica.getTargetPeer().cancelTask(replica);
        } else {
          replica.getTargetPeer().cancelTask(replica);
        }
      } else if (replica.isCancelled()) {
        assert !this.getRunningTasks().contains(replica) : replica;
        assert !this.getSubmittedTasks().contains(replica) : replica;
      } else if (replica.wasPreempted()) {
        assert this.getSubmittedTasks().contains(replica) : replica;
        boolean removed = this.getSubmittedTasks().remove(replica);
        assert removed : replica;
      } else if (this.getSubmittedTasks().contains(replica)) { // está
        // aguardando?
        replica.cancel();
        boolean removed = this.getSubmittedTasks().remove(replica);
        assert removed : replica;
      } else {
        throw new RuntimeException("situação não esperada: " + replica);
      }
    }
  }