Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

ConsulCache error #137

Closed
xieyanze opened this issue Jun 20, 2016 · 6 comments
Closed

ConsulCache error #137

xieyanze opened this issue Jun 20, 2016 · 6 comments

Comments

@xieyanze
Copy link

when serviceHealthCache add Listener
[OkHttp http://192.168.21.171:8500/v1/health/service/Demo-QuickStartService?index=8&wait=20s&passing=true] ERROR com.orbitz.consul.cache.ConsulCache - Error getting response from consul. will retry in 10 SECONDS

@rickfast
Copy link
Owner

Are you running Consul in Docker? Can you successfully curl that endpoint from the command line?

@xieyanze
Copy link
Author

not running docker.
[root@APP-Nginx ~]# curl http://192.168.21.171:8500/v1/health/service/Demo-QuickStartService?index=3873&wait=20s&passing=true
[1] 14338
[2] 14339

can not successfully this endpoint. but this endpoint can opened in web browser successfully

@zjfplayer
Copy link

the reason is in parent class ConsulCache.ConsulCache( Function<V, K> keyConversion, CallbackConsumer<V> callbackConsumer, final long backoffDelayQty, final TimeUnit backoffDelayUnit) ,it will call the method `@Override
public void onFailure(Throwable throwable) {

            if (!isRunning()) {
                return;
            }
            LOGGER.error(String.format("Error getting response from consul. will retry in %d %s", backoffDelayQty, backoffDelayUnit), throwable);

            executorService.schedule(new Runnable() {
                @Override
                public void run() {
                    runCallback();
                }
            }, backoffDelayQty, backoffDelayUnit);
        }`

the command I run consul is consul agent -bind=192.168.1.130 -http-port=8500 -data-dir=e:\consul_0.6.4_windows_amd64 -ui -server -bootstrap, and the output is ==> WARNING: Bootstrap mode enabled! Do not enable unless necessary ==> WARNING: Windows is not recommended as a Consul server. Do not use in production. ==> Starting Consul agent... ==> Starting Consul agent RPC... ==> Consul agent running! Node name: 'zhengjiefeng' Datacenter: 'dc1' Server: true (bootstrap: true) Client Addr: 127.0.0.1 (HTTP: 8500, HTTPS: -1, DNS: 8600, RPC: 8400) Cluster Addr: 192.168.1.130 (LAN: 8301, WAN: 8302) Gossip encrypt: false, RPC-TLS: false, TLS-Incoming: false Atlas: <disabled>
I don`t know how to resolve this problem.

@zjfplayer
Copy link

And the "onFailure" method's parameter throwable throws org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred while retrieving component type of array.

@zjfplayer
Copy link

My test code is your test code in java file which named "ConsulCacheTest" in package "src\test\java\com\orbitz\consul\cache",the method code is `@Test
public void testListeners() throws Exception {
KeyValueClient kvClient = client.keyValueClient();
String root = UUID.randomUUID().toString();

    KVCache nc = KVCache.newCache(
            kvClient, root, 10
    );

    final List<Map<String, Value>> events = new ArrayList<Map<String, Value>>();
    nc.addListener(new ConsulCache.Listener<String, Value>() {
        @Override
        public void notify(Map<String, Value> newValues) {
            events.add(newValues);
        }
    });

    nc.start();

    if (!nc.awaitInitialized(1, TimeUnit.SECONDS)) {
        fail("cache initialization failed");
    }

    for (int i = 0; i < 5; i++) {
        kvClient.putValue(root + "/" + i, String.valueOf(i));
        Thread.sleep(100);
    }

    assertEquals(5, events.size());

    for (int i = 0; i < 5; i++) {

        Map<String, Value> map = events.get(i);
        assertEquals(i + 1, map.size());
        for (int j = 0; j < i; j++) {
            String keyStr = "" + j;
            String valStr = keyStr;
            assertEquals(valStr, map.get(keyStr).getValueAsString().get());
        }
    }
    kvClient.deleteKeys(root);

}`

@xieyanze
Copy link
Author

xieyanze commented Oct 8, 2016

thanks

@xieyanze xieyanze closed this as completed Oct 8, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants