id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
235,900
hazelcast/hazelcast-python-client
hazelcast/proxy/ringbuffer.py
Ringbuffer.read_many
def read_many(self, start_sequence, min_count, max_count): """ Reads a batch of items from the Ringbuffer. If the number of available items after the first read item is smaller than the max_count, these items are returned. So it could be the number of items read is smaller than the max_count. If there are less items available than min_count, then this call blocks. Reading a batch of items is likely to perform better because less overhead is involved. :param start_sequence: (long), the start_sequence of the first item to read. :param min_count: (int), the minimum number of items to read. :param max_count: (int), the maximum number of items to read. :return: (Sequence), the list of read items. """ check_not_negative(start_sequence, "sequence can't be smaller than 0") check_true(max_count >= min_count, "max count should be greater or equal to min count") check_true(min_count <= self.capacity().result(), "min count should be smaller or equal to capacity") check_true(max_count < MAX_BATCH_SIZE, "max count can't be greater than %d" % MAX_BATCH_SIZE) return self._encode_invoke(ringbuffer_read_many_codec, response_handler=self._read_many_response_handler, start_sequence=start_sequence, min_count=min_count, max_count=max_count, filter=None)
python
def read_many(self, start_sequence, min_count, max_count): """ Reads a batch of items from the Ringbuffer. If the number of available items after the first read item is smaller than the max_count, these items are returned. So it could be the number of items read is smaller than the max_count. If there are less items available than min_count, then this call blocks. Reading a batch of items is likely to perform better because less overhead is involved. :param start_sequence: (long), the start_sequence of the first item to read. :param min_count: (int), the minimum number of items to read. :param max_count: (int), the maximum number of items to read. :return: (Sequence), the list of read items. """ check_not_negative(start_sequence, "sequence can't be smaller than 0") check_true(max_count >= min_count, "max count should be greater or equal to min count") check_true(min_count <= self.capacity().result(), "min count should be smaller or equal to capacity") check_true(max_count < MAX_BATCH_SIZE, "max count can't be greater than %d" % MAX_BATCH_SIZE) return self._encode_invoke(ringbuffer_read_many_codec, response_handler=self._read_many_response_handler, start_sequence=start_sequence, min_count=min_count, max_count=max_count, filter=None)
[ "def", "read_many", "(", "self", ",", "start_sequence", ",", "min_count", ",", "max_count", ")", ":", "check_not_negative", "(", "start_sequence", ",", "\"sequence can't be smaller than 0\"", ")", "check_true", "(", "max_count", ">=", "min_count", ",", "\"max count should be greater or equal to min count\"", ")", "check_true", "(", "min_count", "<=", "self", ".", "capacity", "(", ")", ".", "result", "(", ")", ",", "\"min count should be smaller or equal to capacity\"", ")", "check_true", "(", "max_count", "<", "MAX_BATCH_SIZE", ",", "\"max count can't be greater than %d\"", "%", "MAX_BATCH_SIZE", ")", "return", "self", ".", "_encode_invoke", "(", "ringbuffer_read_many_codec", ",", "response_handler", "=", "self", ".", "_read_many_response_handler", ",", "start_sequence", "=", "start_sequence", ",", "min_count", "=", "min_count", ",", "max_count", "=", "max_count", ",", "filter", "=", "None", ")" ]
Reads a batch of items from the Ringbuffer. If the number of available items after the first read item is smaller than the max_count, these items are returned. So it could be the number of items read is smaller than the max_count. If there are less items available than min_count, then this call blocks. Reading a batch of items is likely to perform better because less overhead is involved. :param start_sequence: (long), the start_sequence of the first item to read. :param min_count: (int), the minimum number of items to read. :param max_count: (int), the maximum number of items to read. :return: (Sequence), the list of read items.
[ "Reads", "a", "batch", "of", "items", "from", "the", "Ringbuffer", ".", "If", "the", "number", "of", "available", "items", "after", "the", "first", "read", "item", "is", "smaller", "than", "the", "max_count", "these", "items", "are", "returned", ".", "So", "it", "could", "be", "the", "number", "of", "items", "read", "is", "smaller", "than", "the", "max_count", ".", "If", "there", "are", "less", "items", "available", "than", "min_count", "then", "this", "call", "blocks", ".", "Reading", "a", "batch", "of", "items", "is", "likely", "to", "perform", "better", "because", "less", "overhead", "is", "involved", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/ringbuffer.py#L146-L165
235,901
hazelcast/hazelcast-python-client
hazelcast/proxy/id_generator.py
IdGenerator.init
def init(self, initial): """ Try to initialize this IdGenerator instance with the given id. The first generated id will be 1 greater than id. :param initial: (long), the given id. :return: (bool), ``true`` if initialization succeeded, ``false`` if id is less than 0. """ if initial <= 0: return False step = initial // BLOCK_SIZE with self._lock: init = self._atomic_long.compare_and_set(0, step + 1).result() if init: self._local = step self._residue = (initial % BLOCK_SIZE) + 1 return init
python
def init(self, initial): """ Try to initialize this IdGenerator instance with the given id. The first generated id will be 1 greater than id. :param initial: (long), the given id. :return: (bool), ``true`` if initialization succeeded, ``false`` if id is less than 0. """ if initial <= 0: return False step = initial // BLOCK_SIZE with self._lock: init = self._atomic_long.compare_and_set(0, step + 1).result() if init: self._local = step self._residue = (initial % BLOCK_SIZE) + 1 return init
[ "def", "init", "(", "self", ",", "initial", ")", ":", "if", "initial", "<=", "0", ":", "return", "False", "step", "=", "initial", "//", "BLOCK_SIZE", "with", "self", ".", "_lock", ":", "init", "=", "self", ".", "_atomic_long", ".", "compare_and_set", "(", "0", ",", "step", "+", "1", ")", ".", "result", "(", ")", "if", "init", ":", "self", ".", "_local", "=", "step", "self", ".", "_residue", "=", "(", "initial", "%", "BLOCK_SIZE", ")", "+", "1", "return", "init" ]
Try to initialize this IdGenerator instance with the given id. The first generated id will be 1 greater than id. :param initial: (long), the given id. :return: (bool), ``true`` if initialization succeeded, ``false`` if id is less than 0.
[ "Try", "to", "initialize", "this", "IdGenerator", "instance", "with", "the", "given", "id", ".", "The", "first", "generated", "id", "will", "be", "1", "greater", "than", "id", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/id_generator.py#L31-L46
235,902
hazelcast/hazelcast-python-client
hazelcast/proxy/id_generator.py
IdGenerator.new_id
def new_id(self): """ Generates and returns a cluster-wide unique id. Generated ids are guaranteed to be unique for the entire cluster as long as the cluster is live. If the cluster restarts, then id generation will start from 0. :return: (long), cluster-wide new unique id. """ with self._lock: curr = self._residue self._residue += 1 if self._residue >= BLOCK_SIZE: increment = self._atomic_long.get_and_increment().result() self._local = increment self._residue = 0 return self.new_id() return self._local * BLOCK_SIZE + curr
python
def new_id(self): """ Generates and returns a cluster-wide unique id. Generated ids are guaranteed to be unique for the entire cluster as long as the cluster is live. If the cluster restarts, then id generation will start from 0. :return: (long), cluster-wide new unique id. """ with self._lock: curr = self._residue self._residue += 1 if self._residue >= BLOCK_SIZE: increment = self._atomic_long.get_and_increment().result() self._local = increment self._residue = 0 return self.new_id() return self._local * BLOCK_SIZE + curr
[ "def", "new_id", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "curr", "=", "self", ".", "_residue", "self", ".", "_residue", "+=", "1", "if", "self", ".", "_residue", ">=", "BLOCK_SIZE", ":", "increment", "=", "self", ".", "_atomic_long", ".", "get_and_increment", "(", ")", ".", "result", "(", ")", "self", ".", "_local", "=", "increment", "self", ".", "_residue", "=", "0", "return", "self", ".", "new_id", "(", ")", "return", "self", ".", "_local", "*", "BLOCK_SIZE", "+", "curr" ]
Generates and returns a cluster-wide unique id. Generated ids are guaranteed to be unique for the entire cluster as long as the cluster is live. If the cluster restarts, then id generation will start from 0. :return: (long), cluster-wide new unique id.
[ "Generates", "and", "returns", "a", "cluster", "-", "wide", "unique", "id", ".", "Generated", "ids", "are", "guaranteed", "to", "be", "unique", "for", "the", "entire", "cluster", "as", "long", "as", "the", "cluster", "is", "live", ".", "If", "the", "cluster", "restarts", "then", "id", "generation", "will", "start", "from", "0", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/id_generator.py#L48-L63
235,903
hazelcast/hazelcast-python-client
hazelcast/proxy/executor.py
Executor.execute_on_key_owner
def execute_on_key_owner(self, key, task): """ Executes a task on the owner of the specified key. :param key: (object), the specified key. :param task: (Task), a task executed on the owner of the specified key. :return: (:class:`~hazelcast.future.Future`), future representing pending completion of the task. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) partition_id = self._client.partition_service.get_partition_id(key_data) uuid = self._get_uuid() return self._encode_invoke_on_partition(executor_service_submit_to_partition_codec, partition_id, uuid=uuid, callable=self._to_data(task), partition_id=partition_id)
python
def execute_on_key_owner(self, key, task): """ Executes a task on the owner of the specified key. :param key: (object), the specified key. :param task: (Task), a task executed on the owner of the specified key. :return: (:class:`~hazelcast.future.Future`), future representing pending completion of the task. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) partition_id = self._client.partition_service.get_partition_id(key_data) uuid = self._get_uuid() return self._encode_invoke_on_partition(executor_service_submit_to_partition_codec, partition_id, uuid=uuid, callable=self._to_data(task), partition_id=partition_id)
[ "def", "execute_on_key_owner", "(", "self", ",", "key", ",", "task", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "partition_id", "=", "self", ".", "_client", ".", "partition_service", ".", "get_partition_id", "(", "key_data", ")", "uuid", "=", "self", ".", "_get_uuid", "(", ")", "return", "self", ".", "_encode_invoke_on_partition", "(", "executor_service_submit_to_partition_codec", ",", "partition_id", ",", "uuid", "=", "uuid", ",", "callable", "=", "self", ".", "_to_data", "(", "task", ")", ",", "partition_id", "=", "partition_id", ")" ]
Executes a task on the owner of the specified key. :param key: (object), the specified key. :param task: (Task), a task executed on the owner of the specified key. :return: (:class:`~hazelcast.future.Future`), future representing pending completion of the task.
[ "Executes", "a", "task", "on", "the", "owner", "of", "the", "specified", "key", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/executor.py#L15-L30
235,904
hazelcast/hazelcast-python-client
hazelcast/proxy/executor.py
Executor.execute_on_member
def execute_on_member(self, member, task): """ Executes a task on the specified member. :param member: (Member), the specified member. :param task: (Task), the task executed on the specified member. :return: (:class:`~hazelcast.future.Future`), Future representing pending completion of the task. """ uuid = self._get_uuid() address = member.address return self._execute_on_member(address, uuid, self._to_data(task))
python
def execute_on_member(self, member, task): """ Executes a task on the specified member. :param member: (Member), the specified member. :param task: (Task), the task executed on the specified member. :return: (:class:`~hazelcast.future.Future`), Future representing pending completion of the task. """ uuid = self._get_uuid() address = member.address return self._execute_on_member(address, uuid, self._to_data(task))
[ "def", "execute_on_member", "(", "self", ",", "member", ",", "task", ")", ":", "uuid", "=", "self", ".", "_get_uuid", "(", ")", "address", "=", "member", ".", "address", "return", "self", ".", "_execute_on_member", "(", "address", ",", "uuid", ",", "self", ".", "_to_data", "(", "task", ")", ")" ]
Executes a task on the specified member. :param member: (Member), the specified member. :param task: (Task), the task executed on the specified member. :return: (:class:`~hazelcast.future.Future`), Future representing pending completion of the task.
[ "Executes", "a", "task", "on", "the", "specified", "member", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/executor.py#L32-L42
235,905
hazelcast/hazelcast-python-client
hazelcast/proxy/executor.py
Executor.execute_on_members
def execute_on_members(self, members, task): """ Executes a task on each of the specified members. :param members: (Collection), the specified members. :param task: (Task), the task executed on the specified members. :return: (Map), :class:`~hazelcast.future.Future` tuples representing pending completion of the task on each member. """ task_data = self._to_data(task) futures = [] uuid = self._get_uuid() for member in members: f = self._execute_on_member(member.address, uuid, task_data) futures.append(f) return future.combine_futures(*futures)
python
def execute_on_members(self, members, task): """ Executes a task on each of the specified members. :param members: (Collection), the specified members. :param task: (Task), the task executed on the specified members. :return: (Map), :class:`~hazelcast.future.Future` tuples representing pending completion of the task on each member. """ task_data = self._to_data(task) futures = [] uuid = self._get_uuid() for member in members: f = self._execute_on_member(member.address, uuid, task_data) futures.append(f) return future.combine_futures(*futures)
[ "def", "execute_on_members", "(", "self", ",", "members", ",", "task", ")", ":", "task_data", "=", "self", ".", "_to_data", "(", "task", ")", "futures", "=", "[", "]", "uuid", "=", "self", ".", "_get_uuid", "(", ")", "for", "member", "in", "members", ":", "f", "=", "self", ".", "_execute_on_member", "(", "member", ".", "address", ",", "uuid", ",", "task_data", ")", "futures", ".", "append", "(", "f", ")", "return", "future", ".", "combine_futures", "(", "*", "futures", ")" ]
Executes a task on each of the specified members. :param members: (Collection), the specified members. :param task: (Task), the task executed on the specified members. :return: (Map), :class:`~hazelcast.future.Future` tuples representing pending completion of the task on each member.
[ "Executes", "a", "task", "on", "each", "of", "the", "specified", "members", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/executor.py#L44-L58
235,906
hazelcast/hazelcast-python-client
hazelcast/proxy/executor.py
Executor.execute_on_all_members
def execute_on_all_members(self, task): """ Executes a task on all of the known cluster members. :param task: (Task), the task executed on the all of the members. :return: (Map), :class:`~hazelcast.future.Future` tuples representing pending completion of the task on each member. """ return self.execute_on_members(self._client.cluster.get_member_list(), task)
python
def execute_on_all_members(self, task): """ Executes a task on all of the known cluster members. :param task: (Task), the task executed on the all of the members. :return: (Map), :class:`~hazelcast.future.Future` tuples representing pending completion of the task on each member. """ return self.execute_on_members(self._client.cluster.get_member_list(), task)
[ "def", "execute_on_all_members", "(", "self", ",", "task", ")", ":", "return", "self", ".", "execute_on_members", "(", "self", ".", "_client", ".", "cluster", ".", "get_member_list", "(", ")", ",", "task", ")" ]
Executes a task on all of the known cluster members. :param task: (Task), the task executed on the all of the members. :return: (Map), :class:`~hazelcast.future.Future` tuples representing pending completion of the task on each member.
[ "Executes", "a", "task", "on", "all", "of", "the", "known", "cluster", "members", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/executor.py#L60-L67
235,907
hazelcast/hazelcast-python-client
hazelcast/lifecycle.py
LifecycleService.add_listener
def add_listener(self, on_lifecycle_change): """ Add a listener object to listen for lifecycle events. :param on_lifecycle_change: (Function), function to be called when LifeCycle state is changed. :return: (str), id of the listener. """ id = str(uuid.uuid4()) self._listeners[id] = on_lifecycle_change return id
python
def add_listener(self, on_lifecycle_change): """ Add a listener object to listen for lifecycle events. :param on_lifecycle_change: (Function), function to be called when LifeCycle state is changed. :return: (str), id of the listener. """ id = str(uuid.uuid4()) self._listeners[id] = on_lifecycle_change return id
[ "def", "add_listener", "(", "self", ",", "on_lifecycle_change", ")", ":", "id", "=", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", "self", ".", "_listeners", "[", "id", "]", "=", "on_lifecycle_change", "return", "id" ]
Add a listener object to listen for lifecycle events. :param on_lifecycle_change: (Function), function to be called when LifeCycle state is changed. :return: (str), id of the listener.
[ "Add", "a", "listener", "object", "to", "listen", "for", "lifecycle", "events", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/lifecycle.py#L31-L40
235,908
hazelcast/hazelcast-python-client
hazelcast/lifecycle.py
LifecycleService.remove_listener
def remove_listener(self, registration_id): """ Removes a lifecycle listener. :param registration_id: (str), the id of the listener to be removed. :return: (bool), ``true`` if the listener is removed successfully, ``false`` otherwise. """ try: self._listeners.pop(registration_id) return True except KeyError: return False
python
def remove_listener(self, registration_id): """ Removes a lifecycle listener. :param registration_id: (str), the id of the listener to be removed. :return: (bool), ``true`` if the listener is removed successfully, ``false`` otherwise. """ try: self._listeners.pop(registration_id) return True except KeyError: return False
[ "def", "remove_listener", "(", "self", ",", "registration_id", ")", ":", "try", ":", "self", ".", "_listeners", ".", "pop", "(", "registration_id", ")", "return", "True", "except", "KeyError", ":", "return", "False" ]
Removes a lifecycle listener. :param registration_id: (str), the id of the listener to be removed. :return: (bool), ``true`` if the listener is removed successfully, ``false`` otherwise.
[ "Removes", "a", "lifecycle", "listener", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/lifecycle.py#L42-L53
235,909
hazelcast/hazelcast-python-client
hazelcast/lifecycle.py
LifecycleService.fire_lifecycle_event
def fire_lifecycle_event(self, new_state): """ Called when instance's state changes. :param new_state: (Lifecycle State), the new state of the instance. """ if new_state == LIFECYCLE_STATE_SHUTTING_DOWN: self.is_live = False self.state = new_state self.logger.info(self._git_info + "HazelcastClient is %s", new_state, extra=self._logger_extras) for listener in list(self._listeners.values()): try: listener(new_state) except: self.logger.exception("Exception in lifecycle listener", extra=self._logger_extras)
python
def fire_lifecycle_event(self, new_state): """ Called when instance's state changes. :param new_state: (Lifecycle State), the new state of the instance. """ if new_state == LIFECYCLE_STATE_SHUTTING_DOWN: self.is_live = False self.state = new_state self.logger.info(self._git_info + "HazelcastClient is %s", new_state, extra=self._logger_extras) for listener in list(self._listeners.values()): try: listener(new_state) except: self.logger.exception("Exception in lifecycle listener", extra=self._logger_extras)
[ "def", "fire_lifecycle_event", "(", "self", ",", "new_state", ")", ":", "if", "new_state", "==", "LIFECYCLE_STATE_SHUTTING_DOWN", ":", "self", ".", "is_live", "=", "False", "self", ".", "state", "=", "new_state", "self", ".", "logger", ".", "info", "(", "self", ".", "_git_info", "+", "\"HazelcastClient is %s\"", ",", "new_state", ",", "extra", "=", "self", ".", "_logger_extras", ")", "for", "listener", "in", "list", "(", "self", ".", "_listeners", ".", "values", "(", ")", ")", ":", "try", ":", "listener", "(", "new_state", ")", "except", ":", "self", ".", "logger", ".", "exception", "(", "\"Exception in lifecycle listener\"", ",", "extra", "=", "self", ".", "_logger_extras", ")" ]
Called when instance's state changes. :param new_state: (Lifecycle State), the new state of the instance.
[ "Called", "when", "instance", "s", "state", "changes", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/lifecycle.py#L55-L70
235,910
hazelcast/hazelcast-python-client
hazelcast/proxy/lock.py
Lock.lock
def lock(self, lease_time=-1): """ Acquires the lock. If a lease time is specified, lock will be released after this lease time. If the lock is not available, the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired. :param lease_time: (long), time to wait before releasing the lock (optional). """ return self._encode_invoke(lock_lock_codec, invocation_timeout=MAX_SIZE, lease_time=to_millis(lease_time), thread_id=thread_id(), reference_id=self.reference_id_generator.get_and_increment())
python
def lock(self, lease_time=-1): """ Acquires the lock. If a lease time is specified, lock will be released after this lease time. If the lock is not available, the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired. :param lease_time: (long), time to wait before releasing the lock (optional). """ return self._encode_invoke(lock_lock_codec, invocation_timeout=MAX_SIZE, lease_time=to_millis(lease_time), thread_id=thread_id(), reference_id=self.reference_id_generator.get_and_increment())
[ "def", "lock", "(", "self", ",", "lease_time", "=", "-", "1", ")", ":", "return", "self", ".", "_encode_invoke", "(", "lock_lock_codec", ",", "invocation_timeout", "=", "MAX_SIZE", ",", "lease_time", "=", "to_millis", "(", "lease_time", ")", ",", "thread_id", "=", "thread_id", "(", ")", ",", "reference_id", "=", "self", ".", "reference_id_generator", ".", "get_and_increment", "(", ")", ")" ]
Acquires the lock. If a lease time is specified, lock will be released after this lease time. If the lock is not available, the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired. :param lease_time: (long), time to wait before releasing the lock (optional).
[ "Acquires", "the", "lock", ".", "If", "a", "lease", "time", "is", "specified", "lock", "will", "be", "released", "after", "this", "lease", "time", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/lock.py#L58-L68
235,911
hazelcast/hazelcast-python-client
hazelcast/proxy/lock.py
Lock.try_lock
def try_lock(self, timeout=0, lease_time=-1): """ Tries to acquire the lock. When the lock is not available, * If timeout is not provided, the current thread doesn't wait and returns ``false`` immediately. * If a timeout is provided, the current thread becomes disabled for thread scheduling purposes and lies dormant until one of the followings happens: * the lock is acquired by the current thread, or * the specified waiting time elapses. If lease time is provided, lock will be released after this time elapses. :param timeout: (long), maximum time in seconds to wait for the lock (optional). :param lease_time: (long), time in seconds to wait before releasing the lock (optional). :return: (bool), ``true`` if the lock was acquired and otherwise, ``false``. """ return self._encode_invoke(lock_try_lock_codec, invocation_timeout=MAX_SIZE, lease=to_millis(lease_time), thread_id=thread_id(), timeout=to_millis(timeout), reference_id=self.reference_id_generator.get_and_increment())
python
def try_lock(self, timeout=0, lease_time=-1): """ Tries to acquire the lock. When the lock is not available, * If timeout is not provided, the current thread doesn't wait and returns ``false`` immediately. * If a timeout is provided, the current thread becomes disabled for thread scheduling purposes and lies dormant until one of the followings happens: * the lock is acquired by the current thread, or * the specified waiting time elapses. If lease time is provided, lock will be released after this time elapses. :param timeout: (long), maximum time in seconds to wait for the lock (optional). :param lease_time: (long), time in seconds to wait before releasing the lock (optional). :return: (bool), ``true`` if the lock was acquired and otherwise, ``false``. """ return self._encode_invoke(lock_try_lock_codec, invocation_timeout=MAX_SIZE, lease=to_millis(lease_time), thread_id=thread_id(), timeout=to_millis(timeout), reference_id=self.reference_id_generator.get_and_increment())
[ "def", "try_lock", "(", "self", ",", "timeout", "=", "0", ",", "lease_time", "=", "-", "1", ")", ":", "return", "self", ".", "_encode_invoke", "(", "lock_try_lock_codec", ",", "invocation_timeout", "=", "MAX_SIZE", ",", "lease", "=", "to_millis", "(", "lease_time", ")", ",", "thread_id", "=", "thread_id", "(", ")", ",", "timeout", "=", "to_millis", "(", "timeout", ")", ",", "reference_id", "=", "self", ".", "reference_id_generator", ".", "get_and_increment", "(", ")", ")" ]
Tries to acquire the lock. When the lock is not available, * If timeout is not provided, the current thread doesn't wait and returns ``false`` immediately. * If a timeout is provided, the current thread becomes disabled for thread scheduling purposes and lies dormant until one of the followings happens: * the lock is acquired by the current thread, or * the specified waiting time elapses. If lease time is provided, lock will be released after this time elapses. :param timeout: (long), maximum time in seconds to wait for the lock (optional). :param lease_time: (long), time in seconds to wait before releasing the lock (optional). :return: (bool), ``true`` if the lock was acquired and otherwise, ``false``.
[ "Tries", "to", "acquire", "the", "lock", ".", "When", "the", "lock", "is", "not", "available" ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/lock.py#L70-L88
235,912
hazelcast/hazelcast-python-client
hazelcast/proxy/multi_map.py
MultiMap.contains_key
def contains_key(self, key): """ Determines whether this multimap contains an entry with the key. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the specified key. :return: (bool), ``true`` if this multimap contains an entry for the specified key. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(multi_map_contains_key_codec, key_data, key=key_data, thread_id=thread_id())
python
def contains_key(self, key): """ Determines whether this multimap contains an entry with the key. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the specified key. :return: (bool), ``true`` if this multimap contains an entry for the specified key. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(multi_map_contains_key_codec, key_data, key=key_data, thread_id=thread_id())
[ "def", "contains_key", "(", "self", ",", "key", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "return", "self", ".", "_encode_invoke_on_key", "(", "multi_map_contains_key_codec", ",", "key_data", ",", "key", "=", "key_data", ",", "thread_id", "=", "thread_id", "(", ")", ")" ]
Determines whether this multimap contains an entry with the key. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the specified key. :return: (bool), ``true`` if this multimap contains an entry for the specified key.
[ "Determines", "whether", "this", "multimap", "contains", "an", "entry", "with", "the", "key", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/multi_map.py#L55-L68
235,913
hazelcast/hazelcast-python-client
hazelcast/proxy/multi_map.py
MultiMap.contains_entry
def contains_entry(self, key, value): """ Returns whether the multimap contains an entry with the value. :param key: (object), the specified key. :param value: (object), the specified value. :return: (bool), ``true`` if this multimap contains the key-value tuple. """ check_not_none(key, "key can't be None") check_not_none(value, "value can't be None") key_data = self._to_data(key) value_data = self._to_data(value) return self._encode_invoke_on_key(multi_map_contains_entry_codec, key_data, key=key_data, value=value_data, thread_id=thread_id())
python
def contains_entry(self, key, value): """ Returns whether the multimap contains an entry with the value. :param key: (object), the specified key. :param value: (object), the specified value. :return: (bool), ``true`` if this multimap contains the key-value tuple. """ check_not_none(key, "key can't be None") check_not_none(value, "value can't be None") key_data = self._to_data(key) value_data = self._to_data(value) return self._encode_invoke_on_key(multi_map_contains_entry_codec, key_data, key=key_data, value=value_data, thread_id=thread_id())
[ "def", "contains_entry", "(", "self", ",", "key", ",", "value", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "check_not_none", "(", "value", ",", "\"value can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "value_data", "=", "self", ".", "_to_data", "(", "value", ")", "return", "self", ".", "_encode_invoke_on_key", "(", "multi_map_contains_entry_codec", ",", "key_data", ",", "key", "=", "key_data", ",", "value", "=", "value_data", ",", "thread_id", "=", "thread_id", "(", ")", ")" ]
Returns whether the multimap contains an entry with the value. :param key: (object), the specified key. :param value: (object), the specified value. :return: (bool), ``true`` if this multimap contains the key-value tuple.
[ "Returns", "whether", "the", "multimap", "contains", "an", "entry", "with", "the", "value", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/multi_map.py#L81-L94
235,914
hazelcast/hazelcast-python-client
hazelcast/proxy/multi_map.py
MultiMap.get
def get(self, key): """ Returns the list of values associated with the key. ``None`` if this map does not contain this key. **Warning: This method uses hashCode and equals of the binary form of the key, not the actual implementations of hashCode and equals defined in the key's class.** **Warning-2: The list is NOT backed by the multimap, so changes to the map are list reflected in the collection, and vice-versa.** :param key: (object), the specified key. :return: (Sequence), the list of the values associated with the specified key. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(multi_map_get_codec, key_data, key=key_data, thread_id=thread_id())
python
def get(self, key): """ Returns the list of values associated with the key. ``None`` if this map does not contain this key. **Warning: This method uses hashCode and equals of the binary form of the key, not the actual implementations of hashCode and equals defined in the key's class.** **Warning-2: The list is NOT backed by the multimap, so changes to the map are list reflected in the collection, and vice-versa.** :param key: (object), the specified key. :return: (Sequence), the list of the values associated with the specified key. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(multi_map_get_codec, key_data, key=key_data, thread_id=thread_id())
[ "def", "get", "(", "self", ",", "key", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "return", "self", ".", "_encode_invoke_on_key", "(", "multi_map_get_codec", ",", "key_data", ",", "key", "=", "key_data", ",", "thread_id", "=", "thread_id", "(", ")", ")" ]
Returns the list of values associated with the key. ``None`` if this map does not contain this key. **Warning: This method uses hashCode and equals of the binary form of the key, not the actual implementations of hashCode and equals defined in the key's class.** **Warning-2: The list is NOT backed by the multimap, so changes to the map are list reflected in the collection, and vice-versa.** :param key: (object), the specified key. :return: (Sequence), the list of the values associated with the specified key.
[ "Returns", "the", "list", "of", "values", "associated", "with", "the", "key", ".", "None", "if", "this", "map", "does", "not", "contain", "this", "key", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/multi_map.py#L113-L131
235,915
hazelcast/hazelcast-python-client
hazelcast/proxy/multi_map.py
MultiMap.is_locked
def is_locked(self, key): """ Checks the lock for the specified key. If the lock is acquired, returns ``true``. Otherwise, returns false. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key that is checked for lock. :return: (bool), ``true`` if lock is acquired, false otherwise. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(multi_map_is_locked_codec, key_data, key=key_data)
python
def is_locked(self, key): """ Checks the lock for the specified key. If the lock is acquired, returns ``true``. Otherwise, returns false. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key that is checked for lock. :return: (bool), ``true`` if lock is acquired, false otherwise. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(multi_map_is_locked_codec, key_data, key=key_data)
[ "def", "is_locked", "(", "self", ",", "key", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "return", "self", ".", "_encode_invoke_on_key", "(", "multi_map_is_locked_codec", ",", "key_data", ",", "key", "=", "key_data", ")" ]
Checks the lock for the specified key. If the lock is acquired, returns ``true``. Otherwise, returns false. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key that is checked for lock. :return: (bool), ``true`` if lock is acquired, false otherwise.
[ "Checks", "the", "lock", "for", "the", "specified", "key", ".", "If", "the", "lock", "is", "acquired", "returns", "true", ".", "Otherwise", "returns", "false", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/multi_map.py#L133-L145
235,916
hazelcast/hazelcast-python-client
hazelcast/proxy/multi_map.py
MultiMap.remove
def remove(self, key, value): """ Removes the given key-value tuple from the multimap. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key of the entry to remove. :param value: (object), the value of the entry to remove. :return: (bool), ``true`` if the size of the multimap changed after the remove operation, ``false`` otherwise. """ check_not_none(key, "key can't be None") check_not_none(key, "value can't be None") key_data = self._to_data(key) value_data = self._to_data(value) return self._encode_invoke_on_key(multi_map_remove_entry_codec, key_data, key=key_data, value=value_data, thread_id=thread_id())
python
def remove(self, key, value): """ Removes the given key-value tuple from the multimap. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key of the entry to remove. :param value: (object), the value of the entry to remove. :return: (bool), ``true`` if the size of the multimap changed after the remove operation, ``false`` otherwise. """ check_not_none(key, "key can't be None") check_not_none(key, "value can't be None") key_data = self._to_data(key) value_data = self._to_data(value) return self._encode_invoke_on_key(multi_map_remove_entry_codec, key_data, key=key_data, value=value_data, thread_id=thread_id())
[ "def", "remove", "(", "self", ",", "key", ",", "value", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "check_not_none", "(", "key", ",", "\"value can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "value_data", "=", "self", ".", "_to_data", "(", "value", ")", "return", "self", ".", "_encode_invoke_on_key", "(", "multi_map_remove_entry_codec", ",", "key_data", ",", "key", "=", "key_data", ",", "value", "=", "value_data", ",", "thread_id", "=", "thread_id", "(", ")", ")" ]
Removes the given key-value tuple from the multimap. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key of the entry to remove. :param value: (object), the value of the entry to remove. :return: (bool), ``true`` if the size of the multimap changed after the remove operation, ``false`` otherwise.
[ "Removes", "the", "given", "key", "-", "value", "tuple", "from", "the", "multimap", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/multi_map.py#L197-L213
235,917
hazelcast/hazelcast-python-client
hazelcast/proxy/multi_map.py
MultiMap.remove_all
def remove_all(self, key): """ Removes all the entries with the given key and returns the value list associated with this key. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** **Warning-2: The returned list is NOT backed by the map, so changes to the map are NOT reflected in the list, and vice-versa.** :param key: (object), the key of the entries to remove. :return: (Sequence), the collection of removed values associated with the given key. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(multi_map_remove_codec, key_data, key=key_data, thread_id=thread_id())
python
def remove_all(self, key): """ Removes all the entries with the given key and returns the value list associated with this key. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** **Warning-2: The returned list is NOT backed by the map, so changes to the map are NOT reflected in the list, and vice-versa.** :param key: (object), the key of the entries to remove. :return: (Sequence), the collection of removed values associated with the given key. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(multi_map_remove_codec, key_data, key=key_data, thread_id=thread_id())
[ "def", "remove_all", "(", "self", ",", "key", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "return", "self", ".", "_encode_invoke_on_key", "(", "multi_map_remove_codec", ",", "key_data", ",", "key", "=", "key_data", ",", "thread_id", "=", "thread_id", "(", ")", ")" ]
Removes all the entries with the given key and returns the value list associated with this key. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** **Warning-2: The returned list is NOT backed by the map, so changes to the map are NOT reflected in the list, and vice-versa.** :param key: (object), the key of the entries to remove. :return: (Sequence), the collection of removed values associated with the given key.
[ "Removes", "all", "the", "entries", "with", "the", "given", "key", "and", "returns", "the", "value", "list", "associated", "with", "this", "key", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/multi_map.py#L215-L232
235,918
hazelcast/hazelcast-python-client
hazelcast/proxy/multi_map.py
MultiMap.put
def put(self, key, value): """ Stores a key-value tuple in the multimap. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key to be stored. :param value: (object), the value to be stored. :return: (bool), ``true`` if size of the multimap is increased, ``false`` if the multimap already contains the key-value tuple. """ check_not_none(key, "key can't be None") check_not_none(value, "value can't be None") key_data = self._to_data(key) value_data = self._to_data(value) return self._encode_invoke_on_key(multi_map_put_codec, key_data, key=key_data, value=value_data, thread_id=thread_id())
python
def put(self, key, value): """ Stores a key-value tuple in the multimap. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key to be stored. :param value: (object), the value to be stored. :return: (bool), ``true`` if size of the multimap is increased, ``false`` if the multimap already contains the key-value tuple. """ check_not_none(key, "key can't be None") check_not_none(value, "value can't be None") key_data = self._to_data(key) value_data = self._to_data(value) return self._encode_invoke_on_key(multi_map_put_codec, key_data, key=key_data, value=value_data, thread_id=thread_id())
[ "def", "put", "(", "self", ",", "key", ",", "value", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "check_not_none", "(", "value", ",", "\"value can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "value_data", "=", "self", ".", "_to_data", "(", "value", ")", "return", "self", ".", "_encode_invoke_on_key", "(", "multi_map_put_codec", ",", "key_data", ",", "key", "=", "key_data", ",", "value", "=", "value_data", ",", "thread_id", "=", "thread_id", "(", ")", ")" ]
Stores a key-value tuple in the multimap. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key to be stored. :param value: (object), the value to be stored. :return: (bool), ``true`` if size of the multimap is increased, ``false`` if the multimap already contains the key-value tuple.
[ "Stores", "a", "key", "-", "value", "tuple", "in", "the", "multimap", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/multi_map.py#L234-L251
235,919
hazelcast/hazelcast-python-client
hazelcast/proxy/multi_map.py
MultiMap.value_count
def value_count(self, key): """ Returns the number of values that match the given key in the multimap. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key whose values count is to be returned. :return: (int), the number of values that match the given key in the multimap. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(multi_map_value_count_codec, key_data, key=key_data, thread_id=thread_id())
python
def value_count(self, key): """ Returns the number of values that match the given key in the multimap. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key whose values count is to be returned. :return: (int), the number of values that match the given key in the multimap. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(multi_map_value_count_codec, key_data, key=key_data, thread_id=thread_id())
[ "def", "value_count", "(", "self", ",", "key", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "return", "self", ".", "_encode_invoke_on_key", "(", "multi_map_value_count_codec", ",", "key_data", ",", "key", "=", "key_data", ",", "thread_id", "=", "thread_id", "(", ")", ")" ]
Returns the number of values that match the given key in the multimap. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key whose values count is to be returned. :return: (int), the number of values that match the given key in the multimap.
[ "Returns", "the", "number", "of", "values", "that", "match", "the", "given", "key", "in", "the", "multimap", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/multi_map.py#L271-L284
235,920
hazelcast/hazelcast-python-client
hazelcast/proxy/atomic_reference.py
AtomicReference.alter
def alter(self, function): """ Alters the currently stored reference by applying a function on it. :param function: (Function), A stateful serializable object which represents the Function defined on server side. This object must have a serializable Function counter part registered on server side with the actual ``org.hazelcast.core.IFunction`` implementation. """ check_not_none(function, "function can't be None") return self._encode_invoke(atomic_reference_alter_codec, function=self._to_data(function))
python
def alter(self, function): """ Alters the currently stored reference by applying a function on it. :param function: (Function), A stateful serializable object which represents the Function defined on server side. This object must have a serializable Function counter part registered on server side with the actual ``org.hazelcast.core.IFunction`` implementation. """ check_not_none(function, "function can't be None") return self._encode_invoke(atomic_reference_alter_codec, function=self._to_data(function))
[ "def", "alter", "(", "self", ",", "function", ")", ":", "check_not_none", "(", "function", ",", "\"function can't be None\"", ")", "return", "self", ".", "_encode_invoke", "(", "atomic_reference_alter_codec", ",", "function", "=", "self", ".", "_to_data", "(", "function", ")", ")" ]
Alters the currently stored reference by applying a function on it. :param function: (Function), A stateful serializable object which represents the Function defined on server side. This object must have a serializable Function counter part registered on server side with the actual ``org.hazelcast.core.IFunction`` implementation.
[ "Alters", "the", "currently", "stored", "reference", "by", "applying", "a", "function", "on", "it", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/atomic_reference.py#L14-L24
235,921
hazelcast/hazelcast-python-client
hazelcast/proxy/atomic_reference.py
AtomicReference.alter_and_get
def alter_and_get(self, function): """ Alters the currently stored reference by applying a function on it and gets the result. :param function: (Function), A stateful serializable object which represents the Function defined on server side. This object must have a serializable Function counter part registered on server side with the actual ``org.hazelcast.core.IFunction`` implementation. :return: (object), the new value, the result of the applied function. """ check_not_none(function, "function can't be None") return self._encode_invoke(atomic_reference_alter_and_get_codec, function=self._to_data(function))
python
def alter_and_get(self, function): """ Alters the currently stored reference by applying a function on it and gets the result. :param function: (Function), A stateful serializable object which represents the Function defined on server side. This object must have a serializable Function counter part registered on server side with the actual ``org.hazelcast.core.IFunction`` implementation. :return: (object), the new value, the result of the applied function. """ check_not_none(function, "function can't be None") return self._encode_invoke(atomic_reference_alter_and_get_codec, function=self._to_data(function))
[ "def", "alter_and_get", "(", "self", ",", "function", ")", ":", "check_not_none", "(", "function", ",", "\"function can't be None\"", ")", "return", "self", ".", "_encode_invoke", "(", "atomic_reference_alter_and_get_codec", ",", "function", "=", "self", ".", "_to_data", "(", "function", ")", ")" ]
Alters the currently stored reference by applying a function on it and gets the result. :param function: (Function), A stateful serializable object which represents the Function defined on server side. This object must have a serializable Function counter part registered on server side with the actual ``org.hazelcast.core.IFunction`` implementation. :return: (object), the new value, the result of the applied function.
[ "Alters", "the", "currently", "stored", "reference", "by", "applying", "a", "function", "on", "it", "and", "gets", "the", "result", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/atomic_reference.py#L39-L50
235,922
hazelcast/hazelcast-python-client
hazelcast/proxy/atomic_reference.py
AtomicReference.contains
def contains(self, expected): """ Checks if the reference contains the value. :param expected: (object), the value to check (is allowed to be ``None``). :return: (bool), ``true`` if the value is found, ``false`` otherwise. """ return self._encode_invoke(atomic_reference_contains_codec, expected=self._to_data(expected))
python
def contains(self, expected): """ Checks if the reference contains the value. :param expected: (object), the value to check (is allowed to be ``None``). :return: (bool), ``true`` if the value is found, ``false`` otherwise. """ return self._encode_invoke(atomic_reference_contains_codec, expected=self._to_data(expected))
[ "def", "contains", "(", "self", ",", "expected", ")", ":", "return", "self", ".", "_encode_invoke", "(", "atomic_reference_contains_codec", ",", "expected", "=", "self", ".", "_to_data", "(", "expected", ")", ")" ]
Checks if the reference contains the value. :param expected: (object), the value to check (is allowed to be ``None``). :return: (bool), ``true`` if the value is found, ``false`` otherwise.
[ "Checks", "if", "the", "reference", "contains", "the", "value", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/atomic_reference.py#L69-L78
235,923
hazelcast/hazelcast-python-client
hazelcast/proxy/atomic_reference.py
AtomicReference.get_and_alter
def get_and_alter(self, function): """ Alters the currently stored reference by applying a function on it on and gets the old value. :param function: (Function), A stateful serializable object which represents the Function defined on server side. This object must have a serializable Function counter part registered on server side with the actual ``org.hazelcast.core.IFunction`` implementation. :return: (object), the old value, the value before the function is applied. """ check_not_none(function, "function can't be None") return self._encode_invoke(atomic_reference_get_and_alter_codec, function=self._to_data(function))
python
def get_and_alter(self, function): """ Alters the currently stored reference by applying a function on it on and gets the old value. :param function: (Function), A stateful serializable object which represents the Function defined on server side. This object must have a serializable Function counter part registered on server side with the actual ``org.hazelcast.core.IFunction`` implementation. :return: (object), the old value, the value before the function is applied. """ check_not_none(function, "function can't be None") return self._encode_invoke(atomic_reference_get_and_alter_codec, function=self._to_data(function))
[ "def", "get_and_alter", "(", "self", ",", "function", ")", ":", "check_not_none", "(", "function", ",", "\"function can't be None\"", ")", "return", "self", ".", "_encode_invoke", "(", "atomic_reference_get_and_alter_codec", ",", "function", "=", "self", ".", "_to_data", "(", "function", ")", ")" ]
Alters the currently stored reference by applying a function on it on and gets the old value. :param function: (Function), A stateful serializable object which represents the Function defined on server side. This object must have a serializable Function counter part registered on server side with the actual ``org.hazelcast.core.IFunction`` implementation. :return: (object), the old value, the value before the function is applied.
[ "Alters", "the", "currently", "stored", "reference", "by", "applying", "a", "function", "on", "it", "on", "and", "gets", "the", "old", "value", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/atomic_reference.py#L88-L100
235,924
hazelcast/hazelcast-python-client
hazelcast/proxy/atomic_reference.py
AtomicReference.get_and_set
def get_and_set(self, new_value): """ Gets the old value and sets the new value. :param new_value: (object), the new value. :return: (object), the old value. """ return self._encode_invoke(atomic_reference_get_and_set_codec, new_value=self._to_data(new_value))
python
def get_and_set(self, new_value): """ Gets the old value and sets the new value. :param new_value: (object), the new value. :return: (object), the old value. """ return self._encode_invoke(atomic_reference_get_and_set_codec, new_value=self._to_data(new_value))
[ "def", "get_and_set", "(", "self", ",", "new_value", ")", ":", "return", "self", ".", "_encode_invoke", "(", "atomic_reference_get_and_set_codec", ",", "new_value", "=", "self", ".", "_to_data", "(", "new_value", ")", ")" ]
Gets the old value and sets the new value. :param new_value: (object), the new value. :return: (object), the old value.
[ "Gets", "the", "old", "value", "and", "sets", "the", "new", "value", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/atomic_reference.py#L102-L110
235,925
hazelcast/hazelcast-python-client
hazelcast/proxy/atomic_reference.py
AtomicReference.set
def set(self, new_value): """ Atomically sets the given value. :param new_value: (object), the new value. """ return self._encode_invoke(atomic_reference_set_codec, new_value=self._to_data(new_value))
python
def set(self, new_value): """ Atomically sets the given value. :param new_value: (object), the new value. """ return self._encode_invoke(atomic_reference_set_codec, new_value=self._to_data(new_value))
[ "def", "set", "(", "self", ",", "new_value", ")", ":", "return", "self", ".", "_encode_invoke", "(", "atomic_reference_set_codec", ",", "new_value", "=", "self", ".", "_to_data", "(", "new_value", ")", ")" ]
Atomically sets the given value. :param new_value: (object), the new value.
[ "Atomically", "sets", "the", "given", "value", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/atomic_reference.py#L120-L127
235,926
hazelcast/hazelcast-python-client
hazelcast/proxy/atomic_reference.py
AtomicReference.set_and_get
def set_and_get(self, new_value): """ Sets and gets the value. :param new_value: (object), the new value. :return: (object), the new value. """ return self._encode_invoke(atomic_reference_set_and_get_codec, new_value=self._to_data(new_value))
python
def set_and_get(self, new_value): """ Sets and gets the value. :param new_value: (object), the new value. :return: (object), the new value. """ return self._encode_invoke(atomic_reference_set_and_get_codec, new_value=self._to_data(new_value))
[ "def", "set_and_get", "(", "self", ",", "new_value", ")", ":", "return", "self", ".", "_encode_invoke", "(", "atomic_reference_set_and_get_codec", ",", "new_value", "=", "self", ".", "_to_data", "(", "new_value", ")", ")" ]
Sets and gets the value. :param new_value: (object), the new value. :return: (object), the new value.
[ "Sets", "and", "gets", "the", "value", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/atomic_reference.py#L129-L137
235,927
hazelcast/hazelcast-python-client
hazelcast/serialization/data.py
Data.get_type
def get_type(self): """ Returns serialization type of binary form. :return: Serialization type of binary form. """ if self.total_size() == 0: return CONSTANT_TYPE_NULL return unpack_from(FMT_BE_INT, self._buffer, TYPE_OFFSET)[0]
python
def get_type(self): """ Returns serialization type of binary form. :return: Serialization type of binary form. """ if self.total_size() == 0: return CONSTANT_TYPE_NULL return unpack_from(FMT_BE_INT, self._buffer, TYPE_OFFSET)[0]
[ "def", "get_type", "(", "self", ")", ":", "if", "self", ".", "total_size", "(", ")", "==", "0", ":", "return", "CONSTANT_TYPE_NULL", "return", "unpack_from", "(", "FMT_BE_INT", ",", "self", ".", "_buffer", ",", "TYPE_OFFSET", ")", "[", "0", "]" ]
Returns serialization type of binary form. :return: Serialization type of binary form.
[ "Returns", "serialization", "type", "of", "binary", "form", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/serialization/data.py#L30-L38
235,928
hazelcast/hazelcast-python-client
hazelcast/serialization/data.py
Data.has_partition_hash
def has_partition_hash(self): """ Determines whether this Data has partition hash or not. :return: (bool), ``true`` if Data has partition hash, ``false`` otherwise. """ return self._buffer is not None \ and len(self._buffer) >= HEAP_DATA_OVERHEAD \ and unpack_from(FMT_BE_INT, self._buffer, PARTITION_HASH_OFFSET)[0] != 0
python
def has_partition_hash(self): """ Determines whether this Data has partition hash or not. :return: (bool), ``true`` if Data has partition hash, ``false`` otherwise. """ return self._buffer is not None \ and len(self._buffer) >= HEAP_DATA_OVERHEAD \ and unpack_from(FMT_BE_INT, self._buffer, PARTITION_HASH_OFFSET)[0] != 0
[ "def", "has_partition_hash", "(", "self", ")", ":", "return", "self", ".", "_buffer", "is", "not", "None", "and", "len", "(", "self", ".", "_buffer", ")", ">=", "HEAP_DATA_OVERHEAD", "and", "unpack_from", "(", "FMT_BE_INT", ",", "self", ".", "_buffer", ",", "PARTITION_HASH_OFFSET", ")", "[", "0", "]", "!=", "0" ]
Determines whether this Data has partition hash or not. :return: (bool), ``true`` if Data has partition hash, ``false`` otherwise.
[ "Determines", "whether", "this", "Data", "has", "partition", "hash", "or", "not", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/serialization/data.py#L77-L85
235,929
hazelcast/hazelcast-python-client
hazelcast/serialization/base.py
SerializerRegistry.serializer_for
def serializer_for(self, obj): """ Searches for a serializer for the provided object Serializers will be searched in this order; 1-NULL serializer 2-Default serializers, like primitives, arrays, string and some default types 3-Custom registered types by user 4-Global serializer if registered by user 4-pickle serialization as a fallback :param obj: input object :return: Serializer """ # 1-NULL serializer if obj is None: return self._null_serializer obj_type = type(obj) # 2-Default serializers, Dataserializable, Portable, primitives, arrays, String and some helper types(BigInteger etc) serializer = self.lookup_default_serializer(obj_type, obj) # 3-Custom registered types by user if serializer is None: serializer = self.lookup_custom_serializer(obj_type) # 5-Global serializer if registered by user if serializer is None: serializer = self.lookup_global_serializer(obj_type) # 4 Internal serializer if serializer is None: serializer = self.lookup_python_serializer(obj_type) if serializer is None: raise HazelcastSerializationError("There is no suitable serializer for:" + str(obj_type)) return serializer
python
def serializer_for(self, obj): """ Searches for a serializer for the provided object Serializers will be searched in this order; 1-NULL serializer 2-Default serializers, like primitives, arrays, string and some default types 3-Custom registered types by user 4-Global serializer if registered by user 4-pickle serialization as a fallback :param obj: input object :return: Serializer """ # 1-NULL serializer if obj is None: return self._null_serializer obj_type = type(obj) # 2-Default serializers, Dataserializable, Portable, primitives, arrays, String and some helper types(BigInteger etc) serializer = self.lookup_default_serializer(obj_type, obj) # 3-Custom registered types by user if serializer is None: serializer = self.lookup_custom_serializer(obj_type) # 5-Global serializer if registered by user if serializer is None: serializer = self.lookup_global_serializer(obj_type) # 4 Internal serializer if serializer is None: serializer = self.lookup_python_serializer(obj_type) if serializer is None: raise HazelcastSerializationError("There is no suitable serializer for:" + str(obj_type)) return serializer
[ "def", "serializer_for", "(", "self", ",", "obj", ")", ":", "# 1-NULL serializer", "if", "obj", "is", "None", ":", "return", "self", ".", "_null_serializer", "obj_type", "=", "type", "(", "obj", ")", "# 2-Default serializers, Dataserializable, Portable, primitives, arrays, String and some helper types(BigInteger etc)", "serializer", "=", "self", ".", "lookup_default_serializer", "(", "obj_type", ",", "obj", ")", "# 3-Custom registered types by user", "if", "serializer", "is", "None", ":", "serializer", "=", "self", ".", "lookup_custom_serializer", "(", "obj_type", ")", "# 5-Global serializer if registered by user", "if", "serializer", "is", "None", ":", "serializer", "=", "self", ".", "lookup_global_serializer", "(", "obj_type", ")", "# 4 Internal serializer", "if", "serializer", "is", "None", ":", "serializer", "=", "self", ".", "lookup_python_serializer", "(", "obj_type", ")", "if", "serializer", "is", "None", ":", "raise", "HazelcastSerializationError", "(", "\"There is no suitable serializer for:\"", "+", "str", "(", "obj_type", ")", ")", "return", "serializer" ]
Searches for a serializer for the provided object Serializers will be searched in this order; 1-NULL serializer 2-Default serializers, like primitives, arrays, string and some default types 3-Custom registered types by user 4-Global serializer if registered by user 4-pickle serialization as a fallback :param obj: input object :return: Serializer
[ "Searches", "for", "a", "serializer", "for", "the", "provided", "object", "Serializers", "will", "be", "searched", "in", "this", "order", ";" ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/serialization/base.py#L182-L219
235,930
hazelcast/hazelcast-python-client
hazelcast/near_cache.py
DataRecord.is_expired
def is_expired(self, max_idle_seconds): """ Determines whether this record is expired or not. :param max_idle_seconds: (long), the maximum idle time of record, maximum time after the last access time. :return: (bool), ``true`` is this record is not expired. """ now = current_time() return (self.expiration_time is not None and self.expiration_time < now) or \ (max_idle_seconds is not None and self.last_access_time + max_idle_seconds < now)
python
def is_expired(self, max_idle_seconds): """ Determines whether this record is expired or not. :param max_idle_seconds: (long), the maximum idle time of record, maximum time after the last access time. :return: (bool), ``true`` is this record is not expired. """ now = current_time() return (self.expiration_time is not None and self.expiration_time < now) or \ (max_idle_seconds is not None and self.last_access_time + max_idle_seconds < now)
[ "def", "is_expired", "(", "self", ",", "max_idle_seconds", ")", ":", "now", "=", "current_time", "(", ")", "return", "(", "self", ".", "expiration_time", "is", "not", "None", "and", "self", ".", "expiration_time", "<", "now", ")", "or", "(", "max_idle_seconds", "is", "not", "None", "and", "self", ".", "last_access_time", "+", "max_idle_seconds", "<", "now", ")" ]
Determines whether this record is expired or not. :param max_idle_seconds: (long), the maximum idle time of record, maximum time after the last access time. :return: (bool), ``true`` is this record is not expired.
[ "Determines", "whether", "this", "record", "is", "expired", "or", "not", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/near_cache.py#L56-L66
235,931
hazelcast/hazelcast-python-client
hazelcast/future.py
combine_futures
def combine_futures(*futures): """ Combines set of Futures. :param futures: (Futures), Futures to be combined. :return: Result of the combination. """ expected = len(futures) results = [] completed = AtomicInteger() combined = Future() def done(f): if not combined.done(): if f.is_success(): # TODO: ensure ordering of results as original list results.append(f.result()) if completed.get_and_increment() + 1 == expected: combined.set_result(results) else: combined.set_exception(f.exception(), f.traceback()) for future in futures: future.add_done_callback(done) return combined
python
def combine_futures(*futures): """ Combines set of Futures. :param futures: (Futures), Futures to be combined. :return: Result of the combination. """ expected = len(futures) results = [] completed = AtomicInteger() combined = Future() def done(f): if not combined.done(): if f.is_success(): # TODO: ensure ordering of results as original list results.append(f.result()) if completed.get_and_increment() + 1 == expected: combined.set_result(results) else: combined.set_exception(f.exception(), f.traceback()) for future in futures: future.add_done_callback(done) return combined
[ "def", "combine_futures", "(", "*", "futures", ")", ":", "expected", "=", "len", "(", "futures", ")", "results", "=", "[", "]", "completed", "=", "AtomicInteger", "(", ")", "combined", "=", "Future", "(", ")", "def", "done", "(", "f", ")", ":", "if", "not", "combined", ".", "done", "(", ")", ":", "if", "f", ".", "is_success", "(", ")", ":", "# TODO: ensure ordering of results as original list", "results", ".", "append", "(", "f", ".", "result", "(", ")", ")", "if", "completed", ".", "get_and_increment", "(", ")", "+", "1", "==", "expected", ":", "combined", ".", "set_result", "(", "results", ")", "else", ":", "combined", ".", "set_exception", "(", "f", ".", "exception", "(", ")", ",", "f", ".", "traceback", "(", ")", ")", "for", "future", "in", "futures", ":", "future", ".", "add_done_callback", "(", "done", ")", "return", "combined" ]
Combines set of Futures. :param futures: (Futures), Futures to be combined. :return: Result of the combination.
[ "Combines", "set", "of", "Futures", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/future.py#L233-L257
235,932
hazelcast/hazelcast-python-client
hazelcast/future.py
Future.set_result
def set_result(self, result): """ Sets the result of the Future. :param result: Result of the Future. """ if result is None: self._result = NONE_RESULT else: self._result = result self._event.set() self._invoke_callbacks()
python
def set_result(self, result): """ Sets the result of the Future. :param result: Result of the Future. """ if result is None: self._result = NONE_RESULT else: self._result = result self._event.set() self._invoke_callbacks()
[ "def", "set_result", "(", "self", ",", "result", ")", ":", "if", "result", "is", "None", ":", "self", ".", "_result", "=", "NONE_RESULT", "else", ":", "self", ".", "_result", "=", "result", "self", ".", "_event", ".", "set", "(", ")", "self", ".", "_invoke_callbacks", "(", ")" ]
Sets the result of the Future. :param result: Result of the Future.
[ "Sets", "the", "result", "of", "the", "Future", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/future.py#L25-L36
235,933
hazelcast/hazelcast-python-client
hazelcast/future.py
Future.set_exception
def set_exception(self, exception, traceback=None): """ Sets the exception for this Future in case of errors. :param exception: (Exception), exception to be threw in case of error. :param traceback: (Function), function to be called on traceback (optional). """ if not isinstance(exception, BaseException): raise RuntimeError("Exception must be of BaseException type") self._exception = exception self._traceback = traceback self._event.set() self._invoke_callbacks()
python
def set_exception(self, exception, traceback=None): """ Sets the exception for this Future in case of errors. :param exception: (Exception), exception to be threw in case of error. :param traceback: (Function), function to be called on traceback (optional). """ if not isinstance(exception, BaseException): raise RuntimeError("Exception must be of BaseException type") self._exception = exception self._traceback = traceback self._event.set() self._invoke_callbacks()
[ "def", "set_exception", "(", "self", ",", "exception", ",", "traceback", "=", "None", ")", ":", "if", "not", "isinstance", "(", "exception", ",", "BaseException", ")", ":", "raise", "RuntimeError", "(", "\"Exception must be of BaseException type\"", ")", "self", ".", "_exception", "=", "exception", "self", ".", "_traceback", "=", "traceback", "self", ".", "_event", ".", "set", "(", ")", "self", ".", "_invoke_callbacks", "(", ")" ]
Sets the exception for this Future in case of errors. :param exception: (Exception), exception to be threw in case of error. :param traceback: (Function), function to be called on traceback (optional).
[ "Sets", "the", "exception", "for", "this", "Future", "in", "case", "of", "errors", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/future.py#L38-L50
235,934
hazelcast/hazelcast-python-client
hazelcast/future.py
Future.result
def result(self): """ Returns the result of the Future, which makes the call synchronous if the result has not been computed yet. :return: Result of the Future. """ self._reactor_check() self._event.wait() if self._exception: six.reraise(self._exception.__class__, self._exception, self._traceback) if self._result == NONE_RESULT: return None else: return self._result
python
def result(self): """ Returns the result of the Future, which makes the call synchronous if the result has not been computed yet. :return: Result of the Future. """ self._reactor_check() self._event.wait() if self._exception: six.reraise(self._exception.__class__, self._exception, self._traceback) if self._result == NONE_RESULT: return None else: return self._result
[ "def", "result", "(", "self", ")", ":", "self", ".", "_reactor_check", "(", ")", "self", ".", "_event", ".", "wait", "(", ")", "if", "self", ".", "_exception", ":", "six", ".", "reraise", "(", "self", ".", "_exception", ".", "__class__", ",", "self", ".", "_exception", ",", "self", ".", "_traceback", ")", "if", "self", ".", "_result", "==", "NONE_RESULT", ":", "return", "None", "else", ":", "return", "self", ".", "_result" ]
Returns the result of the Future, which makes the call synchronous if the result has not been computed yet. :return: Result of the Future.
[ "Returns", "the", "result", "of", "the", "Future", "which", "makes", "the", "call", "synchronous", "if", "the", "result", "has", "not", "been", "computed", "yet", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/future.py#L52-L65
235,935
hazelcast/hazelcast-python-client
hazelcast/future.py
Future.continue_with
def continue_with(self, continuation_func, *args): """ Create a continuation that executes when the Future is completed. :param continuation_func: A function which takes the future as the only parameter. Return value of the function will be set as the result of the continuation future. :return: A new Future which will be completed when the continuation is done. """ future = Future() def callback(f): try: future.set_result(continuation_func(f, *args)) except: future.set_exception(sys.exc_info()[1], sys.exc_info()[2]) self.add_done_callback(callback) return future
python
def continue_with(self, continuation_func, *args): """ Create a continuation that executes when the Future is completed. :param continuation_func: A function which takes the future as the only parameter. Return value of the function will be set as the result of the continuation future. :return: A new Future which will be completed when the continuation is done. """ future = Future() def callback(f): try: future.set_result(continuation_func(f, *args)) except: future.set_exception(sys.exc_info()[1], sys.exc_info()[2]) self.add_done_callback(callback) return future
[ "def", "continue_with", "(", "self", ",", "continuation_func", ",", "*", "args", ")", ":", "future", "=", "Future", "(", ")", "def", "callback", "(", "f", ")", ":", "try", ":", "future", ".", "set_result", "(", "continuation_func", "(", "f", ",", "*", "args", ")", ")", "except", ":", "future", ".", "set_exception", "(", "sys", ".", "exc_info", "(", ")", "[", "1", "]", ",", "sys", ".", "exc_info", "(", ")", "[", "2", "]", ")", "self", ".", "add_done_callback", "(", "callback", ")", "return", "future" ]
Create a continuation that executes when the Future is completed. :param continuation_func: A function which takes the future as the only parameter. Return value of the function will be set as the result of the continuation future. :return: A new Future which will be completed when the continuation is done.
[ "Create", "a", "continuation", "that", "executes", "when", "the", "Future", "is", "completed", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/future.py#L133-L150
235,936
hazelcast/hazelcast-python-client
hazelcast/connection.py
ConnectionManager.on_auth
def on_auth(self, f, connection, address): """ Checks for authentication of a connection. :param f: (:class:`~hazelcast.future.Future`), future that contains the result of authentication. :param connection: (:class:`~hazelcast.connection.Connection`), newly established connection. :param address: (:class:`~hazelcast.core.Address`), the adress of new connection. :return: Result of authentication. """ if f.is_success(): self.logger.info("Authenticated with %s", f.result(), extra=self._logger_extras) with self._new_connection_mutex: self.connections[connection.endpoint] = f.result() try: self._pending_connections.pop(address) except KeyError: pass for on_connection_opened, _ in self._connection_listeners: if on_connection_opened: on_connection_opened(f.result()) return f.result() else: self.logger.debug("Error opening %s", connection, extra=self._logger_extras) with self._new_connection_mutex: try: self._pending_connections.pop(address) except KeyError: pass six.reraise(f.exception().__class__, f.exception(), f.traceback())
python
def on_auth(self, f, connection, address): """ Checks for authentication of a connection. :param f: (:class:`~hazelcast.future.Future`), future that contains the result of authentication. :param connection: (:class:`~hazelcast.connection.Connection`), newly established connection. :param address: (:class:`~hazelcast.core.Address`), the adress of new connection. :return: Result of authentication. """ if f.is_success(): self.logger.info("Authenticated with %s", f.result(), extra=self._logger_extras) with self._new_connection_mutex: self.connections[connection.endpoint] = f.result() try: self._pending_connections.pop(address) except KeyError: pass for on_connection_opened, _ in self._connection_listeners: if on_connection_opened: on_connection_opened(f.result()) return f.result() else: self.logger.debug("Error opening %s", connection, extra=self._logger_extras) with self._new_connection_mutex: try: self._pending_connections.pop(address) except KeyError: pass six.reraise(f.exception().__class__, f.exception(), f.traceback())
[ "def", "on_auth", "(", "self", ",", "f", ",", "connection", ",", "address", ")", ":", "if", "f", ".", "is_success", "(", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Authenticated with %s\"", ",", "f", ".", "result", "(", ")", ",", "extra", "=", "self", ".", "_logger_extras", ")", "with", "self", ".", "_new_connection_mutex", ":", "self", ".", "connections", "[", "connection", ".", "endpoint", "]", "=", "f", ".", "result", "(", ")", "try", ":", "self", ".", "_pending_connections", ".", "pop", "(", "address", ")", "except", "KeyError", ":", "pass", "for", "on_connection_opened", ",", "_", "in", "self", ".", "_connection_listeners", ":", "if", "on_connection_opened", ":", "on_connection_opened", "(", "f", ".", "result", "(", ")", ")", "return", "f", ".", "result", "(", ")", "else", ":", "self", ".", "logger", ".", "debug", "(", "\"Error opening %s\"", ",", "connection", ",", "extra", "=", "self", ".", "_logger_extras", ")", "with", "self", ".", "_new_connection_mutex", ":", "try", ":", "self", ".", "_pending_connections", ".", "pop", "(", "address", ")", "except", "KeyError", ":", "pass", "six", ".", "reraise", "(", "f", ".", "exception", "(", ")", ".", "__class__", ",", "f", ".", "exception", "(", ")", ",", "f", ".", "traceback", "(", ")", ")" ]
Checks for authentication of a connection. :param f: (:class:`~hazelcast.future.Future`), future that contains the result of authentication. :param connection: (:class:`~hazelcast.connection.Connection`), newly established connection. :param address: (:class:`~hazelcast.core.Address`), the adress of new connection. :return: Result of authentication.
[ "Checks", "for", "authentication", "of", "a", "connection", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/connection.py#L123-L151
235,937
hazelcast/hazelcast-python-client
hazelcast/connection.py
ConnectionManager.close_connection
def close_connection(self, address, cause): """ Closes the connection with given address. :param address: (:class:`~hazelcast.core.Address`), address of the connection to be closed. :param cause: (Exception), the cause for closing the connection. :return: (bool), ``true`` if the connection is closed, ``false`` otherwise. """ try: connection = self.connections[address] connection.close(cause) except KeyError: self.logger.warning("No connection with %s was found to close.", address, extra=self._logger_extras) return False
python
def close_connection(self, address, cause): """ Closes the connection with given address. :param address: (:class:`~hazelcast.core.Address`), address of the connection to be closed. :param cause: (Exception), the cause for closing the connection. :return: (bool), ``true`` if the connection is closed, ``false`` otherwise. """ try: connection = self.connections[address] connection.close(cause) except KeyError: self.logger.warning("No connection with %s was found to close.", address, extra=self._logger_extras) return False
[ "def", "close_connection", "(", "self", ",", "address", ",", "cause", ")", ":", "try", ":", "connection", "=", "self", ".", "connections", "[", "address", "]", "connection", ".", "close", "(", "cause", ")", "except", "KeyError", ":", "self", ".", "logger", ".", "warning", "(", "\"No connection with %s was found to close.\"", ",", "address", ",", "extra", "=", "self", ".", "_logger_extras", ")", "return", "False" ]
Closes the connection with given address. :param address: (:class:`~hazelcast.core.Address`), address of the connection to be closed. :param cause: (Exception), the cause for closing the connection. :return: (bool), ``true`` if the connection is closed, ``false`` otherwise.
[ "Closes", "the", "connection", "with", "given", "address", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/connection.py#L167-L180
235,938
hazelcast/hazelcast-python-client
hazelcast/connection.py
Heartbeat.start
def start(self): """ Starts sending periodic HeartBeat operations. """ def _heartbeat(): if not self._client.lifecycle.is_live: return self._heartbeat() self._heartbeat_timer = self._client.reactor.add_timer(self._heartbeat_interval, _heartbeat) self._heartbeat_timer = self._client.reactor.add_timer(self._heartbeat_interval, _heartbeat)
python
def start(self): """ Starts sending periodic HeartBeat operations. """ def _heartbeat(): if not self._client.lifecycle.is_live: return self._heartbeat() self._heartbeat_timer = self._client.reactor.add_timer(self._heartbeat_interval, _heartbeat) self._heartbeat_timer = self._client.reactor.add_timer(self._heartbeat_interval, _heartbeat)
[ "def", "start", "(", "self", ")", ":", "def", "_heartbeat", "(", ")", ":", "if", "not", "self", ".", "_client", ".", "lifecycle", ".", "is_live", ":", "return", "self", ".", "_heartbeat", "(", ")", "self", ".", "_heartbeat_timer", "=", "self", ".", "_client", ".", "reactor", ".", "add_timer", "(", "self", ".", "_heartbeat_interval", ",", "_heartbeat", ")", "self", ".", "_heartbeat_timer", "=", "self", ".", "_client", ".", "reactor", ".", "add_timer", "(", "self", ".", "_heartbeat_interval", ",", "_heartbeat", ")" ]
Starts sending periodic HeartBeat operations.
[ "Starts", "sending", "periodic", "HeartBeat", "operations", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/connection.py#L198-L208
235,939
hazelcast/hazelcast-python-client
hazelcast/connection.py
Connection.send_message
def send_message(self, message): """ Sends a message to this connection. :param message: (Message), message to be sent to this connection. """ if not self.live(): raise IOError("Connection is not live.") message.add_flag(BEGIN_END_FLAG) self.write(message.buffer)
python
def send_message(self, message): """ Sends a message to this connection. :param message: (Message), message to be sent to this connection. """ if not self.live(): raise IOError("Connection is not live.") message.add_flag(BEGIN_END_FLAG) self.write(message.buffer)
[ "def", "send_message", "(", "self", ",", "message", ")", ":", "if", "not", "self", ".", "live", "(", ")", ":", "raise", "IOError", "(", "\"Connection is not live.\"", ")", "message", ".", "add_flag", "(", "BEGIN_END_FLAG", ")", "self", ".", "write", "(", "message", ".", "buffer", ")" ]
Sends a message to this connection. :param message: (Message), message to be sent to this connection.
[ "Sends", "a", "message", "to", "this", "connection", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/connection.py#L291-L301
235,940
hazelcast/hazelcast-python-client
hazelcast/connection.py
Connection.receive_message
def receive_message(self): """ Receives a message from this connection. """ # split frames while len(self._read_buffer) >= INT_SIZE_IN_BYTES: frame_length = struct.unpack_from(FMT_LE_INT, self._read_buffer, 0)[0] if frame_length > len(self._read_buffer): return message = ClientMessage(memoryview(self._read_buffer)[:frame_length]) self._read_buffer = self._read_buffer[frame_length:] self._builder.on_message(message)
python
def receive_message(self): """ Receives a message from this connection. """ # split frames while len(self._read_buffer) >= INT_SIZE_IN_BYTES: frame_length = struct.unpack_from(FMT_LE_INT, self._read_buffer, 0)[0] if frame_length > len(self._read_buffer): return message = ClientMessage(memoryview(self._read_buffer)[:frame_length]) self._read_buffer = self._read_buffer[frame_length:] self._builder.on_message(message)
[ "def", "receive_message", "(", "self", ")", ":", "# split frames", "while", "len", "(", "self", ".", "_read_buffer", ")", ">=", "INT_SIZE_IN_BYTES", ":", "frame_length", "=", "struct", ".", "unpack_from", "(", "FMT_LE_INT", ",", "self", ".", "_read_buffer", ",", "0", ")", "[", "0", "]", "if", "frame_length", ">", "len", "(", "self", ".", "_read_buffer", ")", ":", "return", "message", "=", "ClientMessage", "(", "memoryview", "(", "self", ".", "_read_buffer", ")", "[", ":", "frame_length", "]", ")", "self", ".", "_read_buffer", "=", "self", ".", "_read_buffer", "[", "frame_length", ":", "]", "self", ".", "_builder", ".", "on_message", "(", "message", ")" ]
Receives a message from this connection.
[ "Receives", "a", "message", "from", "this", "connection", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/connection.py#L303-L314
235,941
hazelcast/hazelcast-python-client
hazelcast/proxy/semaphore.py
Semaphore.init
def init(self, permits): """ Try to initialize this Semaphore instance with the given permit count. :param permits: (int), the given permit count. :return: (bool), ``true`` if initialization success. """ check_not_negative(permits, "Permits cannot be negative!") return self._encode_invoke(semaphore_init_codec, permits=permits)
python
def init(self, permits): """ Try to initialize this Semaphore instance with the given permit count. :param permits: (int), the given permit count. :return: (bool), ``true`` if initialization success. """ check_not_negative(permits, "Permits cannot be negative!") return self._encode_invoke(semaphore_init_codec, permits=permits)
[ "def", "init", "(", "self", ",", "permits", ")", ":", "check_not_negative", "(", "permits", ",", "\"Permits cannot be negative!\"", ")", "return", "self", ".", "_encode_invoke", "(", "semaphore_init_codec", ",", "permits", "=", "permits", ")" ]
Try to initialize this Semaphore instance with the given permit count. :param permits: (int), the given permit count. :return: (bool), ``true`` if initialization success.
[ "Try", "to", "initialize", "this", "Semaphore", "instance", "with", "the", "given", "permit", "count", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/semaphore.py#L33-L41
235,942
hazelcast/hazelcast-python-client
hazelcast/proxy/semaphore.py
Semaphore.acquire
def acquire(self, permits=1): """ Acquires one or specified amount of permits if available, and returns immediately, reducing the number of available permits by one or given amount. If insufficient permits are available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of following happens: * some other thread invokes one of the release methods for this semaphore, the current thread is next to be assigned permits and the number of available permits satisfies this request, * this Semaphore instance is destroyed, or * some other thread interrupts the current thread. :param permits: (int), the number of permits to acquire (optional). """ check_not_negative(permits, "Permits cannot be negative!") return self._encode_invoke(semaphore_acquire_codec, permits=permits)
python
def acquire(self, permits=1): """ Acquires one or specified amount of permits if available, and returns immediately, reducing the number of available permits by one or given amount. If insufficient permits are available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of following happens: * some other thread invokes one of the release methods for this semaphore, the current thread is next to be assigned permits and the number of available permits satisfies this request, * this Semaphore instance is destroyed, or * some other thread interrupts the current thread. :param permits: (int), the number of permits to acquire (optional). """ check_not_negative(permits, "Permits cannot be negative!") return self._encode_invoke(semaphore_acquire_codec, permits=permits)
[ "def", "acquire", "(", "self", ",", "permits", "=", "1", ")", ":", "check_not_negative", "(", "permits", ",", "\"Permits cannot be negative!\"", ")", "return", "self", ".", "_encode_invoke", "(", "semaphore_acquire_codec", ",", "permits", "=", "permits", ")" ]
Acquires one or specified amount of permits if available, and returns immediately, reducing the number of available permits by one or given amount. If insufficient permits are available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of following happens: * some other thread invokes one of the release methods for this semaphore, the current thread is next to be assigned permits and the number of available permits satisfies this request, * this Semaphore instance is destroyed, or * some other thread interrupts the current thread. :param permits: (int), the number of permits to acquire (optional).
[ "Acquires", "one", "or", "specified", "amount", "of", "permits", "if", "available", "and", "returns", "immediately", "reducing", "the", "number", "of", "available", "permits", "by", "one", "or", "given", "amount", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/semaphore.py#L43-L59
235,943
hazelcast/hazelcast-python-client
hazelcast/proxy/semaphore.py
Semaphore.reduce_permits
def reduce_permits(self, reduction): """ Shrinks the number of available permits by the indicated reduction. This method differs from acquire in that it does not block waiting for permits to become available. :param reduction: (int), the number of permits to remove. """ check_not_negative(reduction, "Reduction cannot be negative!") return self._encode_invoke(semaphore_reduce_permits_codec, reduction=reduction)
python
def reduce_permits(self, reduction): """ Shrinks the number of available permits by the indicated reduction. This method differs from acquire in that it does not block waiting for permits to become available. :param reduction: (int), the number of permits to remove. """ check_not_negative(reduction, "Reduction cannot be negative!") return self._encode_invoke(semaphore_reduce_permits_codec, reduction=reduction)
[ "def", "reduce_permits", "(", "self", ",", "reduction", ")", ":", "check_not_negative", "(", "reduction", ",", "\"Reduction cannot be negative!\"", ")", "return", "self", ".", "_encode_invoke", "(", "semaphore_reduce_permits_codec", ",", "reduction", "=", "reduction", ")" ]
Shrinks the number of available permits by the indicated reduction. This method differs from acquire in that it does not block waiting for permits to become available. :param reduction: (int), the number of permits to remove.
[ "Shrinks", "the", "number", "of", "available", "permits", "by", "the", "indicated", "reduction", ".", "This", "method", "differs", "from", "acquire", "in", "that", "it", "does", "not", "block", "waiting", "for", "permits", "to", "become", "available", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/semaphore.py#L78-L86
235,944
hazelcast/hazelcast-python-client
hazelcast/proxy/semaphore.py
Semaphore.release
def release(self, permits=1): """ Releases one or given number of permits, increasing the number of available permits by one or that amount. There is no requirement that a thread that releases a permit must have acquired that permit by calling one of the acquire methods. Correct usage of a semaphore is established by programming convention in the application. :param permits: (int), the number of permits to release (optional). """ check_not_negative(permits, "Permits cannot be negative!") return self._encode_invoke(semaphore_release_codec, permits=permits)
python
def release(self, permits=1): """ Releases one or given number of permits, increasing the number of available permits by one or that amount. There is no requirement that a thread that releases a permit must have acquired that permit by calling one of the acquire methods. Correct usage of a semaphore is established by programming convention in the application. :param permits: (int), the number of permits to release (optional). """ check_not_negative(permits, "Permits cannot be negative!") return self._encode_invoke(semaphore_release_codec, permits=permits)
[ "def", "release", "(", "self", ",", "permits", "=", "1", ")", ":", "check_not_negative", "(", "permits", ",", "\"Permits cannot be negative!\"", ")", "return", "self", ".", "_encode_invoke", "(", "semaphore_release_codec", ",", "permits", "=", "permits", ")" ]
Releases one or given number of permits, increasing the number of available permits by one or that amount. There is no requirement that a thread that releases a permit must have acquired that permit by calling one of the acquire methods. Correct usage of a semaphore is established by programming convention in the application. :param permits: (int), the number of permits to release (optional).
[ "Releases", "one", "or", "given", "number", "of", "permits", "increasing", "the", "number", "of", "available", "permits", "by", "one", "or", "that", "amount", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/semaphore.py#L88-L98
235,945
hazelcast/hazelcast-python-client
hazelcast/proxy/semaphore.py
Semaphore.try_acquire
def try_acquire(self, permits=1, timeout=0): """ Tries to acquire one or the given number of permits, if they are available, and returns immediately, with the value ``true``, reducing the number of available permits by the given amount. If there are insufficient permits and a timeout is provided, the current thread becomes disabled for thread scheduling purposes and lies dormant until one of following happens: * some other thread invokes the release() method for this semaphore and the current thread is next to be assigned a permit, or * some other thread interrupts the current thread, or * the specified waiting time elapses. If there are insufficient permits and no timeout is provided, this method will return immediately with the value ``false`` and the number of available permits is unchanged. :param permits: (int), the number of permits to acquire (optional). :param timeout: (long), the maximum time in seconds to wait for the permit(s) (optional). :return: (bool), ``true`` if desired amount of permits was acquired, ``false`` otherwise. """ check_not_negative(permits, "Permits cannot be negative!") return self._encode_invoke(semaphore_try_acquire_codec, permits=permits, timeout=to_millis(timeout))
python
def try_acquire(self, permits=1, timeout=0): """ Tries to acquire one or the given number of permits, if they are available, and returns immediately, with the value ``true``, reducing the number of available permits by the given amount. If there are insufficient permits and a timeout is provided, the current thread becomes disabled for thread scheduling purposes and lies dormant until one of following happens: * some other thread invokes the release() method for this semaphore and the current thread is next to be assigned a permit, or * some other thread interrupts the current thread, or * the specified waiting time elapses. If there are insufficient permits and no timeout is provided, this method will return immediately with the value ``false`` and the number of available permits is unchanged. :param permits: (int), the number of permits to acquire (optional). :param timeout: (long), the maximum time in seconds to wait for the permit(s) (optional). :return: (bool), ``true`` if desired amount of permits was acquired, ``false`` otherwise. """ check_not_negative(permits, "Permits cannot be negative!") return self._encode_invoke(semaphore_try_acquire_codec, permits=permits, timeout=to_millis(timeout))
[ "def", "try_acquire", "(", "self", ",", "permits", "=", "1", ",", "timeout", "=", "0", ")", ":", "check_not_negative", "(", "permits", ",", "\"Permits cannot be negative!\"", ")", "return", "self", ".", "_encode_invoke", "(", "semaphore_try_acquire_codec", ",", "permits", "=", "permits", ",", "timeout", "=", "to_millis", "(", "timeout", ")", ")" ]
Tries to acquire one or the given number of permits, if they are available, and returns immediately, with the value ``true``, reducing the number of available permits by the given amount. If there are insufficient permits and a timeout is provided, the current thread becomes disabled for thread scheduling purposes and lies dormant until one of following happens: * some other thread invokes the release() method for this semaphore and the current thread is next to be assigned a permit, or * some other thread interrupts the current thread, or * the specified waiting time elapses. If there are insufficient permits and no timeout is provided, this method will return immediately with the value ``false`` and the number of available permits is unchanged. :param permits: (int), the number of permits to acquire (optional). :param timeout: (long), the maximum time in seconds to wait for the permit(s) (optional). :return: (bool), ``true`` if desired amount of permits was acquired, ``false`` otherwise.
[ "Tries", "to", "acquire", "one", "or", "the", "given", "number", "of", "permits", "if", "they", "are", "available", "and", "returns", "immediately", "with", "the", "value", "true", "reducing", "the", "number", "of", "available", "permits", "by", "the", "given", "amount", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/semaphore.py#L100-L120
235,946
hazelcast/hazelcast-python-client
hazelcast/config.py
ClientConfig.add_membership_listener
def add_membership_listener(self, member_added=None, member_removed=None, fire_for_existing=False): """ Helper method for adding membership listeners :param member_added: (Function), Function to be called when a member is added, in the form of f(member) (optional). :param member_removed: (Function), Function to be called when a member is removed, in the form of f(member) (optional). :param fire_for_existing: if True, already existing members will fire member_added event (optional). :return: `self` for cascading configuration """ self.membership_listeners.append((member_added, member_removed, fire_for_existing)) return self
python
def add_membership_listener(self, member_added=None, member_removed=None, fire_for_existing=False): """ Helper method for adding membership listeners :param member_added: (Function), Function to be called when a member is added, in the form of f(member) (optional). :param member_removed: (Function), Function to be called when a member is removed, in the form of f(member) (optional). :param fire_for_existing: if True, already existing members will fire member_added event (optional). :return: `self` for cascading configuration """ self.membership_listeners.append((member_added, member_removed, fire_for_existing)) return self
[ "def", "add_membership_listener", "(", "self", ",", "member_added", "=", "None", ",", "member_removed", "=", "None", ",", "fire_for_existing", "=", "False", ")", ":", "self", ".", "membership_listeners", ".", "append", "(", "(", "member_added", ",", "member_removed", ",", "fire_for_existing", ")", ")", "return", "self" ]
Helper method for adding membership listeners :param member_added: (Function), Function to be called when a member is added, in the form of f(member) (optional). :param member_removed: (Function), Function to be called when a member is removed, in the form of f(member) (optional). :param fire_for_existing: if True, already existing members will fire member_added event (optional). :return: `self` for cascading configuration
[ "Helper", "method", "for", "adding", "membership", "listeners" ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/config.py#L119-L131
235,947
hazelcast/hazelcast-python-client
hazelcast/config.py
SerializationConfig.set_custom_serializer
def set_custom_serializer(self, _type, serializer): """ Assign a serializer for the type. :param _type: (Type), the target type of the serializer :param serializer: (Serializer), Custom Serializer constructor function """ validate_type(_type) validate_serializer(serializer, StreamSerializer) self._custom_serializers[_type] = serializer
python
def set_custom_serializer(self, _type, serializer): """ Assign a serializer for the type. :param _type: (Type), the target type of the serializer :param serializer: (Serializer), Custom Serializer constructor function """ validate_type(_type) validate_serializer(serializer, StreamSerializer) self._custom_serializers[_type] = serializer
[ "def", "set_custom_serializer", "(", "self", ",", "_type", ",", "serializer", ")", ":", "validate_type", "(", "_type", ")", "validate_serializer", "(", "serializer", ",", "StreamSerializer", ")", "self", ".", "_custom_serializers", "[", "_type", "]", "=", "serializer" ]
Assign a serializer for the type. :param _type: (Type), the target type of the serializer :param serializer: (Serializer), Custom Serializer constructor function
[ "Assign", "a", "serializer", "for", "the", "type", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/config.py#L354-L363
235,948
hazelcast/hazelcast-python-client
hazelcast/config.py
ClientProperties.get
def get(self, property): """ Gets the value of the given property. First checks client config properties, then environment variables and lastly fall backs to the default value of the property. :param property: (:class:`~hazelcast.config.ClientProperty`), Property to get value from :return: Value of the given property """ return self._properties.get(property.name) or os.getenv(property.name) or property.default_value
python
def get(self, property): """ Gets the value of the given property. First checks client config properties, then environment variables and lastly fall backs to the default value of the property. :param property: (:class:`~hazelcast.config.ClientProperty`), Property to get value from :return: Value of the given property """ return self._properties.get(property.name) or os.getenv(property.name) or property.default_value
[ "def", "get", "(", "self", ",", "property", ")", ":", "return", "self", ".", "_properties", ".", "get", "(", "property", ".", "name", ")", "or", "os", ".", "getenv", "(", "property", ".", "name", ")", "or", "property", ".", "default_value" ]
Gets the value of the given property. First checks client config properties, then environment variables and lastly fall backs to the default value of the property. :param property: (:class:`~hazelcast.config.ClientProperty`), Property to get value from :return: Value of the given property
[ "Gets", "the", "value", "of", "the", "given", "property", ".", "First", "checks", "client", "config", "properties", "then", "environment", "variables", "and", "lastly", "fall", "backs", "to", "the", "default", "value", "of", "the", "property", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/config.py#L712-L720
235,949
hazelcast/hazelcast-python-client
hazelcast/config.py
ClientProperties.get_bool
def get_bool(self, property): """ Gets the value of the given property as boolean. :param property: (:class:`~hazelcast.config.ClientProperty`), Property to get value from :return: (bool), Value of the given property """ value = self.get(property) if isinstance(value, bool): return value return value.lower() == "true"
python
def get_bool(self, property): """ Gets the value of the given property as boolean. :param property: (:class:`~hazelcast.config.ClientProperty`), Property to get value from :return: (bool), Value of the given property """ value = self.get(property) if isinstance(value, bool): return value return value.lower() == "true"
[ "def", "get_bool", "(", "self", ",", "property", ")", ":", "value", "=", "self", ".", "get", "(", "property", ")", "if", "isinstance", "(", "value", ",", "bool", ")", ":", "return", "value", "return", "value", ".", "lower", "(", ")", "==", "\"true\"" ]
Gets the value of the given property as boolean. :param property: (:class:`~hazelcast.config.ClientProperty`), Property to get value from :return: (bool), Value of the given property
[ "Gets", "the", "value", "of", "the", "given", "property", "as", "boolean", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/config.py#L722-L732
235,950
hazelcast/hazelcast-python-client
hazelcast/config.py
ClientProperties.get_seconds
def get_seconds(self, property): """ Gets the value of the given property in seconds. If the value of the given property is not a number, throws TypeError. :param property: (:class:`~hazelcast.config.ClientProperty`), Property to get seconds from :return: (float), Value of the given property in seconds """ return TimeUnit.to_seconds(self.get(property), property.time_unit)
python
def get_seconds(self, property): """ Gets the value of the given property in seconds. If the value of the given property is not a number, throws TypeError. :param property: (:class:`~hazelcast.config.ClientProperty`), Property to get seconds from :return: (float), Value of the given property in seconds """ return TimeUnit.to_seconds(self.get(property), property.time_unit)
[ "def", "get_seconds", "(", "self", ",", "property", ")", ":", "return", "TimeUnit", ".", "to_seconds", "(", "self", ".", "get", "(", "property", ")", ",", "property", ".", "time_unit", ")" ]
Gets the value of the given property in seconds. If the value of the given property is not a number, throws TypeError. :param property: (:class:`~hazelcast.config.ClientProperty`), Property to get seconds from :return: (float), Value of the given property in seconds
[ "Gets", "the", "value", "of", "the", "given", "property", "in", "seconds", ".", "If", "the", "value", "of", "the", "given", "property", "is", "not", "a", "number", "throws", "TypeError", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/config.py#L734-L742
235,951
hazelcast/hazelcast-python-client
hazelcast/config.py
ClientProperties.get_seconds_positive_or_default
def get_seconds_positive_or_default(self, property): """ Gets the value of the given property in seconds. If the value of the given property is not a number, throws TypeError. If the value of the given property in seconds is not positive, tries to return the default value in seconds. :param property: (:class:`~hazelcast.config.ClientProperty`), Property to get seconds from :return: (float), Value of the given property in seconds if it is positive. Else, value of the default value of given property in seconds. """ seconds = self.get_seconds(property) return seconds if seconds > 0 else TimeUnit.to_seconds(property.default_value, property.time_unit)
python
def get_seconds_positive_or_default(self, property): """ Gets the value of the given property in seconds. If the value of the given property is not a number, throws TypeError. If the value of the given property in seconds is not positive, tries to return the default value in seconds. :param property: (:class:`~hazelcast.config.ClientProperty`), Property to get seconds from :return: (float), Value of the given property in seconds if it is positive. Else, value of the default value of given property in seconds. """ seconds = self.get_seconds(property) return seconds if seconds > 0 else TimeUnit.to_seconds(property.default_value, property.time_unit)
[ "def", "get_seconds_positive_or_default", "(", "self", ",", "property", ")", ":", "seconds", "=", "self", ".", "get_seconds", "(", "property", ")", "return", "seconds", "if", "seconds", ">", "0", "else", "TimeUnit", ".", "to_seconds", "(", "property", ".", "default_value", ",", "property", ".", "time_unit", ")" ]
Gets the value of the given property in seconds. If the value of the given property is not a number, throws TypeError. If the value of the given property in seconds is not positive, tries to return the default value in seconds. :param property: (:class:`~hazelcast.config.ClientProperty`), Property to get seconds from :return: (float), Value of the given property in seconds if it is positive. Else, value of the default value of given property in seconds.
[ "Gets", "the", "value", "of", "the", "given", "property", "in", "seconds", ".", "If", "the", "value", "of", "the", "given", "property", "is", "not", "a", "number", "throws", "TypeError", ".", "If", "the", "value", "of", "the", "given", "property", "in", "seconds", "is", "not", "positive", "tries", "to", "return", "the", "default", "value", "in", "seconds", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/config.py#L744-L755
235,952
hazelcast/hazelcast-python-client
hazelcast/partition.py
PartitionService.start
def start(self): """ Starts the partition service. """ self.logger.debug("Starting partition service", extra=self._logger_extras) def partition_updater(): self._do_refresh() self.timer = self._client.reactor.add_timer(PARTITION_UPDATE_INTERVAL, partition_updater) self.timer = self._client.reactor.add_timer(PARTITION_UPDATE_INTERVAL, partition_updater)
python
def start(self): """ Starts the partition service. """ self.logger.debug("Starting partition service", extra=self._logger_extras) def partition_updater(): self._do_refresh() self.timer = self._client.reactor.add_timer(PARTITION_UPDATE_INTERVAL, partition_updater) self.timer = self._client.reactor.add_timer(PARTITION_UPDATE_INTERVAL, partition_updater)
[ "def", "start", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Starting partition service\"", ",", "extra", "=", "self", ".", "_logger_extras", ")", "def", "partition_updater", "(", ")", ":", "self", ".", "_do_refresh", "(", ")", "self", ".", "timer", "=", "self", ".", "_client", ".", "reactor", ".", "add_timer", "(", "PARTITION_UPDATE_INTERVAL", ",", "partition_updater", ")", "self", ".", "timer", "=", "self", ".", "_client", ".", "reactor", ".", "add_timer", "(", "PARTITION_UPDATE_INTERVAL", ",", "partition_updater", ")" ]
Starts the partition service.
[ "Starts", "the", "partition", "service", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/partition.py#L23-L33
235,953
hazelcast/hazelcast-python-client
hazelcast/partition.py
PartitionService.get_partition_owner
def get_partition_owner(self, partition_id): """ Gets the owner of the partition if it's set. Otherwise it will trigger partition assignment. :param partition_id: (int), the partition id. :return: (:class:`~hazelcast.core.Address`), owner of partition or ``None`` if it's not set yet. """ if partition_id not in self.partitions: self._do_refresh() return self.partitions.get(partition_id, None)
python
def get_partition_owner(self, partition_id): """ Gets the owner of the partition if it's set. Otherwise it will trigger partition assignment. :param partition_id: (int), the partition id. :return: (:class:`~hazelcast.core.Address`), owner of partition or ``None`` if it's not set yet. """ if partition_id not in self.partitions: self._do_refresh() return self.partitions.get(partition_id, None)
[ "def", "get_partition_owner", "(", "self", ",", "partition_id", ")", ":", "if", "partition_id", "not", "in", "self", ".", "partitions", ":", "self", ".", "_do_refresh", "(", ")", "return", "self", ".", "partitions", ".", "get", "(", "partition_id", ",", "None", ")" ]
Gets the owner of the partition if it's set. Otherwise it will trigger partition assignment. :param partition_id: (int), the partition id. :return: (:class:`~hazelcast.core.Address`), owner of partition or ``None`` if it's not set yet.
[ "Gets", "the", "owner", "of", "the", "partition", "if", "it", "s", "set", ".", "Otherwise", "it", "will", "trigger", "partition", "assignment", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/partition.py#L48-L57
235,954
hazelcast/hazelcast-python-client
hazelcast/partition.py
PartitionService.get_partition_id
def get_partition_id(self, key): """ Returns the partition id for a Data key. :param key: (object), the data key. :return: (int), the partition id. """ data = self._client.serialization_service.to_data(key) count = self.get_partition_count() if count <= 0: return 0 return hash_to_index(data.get_partition_hash(), count)
python
def get_partition_id(self, key): """ Returns the partition id for a Data key. :param key: (object), the data key. :return: (int), the partition id. """ data = self._client.serialization_service.to_data(key) count = self.get_partition_count() if count <= 0: return 0 return hash_to_index(data.get_partition_hash(), count)
[ "def", "get_partition_id", "(", "self", ",", "key", ")", ":", "data", "=", "self", ".", "_client", ".", "serialization_service", ".", "to_data", "(", "key", ")", "count", "=", "self", ".", "get_partition_count", "(", ")", "if", "count", "<=", "0", ":", "return", "0", "return", "hash_to_index", "(", "data", ".", "get_partition_hash", "(", ")", ",", "count", ")" ]
Returns the partition id for a Data key. :param key: (object), the data key. :return: (int), the partition id.
[ "Returns", "the", "partition", "id", "for", "a", "Data", "key", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/partition.py#L59-L70
235,955
hazelcast/hazelcast-python-client
hazelcast/hash.py
murmur_hash3_x86_32
def murmur_hash3_x86_32(data, offset, size, seed=0x01000193): """ murmur3 hash function to determine partition :param data: (byte array), input byte array :param offset: (long), offset. :param size: (long), byte length. :param seed: murmur hash seed hazelcast uses 0x01000193 :return: (int32), calculated hash value. """ key = bytearray(data[offset: offset + size]) length = len(key) nblocks = int(length / 4) h1 = seed c1 = 0xcc9e2d51 c2 = 0x1b873593 # body for block_start in range(0, nblocks * 4, 4): # ??? big endian? k1 = key[block_start + 3] << 24 | \ key[block_start + 2] << 16 | \ key[block_start + 1] << 8 | \ key[block_start + 0] k1 = c1 * k1 & 0xFFFFFFFF k1 = (k1 << 15 | k1 >> 17) & 0xFFFFFFFF # inlined ROTL32 k1 = (c2 * k1) & 0xFFFFFFFF h1 ^= k1 h1 = (h1 << 13 | h1 >> 19) & 0xFFFFFFFF # inlined _ROTL32 h1 = (h1 * 5 + 0xe6546b64) & 0xFFFFFFFF # tail tail_index = nblocks * 4 k1 = 0 tail_size = length & 3 if tail_size >= 3: k1 ^= key[tail_index + 2] << 16 if tail_size >= 2: k1 ^= key[tail_index + 1] << 8 if tail_size >= 1: k1 ^= key[tail_index + 0] if tail_size != 0: k1 = (k1 * c1) & 0xFFFFFFFF k1 = (k1 << 15 | k1 >> 17) & 0xFFFFFFFF # _ROTL32 k1 = (k1 * c2) & 0xFFFFFFFF h1 ^= k1 result = _fmix(h1 ^ length) return -(result & 0x80000000) | (result & 0x7FFFFFFF)
python
def murmur_hash3_x86_32(data, offset, size, seed=0x01000193): """ murmur3 hash function to determine partition :param data: (byte array), input byte array :param offset: (long), offset. :param size: (long), byte length. :param seed: murmur hash seed hazelcast uses 0x01000193 :return: (int32), calculated hash value. """ key = bytearray(data[offset: offset + size]) length = len(key) nblocks = int(length / 4) h1 = seed c1 = 0xcc9e2d51 c2 = 0x1b873593 # body for block_start in range(0, nblocks * 4, 4): # ??? big endian? k1 = key[block_start + 3] << 24 | \ key[block_start + 2] << 16 | \ key[block_start + 1] << 8 | \ key[block_start + 0] k1 = c1 * k1 & 0xFFFFFFFF k1 = (k1 << 15 | k1 >> 17) & 0xFFFFFFFF # inlined ROTL32 k1 = (c2 * k1) & 0xFFFFFFFF h1 ^= k1 h1 = (h1 << 13 | h1 >> 19) & 0xFFFFFFFF # inlined _ROTL32 h1 = (h1 * 5 + 0xe6546b64) & 0xFFFFFFFF # tail tail_index = nblocks * 4 k1 = 0 tail_size = length & 3 if tail_size >= 3: k1 ^= key[tail_index + 2] << 16 if tail_size >= 2: k1 ^= key[tail_index + 1] << 8 if tail_size >= 1: k1 ^= key[tail_index + 0] if tail_size != 0: k1 = (k1 * c1) & 0xFFFFFFFF k1 = (k1 << 15 | k1 >> 17) & 0xFFFFFFFF # _ROTL32 k1 = (k1 * c2) & 0xFFFFFFFF h1 ^= k1 result = _fmix(h1 ^ length) return -(result & 0x80000000) | (result & 0x7FFFFFFF)
[ "def", "murmur_hash3_x86_32", "(", "data", ",", "offset", ",", "size", ",", "seed", "=", "0x01000193", ")", ":", "key", "=", "bytearray", "(", "data", "[", "offset", ":", "offset", "+", "size", "]", ")", "length", "=", "len", "(", "key", ")", "nblocks", "=", "int", "(", "length", "/", "4", ")", "h1", "=", "seed", "c1", "=", "0xcc9e2d51", "c2", "=", "0x1b873593", "# body", "for", "block_start", "in", "range", "(", "0", ",", "nblocks", "*", "4", ",", "4", ")", ":", "# ??? big endian?", "k1", "=", "key", "[", "block_start", "+", "3", "]", "<<", "24", "|", "key", "[", "block_start", "+", "2", "]", "<<", "16", "|", "key", "[", "block_start", "+", "1", "]", "<<", "8", "|", "key", "[", "block_start", "+", "0", "]", "k1", "=", "c1", "*", "k1", "&", "0xFFFFFFFF", "k1", "=", "(", "k1", "<<", "15", "|", "k1", ">>", "17", ")", "&", "0xFFFFFFFF", "# inlined ROTL32", "k1", "=", "(", "c2", "*", "k1", ")", "&", "0xFFFFFFFF", "h1", "^=", "k1", "h1", "=", "(", "h1", "<<", "13", "|", "h1", ">>", "19", ")", "&", "0xFFFFFFFF", "# inlined _ROTL32", "h1", "=", "(", "h1", "*", "5", "+", "0xe6546b64", ")", "&", "0xFFFFFFFF", "# tail", "tail_index", "=", "nblocks", "*", "4", "k1", "=", "0", "tail_size", "=", "length", "&", "3", "if", "tail_size", ">=", "3", ":", "k1", "^=", "key", "[", "tail_index", "+", "2", "]", "<<", "16", "if", "tail_size", ">=", "2", ":", "k1", "^=", "key", "[", "tail_index", "+", "1", "]", "<<", "8", "if", "tail_size", ">=", "1", ":", "k1", "^=", "key", "[", "tail_index", "+", "0", "]", "if", "tail_size", "!=", "0", ":", "k1", "=", "(", "k1", "*", "c1", ")", "&", "0xFFFFFFFF", "k1", "=", "(", "k1", "<<", "15", "|", "k1", ">>", "17", ")", "&", "0xFFFFFFFF", "# _ROTL32", "k1", "=", "(", "k1", "*", "c2", ")", "&", "0xFFFFFFFF", "h1", "^=", "k1", "result", "=", "_fmix", "(", "h1", "^", "length", ")", "return", "-", "(", "result", "&", "0x80000000", ")", "|", "(", "result", "&", "0x7FFFFFFF", ")" ]
murmur3 hash function to determine partition :param data: (byte array), input byte array :param offset: (long), offset. :param size: (long), byte length. :param seed: murmur hash seed hazelcast uses 0x01000193 :return: (int32), calculated hash value.
[ "murmur3", "hash", "function", "to", "determine", "partition" ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/hash.py#L13-L67
235,956
hazelcast/hazelcast-python-client
hazelcast/proxy/list.py
List.add
def add(self, item): """ Adds the specified item to the end of this list. :param item: (object), the specified item to be appended to this list. :return: (bool), ``true`` if item is added, ``false`` otherwise. """ check_not_none(item, "Value can't be None") element_data = self._to_data(item) return self._encode_invoke(list_add_codec, value=element_data)
python
def add(self, item): """ Adds the specified item to the end of this list. :param item: (object), the specified item to be appended to this list. :return: (bool), ``true`` if item is added, ``false`` otherwise. """ check_not_none(item, "Value can't be None") element_data = self._to_data(item) return self._encode_invoke(list_add_codec, value=element_data)
[ "def", "add", "(", "self", ",", "item", ")", ":", "check_not_none", "(", "item", ",", "\"Value can't be None\"", ")", "element_data", "=", "self", ".", "_to_data", "(", "item", ")", "return", "self", ".", "_encode_invoke", "(", "list_add_codec", ",", "value", "=", "element_data", ")" ]
Adds the specified item to the end of this list. :param item: (object), the specified item to be appended to this list. :return: (bool), ``true`` if item is added, ``false`` otherwise.
[ "Adds", "the", "specified", "item", "to", "the", "end", "of", "this", "list", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/list.py#L35-L44
235,957
hazelcast/hazelcast-python-client
hazelcast/proxy/list.py
List.add_at
def add_at(self, index, item): """ Adds the specified item at the specific position in this list. Element in this position and following elements are shifted to the right, if any. :param index: (int), the specified index to insert the item. :param item: (object), the specified item to be inserted. """ check_not_none(item, "Value can't be None") element_data = self._to_data(item) return self._encode_invoke(list_add_with_index_codec, index=index, value=element_data)
python
def add_at(self, index, item): """ Adds the specified item at the specific position in this list. Element in this position and following elements are shifted to the right, if any. :param index: (int), the specified index to insert the item. :param item: (object), the specified item to be inserted. """ check_not_none(item, "Value can't be None") element_data = self._to_data(item) return self._encode_invoke(list_add_with_index_codec, index=index, value=element_data)
[ "def", "add_at", "(", "self", ",", "index", ",", "item", ")", ":", "check_not_none", "(", "item", ",", "\"Value can't be None\"", ")", "element_data", "=", "self", ".", "_to_data", "(", "item", ")", "return", "self", ".", "_encode_invoke", "(", "list_add_with_index_codec", ",", "index", "=", "index", ",", "value", "=", "element_data", ")" ]
Adds the specified item at the specific position in this list. Element in this position and following elements are shifted to the right, if any. :param index: (int), the specified index to insert the item. :param item: (object), the specified item to be inserted.
[ "Adds", "the", "specified", "item", "at", "the", "specific", "position", "in", "this", "list", ".", "Element", "in", "this", "position", "and", "following", "elements", "are", "shifted", "to", "the", "right", "if", "any", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/list.py#L46-L56
235,958
hazelcast/hazelcast-python-client
hazelcast/proxy/list.py
List.add_all
def add_all(self, items): """ Adds all of the items in the specified collection to the end of this list. The order of new elements is determined by the specified collection's iterator. :param items: (Collection), the specified collection which includes the elements to be added to list. :return: (bool), ``true`` if this call changed the list, ``false`` otherwise. """ check_not_none(items, "Value can't be None") data_items = [] for item in items: check_not_none(item, "Value can't be None") data_items.append(self._to_data(item)) return self._encode_invoke(list_add_all_codec, value_list=data_items)
python
def add_all(self, items): """ Adds all of the items in the specified collection to the end of this list. The order of new elements is determined by the specified collection's iterator. :param items: (Collection), the specified collection which includes the elements to be added to list. :return: (bool), ``true`` if this call changed the list, ``false`` otherwise. """ check_not_none(items, "Value can't be None") data_items = [] for item in items: check_not_none(item, "Value can't be None") data_items.append(self._to_data(item)) return self._encode_invoke(list_add_all_codec, value_list=data_items)
[ "def", "add_all", "(", "self", ",", "items", ")", ":", "check_not_none", "(", "items", ",", "\"Value can't be None\"", ")", "data_items", "=", "[", "]", "for", "item", "in", "items", ":", "check_not_none", "(", "item", ",", "\"Value can't be None\"", ")", "data_items", ".", "append", "(", "self", ".", "_to_data", "(", "item", ")", ")", "return", "self", ".", "_encode_invoke", "(", "list_add_all_codec", ",", "value_list", "=", "data_items", ")" ]
Adds all of the items in the specified collection to the end of this list. The order of new elements is determined by the specified collection's iterator. :param items: (Collection), the specified collection which includes the elements to be added to list. :return: (bool), ``true`` if this call changed the list, ``false`` otherwise.
[ "Adds", "all", "of", "the", "items", "in", "the", "specified", "collection", "to", "the", "end", "of", "this", "list", ".", "The", "order", "of", "new", "elements", "is", "determined", "by", "the", "specified", "collection", "s", "iterator", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/list.py#L58-L71
235,959
hazelcast/hazelcast-python-client
hazelcast/proxy/list.py
List.add_all_at
def add_all_at(self, index, items): """ Adds all of the elements in the specified collection into this list at the specified position. Elements in this positions and following elements are shifted to the right, if any. The order of new elements is determined by the specified collection's iterator. :param index: (int), the specified index at which the first element of specified collection is added. :param items: (Collection), the specified collection which includes the elements to be added to list. :return: (bool), ``true`` if this call changed the list, ``false`` otherwise. """ check_not_none(items, "Value can't be None") data_items = [] for item in items: check_not_none(item, "Value can't be None") data_items.append(self._to_data(item)) return self._encode_invoke(list_add_all_with_index_codec, index=index, value_list=data_items)
python
def add_all_at(self, index, items): """ Adds all of the elements in the specified collection into this list at the specified position. Elements in this positions and following elements are shifted to the right, if any. The order of new elements is determined by the specified collection's iterator. :param index: (int), the specified index at which the first element of specified collection is added. :param items: (Collection), the specified collection which includes the elements to be added to list. :return: (bool), ``true`` if this call changed the list, ``false`` otherwise. """ check_not_none(items, "Value can't be None") data_items = [] for item in items: check_not_none(item, "Value can't be None") data_items.append(self._to_data(item)) return self._encode_invoke(list_add_all_with_index_codec, index=index, value_list=data_items)
[ "def", "add_all_at", "(", "self", ",", "index", ",", "items", ")", ":", "check_not_none", "(", "items", ",", "\"Value can't be None\"", ")", "data_items", "=", "[", "]", "for", "item", "in", "items", ":", "check_not_none", "(", "item", ",", "\"Value can't be None\"", ")", "data_items", ".", "append", "(", "self", ".", "_to_data", "(", "item", ")", ")", "return", "self", ".", "_encode_invoke", "(", "list_add_all_with_index_codec", ",", "index", "=", "index", ",", "value_list", "=", "data_items", ")" ]
Adds all of the elements in the specified collection into this list at the specified position. Elements in this positions and following elements are shifted to the right, if any. The order of new elements is determined by the specified collection's iterator. :param index: (int), the specified index at which the first element of specified collection is added. :param items: (Collection), the specified collection which includes the elements to be added to list. :return: (bool), ``true`` if this call changed the list, ``false`` otherwise.
[ "Adds", "all", "of", "the", "elements", "in", "the", "specified", "collection", "into", "this", "list", "at", "the", "specified", "position", ".", "Elements", "in", "this", "positions", "and", "following", "elements", "are", "shifted", "to", "the", "right", "if", "any", ".", "The", "order", "of", "new", "elements", "is", "determined", "by", "the", "specified", "collection", "s", "iterator", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/list.py#L73-L88
235,960
hazelcast/hazelcast-python-client
hazelcast/proxy/list.py
List.contains_all
def contains_all(self, items): """ Determines whether this list contains all of the items in specified collection or not. :param items: (Collection), the specified collection which includes the items to be searched. :return: (bool), ``true`` if all of the items in specified collection exist in this list, ``false`` otherwise. """ check_not_none(items, "Items can't be None") data_items = [] for item in items: check_not_none(item, "item can't be None") data_items.append(self._to_data(item)) return self._encode_invoke(list_contains_all_codec, values=data_items)
python
def contains_all(self, items): """ Determines whether this list contains all of the items in specified collection or not. :param items: (Collection), the specified collection which includes the items to be searched. :return: (bool), ``true`` if all of the items in specified collection exist in this list, ``false`` otherwise. """ check_not_none(items, "Items can't be None") data_items = [] for item in items: check_not_none(item, "item can't be None") data_items.append(self._to_data(item)) return self._encode_invoke(list_contains_all_codec, values=data_items)
[ "def", "contains_all", "(", "self", ",", "items", ")", ":", "check_not_none", "(", "items", ",", "\"Items can't be None\"", ")", "data_items", "=", "[", "]", "for", "item", "in", "items", ":", "check_not_none", "(", "item", ",", "\"item can't be None\"", ")", "data_items", ".", "append", "(", "self", ".", "_to_data", "(", "item", ")", ")", "return", "self", ".", "_encode_invoke", "(", "list_contains_all_codec", ",", "values", "=", "data_items", ")" ]
Determines whether this list contains all of the items in specified collection or not. :param items: (Collection), the specified collection which includes the items to be searched. :return: (bool), ``true`` if all of the items in specified collection exist in this list, ``false`` otherwise.
[ "Determines", "whether", "this", "list", "contains", "all", "of", "the", "items", "in", "specified", "collection", "or", "not", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/list.py#L135-L147
235,961
hazelcast/hazelcast-python-client
hazelcast/proxy/list.py
List.index_of
def index_of(self, item): """ Returns the first index of specified items's occurrences in this list. If specified item is not present in this list, returns -1. :param item: (object), the specified item to be searched for. :return: (int), the first index of specified items's occurrences, -1 if item is not present in this list. """ check_not_none(item, "Value can't be None") item_data = self._to_data(item) return self._encode_invoke(list_index_of_codec, value=item_data)
python
def index_of(self, item): """ Returns the first index of specified items's occurrences in this list. If specified item is not present in this list, returns -1. :param item: (object), the specified item to be searched for. :return: (int), the first index of specified items's occurrences, -1 if item is not present in this list. """ check_not_none(item, "Value can't be None") item_data = self._to_data(item) return self._encode_invoke(list_index_of_codec, value=item_data)
[ "def", "index_of", "(", "self", ",", "item", ")", ":", "check_not_none", "(", "item", ",", "\"Value can't be None\"", ")", "item_data", "=", "self", ".", "_to_data", "(", "item", ")", "return", "self", ".", "_encode_invoke", "(", "list_index_of_codec", ",", "value", "=", "item_data", ")" ]
Returns the first index of specified items's occurrences in this list. If specified item is not present in this list, returns -1. :param item: (object), the specified item to be searched for. :return: (int), the first index of specified items's occurrences, -1 if item is not present in this list.
[ "Returns", "the", "first", "index", "of", "specified", "items", "s", "occurrences", "in", "this", "list", ".", "If", "specified", "item", "is", "not", "present", "in", "this", "list", "returns", "-", "1", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/list.py#L174-L184
235,962
hazelcast/hazelcast-python-client
hazelcast/proxy/list.py
List.last_index_of
def last_index_of(self, item): """ Returns the last index of specified items's occurrences in this list. If specified item is not present in this list, returns -1. :param item: (object), the specified item to be searched for. :return: (int), the last index of specified items's occurrences, -1 if item is not present in this list. """ check_not_none(item, "Value can't be None") item_data = self._to_data(item) return self._encode_invoke(list_last_index_of_codec, value=item_data)
python
def last_index_of(self, item): """ Returns the last index of specified items's occurrences in this list. If specified item is not present in this list, returns -1. :param item: (object), the specified item to be searched for. :return: (int), the last index of specified items's occurrences, -1 if item is not present in this list. """ check_not_none(item, "Value can't be None") item_data = self._to_data(item) return self._encode_invoke(list_last_index_of_codec, value=item_data)
[ "def", "last_index_of", "(", "self", ",", "item", ")", ":", "check_not_none", "(", "item", ",", "\"Value can't be None\"", ")", "item_data", "=", "self", ".", "_to_data", "(", "item", ")", "return", "self", ".", "_encode_invoke", "(", "list_last_index_of_codec", ",", "value", "=", "item_data", ")" ]
Returns the last index of specified items's occurrences in this list. If specified item is not present in this list, returns -1. :param item: (object), the specified item to be searched for. :return: (int), the last index of specified items's occurrences, -1 if item is not present in this list.
[ "Returns", "the", "last", "index", "of", "specified", "items", "s", "occurrences", "in", "this", "list", ".", "If", "specified", "item", "is", "not", "present", "in", "this", "list", "returns", "-", "1", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/list.py#L194-L204
235,963
hazelcast/hazelcast-python-client
hazelcast/proxy/list.py
List.remove
def remove(self, item): """ Removes the specified element's first occurrence from the list if it exists in this list. :param item: (object), the specified element. :return: (bool), ``true`` if the specified element is present in this list. """ check_not_none(item, "Value can't be None") item_data = self._to_data(item) return self._encode_invoke(list_remove_codec, value=item_data)
python
def remove(self, item): """ Removes the specified element's first occurrence from the list if it exists in this list. :param item: (object), the specified element. :return: (bool), ``true`` if the specified element is present in this list. """ check_not_none(item, "Value can't be None") item_data = self._to_data(item) return self._encode_invoke(list_remove_codec, value=item_data)
[ "def", "remove", "(", "self", ",", "item", ")", ":", "check_not_none", "(", "item", ",", "\"Value can't be None\"", ")", "item_data", "=", "self", ".", "_to_data", "(", "item", ")", "return", "self", ".", "_encode_invoke", "(", "list_remove_codec", ",", "value", "=", "item_data", ")" ]
Removes the specified element's first occurrence from the list if it exists in this list. :param item: (object), the specified element. :return: (bool), ``true`` if the specified element is present in this list.
[ "Removes", "the", "specified", "element", "s", "first", "occurrence", "from", "the", "list", "if", "it", "exists", "in", "this", "list", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/list.py#L215-L224
235,964
hazelcast/hazelcast-python-client
hazelcast/proxy/list.py
List.remove_all
def remove_all(self, items): """ Removes all of the elements that is present in the specified collection from this list. :param items: (Collection), the specified collection. :return: (bool), ``true`` if this list changed as a result of the call. """ check_not_none(items, "Value can't be None") data_items = [] for item in items: check_not_none(item, "Value can't be None") data_items.append(self._to_data(item)) return self._encode_invoke(list_compare_and_remove_all_codec, values=data_items)
python
def remove_all(self, items): """ Removes all of the elements that is present in the specified collection from this list. :param items: (Collection), the specified collection. :return: (bool), ``true`` if this list changed as a result of the call. """ check_not_none(items, "Value can't be None") data_items = [] for item in items: check_not_none(item, "Value can't be None") data_items.append(self._to_data(item)) return self._encode_invoke(list_compare_and_remove_all_codec, values=data_items)
[ "def", "remove_all", "(", "self", ",", "items", ")", ":", "check_not_none", "(", "items", ",", "\"Value can't be None\"", ")", "data_items", "=", "[", "]", "for", "item", "in", "items", ":", "check_not_none", "(", "item", ",", "\"Value can't be None\"", ")", "data_items", ".", "append", "(", "self", ".", "_to_data", "(", "item", ")", ")", "return", "self", ".", "_encode_invoke", "(", "list_compare_and_remove_all_codec", ",", "values", "=", "data_items", ")" ]
Removes all of the elements that is present in the specified collection from this list. :param items: (Collection), the specified collection. :return: (bool), ``true`` if this list changed as a result of the call.
[ "Removes", "all", "of", "the", "elements", "that", "is", "present", "in", "the", "specified", "collection", "from", "this", "list", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/list.py#L236-L248
235,965
hazelcast/hazelcast-python-client
hazelcast/proxy/list.py
List.retain_all
def retain_all(self, items): """ Retains only the items that are contained in the specified collection. It means, items which are not present in the specified collection are removed from this list. :param items: (Collection), collections which includes the elements to be retained in this list. :return: (bool), ``true`` if this list changed as a result of the call. """ check_not_none(items, "Value can't be None") data_items = [] for item in items: check_not_none(item, "Value can't be None") data_items.append(self._to_data(item)) return self._encode_invoke(list_compare_and_retain_all_codec, values=data_items)
python
def retain_all(self, items): """ Retains only the items that are contained in the specified collection. It means, items which are not present in the specified collection are removed from this list. :param items: (Collection), collections which includes the elements to be retained in this list. :return: (bool), ``true`` if this list changed as a result of the call. """ check_not_none(items, "Value can't be None") data_items = [] for item in items: check_not_none(item, "Value can't be None") data_items.append(self._to_data(item)) return self._encode_invoke(list_compare_and_retain_all_codec, values=data_items)
[ "def", "retain_all", "(", "self", ",", "items", ")", ":", "check_not_none", "(", "items", ",", "\"Value can't be None\"", ")", "data_items", "=", "[", "]", "for", "item", "in", "items", ":", "check_not_none", "(", "item", ",", "\"Value can't be None\"", ")", "data_items", ".", "append", "(", "self", ".", "_to_data", "(", "item", ")", ")", "return", "self", ".", "_encode_invoke", "(", "list_compare_and_retain_all_codec", ",", "values", "=", "data_items", ")" ]
Retains only the items that are contained in the specified collection. It means, items which are not present in the specified collection are removed from this list. :param items: (Collection), collections which includes the elements to be retained in this list. :return: (bool), ``true`` if this list changed as a result of the call.
[ "Retains", "only", "the", "items", "that", "are", "contained", "in", "the", "specified", "collection", ".", "It", "means", "items", "which", "are", "not", "present", "in", "the", "specified", "collection", "are", "removed", "from", "this", "list", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/list.py#L259-L272
235,966
hazelcast/hazelcast-python-client
hazelcast/proxy/list.py
List.set_at
def set_at(self, index, item): """ Replaces the specified element with the element at the specified position in this list. :param index: (int), index of the item to be replaced. :param item: (object), item to be stored. :return: (object), the previous item in the specified index. """ check_not_none(item, "Value can't be None") element_data = self._to_data(item) return self._encode_invoke(list_set_codec, index=index, value=element_data)
python
def set_at(self, index, item): """ Replaces the specified element with the element at the specified position in this list. :param index: (int), index of the item to be replaced. :param item: (object), item to be stored. :return: (object), the previous item in the specified index. """ check_not_none(item, "Value can't be None") element_data = self._to_data(item) return self._encode_invoke(list_set_codec, index=index, value=element_data)
[ "def", "set_at", "(", "self", ",", "index", ",", "item", ")", ":", "check_not_none", "(", "item", ",", "\"Value can't be None\"", ")", "element_data", "=", "self", ".", "_to_data", "(", "item", ")", "return", "self", ".", "_encode_invoke", "(", "list_set_codec", ",", "index", "=", "index", ",", "value", "=", "element_data", ")" ]
Replaces the specified element with the element at the specified position in this list. :param index: (int), index of the item to be replaced. :param item: (object), item to be stored. :return: (object), the previous item in the specified index.
[ "Replaces", "the", "specified", "element", "with", "the", "element", "at", "the", "specified", "position", "in", "this", "list", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/list.py#L282-L292
235,967
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.add_index
def add_index(self, attribute, ordered=False): """ Adds an index to this map for the specified entries so that queries can run faster. Example: Let's say your map values are Employee objects. >>> class Employee(IdentifiedDataSerializable): >>> active = false >>> age = None >>> name = None >>> #other fields >>> >>> #methods If you query your values mostly based on age and active fields, you should consider indexing these. >>> map = self.client.get_map("employees") >>> map.add_index("age" , true) #ordered, since we have ranged queries for this field >>> map.add_index("active", false) #not ordered, because boolean field cannot have range :param attribute: (str), index attribute of the value. :param ordered: (bool), for ordering the index or not (optional). """ return self._encode_invoke(map_add_index_codec, attribute=attribute, ordered=ordered)
python
def add_index(self, attribute, ordered=False): """ Adds an index to this map for the specified entries so that queries can run faster. Example: Let's say your map values are Employee objects. >>> class Employee(IdentifiedDataSerializable): >>> active = false >>> age = None >>> name = None >>> #other fields >>> >>> #methods If you query your values mostly based on age and active fields, you should consider indexing these. >>> map = self.client.get_map("employees") >>> map.add_index("age" , true) #ordered, since we have ranged queries for this field >>> map.add_index("active", false) #not ordered, because boolean field cannot have range :param attribute: (str), index attribute of the value. :param ordered: (bool), for ordering the index or not (optional). """ return self._encode_invoke(map_add_index_codec, attribute=attribute, ordered=ordered)
[ "def", "add_index", "(", "self", ",", "attribute", ",", "ordered", "=", "False", ")", ":", "return", "self", ".", "_encode_invoke", "(", "map_add_index_codec", ",", "attribute", "=", "attribute", ",", "ordered", "=", "ordered", ")" ]
Adds an index to this map for the specified entries so that queries can run faster. Example: Let's say your map values are Employee objects. >>> class Employee(IdentifiedDataSerializable): >>> active = false >>> age = None >>> name = None >>> #other fields >>> >>> #methods If you query your values mostly based on age and active fields, you should consider indexing these. >>> map = self.client.get_map("employees") >>> map.add_index("age" , true) #ordered, since we have ranged queries for this field >>> map.add_index("active", false) #not ordered, because boolean field cannot have range :param attribute: (str), index attribute of the value. :param ordered: (bool), for ordering the index or not (optional).
[ "Adds", "an", "index", "to", "this", "map", "for", "the", "specified", "entries", "so", "that", "queries", "can", "run", "faster", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L124-L147
235,968
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.add_interceptor
def add_interceptor(self, interceptor): """ Adds an interceptor for this map. Added interceptor will intercept operations and execute user defined methods. :param interceptor: (object), interceptor for the map which includes user defined methods. :return: (str),id of registered interceptor. """ return self._encode_invoke(map_add_interceptor_codec, interceptor=self._to_data(interceptor))
python
def add_interceptor(self, interceptor): """ Adds an interceptor for this map. Added interceptor will intercept operations and execute user defined methods. :param interceptor: (object), interceptor for the map which includes user defined methods. :return: (str),id of registered interceptor. """ return self._encode_invoke(map_add_interceptor_codec, interceptor=self._to_data(interceptor))
[ "def", "add_interceptor", "(", "self", ",", "interceptor", ")", ":", "return", "self", ".", "_encode_invoke", "(", "map_add_interceptor_codec", ",", "interceptor", "=", "self", ".", "_to_data", "(", "interceptor", ")", ")" ]
Adds an interceptor for this map. Added interceptor will intercept operations and execute user defined methods. :param interceptor: (object), interceptor for the map which includes user defined methods. :return: (str),id of registered interceptor.
[ "Adds", "an", "interceptor", "for", "this", "map", ".", "Added", "interceptor", "will", "intercept", "operations", "and", "execute", "user", "defined", "methods", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L149-L156
235,969
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.entry_set
def entry_set(self, predicate=None): """ Returns a list clone of the mappings contained in this map. **Warning: The list is NOT backed by the map, so changes to the map are NOT reflected in the list, and vice-versa.** :param predicate: (Predicate), predicate for the map to filter entries (optional). :return: (Sequence), the list of key-value tuples in the map. .. seealso:: :class:`~hazelcast.serialization.predicate.Predicate` for more info about predicates. """ if predicate: predicate_data = self._to_data(predicate) return self._encode_invoke(map_entries_with_predicate_codec, predicate=predicate_data) else: return self._encode_invoke(map_entry_set_codec)
python
def entry_set(self, predicate=None): """ Returns a list clone of the mappings contained in this map. **Warning: The list is NOT backed by the map, so changes to the map are NOT reflected in the list, and vice-versa.** :param predicate: (Predicate), predicate for the map to filter entries (optional). :return: (Sequence), the list of key-value tuples in the map. .. seealso:: :class:`~hazelcast.serialization.predicate.Predicate` for more info about predicates. """ if predicate: predicate_data = self._to_data(predicate) return self._encode_invoke(map_entries_with_predicate_codec, predicate=predicate_data) else: return self._encode_invoke(map_entry_set_codec)
[ "def", "entry_set", "(", "self", ",", "predicate", "=", "None", ")", ":", "if", "predicate", ":", "predicate_data", "=", "self", ".", "_to_data", "(", "predicate", ")", "return", "self", ".", "_encode_invoke", "(", "map_entries_with_predicate_codec", ",", "predicate", "=", "predicate_data", ")", "else", ":", "return", "self", ".", "_encode_invoke", "(", "map_entry_set_codec", ")" ]
Returns a list clone of the mappings contained in this map. **Warning: The list is NOT backed by the map, so changes to the map are NOT reflected in the list, and vice-versa.** :param predicate: (Predicate), predicate for the map to filter entries (optional). :return: (Sequence), the list of key-value tuples in the map. .. seealso:: :class:`~hazelcast.serialization.predicate.Predicate` for more info about predicates.
[ "Returns", "a", "list", "clone", "of", "the", "mappings", "contained", "in", "this", "map", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L212-L228
235,970
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.evict
def evict(self, key): """ Evicts the specified key from this map. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), key to evict. :return: (bool), ``true`` if the key is evicted, ``false`` otherwise. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._evict_internal(key_data)
python
def evict(self, key): """ Evicts the specified key from this map. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), key to evict. :return: (bool), ``true`` if the key is evicted, ``false`` otherwise. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._evict_internal(key_data)
[ "def", "evict", "(", "self", ",", "key", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "return", "self", ".", "_evict_internal", "(", "key_data", ")" ]
Evicts the specified key from this map. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), key to evict. :return: (bool), ``true`` if the key is evicted, ``false`` otherwise.
[ "Evicts", "the", "specified", "key", "from", "this", "map", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L230-L242
235,971
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.execute_on_entries
def execute_on_entries(self, entry_processor, predicate=None): """ Applies the user defined EntryProcessor to all the entries in the map or entries in the map which satisfies the predicate if provided. Returns the results mapped by each key in the map. :param entry_processor: (object), A stateful serializable object which represents the EntryProcessor defined on server side. This object must have a serializable EntryProcessor counter part registered on server side with the actual ``org.hazelcast.map.EntryProcessor`` implementation. :param predicate: (Predicate), predicate for filtering the entries (optional). :return: (Sequence), list of map entries which includes the keys and the results of the entry process. .. seealso:: :class:`~hazelcast.serialization.predicate.Predicate` for more info about predicates. """ if predicate: return self._encode_invoke(map_execute_with_predicate_codec, entry_processor=self._to_data(entry_processor), predicate=self._to_data(predicate)) return self._encode_invoke(map_execute_on_all_keys_codec, entry_processor=self._to_data(entry_processor))
python
def execute_on_entries(self, entry_processor, predicate=None): """ Applies the user defined EntryProcessor to all the entries in the map or entries in the map which satisfies the predicate if provided. Returns the results mapped by each key in the map. :param entry_processor: (object), A stateful serializable object which represents the EntryProcessor defined on server side. This object must have a serializable EntryProcessor counter part registered on server side with the actual ``org.hazelcast.map.EntryProcessor`` implementation. :param predicate: (Predicate), predicate for filtering the entries (optional). :return: (Sequence), list of map entries which includes the keys and the results of the entry process. .. seealso:: :class:`~hazelcast.serialization.predicate.Predicate` for more info about predicates. """ if predicate: return self._encode_invoke(map_execute_with_predicate_codec, entry_processor=self._to_data(entry_processor), predicate=self._to_data(predicate)) return self._encode_invoke(map_execute_on_all_keys_codec, entry_processor=self._to_data(entry_processor))
[ "def", "execute_on_entries", "(", "self", ",", "entry_processor", ",", "predicate", "=", "None", ")", ":", "if", "predicate", ":", "return", "self", ".", "_encode_invoke", "(", "map_execute_with_predicate_codec", ",", "entry_processor", "=", "self", ".", "_to_data", "(", "entry_processor", ")", ",", "predicate", "=", "self", ".", "_to_data", "(", "predicate", ")", ")", "return", "self", ".", "_encode_invoke", "(", "map_execute_on_all_keys_codec", ",", "entry_processor", "=", "self", ".", "_to_data", "(", "entry_processor", ")", ")" ]
Applies the user defined EntryProcessor to all the entries in the map or entries in the map which satisfies the predicate if provided. Returns the results mapped by each key in the map. :param entry_processor: (object), A stateful serializable object which represents the EntryProcessor defined on server side. This object must have a serializable EntryProcessor counter part registered on server side with the actual ``org.hazelcast.map.EntryProcessor`` implementation. :param predicate: (Predicate), predicate for filtering the entries (optional). :return: (Sequence), list of map entries which includes the keys and the results of the entry process. .. seealso:: :class:`~hazelcast.serialization.predicate.Predicate` for more info about predicates.
[ "Applies", "the", "user", "defined", "EntryProcessor", "to", "all", "the", "entries", "in", "the", "map", "or", "entries", "in", "the", "map", "which", "satisfies", "the", "predicate", "if", "provided", ".", "Returns", "the", "results", "mapped", "by", "each", "key", "in", "the", "map", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L252-L269
235,972
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.execute_on_key
def execute_on_key(self, key, entry_processor): """ Applies the user defined EntryProcessor to the entry mapped by the key. Returns the object which is the result of EntryProcessor's process method. :param key: (object), specified key for the entry to be processed. :param entry_processor: (object), A stateful serializable object which represents the EntryProcessor defined on server side. This object must have a serializable EntryProcessor counter part registered on server side with the actual ``org.hazelcast.map.EntryProcessor`` implementation. :return: (object), result of entry process. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._execute_on_key_internal(key_data, entry_processor)
python
def execute_on_key(self, key, entry_processor): """ Applies the user defined EntryProcessor to the entry mapped by the key. Returns the object which is the result of EntryProcessor's process method. :param key: (object), specified key for the entry to be processed. :param entry_processor: (object), A stateful serializable object which represents the EntryProcessor defined on server side. This object must have a serializable EntryProcessor counter part registered on server side with the actual ``org.hazelcast.map.EntryProcessor`` implementation. :return: (object), result of entry process. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._execute_on_key_internal(key_data, entry_processor)
[ "def", "execute_on_key", "(", "self", ",", "key", ",", "entry_processor", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "return", "self", ".", "_execute_on_key_internal", "(", "key_data", ",", "entry_processor", ")" ]
Applies the user defined EntryProcessor to the entry mapped by the key. Returns the object which is the result of EntryProcessor's process method. :param key: (object), specified key for the entry to be processed. :param entry_processor: (object), A stateful serializable object which represents the EntryProcessor defined on server side. This object must have a serializable EntryProcessor counter part registered on server side with the actual ``org.hazelcast.map.EntryProcessor`` implementation. :return: (object), result of entry process.
[ "Applies", "the", "user", "defined", "EntryProcessor", "to", "the", "entry", "mapped", "by", "the", "key", ".", "Returns", "the", "object", "which", "is", "the", "result", "of", "EntryProcessor", "s", "process", "method", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L271-L285
235,973
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.execute_on_keys
def execute_on_keys(self, keys, entry_processor): """ Applies the user defined EntryProcessor to the entries mapped by the collection of keys. Returns the results mapped by each key in the collection. :param keys: (Collection), collection of the keys for the entries to be processed. :param entry_processor: (object), A stateful serializable object which represents the EntryProcessor defined on server side. This object must have a serializable EntryProcessor counter part registered on server side with the actual ``org.hazelcast.map.EntryProcessor`` implementation. :return: (Sequence), list of map entries which includes the keys and the results of the entry process. """ key_list = [] for key in keys: check_not_none(key, "key can't be None") key_list.append(self._to_data(key)) if len(keys) == 0: return ImmediateFuture([]) return self._encode_invoke(map_execute_on_keys_codec, entry_processor=self._to_data(entry_processor), keys=key_list)
python
def execute_on_keys(self, keys, entry_processor): """ Applies the user defined EntryProcessor to the entries mapped by the collection of keys. Returns the results mapped by each key in the collection. :param keys: (Collection), collection of the keys for the entries to be processed. :param entry_processor: (object), A stateful serializable object which represents the EntryProcessor defined on server side. This object must have a serializable EntryProcessor counter part registered on server side with the actual ``org.hazelcast.map.EntryProcessor`` implementation. :return: (Sequence), list of map entries which includes the keys and the results of the entry process. """ key_list = [] for key in keys: check_not_none(key, "key can't be None") key_list.append(self._to_data(key)) if len(keys) == 0: return ImmediateFuture([]) return self._encode_invoke(map_execute_on_keys_codec, entry_processor=self._to_data(entry_processor), keys=key_list)
[ "def", "execute_on_keys", "(", "self", ",", "keys", ",", "entry_processor", ")", ":", "key_list", "=", "[", "]", "for", "key", "in", "keys", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "key_list", ".", "append", "(", "self", ".", "_to_data", "(", "key", ")", ")", "if", "len", "(", "keys", ")", "==", "0", ":", "return", "ImmediateFuture", "(", "[", "]", ")", "return", "self", ".", "_encode_invoke", "(", "map_execute_on_keys_codec", ",", "entry_processor", "=", "self", ".", "_to_data", "(", "entry_processor", ")", ",", "keys", "=", "key_list", ")" ]
Applies the user defined EntryProcessor to the entries mapped by the collection of keys. Returns the results mapped by each key in the collection. :param keys: (Collection), collection of the keys for the entries to be processed. :param entry_processor: (object), A stateful serializable object which represents the EntryProcessor defined on server side. This object must have a serializable EntryProcessor counter part registered on server side with the actual ``org.hazelcast.map.EntryProcessor`` implementation. :return: (Sequence), list of map entries which includes the keys and the results of the entry process.
[ "Applies", "the", "user", "defined", "EntryProcessor", "to", "the", "entries", "mapped", "by", "the", "collection", "of", "keys", ".", "Returns", "the", "results", "mapped", "by", "each", "key", "in", "the", "collection", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L287-L308
235,974
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.force_unlock
def force_unlock(self, key): """ Releases the lock for the specified key regardless of the lock owner. It always successfully unlocks the key, never blocks, and returns immediately. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key to lock. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(map_force_unlock_codec, key_data, key=key_data, reference_id=self.reference_id_generator.get_and_increment())
python
def force_unlock(self, key): """ Releases the lock for the specified key regardless of the lock owner. It always successfully unlocks the key, never blocks, and returns immediately. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key to lock. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(map_force_unlock_codec, key_data, key=key_data, reference_id=self.reference_id_generator.get_and_increment())
[ "def", "force_unlock", "(", "self", ",", "key", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "return", "self", ".", "_encode_invoke_on_key", "(", "map_force_unlock_codec", ",", "key_data", ",", "key", "=", "key_data", ",", "reference_id", "=", "self", ".", "reference_id_generator", ".", "get_and_increment", "(", ")", ")" ]
Releases the lock for the specified key regardless of the lock owner. It always successfully unlocks the key, never blocks, and returns immediately. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key to lock.
[ "Releases", "the", "lock", "for", "the", "specified", "key", "regardless", "of", "the", "lock", "owner", ".", "It", "always", "successfully", "unlocks", "the", "key", "never", "blocks", "and", "returns", "immediately", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L316-L329
235,975
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.get_all
def get_all(self, keys): """ Returns the entries for the given keys. **Warning: The returned map is NOT backed by the original map, so changes to the original map are NOT reflected in the returned map, and vice-versa.** **Warning 2: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param keys: (Collection), keys to get. :return: (dict), dictionary of map entries. """ check_not_none(keys, "keys can't be None") if not keys: return ImmediateFuture({}) partition_service = self._client.partition_service partition_to_keys = {} for key in keys: check_not_none(key, "key can't be None") key_data = self._to_data(key) partition_id = partition_service.get_partition_id(key_data) try: partition_to_keys[partition_id][key] = key_data except KeyError: partition_to_keys[partition_id] = {key: key_data} return self._get_all_internal(partition_to_keys)
python
def get_all(self, keys): """ Returns the entries for the given keys. **Warning: The returned map is NOT backed by the original map, so changes to the original map are NOT reflected in the returned map, and vice-versa.** **Warning 2: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param keys: (Collection), keys to get. :return: (dict), dictionary of map entries. """ check_not_none(keys, "keys can't be None") if not keys: return ImmediateFuture({}) partition_service = self._client.partition_service partition_to_keys = {} for key in keys: check_not_none(key, "key can't be None") key_data = self._to_data(key) partition_id = partition_service.get_partition_id(key_data) try: partition_to_keys[partition_id][key] = key_data except KeyError: partition_to_keys[partition_id] = {key: key_data} return self._get_all_internal(partition_to_keys)
[ "def", "get_all", "(", "self", ",", "keys", ")", ":", "check_not_none", "(", "keys", ",", "\"keys can't be None\"", ")", "if", "not", "keys", ":", "return", "ImmediateFuture", "(", "{", "}", ")", "partition_service", "=", "self", ".", "_client", ".", "partition_service", "partition_to_keys", "=", "{", "}", "for", "key", "in", "keys", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "partition_id", "=", "partition_service", ".", "get_partition_id", "(", "key_data", ")", "try", ":", "partition_to_keys", "[", "partition_id", "]", "[", "key", "]", "=", "key_data", "except", "KeyError", ":", "partition_to_keys", "[", "partition_id", "]", "=", "{", "key", ":", "key_data", "}", "return", "self", ".", "_get_all_internal", "(", "partition_to_keys", ")" ]
Returns the entries for the given keys. **Warning: The returned map is NOT backed by the original map, so changes to the original map are NOT reflected in the returned map, and vice-versa.** **Warning 2: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param keys: (Collection), keys to get. :return: (dict), dictionary of map entries.
[ "Returns", "the", "entries", "for", "the", "given", "keys", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L352-L382
235,976
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.get_entry_view
def get_entry_view(self, key): """ Returns the EntryView for the specified key. **Warning: This method returns a clone of original mapping, modifying the returned value does not change the actual value in the map. One should put modified value back to make changes visible to all nodes.** **Warning 2: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key of the entry. :return: (EntryView), EntryView of the specified key. .. seealso:: :class:`~hazelcast.core.EntryView` for more info about EntryView. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(map_get_entry_view_codec, key_data, key=key_data, thread_id=thread_id())
python
def get_entry_view(self, key): """ Returns the EntryView for the specified key. **Warning: This method returns a clone of original mapping, modifying the returned value does not change the actual value in the map. One should put modified value back to make changes visible to all nodes.** **Warning 2: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key of the entry. :return: (EntryView), EntryView of the specified key. .. seealso:: :class:`~hazelcast.core.EntryView` for more info about EntryView. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(map_get_entry_view_codec, key_data, key=key_data, thread_id=thread_id())
[ "def", "get_entry_view", "(", "self", ",", "key", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "return", "self", ".", "_encode_invoke_on_key", "(", "map_get_entry_view_codec", ",", "key_data", ",", "key", "=", "key_data", ",", "thread_id", "=", "thread_id", "(", ")", ")" ]
Returns the EntryView for the specified key. **Warning: This method returns a clone of original mapping, modifying the returned value does not change the actual value in the map. One should put modified value back to make changes visible to all nodes.** **Warning 2: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key of the entry. :return: (EntryView), EntryView of the specified key. .. seealso:: :class:`~hazelcast.core.EntryView` for more info about EntryView.
[ "Returns", "the", "EntryView", "for", "the", "specified", "key", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L384-L402
235,977
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.is_locked
def is_locked(self, key): """ Checks the lock for the specified key. If the lock is acquired, it returns ``true``. Otherwise, it returns ``false``. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key that is checked for lock :return: (bool), ``true`` if lock is acquired, ``false`` otherwise. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(map_is_locked_codec, key_data, key=key_data)
python
def is_locked(self, key): """ Checks the lock for the specified key. If the lock is acquired, it returns ``true``. Otherwise, it returns ``false``. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key that is checked for lock :return: (bool), ``true`` if lock is acquired, ``false`` otherwise. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(map_is_locked_codec, key_data, key=key_data)
[ "def", "is_locked", "(", "self", ",", "key", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "return", "self", ".", "_encode_invoke_on_key", "(", "map_is_locked_codec", ",", "key_data", ",", "key", "=", "key_data", ")" ]
Checks the lock for the specified key. If the lock is acquired, it returns ``true``. Otherwise, it returns ``false``. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the key that is checked for lock :return: (bool), ``true`` if lock is acquired, ``false`` otherwise.
[ "Checks", "the", "lock", "for", "the", "specified", "key", ".", "If", "the", "lock", "is", "acquired", "it", "returns", "true", ".", "Otherwise", "it", "returns", "false", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L412-L424
235,978
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.key_set
def key_set(self, predicate=None): """ Returns a List clone of the keys contained in this map or the keys of the entries filtered with the predicate if provided. **Warning: The list is NOT backed by the map, so changes to the map are NOT reflected in the list, and vice-versa.** :param predicate: (Predicate), predicate to filter the entries (optional). :return: (Sequence), a list of the clone of the keys. .. seealso:: :class:`~hazelcast.serialization.predicate.Predicate` for more info about predicates. """ if predicate: predicate_data = self._to_data(predicate) return self._encode_invoke(map_key_set_with_predicate_codec, predicate=predicate_data) else: return self._encode_invoke(map_key_set_codec)
python
def key_set(self, predicate=None): """ Returns a List clone of the keys contained in this map or the keys of the entries filtered with the predicate if provided. **Warning: The list is NOT backed by the map, so changes to the map are NOT reflected in the list, and vice-versa.** :param predicate: (Predicate), predicate to filter the entries (optional). :return: (Sequence), a list of the clone of the keys. .. seealso:: :class:`~hazelcast.serialization.predicate.Predicate` for more info about predicates. """ if predicate: predicate_data = self._to_data(predicate) return self._encode_invoke(map_key_set_with_predicate_codec, predicate=predicate_data) else: return self._encode_invoke(map_key_set_codec)
[ "def", "key_set", "(", "self", ",", "predicate", "=", "None", ")", ":", "if", "predicate", ":", "predicate_data", "=", "self", ".", "_to_data", "(", "predicate", ")", "return", "self", ".", "_encode_invoke", "(", "map_key_set_with_predicate_codec", ",", "predicate", "=", "predicate_data", ")", "else", ":", "return", "self", ".", "_encode_invoke", "(", "map_key_set_codec", ")" ]
Returns a List clone of the keys contained in this map or the keys of the entries filtered with the predicate if provided. **Warning: The list is NOT backed by the map, so changes to the map are NOT reflected in the list, and vice-versa.** :param predicate: (Predicate), predicate to filter the entries (optional). :return: (Sequence), a list of the clone of the keys. .. seealso:: :class:`~hazelcast.serialization.predicate.Predicate` for more info about predicates.
[ "Returns", "a", "List", "clone", "of", "the", "keys", "contained", "in", "this", "map", "or", "the", "keys", "of", "the", "entries", "filtered", "with", "the", "predicate", "if", "provided", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L426-L443
235,979
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.load_all
def load_all(self, keys=None, replace_existing_values=True): """ Loads all keys from the store at server side or loads the given keys if provided. :param keys: (Collection), keys of the entry values to load (optional). :param replace_existing_values: (bool), whether the existing values will be replaced or not with those loaded from the server side MapLoader (optional). """ if keys: key_data_list = list(map(self._to_data, keys)) return self._load_all_internal(key_data_list, replace_existing_values) else: return self._encode_invoke(map_load_all_codec, replace_existing_values=replace_existing_values)
python
def load_all(self, keys=None, replace_existing_values=True): """ Loads all keys from the store at server side or loads the given keys if provided. :param keys: (Collection), keys of the entry values to load (optional). :param replace_existing_values: (bool), whether the existing values will be replaced or not with those loaded from the server side MapLoader (optional). """ if keys: key_data_list = list(map(self._to_data, keys)) return self._load_all_internal(key_data_list, replace_existing_values) else: return self._encode_invoke(map_load_all_codec, replace_existing_values=replace_existing_values)
[ "def", "load_all", "(", "self", ",", "keys", "=", "None", ",", "replace_existing_values", "=", "True", ")", ":", "if", "keys", ":", "key_data_list", "=", "list", "(", "map", "(", "self", ".", "_to_data", ",", "keys", ")", ")", "return", "self", ".", "_load_all_internal", "(", "key_data_list", ",", "replace_existing_values", ")", "else", ":", "return", "self", ".", "_encode_invoke", "(", "map_load_all_codec", ",", "replace_existing_values", "=", "replace_existing_values", ")" ]
Loads all keys from the store at server side or loads the given keys if provided. :param keys: (Collection), keys of the entry values to load (optional). :param replace_existing_values: (bool), whether the existing values will be replaced or not with those loaded from the server side MapLoader (optional).
[ "Loads", "all", "keys", "from", "the", "store", "at", "server", "side", "or", "loads", "the", "given", "keys", "if", "provided", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L445-L457
235,980
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.put_if_absent
def put_if_absent(self, key, value, ttl=-1): """ Associates the specified key with the given value if it is not already associated. If ttl is provided, entry will expire and get evicted after the ttl. This is equivalent to: >>> if not map.contains_key(key): >>> return map.put(key,value) >>> else: >>> return map.get(key) except that the action is performed atomically. **Warning: This method returns a clone of the previous value, not the original (identically equal) value previously put into the map.** **Warning 2: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), key of the entry. :param value: (object), value of the entry. :param ttl: (int), maximum time in seconds for this entry to stay in the map, if not provided, the value configured on server side configuration will be used (optional). :return: (object), old value of the entry. """ check_not_none(key, "key can't be None") check_not_none(value, "value can't be None") key_data = self._to_data(key) value_data = self._to_data(value) return self._put_if_absent_internal(key_data, value_data, ttl)
python
def put_if_absent(self, key, value, ttl=-1): """ Associates the specified key with the given value if it is not already associated. If ttl is provided, entry will expire and get evicted after the ttl. This is equivalent to: >>> if not map.contains_key(key): >>> return map.put(key,value) >>> else: >>> return map.get(key) except that the action is performed atomically. **Warning: This method returns a clone of the previous value, not the original (identically equal) value previously put into the map.** **Warning 2: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), key of the entry. :param value: (object), value of the entry. :param ttl: (int), maximum time in seconds for this entry to stay in the map, if not provided, the value configured on server side configuration will be used (optional). :return: (object), old value of the entry. """ check_not_none(key, "key can't be None") check_not_none(value, "value can't be None") key_data = self._to_data(key) value_data = self._to_data(value) return self._put_if_absent_internal(key_data, value_data, ttl)
[ "def", "put_if_absent", "(", "self", ",", "key", ",", "value", ",", "ttl", "=", "-", "1", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "check_not_none", "(", "value", ",", "\"value can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "value_data", "=", "self", ".", "_to_data", "(", "value", ")", "return", "self", ".", "_put_if_absent_internal", "(", "key_data", ",", "value_data", ",", "ttl", ")" ]
Associates the specified key with the given value if it is not already associated. If ttl is provided, entry will expire and get evicted after the ttl. This is equivalent to: >>> if not map.contains_key(key): >>> return map.put(key,value) >>> else: >>> return map.get(key) except that the action is performed atomically. **Warning: This method returns a clone of the previous value, not the original (identically equal) value previously put into the map.** **Warning 2: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), key of the entry. :param value: (object), value of the entry. :param ttl: (int), maximum time in seconds for this entry to stay in the map, if not provided, the value configured on server side configuration will be used (optional). :return: (object), old value of the entry.
[ "Associates", "the", "specified", "key", "with", "the", "given", "value", "if", "it", "is", "not", "already", "associated", ".", "If", "ttl", "is", "provided", "entry", "will", "expire", "and", "get", "evicted", "after", "the", "ttl", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L544-L574
235,981
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.remove_if_same
def remove_if_same(self, key, value): """ Removes the entry for a key only if it is currently mapped to a given value. This is equivalent to: >>> if map.contains_key(key) and map.get(key).equals(value): >>> map.remove(key) >>> return true >>> else: >>> return false except that the action is performed atomically. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the specified key. :param value: (object), remove the key if it has this value. :return: (bool), ``true`` if the value was removed. """ check_not_none(key, "key can't be None") check_not_none(value, "value can't be None") key_data = self._to_data(key) value_data = self._to_data(value) return self._remove_if_same_internal_(key_data, value_data)
python
def remove_if_same(self, key, value): """ Removes the entry for a key only if it is currently mapped to a given value. This is equivalent to: >>> if map.contains_key(key) and map.get(key).equals(value): >>> map.remove(key) >>> return true >>> else: >>> return false except that the action is performed atomically. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the specified key. :param value: (object), remove the key if it has this value. :return: (bool), ``true`` if the value was removed. """ check_not_none(key, "key can't be None") check_not_none(value, "value can't be None") key_data = self._to_data(key) value_data = self._to_data(value) return self._remove_if_same_internal_(key_data, value_data)
[ "def", "remove_if_same", "(", "self", ",", "key", ",", "value", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "check_not_none", "(", "value", ",", "\"value can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "value_data", "=", "self", ".", "_to_data", "(", "value", ")", "return", "self", ".", "_remove_if_same_internal_", "(", "key_data", ",", "value_data", ")" ]
Removes the entry for a key only if it is currently mapped to a given value. This is equivalent to: >>> if map.contains_key(key) and map.get(key).equals(value): >>> map.remove(key) >>> return true >>> else: >>> return false except that the action is performed atomically. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the specified key. :param value: (object), remove the key if it has this value. :return: (bool), ``true`` if the value was removed.
[ "Removes", "the", "entry", "for", "a", "key", "only", "if", "it", "is", "currently", "mapped", "to", "a", "given", "value", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L610-L634
235,982
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.replace
def replace(self, key, value): """ Replaces the entry for a key only if it is currently mapped to some value. This is equivalent to: >>> if map.contains_key(key): >>> return map.put(key,value) >>> else: >>> return None except that the action is performed atomically. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** **Warning 2: This method returns a clone of the previous value, not the original (identically equal) value previously put into the map.** :param key: (object), the specified key. :param value: (object), the value to replace the previous value. :return: (object), previous value associated with key, or ``None`` if there was no mapping for key. """ check_not_none(key, "key can't be None") check_not_none(value, "value can't be None") key_data = self._to_data(key) value_data = self._to_data(value) return self._replace_internal(key_data, value_data)
python
def replace(self, key, value): """ Replaces the entry for a key only if it is currently mapped to some value. This is equivalent to: >>> if map.contains_key(key): >>> return map.put(key,value) >>> else: >>> return None except that the action is performed atomically. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** **Warning 2: This method returns a clone of the previous value, not the original (identically equal) value previously put into the map.** :param key: (object), the specified key. :param value: (object), the value to replace the previous value. :return: (object), previous value associated with key, or ``None`` if there was no mapping for key. """ check_not_none(key, "key can't be None") check_not_none(value, "value can't be None") key_data = self._to_data(key) value_data = self._to_data(value) return self._replace_internal(key_data, value_data)
[ "def", "replace", "(", "self", ",", "key", ",", "value", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "check_not_none", "(", "value", ",", "\"value can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "value_data", "=", "self", ".", "_to_data", "(", "value", ")", "return", "self", ".", "_replace_internal", "(", "key_data", ",", "value_data", ")" ]
Replaces the entry for a key only if it is currently mapped to some value. This is equivalent to: >>> if map.contains_key(key): >>> return map.put(key,value) >>> else: >>> return None except that the action is performed atomically. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** **Warning 2: This method returns a clone of the previous value, not the original (identically equal) value previously put into the map.** :param key: (object), the specified key. :param value: (object), the value to replace the previous value. :return: (object), previous value associated with key, or ``None`` if there was no mapping for key.
[ "Replaces", "the", "entry", "for", "a", "key", "only", "if", "it", "is", "currently", "mapped", "to", "some", "value", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L646-L674
235,983
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.replace_if_same
def replace_if_same(self, key, old_value, new_value): """ Replaces the entry for a key only if it is currently mapped to a given value. This is equivalent to: >>> if map.contains_key(key) and map.get(key).equals(old_value): >>> map.put(key, new_value) >>> return true >>> else: >>> return false except that the action is performed atomically. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the specified key. :param old_value: (object), replace the key value if it is the old value. :param new_value: (object), the new value to replace the old value. :return: (bool), ``true`` if the value was replaced. """ check_not_none(key, "key can't be None") check_not_none(old_value, "old_value can't be None") check_not_none(new_value, "new_value can't be None") key_data = self._to_data(key) old_value_data = self._to_data(old_value) new_value_data = self._to_data(new_value) return self._replace_if_same_internal(key_data, old_value_data, new_value_data)
python
def replace_if_same(self, key, old_value, new_value): """ Replaces the entry for a key only if it is currently mapped to a given value. This is equivalent to: >>> if map.contains_key(key) and map.get(key).equals(old_value): >>> map.put(key, new_value) >>> return true >>> else: >>> return false except that the action is performed atomically. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the specified key. :param old_value: (object), replace the key value if it is the old value. :param new_value: (object), the new value to replace the old value. :return: (bool), ``true`` if the value was replaced. """ check_not_none(key, "key can't be None") check_not_none(old_value, "old_value can't be None") check_not_none(new_value, "new_value can't be None") key_data = self._to_data(key) old_value_data = self._to_data(old_value) new_value_data = self._to_data(new_value) return self._replace_if_same_internal(key_data, old_value_data, new_value_data)
[ "def", "replace_if_same", "(", "self", ",", "key", ",", "old_value", ",", "new_value", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "check_not_none", "(", "old_value", ",", "\"old_value can't be None\"", ")", "check_not_none", "(", "new_value", ",", "\"new_value can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "old_value_data", "=", "self", ".", "_to_data", "(", "old_value", ")", "new_value_data", "=", "self", ".", "_to_data", "(", "new_value", ")", "return", "self", ".", "_replace_if_same_internal", "(", "key_data", ",", "old_value_data", ",", "new_value_data", ")" ]
Replaces the entry for a key only if it is currently mapped to a given value. This is equivalent to: >>> if map.contains_key(key) and map.get(key).equals(old_value): >>> map.put(key, new_value) >>> return true >>> else: >>> return false except that the action is performed atomically. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), the specified key. :param old_value: (object), replace the key value if it is the old value. :param new_value: (object), the new value to replace the old value. :return: (bool), ``true`` if the value was replaced.
[ "Replaces", "the", "entry", "for", "a", "key", "only", "if", "it", "is", "currently", "mapped", "to", "a", "given", "value", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L676-L704
235,984
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.set
def set(self, key, value, ttl=-1): """ Puts an entry into this map. Similar to the put operation except that set doesn't return the old value, which is more efficient. If ttl is provided, entry will expire and get evicted after the ttl. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), key of the entry. :param value: (object), value of the entry. :param ttl: (int), maximum time in seconds for this entry to stay in the map, 0 means infinite. If ttl is not provided, the value configured on server side configuration will be used (optional). """ check_not_none(key, "key can't be None") check_not_none(value, "value can't be None") key_data = self._to_data(key) value_data = self._to_data(value) return self._set_internal(key_data, value_data, ttl)
python
def set(self, key, value, ttl=-1): """ Puts an entry into this map. Similar to the put operation except that set doesn't return the old value, which is more efficient. If ttl is provided, entry will expire and get evicted after the ttl. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), key of the entry. :param value: (object), value of the entry. :param ttl: (int), maximum time in seconds for this entry to stay in the map, 0 means infinite. If ttl is not provided, the value configured on server side configuration will be used (optional). """ check_not_none(key, "key can't be None") check_not_none(value, "value can't be None") key_data = self._to_data(key) value_data = self._to_data(value) return self._set_internal(key_data, value_data, ttl)
[ "def", "set", "(", "self", ",", "key", ",", "value", ",", "ttl", "=", "-", "1", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "check_not_none", "(", "value", ",", "\"value can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "value_data", "=", "self", ".", "_to_data", "(", "value", ")", "return", "self", ".", "_set_internal", "(", "key_data", ",", "value_data", ",", "ttl", ")" ]
Puts an entry into this map. Similar to the put operation except that set doesn't return the old value, which is more efficient. If ttl is provided, entry will expire and get evicted after the ttl. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), key of the entry. :param value: (object), value of the entry. :param ttl: (int), maximum time in seconds for this entry to stay in the map, 0 means infinite. If ttl is not provided, the value configured on server side configuration will be used (optional).
[ "Puts", "an", "entry", "into", "this", "map", ".", "Similar", "to", "the", "put", "operation", "except", "that", "set", "doesn", "t", "return", "the", "old", "value", "which", "is", "more", "efficient", ".", "If", "ttl", "is", "provided", "entry", "will", "expire", "and", "get", "evicted", "after", "the", "ttl", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L706-L723
235,985
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.try_put
def try_put(self, key, value, timeout=0): """ Tries to put the given key and value into this map and returns immediately if timeout is not provided. If timeout is provided, operation waits until it is completed or timeout is reached. :param key: (object), key of the entry. :param value: (object), value of the entry. :param timeout: (int), operation timeout in seconds (optional). :return: (bool), ``true`` if the put is successful, ``false`` otherwise. """ check_not_none(key, "key can't be None") check_not_none(value, "value can't be None") key_data = self._to_data(key) value_data = self._to_data(value) return self._try_put_internal(key_data, value_data, timeout)
python
def try_put(self, key, value, timeout=0): """ Tries to put the given key and value into this map and returns immediately if timeout is not provided. If timeout is provided, operation waits until it is completed or timeout is reached. :param key: (object), key of the entry. :param value: (object), value of the entry. :param timeout: (int), operation timeout in seconds (optional). :return: (bool), ``true`` if the put is successful, ``false`` otherwise. """ check_not_none(key, "key can't be None") check_not_none(value, "value can't be None") key_data = self._to_data(key) value_data = self._to_data(value) return self._try_put_internal(key_data, value_data, timeout)
[ "def", "try_put", "(", "self", ",", "key", ",", "value", ",", "timeout", "=", "0", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "check_not_none", "(", "value", ",", "\"value can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "value_data", "=", "self", ".", "_to_data", "(", "value", ")", "return", "self", ".", "_try_put_internal", "(", "key_data", ",", "value_data", ",", "timeout", ")" ]
Tries to put the given key and value into this map and returns immediately if timeout is not provided. If timeout is provided, operation waits until it is completed or timeout is reached. :param key: (object), key of the entry. :param value: (object), value of the entry. :param timeout: (int), operation timeout in seconds (optional). :return: (bool), ``true`` if the put is successful, ``false`` otherwise.
[ "Tries", "to", "put", "the", "given", "key", "and", "value", "into", "this", "map", "and", "returns", "immediately", "if", "timeout", "is", "not", "provided", ".", "If", "timeout", "is", "provided", "operation", "waits", "until", "it", "is", "completed", "or", "timeout", "is", "reached", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L758-L774
235,986
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.try_remove
def try_remove(self, key, timeout=0): """ Tries to remove the given key from this map and returns immediately if timeout is not provided. If timeout is provided, operation waits until it is completed or timeout is reached. :param key: (object), key of the entry to be deleted. :param timeout: (int), operation timeout in seconds (optional). :return: (bool), ``true`` if the remove is successful, ``false`` otherwise. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._try_remove_internal(key_data, timeout)
python
def try_remove(self, key, timeout=0): """ Tries to remove the given key from this map and returns immediately if timeout is not provided. If timeout is provided, operation waits until it is completed or timeout is reached. :param key: (object), key of the entry to be deleted. :param timeout: (int), operation timeout in seconds (optional). :return: (bool), ``true`` if the remove is successful, ``false`` otherwise. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._try_remove_internal(key_data, timeout)
[ "def", "try_remove", "(", "self", ",", "key", ",", "timeout", "=", "0", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "return", "self", ".", "_try_remove_internal", "(", "key_data", ",", "timeout", ")" ]
Tries to remove the given key from this map and returns immediately if timeout is not provided. If timeout is provided, operation waits until it is completed or timeout is reached. :param key: (object), key of the entry to be deleted. :param timeout: (int), operation timeout in seconds (optional). :return: (bool), ``true`` if the remove is successful, ``false`` otherwise.
[ "Tries", "to", "remove", "the", "given", "key", "from", "this", "map", "and", "returns", "immediately", "if", "timeout", "is", "not", "provided", ".", "If", "timeout", "is", "provided", "operation", "waits", "until", "it", "is", "completed", "or", "timeout", "is", "reached", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L776-L788
235,987
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.unlock
def unlock(self, key): """ Releases the lock for the specified key. It never blocks and returns immediately. If the current thread is the holder of this lock, then the hold count is decremented. If the hold count is zero, then the lock is released. :param key: (object), the key to lock. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(map_unlock_codec, key_data, key=key_data, thread_id=thread_id(), reference_id=self.reference_id_generator.get_and_increment())
python
def unlock(self, key): """ Releases the lock for the specified key. It never blocks and returns immediately. If the current thread is the holder of this lock, then the hold count is decremented. If the hold count is zero, then the lock is released. :param key: (object), the key to lock. """ check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(map_unlock_codec, key_data, key=key_data, thread_id=thread_id(), reference_id=self.reference_id_generator.get_and_increment())
[ "def", "unlock", "(", "self", ",", "key", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")", "return", "self", ".", "_encode_invoke_on_key", "(", "map_unlock_codec", ",", "key_data", ",", "key", "=", "key_data", ",", "thread_id", "=", "thread_id", "(", ")", ",", "reference_id", "=", "self", ".", "reference_id_generator", ".", "get_and_increment", "(", ")", ")" ]
Releases the lock for the specified key. It never blocks and returns immediately. If the current thread is the holder of this lock, then the hold count is decremented. If the hold count is zero, then the lock is released. :param key: (object), the key to lock.
[ "Releases", "the", "lock", "for", "the", "specified", "key", ".", "It", "never", "blocks", "and", "returns", "immediately", ".", "If", "the", "current", "thread", "is", "the", "holder", "of", "this", "lock", "then", "the", "hold", "count", "is", "decremented", ".", "If", "the", "hold", "count", "is", "zero", "then", "the", "lock", "is", "released", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L790-L802
235,988
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
Map.values
def values(self, predicate=None): """ Returns a list clone of the values contained in this map or values of the entries which are filtered with the predicate if provided. **Warning: The list is NOT backed by the map, so changes to the map are NOT reflected in the list, and vice-versa.** :param predicate: (Predicate), predicate to filter the entries (optional). :return: (Sequence), a list of clone of the values contained in this map. .. seealso:: :class:`~hazelcast.serialization.predicate.Predicate` for more info about predicates. """ if predicate: predicate_data = self._to_data(predicate) return self._encode_invoke(map_values_with_predicate_codec, predicate=predicate_data) else: return self._encode_invoke(map_values_codec)
python
def values(self, predicate=None): """ Returns a list clone of the values contained in this map or values of the entries which are filtered with the predicate if provided. **Warning: The list is NOT backed by the map, so changes to the map are NOT reflected in the list, and vice-versa.** :param predicate: (Predicate), predicate to filter the entries (optional). :return: (Sequence), a list of clone of the values contained in this map. .. seealso:: :class:`~hazelcast.serialization.predicate.Predicate` for more info about predicates. """ if predicate: predicate_data = self._to_data(predicate) return self._encode_invoke(map_values_with_predicate_codec, predicate=predicate_data) else: return self._encode_invoke(map_values_codec)
[ "def", "values", "(", "self", ",", "predicate", "=", "None", ")", ":", "if", "predicate", ":", "predicate_data", "=", "self", ".", "_to_data", "(", "predicate", ")", "return", "self", ".", "_encode_invoke", "(", "map_values_with_predicate_codec", ",", "predicate", "=", "predicate_data", ")", "else", ":", "return", "self", ".", "_encode_invoke", "(", "map_values_codec", ")" ]
Returns a list clone of the values contained in this map or values of the entries which are filtered with the predicate if provided. **Warning: The list is NOT backed by the map, so changes to the map are NOT reflected in the list, and vice-versa.** :param predicate: (Predicate), predicate to filter the entries (optional). :return: (Sequence), a list of clone of the values contained in this map. .. seealso:: :class:`~hazelcast.serialization.predicate.Predicate` for more info about predicates.
[ "Returns", "a", "list", "clone", "of", "the", "values", "contained", "in", "this", "map", "or", "values", "of", "the", "entries", "which", "are", "filtered", "with", "the", "predicate", "if", "provided", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L804-L822
235,989
hazelcast/hazelcast-python-client
hazelcast/transaction.py
TransactionManager.new_transaction
def new_transaction(self, timeout, durability, transaction_type): """ Creates a Transaction object with given timeout, durability and transaction type. :param timeout: (long), the timeout in seconds determines the maximum lifespan of a transaction. :param durability: (int), the durability is the number of machines that can take over if a member fails during a transaction commit or rollback :param transaction_type: (Transaction Type), the transaction type which can be :const:`~hazelcast.transaction.TWO_PHASE` or :const:`~hazelcast.transaction.ONE_PHASE` :return: (:class:`~hazelcast.transaction.Transaction`), new created Transaction. """ connection = self._connect() return Transaction(self._client, connection, timeout, durability, transaction_type)
python
def new_transaction(self, timeout, durability, transaction_type): """ Creates a Transaction object with given timeout, durability and transaction type. :param timeout: (long), the timeout in seconds determines the maximum lifespan of a transaction. :param durability: (int), the durability is the number of machines that can take over if a member fails during a transaction commit or rollback :param transaction_type: (Transaction Type), the transaction type which can be :const:`~hazelcast.transaction.TWO_PHASE` or :const:`~hazelcast.transaction.ONE_PHASE` :return: (:class:`~hazelcast.transaction.Transaction`), new created Transaction. """ connection = self._connect() return Transaction(self._client, connection, timeout, durability, transaction_type)
[ "def", "new_transaction", "(", "self", ",", "timeout", ",", "durability", ",", "transaction_type", ")", ":", "connection", "=", "self", ".", "_connect", "(", ")", "return", "Transaction", "(", "self", ".", "_client", ",", "connection", ",", "timeout", ",", "durability", ",", "transaction_type", ")" ]
Creates a Transaction object with given timeout, durability and transaction type. :param timeout: (long), the timeout in seconds determines the maximum lifespan of a transaction. :param durability: (int), the durability is the number of machines that can take over if a member fails during a transaction commit or rollback :param transaction_type: (Transaction Type), the transaction type which can be :const:`~hazelcast.transaction.TWO_PHASE` or :const:`~hazelcast.transaction.ONE_PHASE` :return: (:class:`~hazelcast.transaction.Transaction`), new created Transaction.
[ "Creates", "a", "Transaction", "object", "with", "given", "timeout", "durability", "and", "transaction", "type", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/transaction.py#L63-L74
235,990
hazelcast/hazelcast-python-client
hazelcast/transaction.py
Transaction.begin
def begin(self): """ Begins this transaction. """ if hasattr(self._locals, 'transaction_exists') and self._locals.transaction_exists: raise TransactionError("Nested transactions are not allowed.") if self.state != _STATE_NOT_STARTED: raise TransactionError("Transaction has already been started.") self._locals.transaction_exists = True self.start_time = time.time() self.thread_id = thread_id() try: request = transaction_create_codec.encode_request(timeout=int(self.timeout * 1000), durability=self.durability, transaction_type=self.transaction_type, thread_id=self.thread_id) response = self.client.invoker.invoke_on_connection(request, self.connection).result() self.id = transaction_create_codec.decode_response(response)["response"] self.state = _STATE_ACTIVE except: self._locals.transaction_exists = False raise
python
def begin(self): """ Begins this transaction. """ if hasattr(self._locals, 'transaction_exists') and self._locals.transaction_exists: raise TransactionError("Nested transactions are not allowed.") if self.state != _STATE_NOT_STARTED: raise TransactionError("Transaction has already been started.") self._locals.transaction_exists = True self.start_time = time.time() self.thread_id = thread_id() try: request = transaction_create_codec.encode_request(timeout=int(self.timeout * 1000), durability=self.durability, transaction_type=self.transaction_type, thread_id=self.thread_id) response = self.client.invoker.invoke_on_connection(request, self.connection).result() self.id = transaction_create_codec.decode_response(response)["response"] self.state = _STATE_ACTIVE except: self._locals.transaction_exists = False raise
[ "def", "begin", "(", "self", ")", ":", "if", "hasattr", "(", "self", ".", "_locals", ",", "'transaction_exists'", ")", "and", "self", ".", "_locals", ".", "transaction_exists", ":", "raise", "TransactionError", "(", "\"Nested transactions are not allowed.\"", ")", "if", "self", ".", "state", "!=", "_STATE_NOT_STARTED", ":", "raise", "TransactionError", "(", "\"Transaction has already been started.\"", ")", "self", ".", "_locals", ".", "transaction_exists", "=", "True", "self", ".", "start_time", "=", "time", ".", "time", "(", ")", "self", ".", "thread_id", "=", "thread_id", "(", ")", "try", ":", "request", "=", "transaction_create_codec", ".", "encode_request", "(", "timeout", "=", "int", "(", "self", ".", "timeout", "*", "1000", ")", ",", "durability", "=", "self", ".", "durability", ",", "transaction_type", "=", "self", ".", "transaction_type", ",", "thread_id", "=", "self", ".", "thread_id", ")", "response", "=", "self", ".", "client", ".", "invoker", ".", "invoke_on_connection", "(", "request", ",", "self", ".", "connection", ")", ".", "result", "(", ")", "self", ".", "id", "=", "transaction_create_codec", ".", "decode_response", "(", "response", ")", "[", "\"response\"", "]", "self", ".", "state", "=", "_STATE_ACTIVE", "except", ":", "self", ".", "_locals", ".", "transaction_exists", "=", "False", "raise" ]
Begins this transaction.
[ "Begins", "this", "transaction", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/transaction.py#L97-L117
235,991
hazelcast/hazelcast-python-client
hazelcast/transaction.py
Transaction.commit
def commit(self): """ Commits this transaction. """ self._check_thread() if self.state != _STATE_ACTIVE: raise TransactionError("Transaction is not active.") try: self._check_timeout() request = transaction_commit_codec.encode_request(self.id, self.thread_id) self.client.invoker.invoke_on_connection(request, self.connection).result() self.state = _STATE_COMMITTED except: self.state = _STATE_PARTIAL_COMMIT raise finally: self._locals.transaction_exists = False
python
def commit(self): """ Commits this transaction. """ self._check_thread() if self.state != _STATE_ACTIVE: raise TransactionError("Transaction is not active.") try: self._check_timeout() request = transaction_commit_codec.encode_request(self.id, self.thread_id) self.client.invoker.invoke_on_connection(request, self.connection).result() self.state = _STATE_COMMITTED except: self.state = _STATE_PARTIAL_COMMIT raise finally: self._locals.transaction_exists = False
[ "def", "commit", "(", "self", ")", ":", "self", ".", "_check_thread", "(", ")", "if", "self", ".", "state", "!=", "_STATE_ACTIVE", ":", "raise", "TransactionError", "(", "\"Transaction is not active.\"", ")", "try", ":", "self", ".", "_check_timeout", "(", ")", "request", "=", "transaction_commit_codec", ".", "encode_request", "(", "self", ".", "id", ",", "self", ".", "thread_id", ")", "self", ".", "client", ".", "invoker", ".", "invoke_on_connection", "(", "request", ",", "self", ".", "connection", ")", ".", "result", "(", ")", "self", ".", "state", "=", "_STATE_COMMITTED", "except", ":", "self", ".", "state", "=", "_STATE_PARTIAL_COMMIT", "raise", "finally", ":", "self", ".", "_locals", ".", "transaction_exists", "=", "False" ]
Commits this transaction.
[ "Commits", "this", "transaction", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/transaction.py#L119-L135
235,992
hazelcast/hazelcast-python-client
hazelcast/transaction.py
Transaction.rollback
def rollback(self): """ Rollback of this current transaction. """ self._check_thread() if self.state not in (_STATE_ACTIVE, _STATE_PARTIAL_COMMIT): raise TransactionError("Transaction is not active.") try: if self.state != _STATE_PARTIAL_COMMIT: request = transaction_rollback_codec.encode_request(self.id, self.thread_id) self.client.invoker.invoke_on_connection(request, self.connection).result() self.state = _STATE_ROLLED_BACK finally: self._locals.transaction_exists = False
python
def rollback(self): """ Rollback of this current transaction. """ self._check_thread() if self.state not in (_STATE_ACTIVE, _STATE_PARTIAL_COMMIT): raise TransactionError("Transaction is not active.") try: if self.state != _STATE_PARTIAL_COMMIT: request = transaction_rollback_codec.encode_request(self.id, self.thread_id) self.client.invoker.invoke_on_connection(request, self.connection).result() self.state = _STATE_ROLLED_BACK finally: self._locals.transaction_exists = False
[ "def", "rollback", "(", "self", ")", ":", "self", ".", "_check_thread", "(", ")", "if", "self", ".", "state", "not", "in", "(", "_STATE_ACTIVE", ",", "_STATE_PARTIAL_COMMIT", ")", ":", "raise", "TransactionError", "(", "\"Transaction is not active.\"", ")", "try", ":", "if", "self", ".", "state", "!=", "_STATE_PARTIAL_COMMIT", ":", "request", "=", "transaction_rollback_codec", ".", "encode_request", "(", "self", ".", "id", ",", "self", ".", "thread_id", ")", "self", ".", "client", ".", "invoker", ".", "invoke_on_connection", "(", "request", ",", "self", ".", "connection", ")", ".", "result", "(", ")", "self", ".", "state", "=", "_STATE_ROLLED_BACK", "finally", ":", "self", ".", "_locals", ".", "transaction_exists", "=", "False" ]
Rollback of this current transaction.
[ "Rollback", "of", "this", "current", "transaction", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/transaction.py#L137-L150
235,993
hazelcast/hazelcast-python-client
hazelcast/discovery.py
HazelcastCloudAddressProvider.load_addresses
def load_addresses(self): """ Loads member addresses from Hazelcast.cloud endpoint. :return: (Sequence), The possible member addresses to connect to. """ try: return list(self.cloud_discovery.discover_nodes().keys()) except Exception as ex: self.logger.warning("Failed to load addresses from Hazelcast.cloud: {}".format(ex.args[0]), extra=self._logger_extras) return []
python
def load_addresses(self): """ Loads member addresses from Hazelcast.cloud endpoint. :return: (Sequence), The possible member addresses to connect to. """ try: return list(self.cloud_discovery.discover_nodes().keys()) except Exception as ex: self.logger.warning("Failed to load addresses from Hazelcast.cloud: {}".format(ex.args[0]), extra=self._logger_extras) return []
[ "def", "load_addresses", "(", "self", ")", ":", "try", ":", "return", "list", "(", "self", ".", "cloud_discovery", ".", "discover_nodes", "(", ")", ".", "keys", "(", ")", ")", "except", "Exception", "as", "ex", ":", "self", ".", "logger", ".", "warning", "(", "\"Failed to load addresses from Hazelcast.cloud: {}\"", ".", "format", "(", "ex", ".", "args", "[", "0", "]", ")", ",", "extra", "=", "self", ".", "_logger_extras", ")", "return", "[", "]" ]
Loads member addresses from Hazelcast.cloud endpoint. :return: (Sequence), The possible member addresses to connect to.
[ "Loads", "member", "addresses", "from", "Hazelcast", ".", "cloud", "endpoint", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/discovery.py#L27-L38
235,994
hazelcast/hazelcast-python-client
hazelcast/discovery.py
HazelcastCloudAddressTranslator.translate
def translate(self, address): """ Translates the given address to another address specific to network or service. :param address: (:class:`~hazelcast.core.Address`), private address to be translated :return: (:class:`~hazelcast.core.Address`), new address if given address is known, otherwise returns null """ if address is None: return None public_address = self._private_to_public.get(address) if public_address: return public_address self.refresh() return self._private_to_public.get(address)
python
def translate(self, address): """ Translates the given address to another address specific to network or service. :param address: (:class:`~hazelcast.core.Address`), private address to be translated :return: (:class:`~hazelcast.core.Address`), new address if given address is known, otherwise returns null """ if address is None: return None public_address = self._private_to_public.get(address) if public_address: return public_address self.refresh() return self._private_to_public.get(address)
[ "def", "translate", "(", "self", ",", "address", ")", ":", "if", "address", "is", "None", ":", "return", "None", "public_address", "=", "self", ".", "_private_to_public", ".", "get", "(", "address", ")", "if", "public_address", ":", "return", "public_address", "self", ".", "refresh", "(", ")", "return", "self", ".", "_private_to_public", ".", "get", "(", "address", ")" ]
Translates the given address to another address specific to network or service. :param address: (:class:`~hazelcast.core.Address`), private address to be translated :return: (:class:`~hazelcast.core.Address`), new address if given address is known, otherwise returns null
[ "Translates", "the", "given", "address", "to", "another", "address", "specific", "to", "network", "or", "service", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/discovery.py#L53-L69
235,995
hazelcast/hazelcast-python-client
hazelcast/discovery.py
HazelcastCloudAddressTranslator.refresh
def refresh(self): """ Refreshes the internal lookup table if necessary. """ try: self._private_to_public = self.cloud_discovery.discover_nodes() except Exception as ex: self.logger.warning("Failed to load addresses from Hazelcast.cloud: {}".format(ex.args[0]), extra=self._logger_extras)
python
def refresh(self): """ Refreshes the internal lookup table if necessary. """ try: self._private_to_public = self.cloud_discovery.discover_nodes() except Exception as ex: self.logger.warning("Failed to load addresses from Hazelcast.cloud: {}".format(ex.args[0]), extra=self._logger_extras)
[ "def", "refresh", "(", "self", ")", ":", "try", ":", "self", ".", "_private_to_public", "=", "self", ".", "cloud_discovery", ".", "discover_nodes", "(", ")", "except", "Exception", "as", "ex", ":", "self", ".", "logger", ".", "warning", "(", "\"Failed to load addresses from Hazelcast.cloud: {}\"", ".", "format", "(", "ex", ".", "args", "[", "0", "]", ")", ",", "extra", "=", "self", ".", "_logger_extras", ")" ]
Refreshes the internal lookup table if necessary.
[ "Refreshes", "the", "internal", "lookup", "table", "if", "necessary", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/discovery.py#L71-L79
235,996
hazelcast/hazelcast-python-client
hazelcast/discovery.py
HazelcastCloudDiscovery.get_host_and_url
def get_host_and_url(properties, cloud_token): """ Helper method to get host and url that can be used in HTTPSConnection. :param properties: Client config properties. :param cloud_token: Cloud discovery token. :return: Host and URL pair """ host = properties.get(HazelcastCloudDiscovery.CLOUD_URL_BASE_PROPERTY.name, HazelcastCloudDiscovery.CLOUD_URL_BASE_PROPERTY.default_value) host = host.replace("https://", "") host = host.replace("http://", "") return host, HazelcastCloudDiscovery._CLOUD_URL_PATH + cloud_token
python
def get_host_and_url(properties, cloud_token): """ Helper method to get host and url that can be used in HTTPSConnection. :param properties: Client config properties. :param cloud_token: Cloud discovery token. :return: Host and URL pair """ host = properties.get(HazelcastCloudDiscovery.CLOUD_URL_BASE_PROPERTY.name, HazelcastCloudDiscovery.CLOUD_URL_BASE_PROPERTY.default_value) host = host.replace("https://", "") host = host.replace("http://", "") return host, HazelcastCloudDiscovery._CLOUD_URL_PATH + cloud_token
[ "def", "get_host_and_url", "(", "properties", ",", "cloud_token", ")", ":", "host", "=", "properties", ".", "get", "(", "HazelcastCloudDiscovery", ".", "CLOUD_URL_BASE_PROPERTY", ".", "name", ",", "HazelcastCloudDiscovery", ".", "CLOUD_URL_BASE_PROPERTY", ".", "default_value", ")", "host", "=", "host", ".", "replace", "(", "\"https://\"", ",", "\"\"", ")", "host", "=", "host", ".", "replace", "(", "\"http://\"", ",", "\"\"", ")", "return", "host", ",", "HazelcastCloudDiscovery", ".", "_CLOUD_URL_PATH", "+", "cloud_token" ]
Helper method to get host and url that can be used in HTTPSConnection. :param properties: Client config properties. :param cloud_token: Cloud discovery token. :return: Host and URL pair
[ "Helper", "method", "to", "get", "host", "and", "url", "that", "can", "be", "used", "in", "HTTPSConnection", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/discovery.py#L146-L158
235,997
hazelcast/hazelcast-python-client
hazelcast/proxy/count_down_latch.py
CountDownLatch.try_set_count
def try_set_count(self, count): """ Sets the count to the given value if the current count is zero. If count is not zero, this method does nothing and returns ``false``. :param count: (int), the number of times count_down() must be invoked before threads can pass through await(). :return: (bool), ``true`` if the new count was set, ``false`` if the current count is not zero. """ check_not_negative(count, "count can't be negative") return self._encode_invoke(count_down_latch_try_set_count_codec, count=count)
python
def try_set_count(self, count): """ Sets the count to the given value if the current count is zero. If count is not zero, this method does nothing and returns ``false``. :param count: (int), the number of times count_down() must be invoked before threads can pass through await(). :return: (bool), ``true`` if the new count was set, ``false`` if the current count is not zero. """ check_not_negative(count, "count can't be negative") return self._encode_invoke(count_down_latch_try_set_count_codec, count=count)
[ "def", "try_set_count", "(", "self", ",", "count", ")", ":", "check_not_negative", "(", "count", ",", "\"count can't be negative\"", ")", "return", "self", ".", "_encode_invoke", "(", "count_down_latch_try_set_count_codec", ",", "count", "=", "count", ")" ]
Sets the count to the given value if the current count is zero. If count is not zero, this method does nothing and returns ``false``. :param count: (int), the number of times count_down() must be invoked before threads can pass through await(). :return: (bool), ``true`` if the new count was set, ``false`` if the current count is not zero.
[ "Sets", "the", "count", "to", "the", "given", "value", "if", "the", "current", "count", "is", "zero", ".", "If", "count", "is", "not", "zero", "this", "method", "does", "nothing", "and", "returns", "false", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/count_down_latch.py#L65-L74
235,998
hazelcast/hazelcast-python-client
hazelcast/proxy/base.py
Proxy.destroy
def destroy(self): """ Destroys this proxy. :return: (bool), ``true`` if this proxy is deleted successfully, ``false`` otherwise. """ self._on_destroy() return self._client.proxy.destroy_proxy(self.service_name, self.name)
python
def destroy(self): """ Destroys this proxy. :return: (bool), ``true`` if this proxy is deleted successfully, ``false`` otherwise. """ self._on_destroy() return self._client.proxy.destroy_proxy(self.service_name, self.name)
[ "def", "destroy", "(", "self", ")", ":", "self", ".", "_on_destroy", "(", ")", "return", "self", ".", "_client", ".", "proxy", ".", "destroy_proxy", "(", "self", ".", "service_name", ",", "self", ".", "name", ")" ]
Destroys this proxy. :return: (bool), ``true`` if this proxy is deleted successfully, ``false`` otherwise.
[ "Destroys", "this", "proxy", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/base.py#L40-L47
235,999
hazelcast/hazelcast-python-client
hazelcast/cluster.py
ClusterService.add_listener
def add_listener(self, member_added=None, member_removed=None, fire_for_existing=False): """ Adds a membership listener to listen for membership updates, it will be notified when a member is added to cluster or removed from cluster. There is no check for duplicate registrations, so if you register the listener twice, it will get events twice. :param member_added: (Function), function to be called when a member is added to the cluster (optional). :param member_removed: (Function), function to be called when a member is removed to the cluster (optional). :param fire_for_existing: (bool), (optional). :return: (str), registration id of the listener which will be used for removing this listener. """ registration_id = str(uuid.uuid4()) self.listeners[registration_id] = (member_added, member_removed) if fire_for_existing: for member in self.get_member_list(): member_added(member) return registration_id
python
def add_listener(self, member_added=None, member_removed=None, fire_for_existing=False): """ Adds a membership listener to listen for membership updates, it will be notified when a member is added to cluster or removed from cluster. There is no check for duplicate registrations, so if you register the listener twice, it will get events twice. :param member_added: (Function), function to be called when a member is added to the cluster (optional). :param member_removed: (Function), function to be called when a member is removed to the cluster (optional). :param fire_for_existing: (bool), (optional). :return: (str), registration id of the listener which will be used for removing this listener. """ registration_id = str(uuid.uuid4()) self.listeners[registration_id] = (member_added, member_removed) if fire_for_existing: for member in self.get_member_list(): member_added(member) return registration_id
[ "def", "add_listener", "(", "self", ",", "member_added", "=", "None", ",", "member_removed", "=", "None", ",", "fire_for_existing", "=", "False", ")", ":", "registration_id", "=", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", "self", ".", "listeners", "[", "registration_id", "]", "=", "(", "member_added", ",", "member_removed", ")", "if", "fire_for_existing", ":", "for", "member", "in", "self", ".", "get_member_list", "(", ")", ":", "member_added", "(", "member", ")", "return", "registration_id" ]
Adds a membership listener to listen for membership updates, it will be notified when a member is added to cluster or removed from cluster. There is no check for duplicate registrations, so if you register the listener twice, it will get events twice. :param member_added: (Function), function to be called when a member is added to the cluster (optional). :param member_removed: (Function), function to be called when a member is removed to the cluster (optional). :param fire_for_existing: (bool), (optional). :return: (str), registration id of the listener which will be used for removing this listener.
[ "Adds", "a", "membership", "listener", "to", "listen", "for", "membership", "updates", "it", "will", "be", "notified", "when", "a", "member", "is", "added", "to", "cluster", "or", "removed", "from", "cluster", ".", "There", "is", "no", "check", "for", "duplicate", "registrations", "so", "if", "you", "register", "the", "listener", "twice", "it", "will", "get", "events", "twice", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/cluster.py#L63-L82