Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
Distributed File System
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tmp1u19
Distributed File System
Commits
bbe2edae
Commit
bbe2edae
authored
4 years ago
by
tmp1u19
Browse files
Options
Downloads
Patches
Plain Diff
Dstores can now join the Controller
parent
411ca5e6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Controller.java
+22
-3
22 additions, 3 deletions
src/Controller.java
src/Dstore.java
+21
-1
21 additions, 1 deletion
src/Dstore.java
with
43 additions
and
4 deletions
src/Controller.java
+
22
−
3
View file @
bbe2edae
import
java.io.*
;
import
java.io.*
;
import
java.net.*
;
import
java.net.*
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
Controller
{
public
class
Controller
{
...
@@ -20,24 +22,41 @@ public class Controller {
...
@@ -20,24 +22,41 @@ public class Controller {
int
rebalance_period
=
Integer
.
parseInt
(
args
[
3
]);
int
rebalance_period
=
Integer
.
parseInt
(
args
[
3
]);
System
.
out
.
println
(
"Started"
);
System
.
out
.
println
(
"Started"
);
List
<
Socket
>
ports
=
new
ArrayList
<>();
try
{
try
{
ServerSocket
socket
=
new
ServerSocket
(
cport
);
ServerSocket
socket
=
new
ServerSocket
(
cport
);
socket
.
setSoTimeout
(
10
*
timeout
);
for
(;;)
{
for
(;;)
{
try
{
try
{
if
(
R
>
0
)
{
if
(
R
>
0
)
{
Socket
client
=
socket
.
accept
();
System
.
out
.
println
(
"waiting for Dstore to join"
);
Socket
client
=
socket
.
accept
();
// establish a connection between client and server
System
.
out
.
print
(
R
+
": "
);
ports
.
add
(
client
);
R
=
R
-
1
;
R
=
R
-
1
;
}
else
{
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
client
.
getInputStream
()));
String
line
;
while
((
line
=
in
.
readLine
())
!=
null
)
System
.
out
.
println
(
line
+
" received"
);
client
.
close
();
}
else
{
break
;
}
}
}
catch
(
Exception
e1
)
{
}
catch
(
Exception
e1
)
{
System
.
out
.
println
(
e1
);
System
.
out
.
println
(
e1
);
}
}
}
}
/*
#TODO
- use threads to connect multiple clients to a server
*/
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"error"
+
e
);
System
.
out
.
println
(
"error"
+
e
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/Dstore.java
+
21
−
1
View file @
bbe2edae
import
java.io.*
;
import
java.net.*
;
public
class
Dstore
{
public
class
Dstore
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
@@ -11,6 +14,23 @@ public class Dstore {
...
@@ -11,6 +14,23 @@ public class Dstore {
// where to store the data locally
// where to store the data locally
String
file_folder
=
args
[
3
];
String
file_folder
=
args
[
3
];
System
.
out
.
println
(
"Adding"
);
InetAddress
ip
;
try
{
ip
=
InetAddress
.
getLocalHost
();
Socket
socket
=
new
Socket
();
socket
.
connect
(
new
InetSocketAddress
(
ip
,
cport
),
timeout
);
for
(;;)
{
PrintWriter
out
=
new
PrintWriter
(
socket
.
getOutputStream
());
out
.
println
(
"adding Dstore"
);
out
.
flush
();
System
.
out
.
println
(
"Dstore was added"
);
Thread
.
sleep
(
1000
);
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"error "
+
e
);
}
}
}
}
}
\ No newline at end of file
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