Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact Information #20

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Contact Information #20

wants to merge 9 commits into from

Conversation

chandms
Copy link

@chandms chandms commented Apr 21, 2018

No description provided.

@@ -413,7 +413,7 @@ public void run() {
}
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?

@@ -40,12 +45,26 @@
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.

@@ -33,7 +33,7 @@ public void downloadFile(String fileID, String fileName, String filePath, String
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.

@@ -18,69 +18,73 @@
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.

@@ -287,6 +330,26 @@ public void run() {
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() {
//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.

mapFileServerDirectory = baseDirectory;
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

mapFileServerDirectory = baseDirectory;
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