Skip to content
Snippets Groups Projects
Commit 3588d09b authored by ik1g19's avatar ik1g19
Browse files

storing is balanced

parent c491d683
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -33,7 +33,7 @@ public class ClientMain {
// try { client.store(new File("test2.txt")); } catch(IOException e) { e.printStackTrace(); }
try {Thread.sleep(1000);} catch (InterruptedException e) {System.out.println(e);}
try {Thread.sleep(5000);} catch (InterruptedException e) {System.out.println(e);}
try { client.store(new File("test2.txt")); } catch(IOException e) { e.printStackTrace(); }
......
......@@ -167,19 +167,24 @@ public class Controller extends Server {
controllerThreadComms.queueDStoreRequest(dStoreID, "LIST");
Optional<String> wrappedResponse = controllerThreadComms.waitForResponse(dStoreID, "LIST", timeout);
String response = "";
if (wrappedResponse.isPresent()) response = wrappedResponse.get();
String response;
Integer fileCount;
if (wrappedResponse.isPresent()) {
response = wrappedResponse.get();
List<String> files = Arrays.stream(response.split(" ")).
skip(1).
collect(Collectors.toList());
Integer fileCount;
if (files.get(0).equals("empty")) fileCount = 0;
else fileCount = files.size() - 1;
else fileCount = files.size();
}
else {threadIDErr("Timeout expired while waiting for LIST reply"); fileCount = -1;}
return new Pair<>(connection, fileCount);
}).
filter(x -> x.getSnd() != -1).
sorted(Comparator.comparing(Pair::getSnd)).
map(x -> x.getFst()).
limit(r).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment