coordination: remove double serialization of capabilities
The capabilities was meant to be a byte string only, but since now all drivers have been enhanced to serialize the data in a way or another, it accepts anything. There's no need to pass a byte string anymore. Change-Id: Ib732dccd18d67edd9e39e990b8ca3a8da7ab5663
This commit is contained in:
@@ -277,8 +277,7 @@ class CoordinationDriver(object):
|
|||||||
:return: A :py:class:`~tooz.partitioner.Partitioner` object.
|
:return: A :py:class:`~tooz.partitioner.Partitioner` object.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.join_group_create(
|
self.join_group_create(group_id, capabilities={'weight': weight})
|
||||||
group_id, capabilities=utils.dumps({'weight': weight}))
|
|
||||||
return partitioner.Partitioner(self, group_id, partitions=partitions)
|
return partitioner.Partitioner(self, group_id, partitions=partitions)
|
||||||
|
|
||||||
def leave_partitioned_group(self, partitioner):
|
def leave_partitioned_group(self, partitioner):
|
||||||
|
|||||||
@@ -13,13 +13,7 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import logging
|
|
||||||
|
|
||||||
from tooz import hashring
|
from tooz import hashring
|
||||||
from tooz import utils
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class Partitioner(object):
|
class Partitioner(object):
|
||||||
@@ -45,20 +39,12 @@ class Partitioner(object):
|
|||||||
self._coord.watch_leave_group(self.group_id, self._on_member_leave)
|
self._coord.watch_leave_group(self.group_id, self._on_member_leave)
|
||||||
self.ring = hashring.HashRing([], partitions=self.partitions)
|
self.ring = hashring.HashRing([], partitions=self.partitions)
|
||||||
for m_id, cap in caps:
|
for m_id, cap in caps:
|
||||||
self.ring.add_node(m_id, utils.loads(cap.get()).get("weight", 1))
|
self.ring.add_node(m_id, cap.get().get("weight", 1))
|
||||||
|
|
||||||
def _on_member_join(self, event):
|
def _on_member_join(self, event):
|
||||||
try:
|
weight = self._coord.get_member_capabilities(
|
||||||
weight = utils.loads(self._coord.get_member_capabilities(
|
self.group_id, event.member_id).get().get("weight", 1)
|
||||||
self.group_id, event.member_id).get()).get("weight", 1)
|
self.ring.add_node(event.member_id, weight)
|
||||||
except utils.SerializationError:
|
|
||||||
# This node does not seem to have joined with the partitioner
|
|
||||||
# system, so just ignore it.
|
|
||||||
LOG.warning(
|
|
||||||
"Node %s did not join group %s in partition mode, ignoring",
|
|
||||||
self.group_id, event.member_id)
|
|
||||||
else:
|
|
||||||
self.ring.add_node(event.member_id, weight)
|
|
||||||
|
|
||||||
def _on_member_leave(self, event):
|
def _on_member_leave(self, event):
|
||||||
self.ring.remove_node(event.member_id)
|
self.ring.remove_node(event.member_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user