Commit 9202e523 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Add one more parameter to Ask TIDs, to specify a wanted partition explicitly.

git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@188 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 330e087f
......@@ -9,7 +9,7 @@ from random import shuffle
from neo.client.mq import MQ
from neo.node import NodeManager, MasterNode, StorageNode
from neo.connection import MTClientConnection
from neo.protocol import Packet, INVALID_UUID, INVALID_TID, \
from neo.protocol import Packet, INVALID_UUID, INVALID_TID, INVALID_PARTITION, \
STORAGE_NODE_TYPE, CLIENT_NODE_TYPE, \
TEMPORARILY_DOWN_STATE, \
UP_TO_DATE_STATE, FEEDING_STATE, INVALID_SERIAL
......@@ -698,7 +698,7 @@ class Application(object):
try:
msg_id = conn.getNextId()
p = Packet()
p.askTIDs(msg_id, first, last)
p.askTIDs(msg_id, first, last, INVALID_PARTITION)
conn.addPacket(p)
finally:
conn.unlock()
......
......@@ -234,7 +234,7 @@ class EventHandler(object):
serial_end, compression, checksum, data):
self.handleUnexpectedPacket(conn, packet)
def handleAskTIDs(self, conn, packet, first, last):
def handleAskTIDs(self, conn, packet, first, last, partition):
self.handleUnexpectedPacket(conn, packet)
def handleAnswerTIDs(self, conn, packet, tid_list):
......
......@@ -211,6 +211,7 @@ INVALID_TID = '\0\0\0\0\0\0\0\0'
INVALID_SERIAL = '\0\0\0\0\0\0\0\0'
INVALID_OID = '\0\0\0\0\0\0\0\0'
INVALID_PTID = '\0\0\0\0\0\0\0\0'
INVALID_PARTITION = 0xffffffff
class ProtocolError(Exception): pass
......@@ -575,10 +576,10 @@ class Packet(object):
compression, checksum, len(data)) + data
return self
def askTIDs(self, msg_id, first, last):
def askTIDs(self, msg_id, first, last, partition):
self._id = msg_id
self._type = ASK_TIDS
self._body = pack('!QQ', first, last)
self._body = pack('!QQL', first, last, partition)
return self
def answerTIDs(self, msg_id, tid_list):
......@@ -1025,10 +1026,10 @@ class Packet(object):
def _decodeAskTIDs(self):
try:
first, last = unpack('!QQ', self._body)
first, last, partition = unpack('!QQL', self._body)
except:
raise ProtocolError(self, 'invalid ask tids')
return first, last
return first, last, partition
decode_table[ASK_TIDS] = _decodeAskTIDs
def _decodeAnswerTIDs(self):
......
......@@ -192,7 +192,7 @@ class StorageEventHandler(EventHandler):
def handleAskObject(self, conn, packet, oid, serial, tid):
self.handleUnexpectedPacket(conn, packet)
def handleAskTIDs(self, conn, packet, first, last):
def handleAskTIDs(self, conn, packet, first, last, partition):
self.handleUnexpectedPacket(conn, packet)
def handleAskObjectHistory(self, conn, packet, oid, first, last):
......
......@@ -2,6 +2,7 @@ import logging
from neo.storage.handler import StorageEventHandler
from neo.protocol import INVALID_UUID, INVALID_SERIAL, INVALID_TID, \
INVALID_PARTITION, \
RUNNING_STATE, BROKEN_STATE, TEMPORARILY_DOWN_STATE, \
MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE
from neo.util import dump
......@@ -313,7 +314,7 @@ class OperationEventHandler(StorageEventHandler):
p.oidNotFound(packet.getId(), '%s does not exist' % dump(oid))
conn.addPacket(p)
def handleAskTIDs(self, conn, packet, first, last):
def handleAskTIDs(self, conn, packet, first, last, partition):
# This method is complicated, because I must return TIDs only
# about usable partitions assigned to me.
if first >= last:
......@@ -323,14 +324,17 @@ class OperationEventHandler(StorageEventHandler):
app = self.app
# Collect all usable partitions for me.
getCellList = app.pt.getCellList
partition_list = []
for offset in xrange(app.num_partitions):
for cell in getCellList(offset, True):
if cell.getUUID() == app.uuid:
partition_list.append(offset)
break
if partition == INVALID_PARTITION:
# Collect all usable partitions for me.
getCellList = app.pt.getCellList
partition_list = []
for offset in xrange(app.num_partitions):
for cell in getCellList(offset, True):
if cell.getUUID() == app.uuid:
partition_list.append(offset)
break
else:
partition_list = [partition]
tid_list = app.dm.getTIDList(first, last - first,
app.num_partitions, partition_list)
......
......@@ -183,7 +183,7 @@ class Replicator(object):
msg_id = self.current_connection.getNextId()
p = Packet()
p.askTIDs(msg_id, 0, 1000)
p.askTIDs(msg_id, 0, 1000, self.current_partition.getRID())
self.current_connection.addPacket(p)
self.current_connection.expectMessage(timeout = 300)
......
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