Skip to content

Commit

Permalink
last update
Browse files Browse the repository at this point in the history
  • Loading branch information
EC2 Default User committed May 13, 2019
1 parent 94a9c38 commit 429e205
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 19 deletions.
13 changes: 13 additions & 0 deletions Dockerfile.acquire_leader
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM golang:1.12

WORKDIR $GOPATH/src/cos518project/
COPY . .

# Dependencies
RUN go get -d -v ./...

# Build executable
RUN go build -o chubby/acquire_lock_client chubby/cmd/acquire_Lock_Client.go

# Run simple_client exec
CMD ["chubby/acquire_lock_client"]
13 changes: 13 additions & 0 deletions Dockerfile.leader_client
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM golang:1.12

WORKDIR $GOPATH/src/cos518project/
COPY . .

# Dependencies
RUN go get -d -v ./...

# Build executable
RUN go build -o chubby/leader_election_client1 chubby/cmd/leader_election.go

# Run simple_client exec
CMD ["chubby/leader_election_client1"]
2 changes: 1 addition & 1 deletion Dockerfile.simple_client
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ RUN go get -d -v ./...
RUN go build -o bin/simple_client chubby/cmd/simple_client.go

# Run simple_client exec
CMD ["bin/simple_client"]
CMD ["bin/simple_client"]
2 changes: 1 addition & 1 deletion chubby/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ leader_election_client1:
go build -o leader_election_client1 cmd/leader_election.go

acquire_lock_client:
go build -o acquire_lock_client cmd/acquire_Lock_Client.go
go build -o acquire_lock_client cmd/acquire_Lock_Client.go
18 changes: 14 additions & 4 deletions chubby/cmd/acquire_Lock_Client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func main() {

quitCh := make(chan os.Signal, 1)
signal.Notify(quitCh, os.Kill, os.Interrupt, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)

time.Sleep(5*time.Second)
sess, err := client.InitSession(api.ClientID(acquireLock_clientID))
if err != nil {
log.Fatal(err)
Expand All @@ -47,7 +47,17 @@ func main() {
if err != nil {
log.Fatal(err)
}
break
content, err := sess.ReadContent("Lock/Lock1")
if err != nil {
log.Fatal(err)
} else {
fmt.Printf("Read Content is %s\n",content)
}
if content == acquireLock_clientID {
elapsed := time.Since(startTime)
log.Printf("Successfully acquired lock after %s\n",elapsed)
}
return
}
}

Expand All @@ -59,9 +69,9 @@ func main() {
}
if content == acquireLock_clientID {
elapsed := time.Since(startTime)
fmt.Printf("Successfully acquired lock after %s\n",elapsed)
log.Printf("Successfully acquired lock after %s\n",elapsed)
}

// Exit on signal.
<-quitCh
}
}
2 changes: 1 addition & 1 deletion chubby/server/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"time"
)

const DefaultLeaseExt = 12 * time.Second
const DefaultLeaseExt = 15 * time.Second

// Session contains metadata for one Chubby session.
// For simplicity, we say that each client can only init one session with
Expand Down
37 changes: 25 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,32 @@ services:
static-network:
ipv4_address: 172.20.128.5

# client:
# build:
# context: .
# dockerfile: Dockerfile.client_fast_reqs
# restart: on-failure
# depends_on:
# - "node1"
# networks:
# static-network:
# ipv4_address: 172.20.192.1

client1:
build:
context: .
dockerfile: Dockerfile.leader_client
restart: on-failure
depends_on:
- "node1"
- "node2"
- "node3"
- "node4"
- "node5"
networks:
static-network:
ipv4_address: 172.20.192.1
client2:
build:
context: .
dockerfile: Dockerfile.acquire_leader
restart: on-failure
depends_on:
- "client1"
networks:
static-network:
ipv4_address: 172.20.193.1
networks:
static-network:
ipam:
config:
- subnet: 172.20.0.0/16
- subnet: 172.20.0.0/16

0 comments on commit 429e205

Please sign in to comment.