Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefane Fermigier
neo
Commits
727899e2
Commit
727899e2
authored
Sep 24, 2015
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass app as first parameter of (*Client|Listening)Connection
Application will hold SSL parameters.
parent
7d5b1559
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
24 additions
and
25 deletions
+24
-25
neo/admin/app.py
neo/admin/app.py
+1
-1
neo/client/app.py
neo/client/app.py
+1
-1
neo/client/pool.py
neo/client/pool.py
+1
-1
neo/lib/bootstrap.py
neo/lib/bootstrap.py
+5
-4
neo/lib/connection.py
neo/lib/connection.py
+5
-5
neo/master/app.py
neo/master/app.py
+3
-3
neo/neoctl/neoctl.py
neo/neoctl/neoctl.py
+1
-2
neo/storage/app.py
neo/storage/app.py
+1
-1
neo/storage/checker.py
neo/storage/checker.py
+1
-2
neo/storage/replicator.py
neo/storage/replicator.py
+1
-1
neo/tests/testConnection.py
neo/tests/testConnection.py
+4
-4
No files found.
neo/admin/app.py
View file @
727899e2
...
...
@@ -80,7 +80,7 @@ class Application(BaseApplication):
# Make a listening port.
handler
=
AdminEventHandler
(
self
)
self
.
listening_conn
=
ListeningConnection
(
self
.
em
,
handler
,
self
.
server
)
self
.
listening_conn
=
ListeningConnection
(
self
,
handler
,
self
.
server
)
while
self
.
cluster_state
!=
ClusterStates
.
STOPPING
:
self
.
connectToPrimary
()
...
...
neo/client/app.py
View file @
727899e2
...
...
@@ -226,7 +226,7 @@ class Application(ThreadedApplication):
index
=
(
index
+
1
)
%
len
(
master_list
)
self
.
trying_master_node
=
master_list
[
index
]
# Connect to master
conn
=
MTClientConnection
(
self
.
em
,
conn
=
MTClientConnection
(
self
,
self
.
notifications_handler
,
node
=
self
.
trying_master_node
,
dispatcher
=
self
.
dispatcher
)
...
...
neo/client/pool.py
View file @
727899e2
...
...
@@ -53,7 +53,7 @@ class ConnectionPool(object):
"""Init a connection to a given storage node."""
app
=
self
.
app
logging
.
debug
(
'trying to connect to %s - %s'
,
node
,
node
.
getState
())
conn
=
MTClientConnection
(
app
.
em
,
app
.
storage_event_handler
,
node
,
conn
=
MTClientConnection
(
app
,
app
.
storage_event_handler
,
node
,
dispatcher
=
app
.
dispatcher
)
p
=
Packets
.
RequestIdentification
(
NodeTypes
.
CLIENT
,
app
.
uuid
,
None
,
app
.
name
)
...
...
neo/lib/bootstrap.py
View file @
727899e2
...
...
@@ -119,7 +119,8 @@ class BootstrapManager(EventHandler):
Returns when the connection is made.
"""
logging
.
info
(
'connecting to a primary master node'
)
em
,
nm
=
self
.
app
.
em
,
self
.
app
.
nm
app
=
self
.
app
poll
=
app
.
em
.
poll
index
=
0
self
.
current
=
None
conn
=
None
...
...
@@ -129,12 +130,12 @@ class BootstrapManager(EventHandler):
# conn closed
conn
=
None
# select a master
master_list
=
nm
.
getMasterList
()
master_list
=
app
.
nm
.
getMasterList
()
index
=
(
index
+
1
)
%
len
(
master_list
)
self
.
current
=
master_list
[
index
]
if
conn
is
None
:
# open the connection
conn
=
ClientConnection
(
em
,
self
,
self
.
current
)
conn
=
ClientConnection
(
app
,
self
,
self
.
current
)
# Yes, the connection may be already closed. This happens when
# the kernel reacts so quickly to a closed port that 'connect'
# fails on the first call. In such case, poll(1) would deadlock
...
...
@@ -142,7 +143,7 @@ class BootstrapManager(EventHandler):
if
conn
.
isClosed
():
continue
# still processing
em
.
poll
(
1
)
poll
(
1
)
return
(
self
.
current
,
conn
,
self
.
uuid
,
self
.
num_partitions
,
self
.
num_replicas
)
...
...
neo/lib/connection.py
View file @
727899e2
...
...
@@ -308,12 +308,12 @@ attributeTracker.track(BaseConnection)
class
ListeningConnection
(
BaseConnection
):
"""A listen connection."""
def
__init__
(
self
,
event_manager
,
handler
,
addr
):
def
__init__
(
self
,
app
,
handler
,
addr
):
logging
.
debug
(
'listening to %s:%d'
,
*
addr
)
connector
=
self
.
ConnectorClass
(
addr
)
BaseConnection
.
__init__
(
self
,
event_manager
,
handler
,
connector
,
addr
)
BaseConnection
.
__init__
(
self
,
app
.
em
,
handler
,
connector
,
addr
)
connector
.
makeListeningConnection
()
event_manager
.
register
(
self
)
self
.
em
.
register
(
self
)
def
readable
(
self
):
try
:
...
...
@@ -646,10 +646,10 @@ class ClientConnection(Connection):
connecting
=
True
client
=
True
def
__init__
(
self
,
event_manager
,
handler
,
node
):
def
__init__
(
self
,
app
,
handler
,
node
):
addr
=
node
.
getAddress
()
connector
=
self
.
ConnectorClass
(
addr
)
Connection
.
__init__
(
self
,
event_manager
,
handler
,
connector
,
addr
)
Connection
.
__init__
(
self
,
app
.
em
,
handler
,
connector
,
addr
)
node
.
setConnection
(
self
)
handler
.
connectionStarted
(
self
)
self
.
_connect
()
...
...
neo/master/app.py
View file @
727899e2
...
...
@@ -133,7 +133,7 @@ class Application(BaseApplication):
def
_run
(
self
):
"""Make sure that the status is sane and start a loop."""
# Make a listening port.
self
.
listening_conn
=
ListeningConnection
(
self
.
em
,
None
,
self
.
server
)
self
.
listening_conn
=
ListeningConnection
(
self
,
None
,
self
.
server
)
# Start a normal operation.
while
self
.
cluster_state
!=
ClusterStates
.
STOPPING
:
...
...
@@ -184,7 +184,7 @@ class Application(BaseApplication):
self
.
negotiating_master_node_set
):
for
addr
in
self
.
unconnected_master_node_set
:
self
.
negotiating_master_node_set
.
add
(
addr
)
ClientConnection
(
self
.
em
,
client_handler
,
ClientConnection
(
self
,
client_handler
,
# XXX: Ugly, but the whole election code will be
# replaced soon
getByAddress
(
addr
))
...
...
@@ -371,7 +371,7 @@ class Application(BaseApplication):
# Reconnect to primary master node.
primary_handler
=
secondary
.
PrimaryHandler
(
self
)
ClientConnection
(
self
.
em
,
primary_handler
,
self
.
primary_master_node
)
ClientConnection
(
self
,
primary_handler
,
self
.
primary_master_node
)
# and another for the future incoming connections
self
.
listening_conn
.
setHandler
(
...
...
neo/neoctl/neoctl.py
View file @
727899e2
...
...
@@ -35,8 +35,7 @@ class NeoCTL(BaseApplication):
def
__getConnection
(
self
):
if
not
self
.
connected
:
self
.
connection
=
ClientConnection
(
self
.
em
,
self
.
handler
,
self
.
server
)
self
.
connection
=
ClientConnection
(
self
,
self
.
handler
,
self
.
server
)
# Never delay reconnection to master. This speeds up unit tests
# and it should not change anything for normal use.
self
.
connection
.
setReconnectionNoDelay
()
...
...
neo/storage/app.py
View file @
727899e2
...
...
@@ -167,7 +167,7 @@ class Application(BaseApplication):
# Make a listening port
handler
=
identification
.
IdentificationHandler
(
self
)
self
.
listening_conn
=
ListeningConnection
(
self
.
em
,
handler
,
self
.
server
)
self
.
listening_conn
=
ListeningConnection
(
self
,
handler
,
self
.
server
)
self
.
server
=
self
.
listening_conn
.
getAddress
()
# Connect to a primary master node, verify data, and
...
...
neo/storage/checker.py
View file @
727899e2
...
...
@@ -45,8 +45,7 @@ class Checker(object):
conn
=
node
.
getConnection
()
conn
.
asClient
()
else
:
conn
=
ClientConnection
(
app
.
em
,
StorageOperationHandler
(
app
),
node
)
conn
=
ClientConnection
(
app
,
StorageOperationHandler
(
app
),
node
)
conn
.
ask
(
Packets
.
RequestIdentification
(
NodeTypes
.
STORAGE
,
uuid
,
app
.
server
,
name
))
self
.
conn_dict
[
conn
]
=
node
.
isIdentified
()
...
...
neo/storage/replicator.py
View file @
727899e2
...
...
@@ -254,7 +254,7 @@ class Replicator(object):
self
.
fetchTransactions
()
else
:
assert
name
or
node
.
getUUID
()
!=
app
.
uuid
,
"loopback connection"
conn
=
ClientConnection
(
app
.
em
,
StorageOperationHandler
(
app
),
node
)
conn
=
ClientConnection
(
app
,
StorageOperationHandler
(
app
),
node
)
conn
.
ask
(
Packets
.
RequestIdentification
(
NodeTypes
.
STORAGE
,
None
if
name
else
app
.
uuid
,
app
.
server
,
name
or
app
.
name
))
if
previous_node
is
not
None
and
previous_node
.
isConnected
():
...
...
neo/tests/testConnection.py
View file @
727899e2
...
...
@@ -60,7 +60,7 @@ class ConnectionTests(NeoUnitTestBase):
def
setUp
(
self
):
NeoUnitTestBase
.
setUp
(
self
)
self
.
app
=
Mock
({
'__repr__'
:
'Fake App'
})
self
.
em
=
Mock
({
'__repr__'
:
'Fake Em'
})
self
.
em
=
self
.
app
.
em
=
Mock
({
'__repr__'
:
'Fake Em'
})
self
.
handler
=
Mock
({
'__repr__'
:
'Fake Handler'
})
self
.
address
=
(
"127.0.0.7"
,
93413
)
self
.
node
=
Mock
({
'getAddress'
:
self
.
address
})
...
...
@@ -68,7 +68,7 @@ class ConnectionTests(NeoUnitTestBase):
def
_makeListeningConnection
(
self
,
addr
):
with
dummy_connector
:
conn
=
ListeningConnection
(
self
.
em
,
self
.
handler
,
addr
)
conn
=
ListeningConnection
(
self
.
app
,
self
.
handler
,
addr
)
self
.
connector
=
conn
.
connector
return
conn
...
...
@@ -79,7 +79,7 @@ class ConnectionTests(NeoUnitTestBase):
def
_makeClientConnection
(
self
):
with
dummy_connector
:
conn
=
ClientConnection
(
self
.
em
,
self
.
handler
,
self
.
node
)
conn
=
ClientConnection
(
self
.
app
,
self
.
handler
,
self
.
node
)
self
.
connector
=
conn
.
connector
return
conn
...
...
@@ -750,7 +750,7 @@ class MTConnectionTests(ConnectionTests):
def
_makeClientConnection
(
self
):
with
dummy_connector
:
conn
=
MTClientConnection
(
self
.
em
,
self
.
handler
,
self
.
node
,
conn
=
MTClientConnection
(
self
.
app
,
self
.
handler
,
self
.
node
,
dispatcher
=
self
.
dispatcher
)
self
.
connector
=
conn
.
connector
return
conn
...
...
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