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.3.1.Final
Show newest version
package org.infinispan.client.hotrod.impl.operations;

import org.infinispan.client.hotrod.impl.ClientStatistics;
import org.infinispan.client.hotrod.impl.InternalRemoteCache;
import org.infinispan.client.hotrod.impl.protocol.Codec;
import org.infinispan.client.hotrod.impl.protocol.HotRodConstants;
import org.infinispan.client.hotrod.impl.transport.netty.HeaderDecoder;

import io.netty.buffer.ByteBuf;

public class GetOperation extends AbstractKeyOperation {
   public GetOperation(InternalRemoteCache internalRemoteCache, byte[] keyBytes) {
      super(internalRemoteCache, keyBytes);
   }

   @Override
   public V createResponse(ByteBuf buf, short status, HeaderDecoder decoder, Codec codec, CacheUnmarshaller unmarshaller) {
      if (!HotRodConstants.isNotExist(status) && HotRodConstants.isSuccess(status)) {
         return unmarshaller.readValue(buf);
      }
      return null;
   }

   @Override
   public void handleStatsCompletion(ClientStatistics statistics, long startTime, short status, Object responseValue) {
      statistics.dataRead(!HotRodConstants.isNotExist(status) && HotRodConstants.isSuccess(status), startTime, 1);
   }

   @Override
   public short requestOpCode() {
      return HotRodConstants.GET_REQUEST;
   }

   @Override
   public short responseOpCode() {
      return HotRodConstants.GET_RESPONSE;
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy