Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
distributed systems cw
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ik1g19
distributed systems cw
Commits
3588d09b
Commit
3588d09b
authored
4 years ago
by
ik1g19
Browse files
Options
Downloads
Patches
Plain Diff
storing is balanced
parent
c491d683
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
ClientAndLoggers/ClientMain.class
+0
-0
0 additions, 0 deletions
ClientAndLoggers/ClientMain.class
ClientAndLoggers/ClientMain.java
+1
-1
1 addition, 1 deletion
ClientAndLoggers/ClientMain.java
src/Controller.java
+13
-8
13 additions, 8 deletions
src/Controller.java
with
14 additions
and
9 deletions
ClientAndLoggers/ClientMain.class
+
0
−
0
View file @
3588d09b
No preview for this file type
This diff is collapsed.
Click to expand it.
ClientAndLoggers/ClientMain.java
+
1
−
1
View file @
3588d09b
...
...
@@ -33,7 +33,7 @@ public class ClientMain {
// try { client.store(new File("test2.txt")); } catch(IOException e) { e.printStackTrace(); }
try
{
Thread
.
sleep
(
1
000
);}
catch
(
InterruptedException
e
)
{
System
.
out
.
println
(
e
);}
try
{
Thread
.
sleep
(
5
000
);}
catch
(
InterruptedException
e
)
{
System
.
out
.
println
(
e
);}
try
{
client
.
store
(
new
File
(
"test2.txt"
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
...
...
This diff is collapsed.
Click to expand it.
src/Controller.java
+
13
−
8
View file @
3588d09b
...
...
@@ -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
).
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment