Created
July 12, 2016 00:33
-
-
Save khaosans/5ea52fdb3eb0a41d3dad6e5d38524460 to your computer and use it in GitHub Desktop.
hazelcast
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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