def init():
    logging.basicConfig(
        format='%(asctime)s%(msecs)03d [%(name)s] %(levelname)s: %(message)s',
        datefmt="%H:%M%:%S,")
    logging.getLogger().setLevel(logging.INFO)
    logger = logging.getLogger("main")

    config = hazelcast.ClientConfig()
    config.group_config.name = "dev"
    config.group_config.password = "******"
    config.network_config.addresses.append("127.0.0.1:5701")

    near_cache_config = NearCacheConfig(MAP_NAME)
    near_cache_config.in_memory_format = IN_MEMORY_FORMAT.OBJECT
    config.add_near_cache_config(near_cache_config)

    client = hazelcast.HazelcastClient(config)

    my_map = client.get_map(MAP_NAME).blocking()

    print "START INIT"
    for key in xrange(0, ENTRY_COUNT):
        my_map.put(key, VALUE)
    for key in xrange(0, ENTRY_COUNT):
        my_map.get(key)
    print "INIT COMPLETE"
    return my_map
def init():
    logging.basicConfig(format='%(asctime)s%(msecs)03d [%(name)s] %(levelname)s: %(message)s', datefmt="%H:%M%:%S,")
    logging.getLogger().setLevel(logging.INFO)
    logger = logging.getLogger("main")

    config = hazelcast.ClientConfig()
    config.group_config.name = "dev"
    config.group_config.password = "******"
    config.network_config.addresses.append("127.0.0.1:5701")

    near_cache_config = NearCacheConfig(MAP_NAME)
    near_cache_config.in_memory_format = IN_MEMORY_FORMAT.OBJECT
    config.add_near_cache_config(near_cache_config)

    client = hazelcast.HazelcastClient(config)

    my_map = client.get_map(MAP_NAME).blocking()

    print "START INIT"
    for key in xrange(0, ENTRY_COUNT):
        my_map.put(key, VALUE)
    for key in xrange(0, ENTRY_COUNT):
        my_map.get(key)
    print "INIT COMPLETE"
    return my_map
    def test_near_cache_config(self):
        config = NearCacheConfig(random_string())
        with self.assertRaises(ValueError):
            config.in_memory_format = 100

        with self.assertRaises(ValueError):
            config.eviction_policy = 100

        with self.assertRaises(ValueError):
            config.time_to_live_seconds = -1

        with self.assertRaises(ValueError):
            config.max_idle_seconds = -1

        with self.assertRaises(ValueError):
            config.eviction_max_size = 0
    def test_near_cache_config(self):
        config = NearCacheConfig(random_string())
        with self.assertRaises(ValueError):
            config.in_memory_format = 100

        with self.assertRaises(ValueError):
            config.eviction_policy = 100

        with self.assertRaises(ValueError):
            config.time_to_live_seconds = -1

        with self.assertRaises(ValueError):
            config.max_idle_seconds = -1

        with self.assertRaises(ValueError):
            config.eviction_max_size = 0
Beispiel #5
0
def init():
    logging.basicConfig(
        format='%(asctime)s%(msecs)03d [%(name)s] %(levelname)s: %(message)s',
        datefmt="%H:%M%:%S,")
    logging.getLogger().setLevel(logging.INFO)
    logger = logging.getLogger("main")

    config = hazelcast.ClientConfig()
    config.group_config.name = "dev"
    config.group_config.password = "******"
    config.network_config.addresses.append("127.0.0.1")

    near_cache_config = NearCacheConfig(MAP_NAME)
    near_cache_config.in_memory_format = IN_MEMORY_FORMAT.OBJECT
    config.add_near_cache_config(near_cache_config)

    try:
        from hzrc.client import HzRemoteController

        rc = HzRemoteController('127.0.0.1', '9701')

        if not rc.ping():
            logger.info("Remote Controller Server not running... exiting.")
            exit()
        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))
    except (ImportError, NameError):
        config.network_config.addresses.append('127.0.0.1')

    client = hazelcast.HazelcastClient(config)

    my_map = client.get_map(MAP_NAME).blocking()

    print "START INIT"
    for key in xrange(0, ENTRY_COUNT):
        my_map.put(key, VALUE)
    for key in xrange(0, ENTRY_COUNT):
        my_map.get(key)
    print "INIT COMPLETE"
    return my_map