Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
71512f8
Add 4.0 codecs and implement new client message
mdumandag Aug 6, 2020
061b926
implement new client message reader
mdumandag Aug 10, 2020
8761684
implement partition service
mdumandag Aug 10, 2020
6e71e52
implement cluster service
mdumandag Aug 11, 2020
5459267
implement heartbeat manager
mdumandag Aug 12, 2020
fe3c0ce
change connection implementation
mdumandag Aug 12, 2020
ac2f930
update address providers & translators
mdumandag Aug 12, 2020
e4ba05b
fix cyclic imports
mdumandag Aug 12, 2020
c18c93a
initial config and connection manager changes
mdumandag Aug 13, 2020
e75f318
more connection manager changes
mdumandag Aug 14, 2020
fdf5b4b
finish connection manager implementation
mdumandag Aug 17, 2020
f5b793c
change listener service
mdumandag Aug 18, 2020
ca34d50
change incovation service
mdumandag Aug 19, 2020
04b2792
make the client work
mdumandag Aug 20, 2020
b6afff7
fix proxy implementations
mdumandag Aug 21, 2020
998ed39
fix proxies and their tests
mdumandag Aug 24, 2020
4740a28
update remote controller, fix serialization and ssl tests
mdumandag Aug 25, 2020
9022d9b
reconnect fix and more tests
mdumandag Aug 26, 2020
bfe04f5
more test fixes
mdumandag Aug 27, 2020
ef9a17e
fix more tests
mdumandag Aug 31, 2020
431875e
add index config, its tests and connection strategy tests
mdumandag Sep 1, 2020
d240418
more cleanup
mdumandag Sep 2, 2020
339e109
add map#set_ttl
mdumandag Sep 2, 2020
adf3ad6
rename invoker to invocation_service
mdumandag Sep 2, 2020
ede2120
more cleanup
mdumandag Sep 3, 2020
26ae618
update readme
mdumandag Sep 3, 2020
86f5780
more cleanup
mdumandag Sep 4, 2020
a2c4f8d
fix more tests
mdumandag Sep 7, 2020
4050349
move enums to config
mdumandag Sep 7, 2020
9d2f882
fix run-tests.sh
mdumandag Sep 7, 2020
a320e14
double check active connections for hot-path without the lock
mdumandag Sep 21, 2020
b0edeb7
wait for timers to finish in the reactor shutdown
mdumandag Sep 21, 2020
266e1ed
cancel invocation on timeout
mdumandag Sep 21, 2020
cd46a0e
don't timeout invocations if there is no exception
mdumandag Sep 21, 2020
c9e33e9
seperate private API from the public API
mdumandag Sep 23, 2020
da8d7cd
rename logger config
mdumandag Sep 24, 2020
1ecbef1
rename connection manager and client info
mdumandag Sep 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1,367 changes: 750 additions & 617 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions benchmarks/map_async_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def do_benchmark():
logger.info("Remote Controller Server OK...")
rc_cluster = rc.createCluster(None, None)
rc_member = rc.startMember(rc_cluster.id)
config.network_config.addresses.append('{}:{}'.format(rc_member.host, rc_member.port))
config.network.addresses.append('{}:{}'.format(rc_member.host, rc_member.port))
except (ImportError, NameError):
config.network_config.addresses.append('127.0.0.1')
config.network.addresses.append('127.0.0.1')

client = hazelcast.HazelcastClient(config)

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/map_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def do_benchmark():
logger.info("Remote Controller Server OK...")
rc_cluster = rc.createCluster(None, None)
rc_member = rc.startMember(rc_cluster.id)
config.network_config.addresses.append('{}:{}'.format(rc_member.host, rc_member.port))
config.network.addresses.append('{}:{}'.format(rc_member.host, rc_member.port))
except (ImportError, NameError):
config.network_config.addresses.append('127.0.0.1')
config.network.addresses.append('127.0.0.1')

client = hazelcast.HazelcastClient(config)
my_map = client.get_map("default")
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/simple_map_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def do_benchmark():
logger.info("Remote Controller Server OK...")
rc_cluster = rc.createCluster(None, None)
rc_member = rc.startMember(rc_cluster.id)
config.network_config.addresses.append('{}:{}'.format(rc_member.host, rc_member.port))
config.network.addresses.append('{}:{}'.format(rc_member.host, rc_member.port))
except (ImportError, NameError):
config.network_config.addresses.append('127.0.0.1')
config.network.addresses.append('127.0.0.1')

client = hazelcast.HazelcastClient(config)

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/simple_map_bench_multiprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def do_benchmark():
logger.info("Remote Controller Server OK...")
rc_cluster = rc.createCluster(None, None)
rc_member = rc.startMember(rc_cluster.id)
config.network_config.addresses.append('{}:{}'.format(rc_member.host, rc_member.port))
config.network.addresses.append('{}:{}'.format(rc_member.host, rc_member.port))
except (ImportError, NameError):
config.network_config.addresses.append('127.0.0.1')
config.network.addresses.append('127.0.0.1')

client = hazelcast.HazelcastClient(config)

Expand Down
6 changes: 3 additions & 3 deletions benchmarks/simple_map_nearcache_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def init():
config = hazelcast.ClientConfig()
config.group_config.name = "dev"
config.group_config.password = "dev-pass"
config.network_config.addresses.append("127.0.0.1")
config.network.addresses.append("127.0.0.1")

near_cache_config = NearCacheConfig(MAP_NAME)
near_cache_config.in_memory_format = IN_MEMORY_FORMAT.OBJECT
Expand All @@ -46,9 +46,9 @@ def init():
logger.info("Remote Controller Server OK...")
rc_cluster = rc.createCluster(None, None)
rc_member = rc.startMember(rc_cluster.id)
config.network_config.addresses.append('{}:{}'.format(rc_member.host, rc_member.port))
config.network.addresses.append('{}:{}'.format(rc_member.host, rc_member.port))
except (ImportError, NameError):
config.network_config.addresses.append('127.0.0.1')
config.network.addresses.append('127.0.0.1')

client = hazelcast.HazelcastClient(config)

Expand Down
Empty file removed examples/__init__.py
Empty file.
Empty file.
35 changes: 19 additions & 16 deletions examples/cloud-discovery/hazelcast_cloud_discovery_example.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
import hazelcast

if __name__ == "__main__":
config = hazelcast.ClientConfig()
config = hazelcast.ClientConfig()

# Set up group name and password for authentication
config.group_config.name = "name"
config.group_config.password = "password"
# Set up cluster name for authentication
config.cluster_name.name = "YOUR_CLUSTER_NAME"

# Enable SSL for encryption. Default CA certificates will be used.
config.network_config.ssl_config.enabled = True
# Enable Hazelcast.Cloud configuration and set the token of your cluster.
config.network.cloud.enabled = True
config.network.cloud.discovery_token = "YOUR_CLUSTER_DISCOVERY_TOKEN"

# Enable Hazelcast.Cloud configuration and set the token of your cluster.
config.network_config.cloud_config.enabled = True
config.network_config.cloud_config.discovery_token = "token"
# If you have enabled encryption for your cluster, also configure TLS/SSL for the client.
# Otherwise, skip this step.
config.network.ssl.enabled = True
config.network.ssl.cafile = "/path/to/ca.pem"
config.network.ssl.certfile = "/path/to/cert.pem"
config.network.ssl.keyfile = "/path/to/key.pem"
config.network.ssl.password = "YOUR_KEY_STORE_PASSWORD"

# Start a new Hazelcast client with this configuration.
client = hazelcast.HazelcastClient(config)
# Start a new Hazelcast client with this configuration.
client = hazelcast.HazelcastClient(config)

my_map = client.get_map("map-on-the-cloud")
my_map.put("key", "hazelcast.cloud")
my_map = client.get_map("map-on-the-cloud").blocking()
my_map.put("key", "value")

print(my_map.get("key"))
print(my_map.get("key"))

client.shutdown()
client.shutdown()
Empty file.
29 changes: 12 additions & 17 deletions examples/flake-id-generator/flake_id_generator_example.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import hazelcast
import logging

if __name__ == "__main__":
logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)
config = hazelcast.ClientConfig()
flake_id_generator_config = hazelcast.FlakeIdGeneratorConfig()

config = hazelcast.ClientConfig()
flake_id_generator_config = hazelcast.FlakeIdGeneratorConfig()
# Default value is 600000 (10 minutes)
flake_id_generator_config.prefetch_validity_in_millis = 30000

# Default value is 600000 (10 minutes)
flake_id_generator_config.prefetch_validity_in_millis = 30000
# Default value is 100
flake_id_generator_config.prefetch_count = 50

# Default value is 100
flake_id_generator_config.prefetch_count = 50
config.add_flake_id_generator_config(flake_id_generator_config)
client = hazelcast.HazelcastClient(config)

config.add_flake_id_generator_config(flake_id_generator_config)
client = hazelcast.HazelcastClient(config)
generator = client.get_flake_id_generator("id-generator").blocking()

generator = client.get_flake_id_generator("id-generator").blocking()
for _ in range(100):
print("Id: {}".format(generator.new_id()))

for _ in range(100):
print("Id: {}".format(generator.new_id()))

client.shutdown()
client.shutdown()
Empty file.
35 changes: 17 additions & 18 deletions examples/hazelcast-json-value/hazelcast_json_value_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,27 @@
from hazelcast.core import HazelcastJsonValue
from hazelcast.serialization.predicate import and_, is_greater_than, sql

if __name__ == "__main__":
client = hazelcast.HazelcastClient()
employees_map = client.get_map("employees").blocking()
client = hazelcast.HazelcastClient()
employees_map = client.get_map("employees").blocking()

alice = "{\"name\": \"Alice\", \"age\": 35}"
andy = "{\"name\": \"Andy\", \"age\": 22}"
bob = {"name": "Bob", "age": 37}
alice = "{\"name\": \"Alice\", \"age\": 35}"
andy = "{\"name\": \"Andy\", \"age\": 22}"
bob = {"name": "Bob", "age": 37}

# HazelcastJsonValue can be constructed from JSON strings
employees_map.put(0, HazelcastJsonValue(alice))
employees_map.put(1, HazelcastJsonValue(andy))
# HazelcastJsonValue can be constructed from JSON strings
employees_map.put(0, HazelcastJsonValue(alice))
employees_map.put(1, HazelcastJsonValue(andy))

# or from JSON serializable objects
employees_map.put(2, HazelcastJsonValue(bob))
# or from JSON serializable objects
employees_map.put(2, HazelcastJsonValue(bob))

# Employees whose name starts with 'A' and age is greater than 30
predicate = and_(sql("name like A%"), is_greater_than("age", 30))
# Employees whose name starts with 'A' and age is greater than 30
predicate = and_(sql("name like A%"), is_greater_than("age", 30))

values = employees_map.values(predicate)
values = employees_map.values(predicate)

for value in values:
print(value.to_string()) # As JSON string
print(value.loads()) # As Python object
for value in values:
print(value.to_string()) # As JSON string
print(value.loads()) # As Python object

client.shutdown()
client.shutdown()
24 changes: 11 additions & 13 deletions examples/learning-basics/1-configure_client.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import hazelcast

if __name__ == "__main__":
# Create configuration for the client
config = hazelcast.ClientConfig()
print("Cluster name: {}".format(config.group_config.name))
# Create configuration for the client
config = hazelcast.ClientConfig()
print("Cluster name: {}".format(config.cluster_name))

# Add member's host:port to the configuration.
# For each member on your Hazelcast cluster, you should add its host:port pair to the configuration.
config.network_config.addresses.append("127.0.0.1:5701")
config.network_config.addresses.append("127.0.0.1:5702")
# Add member's host:port to the configuration.
# For each member on your Hazelcast cluster, you should add its host:port pair to the configuration.
config.network.addresses.append("127.0.0.1:5701")
config.network.addresses.append("127.0.0.1:5702")

# Create a client using the configuration above
client = hazelcast.HazelcastClient(config)
print("Client is {}".format(client.lifecycle.state))
# Create a client using the configuration above
client = hazelcast.HazelcastClient(config)

# Disconnect the client and shutdown
client.shutdown()
# Disconnect the client and shutdown
client.shutdown()
37 changes: 18 additions & 19 deletions examples/learning-basics/2-create_a_map.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import hazelcast

if __name__ == "__main__":
# Connect
config = hazelcast.ClientConfig()
config.network_config.addresses.append("127.0.0.1:5701")
client = hazelcast.HazelcastClient(config)
# Connect
config = hazelcast.ClientConfig()
config.network.addresses.append("127.0.0.1:5701")
client = hazelcast.HazelcastClient(config)

# Get a map that is stored on the server side. We can access it from the client
greetings_map = client.get_map("greetings-map")
# Get a map that is stored on the server side. We can access it from the client
greetings_map = client.get_map("greetings-map")

# Map is empty on the first run. It will be non-empty if Hazelcast has data on this map
print("Map: {}, Size: {}".format(greetings_map.name, greetings_map.size().result()))
# Map is empty on the first run. It will be non-empty if Hazelcast has data on this map
print("Map: {}, Size: {}".format(greetings_map.name, greetings_map.size().result()))

# Write data to map. If there is a data with the same key already, it will be overwritten
greetings_map.put("English", "hello world")
greetings_map.put("Spanish", "hola mundo")
greetings_map.put("Italian", "ciao mondo")
greetings_map.put("German", "hallo welt")
greetings_map.put("French", "bonjour monde")
# Write data to map. If there is a data with the same key already, it will be overwritten
greetings_map.put("English", "hello world")
greetings_map.put("Spanish", "hola mundo")
greetings_map.put("Italian", "ciao mondo")
greetings_map.put("German", "hallo welt")
greetings_map.put("French", "bonjour monde")

# 5 data is added to the map. There should be at least 5 data on the server side
print("Map: {}, Size: {}".format(greetings_map.name, greetings_map.size().result()))
# 5 data is added to the map. There should be at least 5 data on the server side
print("Map: {}, Size: {}".format(greetings_map.name, greetings_map.size().result()))

# Shutdown the client
client.shutdown()
# Shutdown the client
client.shutdown()
27 changes: 13 additions & 14 deletions examples/learning-basics/3-read_from_a_map.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import hazelcast

if __name__ == "__main__":
# Connect
config = hazelcast.ClientConfig()
config.network_config.addresses.append("127.0.0.1:5701")
client = hazelcast.HazelcastClient(config)
# Connect
config = hazelcast.ClientConfig()
config.network.addresses.append("127.0.0.1:5701")
client = hazelcast.HazelcastClient(config)

# We can access maps on the server from the client. Let's access the greetings map that we created already
greetings_map = client.get_map("greetings-map")
# We can access maps on the server from the client. Let's access the greetings map that we created already
greetings_map = client.get_map("greetings-map")

# Get the keys of the map
keys = greetings_map.key_set().result()
# Get the keys of the map
keys = greetings_map.key_set().result()

# Print key-value pairs
for key in keys:
print("{} -> {}".format(key, greetings_map.get(key).result()))
# Print key-value pairs
for key in keys:
print("{} -> {}".format(key, greetings_map.get(key).result()))

# Shutdown the client
client.shutdown()
# Shutdown the client
client.shutdown()
Empty file.
Empty file removed examples/list/__init__.py
Empty file.
29 changes: 14 additions & 15 deletions examples/list/list_example.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import hazelcast

if __name__ == "__main__":
client = hazelcast.HazelcastClient()
client = hazelcast.HazelcastClient()

my_list = client.get_list("cities-list")
my_list = client.get_list("cities-list")

my_list.add("Tokyo")
my_list.add("Paris")
my_list.add("London")
my_list.add("New York")
my_list.add("Istanbul")
my_list.add("Tokyo")
my_list.add("Paris")
my_list.add("London")
my_list.add("New York")
my_list.add("Istanbul")

print("List size: {}".format(my_list.size().result()))
print("First element: {}".format(my_list.get(0).result()))
print("Contains Istanbul: {}".format(my_list.contains("Istanbul").result()))
print("Sublist: {}".format(my_list.sub_list(3, 5).result()))
print("List size: {}".format(my_list.size().result()))
print("First element: {}".format(my_list.get(0).result()))
print("Contains Istanbul: {}".format(my_list.contains("Istanbul").result()))
print("Sublist: {}".format(my_list.sub_list(3, 5).result()))

my_list.remove("Tokyo")
print("Final size: {}".format(my_list.size().result()))
my_list.remove("Tokyo")
print("Final size: {}".format(my_list.size().result()))

client.shutdown()
client.shutdown()
Empty file removed examples/map/__init__.py
Empty file.
35 changes: 18 additions & 17 deletions examples/map/map_async_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,30 @@


def fill_map(hz_map, count=10):
for i in range(count):
hz_map.put("key-" + str(i), "value-" + str(i))
entries = {"key-" + str(i): "value-" + str(i) for i in range(count)}
hz_map.put_all(entries)


if __name__ == "__main__":
client = hazelcast.HazelcastClient()
def put_callback(future):
print("Map put: {}".format(future.result()))

my_map = client.get_map("async-map")
fill_map(my_map)

print("Map size: {}".format(my_map.size().result()))
def contains_callback(future):
print("Map contains: {}".format(future.result()))

def put_callback(future):
print("Map put: {}".format(future.result()))

my_map.put("key", "async-value").add_done_callback(put_callback)
client = hazelcast.HazelcastClient()

def contains_callback(future):
print("Map contains: {}".format(future.result()))
my_map = client.get_map("async-map")
fill_map(my_map)

key = random.random()
print("Random key: {}".format(key))
my_map.contains_key(key).add_done_callback(contains_callback)
print("Map size: {}".format(my_map.size().result()))

time.sleep(10)
client.shutdown()
my_map.put("key", "async-value").add_done_callback(put_callback)

key = random.random()
print("Random key: {}".format(key))
my_map.contains_key(key).add_done_callback(contains_callback)

time.sleep(3)
client.shutdown()
Loading