use of org.nustaq.kontraktor.remoting.base.ActorClientConnector in project kontraktor by RuedigerMoeller.
the class KxReactiveStreams method connect.
/**
* @param eventType
* @param connectable
* @param disconHandler - can be null
* @param <T>
* @return
*/
public <T> IPromise<KxPublisher<T>> connect(Class<T> eventType, ConnectableActor connectable, Callback<ActorClientConnector> disconHandler) {
Callback<ActorClientConnector> discon = (acc, err) -> {
Log.Info(this, "Client disconnected");
acc.closeClient();
if (disconHandler != null) {
disconHandler.complete(acc, err);
}
};
IPromise connect = connectable.actorClass(KxPublisherActor.class).inboundQueueSize(scheduler.getDefaultQSize()).connect(discon, r -> {
Object remoteref = r;
if (((KxPublisherActor) remoteref)._callerSideSubscribers != null) {
((KxPublisherActor) remoteref)._callerSideSubscribers.forEach(subs -> {
((Subscriber) subs).onError(new IOException("connection lost"));
});
((KxPublisherActor) remoteref)._callerSideSubscribers = null;
}
});
Promise<KxPublisher<T>> res = new Promise<>();
connect.then((publisher, err) -> {
if (publisher != null) {
((KxPublisherActor) publisher)._streams = this;
res.resolve((KxPublisher<T>) publisher);
} else {
res.reject(err);
}
});
return res;
}
use of org.nustaq.kontraktor.remoting.base.ActorClientConnector in project kontraktor by RuedigerMoeller.
the class TCPNIOKStreamsTest method testClient1.
@Test
@Ignore
public void testClient1() throws InterruptedException {
AtomicLong received = new AtomicLong(0);
Callback<ActorClientConnector> discon = (acc, err) -> {
System.out.println("Client disconnected");
};
KxPublisher<String> remote = get().connect(String.class, getRemoteConnector(), discon).await();
RateMeasure ms = new RateMeasure("event rate");
remote.syncMap(string -> string.length()).syncMap(number -> number > 10 ? number : number).subscribe((str, err) -> {
if (isErrorOrComplete(err)) {
System.out.println("complete");
} else if (isError(err)) {
System.out.println("ERROR");
} else {
received.incrementAndGet();
ms.count();
}
});
while (true) {
Thread.sleep(100);
}
}
use of org.nustaq.kontraktor.remoting.base.ActorClientConnector in project kontraktor by RuedigerMoeller.
the class TCPNIOKStreamsTest method testClient.
@Test
@Ignore
public void testClient() throws InterruptedException {
AtomicLong received = new AtomicLong(0);
Callback<ActorClientConnector> discon = (acc, err) -> {
System.out.println("Client disconnected");
};
KxPublisher<String> remote = get().connect(String.class, getRemoteConnector(), discon).await();
RateMeasure ms = new RateMeasure("event rate");
remote.subscribe((str, err) -> {
if (isErrorOrComplete(err)) {
System.out.println("complete e:" + err + " r:" + str);
} else if (isError(err)) {
System.out.println("ERROR " + err);
} else {
received.incrementAndGet();
ms.count();
}
});
while (true) {
Thread.sleep(100);
}
}
use of org.nustaq.kontraktor.remoting.base.ActorClientConnector in project kontraktor by RuedigerMoeller.
the class TCPNIOKStreamsTest method testClient3.
// cleanup of async processors
@Test
// cleanup of async processors
@Ignore
public void testClient3() throws InterruptedException {
AtomicLong received = new AtomicLong(0);
Callback<ActorClientConnector> discon = (acc, err) -> {
System.out.println("Client disconnected");
};
KxPublisher<String> remote = get().connect(String.class, getRemoteConnector(), discon).await();
RateMeasure ms = new RateMeasure("event rate");
remote.map(string -> string.length()).map(number -> number > 10 ? number : number).subscribe((str, err) -> {
if (isComplete(err)) {
System.out.println("complete");
} else if (isError(err)) {
System.out.println("ERROR " + err);
} else {
received.incrementAndGet();
ms.count();
}
});
while (true) {
Thread.sleep(100);
}
}
use of org.nustaq.kontraktor.remoting.base.ActorClientConnector in project kontraktor by RuedigerMoeller.
the class TCPNIOKStreamsTest method testClient2.
// slowdown
@Test
// slowdown
@Ignore
public void testClient2() throws InterruptedException {
AtomicLong received = new AtomicLong(0);
Callback<ActorClientConnector> discon = (acc, err) -> {
System.out.println("Client disconnected");
};
KxPublisher<String> remote = get().connect(String.class, getRemoteConnector(), discon).await();
RateMeasure ms = new RateMeasure("event rate");
remote.syncMap(string -> string.length()).syncMap(number -> number > 10 ? number : number).subscribe((str, err) -> {
if (isErrorOrComplete(err)) {
System.out.println("complete");
} else if (isError(err)) {
System.out.println("ERROR");
} else {
received.incrementAndGet();
ms.count();
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
while (true) {
Thread.sleep(100);
}
}
Aggregations