public static JSONArray monitorForHA() {
        Map<String, Cache> CACHE = Redis.unmodifiableCache();

        JSONArray monitors = new JSONArray();

        if (CACHE == null || CACHE.isEmpty())
            return monitors;

        JSONObject monitor = new JSONObject();
        monitor.put("application", EnvUtil.getApplication());
        monitor.put("nodeId", LocalNodeManager.LOCAL_NODE_ID);

        for (Map.Entry<String, Cache> entry : CACHE.entrySet()) {
            Cache cache = entry.getValue();
            if (cache == null)
                continue;

            try {
                monitor.put("instance", cache.getName());

                monitors.add(new JSONObject() {{
                    putAll(monitor);

                    put("value", cache.highAvailable() ? 1 : -1);
                    put("name", "HA");
                }});
            } catch (Exception e) {
                LOG.error(String.format("Jedis Pool: %s (Grafana) monitor 出现异常", entry.getKey()), e);
            }
        }

        return monitors;
    }
public static JSONArray monitorForHA ( ) { Map < String , Cache > CACHE = Redis . unmodifiableCache ( ) ; JSONArray monitors = new JSONArray ( ) ; if ( CACHE == null || CACHE . isEmpty ( ) ) return monitors ; JSONObject monitor = new JSONObject ( ) ; monitor . put ( "application" , EnvUtil . getApplication ( ) ) ; monitor . put ( "nodeId" , LocalNodeManager . LOCAL_NODE_ID ) ; for ( Map . Entry < String , Cache > entry : CACHE . entrySet ( ) ) { Cache cache = entry . getValue ( ) ; if ( cache == null ) continue ; try { monitor . put ( "instance" , cache . getName ( ) ) ; monitors . add ( new JSONObject ( ) { { putAll ( monitor ) ; put ( "value" , cache . highAvailable ( ) ? 1 : - 1 ) ; put ( "name" , "HA" ) ; } } ) ; } catch ( Exception e ) { LOG . error ( String . format ( "Jedis Pool: %s (Grafana) monitor 出现异常" , entry . getKey ( ) ) , e ) ; } } return monitors ; }
健康检查

@return