Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jean-Paul Smets
slapos
Commits
a9636aa1
Commit
a9636aa1
authored
Nov 12, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made the script 'runnable'
parent
a28bfd61
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
12 deletions
+9
-12
slapos/recipe/addresiliency/template/bully_new.py.in
slapos/recipe/addresiliency/template/bully_new.py.in
+9
-12
No files found.
slapos/recipe/addresiliency/template/bully_new.py.in
View file @
a9636aa1
...
@@ -4,12 +4,12 @@ import socket
...
@@ -4,12 +4,12 @@ import socket
import time
import time
import sys
import sys
import thread
import thread
import time
import os
import os
sys.path[:] = %(syspath)s
sys.path[:] = %(syspath)s
from slapos import slap as slapmodule
from slapos import slap as slapmodule
import slapos
port = 50000
port = 50000
...
@@ -43,7 +43,6 @@ class ResilientInstance(object):
...
@@ -43,7 +43,6 @@ class ResilientInstance(object):
self.id = 0
self.id = 0
self.state = 'normal'
self.state = 'normal'
self.halter = 0
self.halter = 0
self.nbComp = nbComp
self.inElection = False
self.inElection = False
self.alive = True
self.alive = True
self.lastPing = time.clock()
self.lastPing = time.clock()
...
@@ -68,6 +67,7 @@ class ResilientInstance(object):
...
@@ -68,6 +67,7 @@ class ResilientInstance(object):
## Needs to be changed to use the master
## Needs to be changed to use the master
def aliveManagement(self):
def aliveManagement(self):
while self.alive:
while self.alive:
print 'XXX sleeping for 30 minutes'
time.sleep(30*60)
time.sleep(30*60)
if self.id == 0:
if self.id == 0:
continue
continue
...
@@ -165,9 +165,7 @@ class FilteredCanal(object):
...
@@ -165,9 +165,7 @@ class FilteredCanal(object):
self.lock.acquire()
self.lock.acquire()
if self.list:
if self.list:
self.lock.release()
self.lock.release()
val = self.list[0]
return self.list.pop(0)
self.list = self.list[1:]
return val
self.lock.release()
self.lock.release()
return [None, None]
return [None, None]
...
@@ -175,8 +173,6 @@ class FilteredCanal(object):
...
@@ -175,8 +173,6 @@ class FilteredCanal(object):
class Wrapper(object):
class Wrapper(object):
def __init__(self, timeout=20):
def __init__(self, timeout=20):
self.read_pipes = [os.fdopen(x) for x in read_pipes]
self.write_pipes = write_pipes
self.canals = []
self.canals = []
self.ips = []
self.ips = []
self.id = 0
self.id = 0
...
@@ -195,7 +191,7 @@ class Wrapper(object):
...
@@ -195,7 +191,7 @@ class Wrapper(object):
self.getConnectionInfos()
self.getConnectionInfos()
self.socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
self.socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
self.socket.bind((self.ips[self.id], port + self.id))
self.socket.bind((self.ips[self.id], port + self.id))
s.listen(5)
s
elf.socket
.listen(5)
def send(self, message, number):
def send(self, message, number):
self.getConnectionInfos()
self.getConnectionInfos()
...
@@ -214,15 +210,15 @@ class Wrapper(object):
...
@@ -214,15 +210,15 @@ class Wrapper(object):
return created
return created
def recv(self):
def recv(self):
client, _ = s.accept()
client, _ = s
elf.socket
.accept()
client_message = client.recv(1024)
client_message = client.recv(1024)
if client_message:
if client_message:
message, sender = client_message.split()
message, sender = client_message.split()
for canal in self.canals:
for canal in self.canals:
canal.append(message,
sender
)
canal.append(message,
int(sender)
)
wrapper =
create
Wrapper(20)
wrapper = Wrapper(20)
computer = ResilientInstance(wrapper)
computer = ResilientInstance(wrapper)
...
@@ -239,6 +235,7 @@ thread.start_new_thread(computer.main, ())
...
@@ -239,6 +235,7 @@ thread.start_new_thread(computer.main, ())
thread.start_new_thread(computer.aliveManagement, ())
thread.start_new_thread(computer.aliveManagement, ())
while True:
while True:
# XXX tight loop
continue
continue
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment