Search in sources :

Example 6 with Pair

use of org.nustaq.kontraktor.util.Pair in project kontraktor by RuedigerMoeller.

the class ServiceRegistry method serviceDumper.

public void serviceDumper() {
    if (!isStopped()) {
        try {
            Log.Info(this, "------");
            services.forEach((k, sd) -> Log.Info(this, "" + sd));
            Log.Info(this, "------");
            listeners.forEach(cb -> {
                cb.pipe(new Pair(SERVICEDUMP, services));
            });
            if (ClusterCfg.isDirty()) {
                config = ClusterCfg.read();
                listeners.forEach(cb -> cb.pipe(new Pair(CONFIGUPDATE, config)));
            }
        } catch (Exception e) {
            Log.Error(this, e);
        }
        delayed(10000, () -> serviceDumper());
    }
}
Also used : Pair(org.nustaq.kontraktor.util.Pair)

Example 7 with Pair

use of org.nustaq.kontraktor.util.Pair in project kontraktor by RuedigerMoeller.

the class KxStreamServer method init.

public void init() {
    streams = new HashMap<>();
    timeSink = new EventSink<Long>();
    // EventSink is *not* remoteable,
    // need to create an remoteable async publisher (is actor, so remoteable)
    streams.put("TIME", new Pair(timeSink.map(l -> l), true));
    tick();
}
Also used : Pair(org.nustaq.kontraktor.util.Pair)

Example 8 with Pair

use of org.nustaq.kontraktor.util.Pair in project kontraktor by RuedigerMoeller.

the class RESTActor method postStuff1.

// curl -i -X POST --data "{ \"key\": \"value\", \"nkey\": 13 }" http://localhost:8080/api/stuff1
public IPromise postStuff1(JsonObject body, HeaderMap headerValues) {
    headerValues.forEach(hv -> {
        Log.Info(this, "" + hv.getHeaderName());
        hv.forEach(s -> {
            Log.Info(this, "    " + s);
        });
    });
    Log.Info(this, "" + body);
    return resolve(new Pair(202, body.toString()));
}
Also used : Pair(org.nustaq.kontraktor.util.Pair)

Example 9 with Pair

use of org.nustaq.kontraktor.util.Pair in project kontraktor by RuedigerMoeller.

the class HttpObjectSocket method getNextQueuedMessage.

public Pair<byte[], Integer> getNextQueuedMessage() {
    synchronized (this) {
        // if ( queue.available() < 8 )
        {
            try {
                flush();
            } catch (Exception e) {
                FSTUtil.rethrow(e);
            }
        }
        if (queue.available() > 8) {
            int seq = queue.readInt();
            int len = queue.readInt();
            if (len > 0 && queue.available() >= len)
                return new Pair(queue.readByteArray(len), seq);
            else
                return new Pair(new byte[0], 0);
        } else {
            return new Pair(new byte[0], 0);
        }
    }
}
Also used : IOException(java.io.IOException) Pair(org.nustaq.kontraktor.util.Pair)

Aggregations

Pair (org.nustaq.kontraktor.util.Pair)9 IOException (java.io.IOException)3 JCommander (com.beust.jcommander.JCommander)1 JsonObject (com.eclipsesource.json.JsonObject)1 JsonValue (com.eclipsesource.json.JsonValue)1 java.io (java.io)1 Serializable (java.io.Serializable)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Annotation (java.lang.annotation.Annotation)1 ByteBuffer (java.nio.ByteBuffer)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 IPromise (org.nustaq.kontraktor.IPromise)1 Kson (org.nustaq.kson.Kson)1