public static void init() { EventHandler.setController(new PullBasedPeerController()); Network.init(); OverlayFactory.init(); PeerFactory.init(); Network.init(); Message.init(); Iterator<Video> itv = Repository.getVideoIterator(); p2pOverlay = new ArrayList<Overlay>(); Servers = new ArrayList<Server>(); while (itv.hasNext()) { p2pOverlay.add(OverlayFactory.genOverlay(itv.next())); } Peer tmp = PeerFactory.genPeer(null); while (tmp != null) { Output.printP2PEvent( "Server" + tmp.getPeerID() + " created! Bandwidth:" + Utilities.displayDouble(tmp.getUploadBW())); Servers.add((Server) tmp); tmp = PeerFactory.genPeer(null); } }
public static void dropService(User who) { Iterator<Video> itvr = who.getPlayedIterator(); while (itvr.hasNext()) { getOverlay(itvr.next()).leaveOverlay(who); } who.leave(); who.getPeer().destroy(); Output.printTrack( who, "User" + who.getUserID() + " stayed in system for:" + Utilities.displayDouble(who.getLeaveTime() - who.getInitTime()) + " network overload:" + Utilities.displayPercentage(who.getPeer().networkOverload()) + "% be interrupted:" + who.getInterruptedTime() + "s"); Output.stopTracing(who); }