示例#1
0
 def sync_client_connect():
     hs_to_listener = HandshakeTimeoutListener()
     client = Client(timeout=5.0, handshake_timeout=3.0, event_listeners=[hs_to_listener])
     start = time.monotonic()
     try:
         client.connect(DEFAULT_HOST, DEFAULT_PORT)
         assert all(n.alive for n in client._nodes)
         client.get_cache_names()
     except Exception as e:
         return time.monotonic() - start, hs_to_listener.events, e
     return time.monotonic() - start, hs_to_listener.events, None
示例#2
0
# create indices
for query in [CITY_CREATE_INDEX, LANGUAGE_CREATE_INDEX]:
    client.sql(query)

# load data
for row in COUNTRY_DATA:
    client.sql(COUNTRY_INSERT_QUERY, query_args=row)

for row in CITY_DATA:
    client.sql(CITY_INSERT_QUERY, query_args=row)

for row in LANGUAGE_DATA:
    client.sql(LANGUAGE_INSERT_QUERY, query_args=row)

# examine the storage
result = client.get_cache_names()
print(result)
# [
#     'SQL_PUBLIC_CITY',
#     'SQL_PUBLIC_COUNTRY',
#     'PUBLIC',
#     'SQL_PUBLIC_COUNTRYLANGUAGE'
# ]

city_cache = client.get_or_create_cache('SQL_PUBLIC_CITY')
print(city_cache.settings[PROP_NAME])
# 'SQL_PUBLIC_CITY'

print(city_cache.settings[PROP_QUERY_ENTITIES])
# {
#     'key_type_name': (