Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs425-mp4
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
zf4
cs425-mp4
Commits
e1d4551c
Commit
e1d4551c
authored
6 years ago
by
zf4
Browse files
Options
Downloads
Patches
Plain Diff
worker data conn map
parent
92916998
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/crane/crane_master.go
+11
-5
11 additions, 5 deletions
src/crane/crane_master.go
src/crane/worker.go
+1
-1
1 addition, 1 deletion
src/crane/worker.go
with
12 additions
and
6 deletions
src/crane/crane_master.go
+
11
−
5
View file @
e1d4551c
...
...
@@ -35,6 +35,7 @@ var jobFinished bool // true if a job is just finished
var
boltID
int
// unique id for each bolt
var
possibleServerIdx
int
// index of last chosen server
var
workerConn
map
[
int
]
net
.
Conn
// map worker servNum to its corresponding connection
var
workerDataConn
map
[
int
]
net
.
Conn
var
workerPort
int
var
needRestart
bool
...
...
@@ -72,6 +73,7 @@ func InitializeCraneMaster() {
boltID
=
1
// 0 for spout, i.e., master node
possibleServerIdx
=
0
workerConn
=
make
(
map
[
int
]
net
.
Conn
)
workerDataConn
=
make
(
map
[
int
]
net
.
Conn
)
childrenBolts
=
nil
// Check if I am backup
if
shared
.
GetOwnServerNumber
()
==
MASTER_ONE
{
...
...
@@ -388,14 +390,18 @@ func runSpout() {
// fmt.Println(childrenBolts)
// fmt.Println(child)
// Send data
conn
,
err
:=
net
.
Dial
(
"tcp"
,
shared
.
GetServerAddressFromNumber
(
childServ
)
+
":"
+
strconv
.
Itoa
(
shared
.
CraneWorkerPort
))
if
err
!=
nil
{
panic
(
err
)
if
_
,
ok
:=
workerDataConn
[
childServ
];
!
ok
{
conn
,
err
:=
net
.
Dial
(
"tcp"
,
shared
.
GetServerAddressFromNumber
(
childServ
)
+
":"
+
strconv
.
Itoa
(
shared
.
CraneWorkerPort
))
if
err
!=
nil
{
panic
(
err
)
}
workerDataConn
[
childServ
]
=
conn
}
buf
:=
new
(
bytes
.
Buffer
)
gobEncoder
:=
gob
.
NewEncoder
(
buf
)
gobEncoder
.
Encode
(
data
)
conn
.
Write
(
buf
.
Bytes
())
workerDataConn
[
childServ
]
.
Write
(
buf
.
Bytes
())
// read the response
// readBuf := make([]byte, 1024)
// n, err := conn.Read(readBuf)
...
...
@@ -403,7 +409,7 @@ func runSpout() {
// fmt.Println(err)
// }
// fmt.Println(string(readBuf[:n]))
conn
.
Close
()
//
conn.Close()
if
needRestart
{
needRestart
=
false
return
...
...
This diff is collapsed.
Click to expand it.
src/crane/worker.go
+
1
−
1
View file @
e1d4551c
...
...
@@ -111,7 +111,7 @@ func handleWorkerRequest(conn net.Conn) {
gobDecoder
.
Decode
(
data
)
// Write ack response
//conn.Write([]byte("Ack"))
go
processData
(
*
data
)
processData
(
*
data
)
}
}
conn
.
Close
()
...
...
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