Skip to content

Conversation

@chandms
Copy link

@chandms chandms commented Apr 21, 2018

No description provided.

}
else{
try {
new Thread(fileTransporter.new ListFetcher(controller, new URL("http://"+s+":8080/list"), s)).start();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just change this port while testing. Do not commit this change.

@@ -1,5 +1,6 @@
package bishakh.psync;

import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this?

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here. port.

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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

port

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

port

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

port

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

port

Copy link
Contributor

@archie94 archie94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary comments

writer.close();
for(Map.Entry m:mp.entrySet())
{
//System.out.println(m.getKey()+" "+m.getValue());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont commit commented codes

printWriter.println(m.getKey()+" "+m.getValue());
}
printWriter.close();
////////////
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary comments

public SyncService() throws IOException {

public SyncService() {
//System.exit(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

databaseAndLogDirectory = baseDirectory;
PEER_ID = inputPeerId;

//System.exit(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

databaseAndLogDirectory = baseDirectory;
PEER_ID = inputPeerId;

//System.exit(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented codes.

syncDirectory = baseDirectory + File.separator + "sync" + File.separator;
public SyncService(String inputPeerId, String baseDirectory, int priorityMethod, boolean restrictedEpidemicFlag) throws IOException {

//System.exit(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

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" + "/";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? why this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay then I am replacing last '/' with File.separator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants