@Override public void run() { // TODO Auto-generated method stub Descrittore descr = null; System.out.println("@ Downloader partito !!"); if (Peer.prova == 0) { // contatto il server via RMI descr = contatta_server(this.nomefile); if (descr == null) { System.out.println("# RMI non ha trovato il descrittore per " + this.nomefile); return; } else if ((this.lista_peers = contatta_Tracker(descr)) == null) { System.out.println("# Downloader : problemi contattando il tracker per " + this.nomefile); return; } polling_man.aggiungi(descr.nome, (Integer) descr.getUdp()); System.out.println("ho aggiunto la porta udp"); if (Peer.gest_files.contiene(descr.nome)) System.out.println("I metadati riguardo al file " + descr.nome + "sono già in memoria"); else { FileAccess file_access = null; try { file_access = new FileAccess(new Rapp_file(descr.nome, descr.hash_array, false)); } catch (FileNotFoundException e) { // TODO Auto-generated catch block System.out.println( "# Problemi con la creazione del file fisico di " + descr.nome + " !! "); e.printStackTrace(); return; } int is_seeder = 0; // di default a 0 (falso) // gestore file ritorna l'eventuale condizione di seeder del peer riguardo al determinato // file if ((is_seeder = Peer.gest_files.aggiungi(file_access)) == 0) { // se non è un seeder System.out.println("@ File access creato !"); vita_sociale(file_access, lista_peers); System.out.println("@ Vita sociale superato !"); } } } /* if(Peer.prova==1) //TODO togliere poi questa { FileAccess file_access=null; try { file_access = new FileAccess(new Rapp_file("babbo1", Peer.hash_babbo,false)); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block System.out.println("# Problemi con la creazione del file"); e1.printStackTrace(); } Peer.gest_files.aggiungi(file_access); System.out.println("@ File access creato !"); InetAddress mio=null; this.lista_peers=new ArrayList<InetAddress>(); try { mio=InetAddress.getLocalHost(); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } if(mio!=null) this.lista_peers.add(mio); else System.out.println("# prendere il mio Indirizzo è andato male"); vita_sociale(file_access,this.lista_peers); System.out.println("@ Vita sociale superato !"); }*/ }