Remove transaction support from sharding API
The size of Zookeeper transactions is limited by the `jute.maxbuffer` setting. It is the same setting that also defines the maximum allowed size of a Znode. This means that it doesn't make sense to use Zookeeper transactions in combination with sharding. Change-Id: I828bca32219b07b064d967f46379568c4d94c151
This commit is contained in:
parent
c237772ac8
commit
b3eb3e6715
|
@ -17,7 +17,6 @@ from contextlib import suppress
|
|||
import zlib
|
||||
|
||||
from kazoo.exceptions import NoNodeError
|
||||
from kazoo.client import TransactionRequest
|
||||
|
||||
# The default size limit for a node in Zookeeper is ~1MiB. However, as this
|
||||
# also includes the size of the key we can not use all of it for data.
|
||||
|
@ -29,7 +28,6 @@ class RawShardIO(io.RawIOBase):
|
|||
def __init__(self, client, path):
|
||||
self.client = client
|
||||
self.shard_base = path
|
||||
self.is_transaction = isinstance(client, TransactionRequest)
|
||||
|
||||
def readable(self):
|
||||
return True
|
||||
|
@ -40,8 +38,6 @@ class RawShardIO(io.RawIOBase):
|
|||
def truncate(self, size=None):
|
||||
if size != 0:
|
||||
raise ValueError("Can only truncate to 0")
|
||||
if self.is_transaction:
|
||||
raise Exception("Truncate within transactions unimplemented")
|
||||
with suppress(NoNodeError):
|
||||
self.client.delete(self.shard_base, recursive=True)
|
||||
|
||||
|
@ -69,13 +65,11 @@ class RawShardIO(io.RawIOBase):
|
|||
shard_bytes = bytes(shard_data[0:NODE_BYTE_SIZE_LIMIT])
|
||||
shard_bytes = zlib.compress(shard_bytes)
|
||||
assert(len(shard_bytes) < NODE_BYTE_SIZE_LIMIT)
|
||||
kw = dict(sequence=True)
|
||||
if not self.is_transaction:
|
||||
kw['makepath'] = True
|
||||
self.client.create(
|
||||
"{}/".format(self.shard_base),
|
||||
shard_bytes,
|
||||
**kw
|
||||
sequence=True,
|
||||
makepath=True,
|
||||
)
|
||||
return min(byte_count, NODE_BYTE_SIZE_LIMIT)
|
||||
|
||||
|
|
Loading…
Reference in New Issue