Commit 50736599 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Storage nodes bind on any available port by default.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2351 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 0ae725dd
...@@ -59,9 +59,7 @@ class ConfigurationManager(object): ...@@ -59,9 +59,7 @@ class ConfigurationManager(object):
if ':' in bind: if ':' in bind:
(ip, port) = bind.split(':') (ip, port) = bind.split(':')
else: else:
ip = bind (ip, port) = (bind, 0)
# took port from default bind address
port = self.defaults['bind'].split(':')[1]
ip = util.resolve(ip) ip = util.resolve(ip)
return (ip, int(port)) return (ip, int(port))
......
...@@ -395,6 +395,9 @@ class ListeningConnection(BaseConnection): ...@@ -395,6 +395,9 @@ class ListeningConnection(BaseConnection):
except ConnectorTryAgainException: except ConnectorTryAgainException:
pass pass
def getAddress(self):
return self.connector.getAddress()
def writable(self): def writable(self):
return False return False
......
...@@ -89,6 +89,9 @@ class SocketConnector: ...@@ -89,6 +89,9 @@ class SocketConnector:
def getError(self): def getError(self):
return self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR) return self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
def getAddress(self):
return self.socket.getsockname()
def getDescriptor(self): def getDescriptor(self):
# this descriptor must only be used by the event manager, where it # this descriptor must only be used by the event manager, where it
# guarantee unicity only while the connector is opened and registered # guarantee unicity only while the connector is opened and registered
......
...@@ -43,7 +43,7 @@ parser.add_option('-d', '--database', help = 'database connections string') ...@@ -43,7 +43,7 @@ parser.add_option('-d', '--database', help = 'database connections string')
defaults = dict( defaults = dict(
name = 'storage', name = 'storage',
bind = '127.0.0.1:20000', bind = '127.0.0.1',
masters = '127.0.0.1:10000', masters = '127.0.0.1:10000',
adapter = 'MySQL', adapter = 'MySQL',
) )
......
...@@ -169,6 +169,7 @@ class Application(object): ...@@ -169,6 +169,7 @@ class Application(object):
handler = identification.IdentificationHandler(self) handler = identification.IdentificationHandler(self)
self.listening_conn = ListeningConnection(self.em, handler, self.listening_conn = ListeningConnection(self.em, handler,
addr=self.server, connector=self.connector_handler()) addr=self.server, connector=self.connector_handler())
self.server = self.listening_conn.getAddress()
# Connect to a primary master node, verify data, and # Connect to a primary master node, verify data, and
# start the operation. This cycle will be executed permanently, # start the operation. This cycle will be executed permanently,
......
...@@ -406,6 +406,9 @@ class DoNothingConnector(Mock): ...@@ -406,6 +406,9 @@ class DoNothingConnector(Mock):
def makeClientConnection(self, addr): def makeClientConnection(self, addr):
self.addr = addr self.addr = addr
def makeListeningConnection(self, addr):
self.addr = addr
def getDescriptor(self): def getDescriptor(self):
return self.desc return self.desc
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment