All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.hotrod.impl.operations.IterationEndOperation Maven / Gradle / Ivy

package org.infinispan.hotrod.impl.operations;

import static org.infinispan.hotrod.impl.logging.Log.HOTROD;

import java.util.concurrent.CompletableFuture;

import org.infinispan.api.common.CacheOptions;
import org.infinispan.hotrod.impl.transport.netty.HeaderDecoder;

import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;

/**
 * @since 14.0
 */
public class IterationEndOperation extends HotRodOperation {
   private final byte[] iterationId;
   private final Channel channel;

   protected IterationEndOperation(OperationContext operationContext, CacheOptions options, byte[] iterationId, Channel channel) {
      super(operationContext, ITERATION_END_REQUEST, ITERATION_END_RESPONSE, options);
      this.iterationId = iterationId;
      this.channel = channel;
   }

   @Override
   public CompletableFuture execute() {
      if (!channel.isActive()) {
         throw HOTROD.channelInactive(channel.remoteAddress(), channel.remoteAddress());
      }
      scheduleRead(channel);
      sendArrayOperation(channel, iterationId);
      releaseChannel(channel);
      return this;
   }

   @Override
   public void acceptResponse(ByteBuf buf, short status, HeaderDecoder decoder) {
      complete(new IterationEndResponse(status));
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy