Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.infinispan.client.hotrod.impl.operations;
 
 import java.util.Set;
 

Author(s):
gustavonalle
Since:
8.0
   private static final Log log = LogFactory.getLog(IterationStartOperation.class);
   private final String filterConverterFactory;
   private final Set<Integersegments;
   private final int batchSize;
   private final TransportFactory transportFactory;
   protected IterationStartOperation(Codec codecFlag[] flagsbyte[] cacheNameAtomicInteger topologyId,
                                     String filterConverterFactorySet<Integersegmentsint batchSizeTransportFactory transportFactory) {
      super(codectransportFactorycacheNametopologyIdflags);
      this. = filterConverterFactory;
      this. = segments;
      this. = batchSize;
      this. = transportFactory;
   }
   @Override
   protected Transport getTransport(int retryCountSet<SocketAddressfailedServers) {
      if(.isDebugEnabled() && consistentHash == null) {
         .noConsistentHashAvailable();
      }
      if ( == null || .isEmpty() || consistentHash == null) {
         return .getTransport(failedServers);
      }
      SegmentConsistentHash segmentConsistentHash = (SegmentConsistentHashconsistentHash;
      SocketAddress[][] owners = segmentConsistentHash.getSegmentOwners();
      Set<SocketAddressbestServers = new HashSet<>();
      .forEach(s -> Collections.addAll(bestServersowners[s][0]));
      if (failedServers != null) {
         failedServers.forEach(bestServers::remove);
      }
      if (bestServers.isEmpty()) {
         return .getTransport(failedServers);
      }
      return .getAddressTransport(bestServers.iterator().next());
   }
   @Override
   protected IterationStartResponse executeOperation(Transport transport) {
      HeaderParams params = writeHeader(transport);
      if ( == null) {
         transport.writeSignedVInt(-1);
      } else {
         // TODO use a more compact BitSet implementation, like http://roaringbitmap.org/
         BitSet bitSet = new BitSet();
         .stream().forEach(bitSet::set);
         transport.writeOptionalArray(bitSet.toByteArray());
      }
      transport.writeVInt();
      transport.flush();
      readHeaderAndValidate(transportparams);
   }
   @Override
   protected void releaseTransport(Transport transport) {
   }
New to GrepCode? Check out our FAQ X