Skip to content

Instantly share code, notes, and snippets.

@khaosans
Created July 12, 2016 00:33
Show Gist options
  • Save khaosans/5ea52fdb3eb0a41d3dad6e5d38524460 to your computer and use it in GitHub Desktop.
Save khaosans/5ea52fdb3eb0a41d3dad6e5d38524460 to your computer and use it in GitHub Desktop.
hazelcast
import hazelcast, logging, sys
import signal
def log_cache_info(cache, client):
cache = client.get_map(cache).blocking()
logging.info(
"CacheName: " + cache.name + " CacheSize: " + str(cache.size()) + " KlusterSize: " + str(client.cluster.size())
)
def handler(signum, frame):
print 'Signal handler called with signal', signum
raise IOError("Couldn't open device!")
def main():
config = hazelcast.ClientConfig()
# Hazelcast.Address is the hostname or IP address, e.g. 'localhost:5701'
if sys.argv.__len__() < 2:
print 'Missing ip address for hazelcast node'
sys.exit(0)
config.network_config.addresses.append(sys.argv[1] + ':5701')
# basic logging setup to see client logs
logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)
try:
signal.signal(signal.SIGALRM, handler)
signal.alarm(1)
client = hazelcast.HazelcastClient(config)
signal.alarm(0)
log_cache_info("idToDocumentNodeDTOCache", client)
log_cache_info("scopeRefBaselineToIdCache", client)
log_cache_info("projectToAclNodeIdsCache", client)
client.shutdown()
except IOError:
print 'unable to connect to node'
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment