org.infinispan.client.hotrod.impl.operations.BulkGetKeysOperation Maven / Gradle / Ivy
package org.infinispan.client.hotrod.impl.operations;
import java.net.SocketAddress;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import org.infinispan.client.hotrod.Flag;
import org.infinispan.client.hotrod.impl.protocol.Codec;
import org.infinispan.client.hotrod.impl.protocol.HeaderParams;
import org.infinispan.client.hotrod.impl.transport.Transport;
import org.infinispan.client.hotrod.impl.transport.TransportFactory;
/**
* Reads all keys. Similar to BulkGet, but without the entry values.
*
* @author Ray Tsang
* @since 5.2
*/
public class BulkGetKeysOperation extends RetryOnFailureOperation> {
private final int scope;
public BulkGetKeysOperation(Codec codec, TransportFactory transportFactory, byte[] cacheName, AtomicInteger topologyId, Flag[] flags, int scope) {
super(codec, transportFactory, cacheName, topologyId, flags);
this.scope = scope;
}
@Override
protected Transport getTransport(int retryCount, Set failedServers) {
return transportFactory.getTransport(failedServers, cacheName);
}
@Override
protected Set executeOperation(Transport transport) {
HeaderParams params = writeHeader(transport, BULK_GET_KEYS_REQUEST);
transport.writeVInt(scope);
transport.flush();
readHeaderAndValidate(transport, params);
Set result = new HashSet();
while ( transport.readByte() == 1) { //there's more!
result.add(transport.readArray());
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy