Search in sources :

Example 1 with Monitorable

use of org.nustaq.kontraktor.monitoring.Monitorable in project kontraktor by RuedigerMoeller.

the class HttpMonitor method getMonitorables.

protected IPromise<Object[]> getMonitorables(int depth, Monitorable monitorable) {
    // System.out.println("dumpmon " + monitorable);
    Promise p = new Promise();
    monitorable.$getReport().then((report, err) -> {
        Object[] result = new Object[2];
        result[0] = report;
        monitorable.$getSubMonitorables().then((monitorables, errmon) -> {
            if (monitorables.length > 0 && depth >= 1) {
                Object[] subResult = new Object[monitorables.length];
                result[1] = subResult;
                IPromise[] futs = new IPromise[monitorables.length];
                for (int i = 0; i < monitorables.length; i++) {
                    Monitorable submon = monitorables[i];
                    futs[i] = getMonitorables(depth - 1, submon);
                }
                all(futs).then((futArr, err0) -> {
                    IPromise[] futures = (IPromise[]) futArr;
                    for (int i = 0; i < futures.length; i++) {
                        IPromise future = futures[i];
                        subResult[i] = future.get();
                    }
                    p.settle(result, null);
                });
            } else
                p.settle(result, null);
        });
    });
    return p;
}
Also used : IPromise(org.nustaq.kontraktor.IPromise) Promise(org.nustaq.kontraktor.Promise) Monitorable(org.nustaq.kontraktor.monitoring.Monitorable) IPromise(org.nustaq.kontraktor.IPromise)

Example 2 with Monitorable

use of org.nustaq.kontraktor.monitoring.Monitorable in project kontraktor by RuedigerMoeller.

the class HttpMonitor method getMonitorableKeys.

public IPromise<String[]> getMonitorableKeys(String simpleClzName) {
    ArrayList<String> result = new ArrayList();
    monitored.entrySet().forEach((entry) -> {
        Monitorable mon = entry.getValue();
        if (mon instanceof Actor)
            mon = ((Actor) mon).getActor();
        if (entry.getValue() != null && mon.getClass().getSimpleName().equals(simpleClzName)) {
            result.add(entry.getKey());
        }
    });
    String[] res = new String[result.size()];
    result.toArray(res);
    return new Promise(res);
}
Also used : Monitorable(org.nustaq.kontraktor.monitoring.Monitorable) IPromise(org.nustaq.kontraktor.IPromise) Promise(org.nustaq.kontraktor.Promise) Actor(org.nustaq.kontraktor.Actor) ArrayList(java.util.ArrayList)

Aggregations

IPromise (org.nustaq.kontraktor.IPromise)2 Promise (org.nustaq.kontraktor.Promise)2 Monitorable (org.nustaq.kontraktor.monitoring.Monitorable)2 ArrayList (java.util.ArrayList)1 Actor (org.nustaq.kontraktor.Actor)1