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

org.infinispan.client.hotrod.impl.operations.GetOperation Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
package org.infinispan.client.hotrod.impl.operations;

import net.jcip.annotations.Immutable;
import org.infinispan.client.hotrod.configuration.Configuration;
import org.infinispan.client.hotrod.impl.protocol.Codec;
import org.infinispan.client.hotrod.impl.protocol.HotRodConstants;
import org.infinispan.client.hotrod.impl.transport.Transport;
import org.infinispan.client.hotrod.impl.transport.TransportFactory;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * Implements "get" operation as described by Hot Rod protocol specification.
 *
 * @author [email protected]
 * @since 4.1
 */
@Immutable
public class GetOperation extends AbstractKeyOperation {

   public GetOperation(Codec codec, TransportFactory transportFactory,
                       Object key, byte[] keyBytes, byte[] cacheName, AtomicInteger topologyId, int flags,
                       Configuration cfg) {
      super(codec, transportFactory, key, keyBytes, cacheName, topologyId, flags, cfg);
   }

   @Override
   public V executeOperation(Transport transport) {
      V result = null;
      short status = sendKeyOperation(keyBytes, transport, GET_REQUEST, GET_RESPONSE);
      if (HotRodConstants.isNotExist(status)) {
         result = null;
      } else {
         if (HotRodConstants.isSuccess(status)) {
            result = codec.readUnmarshallByteArray(transport, status, cfg.serialWhitelist());
         }
      }
      return result;
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy