Conversation
| } | ||
| else{ | ||
| try { | ||
| new Thread(fileTransporter.new ListFetcher(controller, new URL("http://"+s+":8080/list"), s)).start(); |
There was a problem hiding this comment.
Just change this port while testing. Do not commit this change.
| @@ -1,5 +1,6 @@ | |||
| package bishakh.psync; | |||
|
|
|||
| import javax.swing.plaf.basic.BasicInternalFrameTitlePane; | |||
| public volatile ConcurrentHashMap<String, ArrayList<String>> priorityPeerList; | ||
| public volatile ConcurrentHashMap<String, ArrayList<String>> originalPeerList; | ||
|
|
||
| public Discoverer(String BROADCAST_IP, String PEER_ID, int PORT, Logger LoggerObj,File ffile) { |
There was a problem hiding this comment.
fileName? what file name. use a better variable name please.
| if(!parent.exists() && !parent.mkdirs()){ | ||
| throw new IllegalStateException("Couldn't create dir: " + parent); | ||
| } | ||
| URL fileUrl = new URL("http://"+ peerIP +":8080/getFile/" + fileID); |
| private static String mapFileServerDirectory = "/home/alarm/DMS/"; | ||
| private static String databaseAndLogDirectory = "/home/alarm/DMS/"; | ||
| private static String databaseName = "fileDB.txt"; | ||
| private static String contactFile = "contact.txt"; |
There was a problem hiding this comment.
contactFileName or contactHistoryFileName
more descriptive name = better
| fileManager = new FileManager(PEER_ID, databaseName, databaseAndLogDirectory, syncDirectory, mapFileServerDirectory, logger); | ||
| fileTransporter = new FileTransporter(syncDirectory, logger); | ||
| controller = new Controller(discoverer, fileManager, fileTransporter, syncInterval, maxRunningDownloads, logger, 2, true); | ||
| webServer = new WebServer(8080, controller, logger); |
| fileManager = new FileManager(PEER_ID, databaseName, databaseAndLogDirectory, syncDirectory, mapFileServerDirectory, logger); | ||
| fileTransporter = new FileTransporter(syncDirectory, logger); | ||
| controller = new Controller(discoverer, fileManager, fileTransporter, syncInterval, maxRunningDownloads, logger, 2, true); | ||
| webServer = new WebServer(8080, controller, logger); |
| fileManager = new FileManager(PEER_ID, databaseName, databaseAndLogDirectory, syncDirectory, mapFileServerDirectory, logger); | ||
| fileTransporter = new FileTransporter(syncDirectory, logger); | ||
| controller = new Controller(discoverer, fileManager, fileTransporter, syncInterval, maxRunningDownloads, logger, priorityMethod, true); | ||
| webServer = new WebServer(8080, controller, logger); |
| fileManager = new FileManager(PEER_ID, databaseName, databaseAndLogDirectory, syncDirectory, mapFileServerDirectory, logger); | ||
| fileTransporter = new FileTransporter(syncDirectory, logger); | ||
| controller = new Controller(discoverer, fileManager, fileTransporter, syncInterval, maxRunningDownloads, logger, priorityMethod, restrictedEpidemicFlag); | ||
| webServer = new WebServer(8080, controller, logger); |
archie94
left a comment
There was a problem hiding this comment.
Documenting codes as you go along is always appreciated, but commenting out code lines adds no value. Kindly remove them.
| if(willUpdatePeer) { | ||
| String peerID = new String(datagramPacket.getData(), 0, datagramPacket.getLength()); | ||
| updatePeers(datagramPacket.getAddress().getHostAddress(), peerID); | ||
| /////////Added code |
There was a problem hiding this comment.
Remove unnecessary comments
| writer.close(); | ||
| for(Map.Entry m:mp.entrySet()) | ||
| { | ||
| //System.out.println(m.getKey()+" "+m.getValue()); |
There was a problem hiding this comment.
Dont commit commented codes
| printWriter.println(m.getKey()+" "+m.getValue()); | ||
| } | ||
| printWriter.close(); | ||
| //////////// |
There was a problem hiding this comment.
Remove unnecessary comments
| public SyncService() throws IOException { | ||
|
|
||
| public SyncService() { | ||
| //System.exit(0); |
| databaseAndLogDirectory = baseDirectory; | ||
| PEER_ID = inputPeerId; | ||
|
|
||
| //System.exit(0); |
| databaseAndLogDirectory = baseDirectory; | ||
| PEER_ID = inputPeerId; | ||
|
|
||
| //System.exit(0); |
| syncDirectory = baseDirectory + File.separator + "sync" + File.separator; | ||
| public SyncService(String inputPeerId, String baseDirectory, int priorityMethod, boolean restrictedEpidemicFlag) throws IOException { | ||
|
|
||
| //System.exit(0); |
| public SyncService(String inputPeerId, String baseDirectory, int priorityMethod) { | ||
| syncDirectory = baseDirectory + File.separator + "sync" + File.separator; | ||
| public SyncService(String inputPeerId, String baseDirectory, int priorityMethod) throws IOException { | ||
| syncDirectory = baseDirectory +"sync" + "/"; |
There was a problem hiding this comment.
Suppose my baseDirectory is provided as "C:/Users/Desktop/WorkingDirectory/" (with a trailing '/').
So, no need to give File.separator after baseDirectory unless syncDirectory would be like "C:/Users/Desktop/WorkingDirectory/ \ sync".
And I just mentioned '/' instead of File.separator, it does not create problem.
There was a problem hiding this comment.
There was a problem hiding this comment.
There was a problem hiding this comment.
Okay then I am replacing last '/' with File.separator
No description provided.