use of org.apache.ignite.internal.client.thin.ClientNotificationType.CONTINUOUS_QUERY_EVENT in project ignite by apache.
the class ClientCacheEntryListenerHandler method startListen.
/**
* Send request to the server and start
*/
public synchronized void startListen(CacheEntryUpdatedListener<K, V> locLsnr, ClientDisconnectListener disconnectLsnr, Factory<? extends CacheEntryEventFilter<? super K, ? super V>> rmtFilterFactory, int pageSize, long timeInterval, boolean includeExpired) {
assert locLsnr != null;
if (clientCh != null)
throw new IllegalStateException("Listener was already started");
this.locLsnr = locLsnr;
this.disconnectLsnr = disconnectLsnr;
Consumer<PayloadOutputChannel> qryWriter = payloadCh -> {
BinaryOutputStream out = payloadCh.out();
out.writeInt(ClientUtils.cacheId(jCacheAdapter.getName()));
out.writeByte(keepBinary ? KEEP_BINARY_FLAG_MASK : 0);
out.writeInt(pageSize);
out.writeLong(timeInterval);
out.writeBoolean(includeExpired);
if (rmtFilterFactory == null)
out.writeByte(GridBinaryMarshaller.NULL);
else {
utils.writeObject(out, rmtFilterFactory);
out.writeByte(JAVA_PLATFORM);
}
};
Function<PayloadInputChannel, T2<ClientChannel, Long>> qryReader = payloadCh -> {
ClientChannel ch = payloadCh.clientChannel();
Long rsrcId = payloadCh.in().readLong();
ch.addNotificationListener(CONTINUOUS_QUERY_EVENT, rsrcId, this);
return new T2<>(ch, rsrcId);
};
try {
T2<ClientChannel, Long> params = ch.service(ClientOperation.QUERY_CONTINUOUS, qryWriter, qryReader);
clientCh = params.get1();
rsrcId = params.get2();
} catch (ClientError e) {
throw new ClientException(e);
}
}
Aggregations