Package: hazelcast-python-client
Hazelcastis an open-source distributed
in-memory data store and computation platform that provides a wide
variety of distributed data structures and concurrency primitives.Hazelcast Python client is a way to communicate to Hazelcast clusters
and access the cluster data. The client provides a Future-based
asynchronous API suitable for wide ranges of use cases.InstallationHazelcastHazelcast Python client requires a working Hazelcast cluster to run.
This cluster handles the storage and manipulation of the user data.A Hazelcast cluster consists of one or more cluster members. These
members generally run on multiple virtual or physical machines and are
connected to each other via the network. Any data put on the cluster is
partitioned to multiple members transparent to the user. It is therefore
very easy to scale the system by adding new members as the data grows.
Hazelcast cluster also offers resilience. Should any hardware or
software problem causes a crash to any member, the data on that member
is recovered from backups and the cluster continues to operate without
any downtime.The quickest way to start a single member cluster for development
purposes is to use ourDocker
images.dockerrun-p5701:5701hazelcast/hazelcast:5.3.0You can also use our ZIP or TARdistributions.
Once you have downloaded, you can start the Hazelcast member using
thebin/hz-startscript.Clientpipinstallhazelcast-python-clientOverviewUsageimporthazelcast# Connect to Hazelcast cluster.client=hazelcast.HazelcastClient()# Get or create the "distributed-map" on the cluster.distributed_map=client.get_map("distributed-map")# Put "key", "value" pair into the "distributed-map" and wait for# the request to complete.distributed_map.set("key","value").result()# Try to get the value associated with the given key from the cluster# and attach a callback to be executed once the response for the# get request is received. Note that, the set request above was# blocking since it calls ".result()" on the returned Future, whereas# the get request below is non-blocking.get_future=distributed_map.get("key")get_future.add_done_callback(lambdafuture:print(future.result()))# Do other operations. The operations below won't wait for# the get request above to complete.print("Map size:",distributed_map.size().result())# Shutdown the client.client.shutdown()If you are using Hazelcast and the Python client on the same machine,
the default configuration should work out-of-the-box. However,
you may need to configure the client to connect to cluster nodes that
are running on different machines or to customize client properties.Configurationimporthazelcastclient=hazelcast.HazelcastClient(cluster_name="cluster-name",cluster_members=["10.90.0.2:5701","10.90.0.3:5701",],lifecycle_listeners=[lambdastate:print("Lifecycle event >>>",state),])print("Connected to cluster")client.shutdown()Refer tothe documentationto learn more about supported configuration options.FeaturesDistributed, partitioned and queryable in-memory key-value store
implementation, calledMapEventually consistent cache implementation to store a subset of the
Map data locally in the memory of the client, calledNear CacheAdditional data structures and simple messaging constructs such asSet,MultiMap,Queue,TopicCluster-wide unique ID generator, calledFlakeIdGeneratorDistributed, CRDT based counter, calledPNCounterDistributed concurrency primitives from CP Subsystem such asFencedLock,Semaphore,AtomicLongIntegration withHazelcast ViridianSupport for serverless and traditional web service architectures withUnisocketandSmartoperation modesAbility to listen to client lifecycle, cluster state, and distributed
data structure eventsandmany
moreGetting HelpYou can use the following channels for your questions and
development/usage issues:GitHub
repositoryDocumentationSlackGoogle GroupsStack
OverflowContributingWe encourage any type of contribution in the form of issue reports or
pull requests.Issue ReportsFor issue reports, please share the following information with us to
quickly resolve the problems:Hazelcast and the client version that you useGeneral information about the environment and the architecture you
use like Python version, cluster size, number of clients, Java
version, JVM parameters, operating system etc.Logs and stack traces, if anyDetailed description of the steps to reproduce the issuePull RequestsContributions are submitted, reviewed and accepted using the pull
requests on GitHub. For an enhancement or larger feature, please
create a GitHub issue first to discuss.DevelopmentClone theGitHub repository.Runpython setup.py installto install the Python client.If you are planning to contribute:Runpip install-rrequirements-dev.txtto install development
dependencies.Useblackto reformat the code
by running theblack--configblack.toml .command.Usemypyto check type annotations
by running themypy hazelcastcommand.Make sure that tests are passing by following the steps described
in the next section.TestingIn order to test Hazelcast Python client locally, you will need the
following:Java 8 or newerMavenFollowing commands starts the tests:pythonrun_tests.pyTest script automatically downloadshazelcast-remote-controllerand
Hazelcast. The script uses Maven to download those.LicenseApache 2.0 License.CopyrightCopyright (c) 2008-2023, Hazelcast, Inc. All Rights Reserved.Visithazelcast.comfor more
information.