Package org.infinispan.client.hotrod.impl.transport

Examples of org.infinispan.client.hotrod.impl.transport.Transport


   }

   public byte[] get(byte[] key, Flag[] flags) {
      for (int i = 0; i < transportFactory.getTransportCount(); i++) {
         try {
            Transport transport = getTransport(key, i == 0);
            try {
               short status = sendKeyOperation(key, transport, GET_REQUEST, flags, GET_RESPONSE);
               if (status == KEY_DOES_NOT_EXIST_STATUS) {
                  return null;
               }
               if (status == NO_ERROR_STATUS) {
                  return transport.readArray();
               }
            } finally {
               releaseTransport(transport);
            }
         } catch (TransportException te) {
View Full Code Here


      throw new IllegalStateException("We should not reach here!");
   }

   public byte[] remove(byte[] key, Flag[] flags) {
      for (int i = 0; i < transportFactory.getTransportCount(); i++) {
         Transport transport = getTransport(key, i == 0);
         try {
            short status = sendKeyOperation(key, transport, REMOVE_REQUEST, flags, REMOVE_RESPONSE);
            if (status == KEY_DOES_NOT_EXIST_STATUS) {
               return null;
            } else if (status == NO_ERROR_STATUS) {
View Full Code Here

      throw new IllegalStateException("We should not reach here!");
   }

   public boolean containsKey(byte[] key, Flag... flags) {
      for (int i = 0; i < transportFactory.getTransportCount(); i++) {
         Transport transport = getTransport(key, i == 0);
         try {
            short status = sendKeyOperation(key, transport, CONTAINS_KEY_REQUEST, flags, CONTAINS_KEY_RESPONSE);
            if (status == KEY_DOES_NOT_EXIST_STATUS) {
               return false;
            } else if (status == NO_ERROR_STATUS) {
View Full Code Here

      throw new IllegalStateException("We should not reach here!");
   }

   public BinaryVersionedValue getWithVersion(byte[] key, Flag... flags) {
      for (int i = 0; i < transportFactory.getTransportCount(); i++) {
         Transport transport = getTransport(key, i == 0);
         try {
            short status = sendKeyOperation(key, transport, GET_WITH_VERSION, flags, GET_WITH_VERSION_RESPONSE);
            if (status == KEY_DOES_NOT_EXIST_STATUS) {
               return null;
            }
            if (status == NO_ERROR_STATUS) {
               long version = transport.readLong();
               if (log.isTraceEnabled()) {
                  log.trace("Received version: " + version);
               }
               byte[] value = transport.readArray();
               return new BinaryVersionedValue(version, value);
            }
         } catch (TransportException te) {
            logErrorAndThrowExceptionIfNeeded(i, te);
         } finally {
View Full Code Here

   }


   public byte[] put(byte[] key, byte[] value, int lifespan, int maxIdle, Flag... flags) {
      for (int i = 0; i < transportFactory.getTransportCount(); i++) {
         Transport transport = getTransport(key, i == 0);
         try {
            short status = sendPutOperation(key, value, transport, PUT_REQUEST, PUT_RESPONSE, lifespan, maxIdle, flags);
            if (status != NO_ERROR_STATUS) {
               throw new InvalidResponseException("Unexpected response status: " + Integer.toHexString(status));
            }
View Full Code Here

      throw new IllegalStateException("This should not be reached!");
   }

   public byte[] putIfAbsent(byte[] key, byte[] value, int lifespan, int maxIdle, Flag... flags) {
      for (int i = 0; i < transportFactory.getTransportCount(); i++) {
         Transport transport = getTransport(key, i == 0);
         try {
            short status = sendPutOperation(key, value, transport, PUT_IF_ABSENT_REQUEST, PUT_IF_ABSENT_RESPONSE, lifespan, maxIdle, flags);
            if (status == NO_ERROR_STATUS || status == NOT_PUT_REMOVED_REPLACED_STATUS) {
               byte[] bytes = returnPossiblePrevValue(transport, flags);
               if (log.isTraceEnabled()) {
View Full Code Here

      throw new IllegalStateException("We should not reach here!");
   }

   public byte[] replace(byte[] key, byte[] value, int lifespan, int maxIdle, Flag... flags) {
      for (int i = 0; i < transportFactory.getTransportCount(); i++) {
         Transport transport = getTransport(key, i == 0);
         try {
            short status = sendPutOperation(key, value, transport, REPLACE_REQUEST, REPLACE_RESPONSE, lifespan, maxIdle, flags);
            if (status == NO_ERROR_STATUS || status == NOT_PUT_REMOVED_REPLACED_STATUS) {
               return returnPossiblePrevValue(transport, flags);
            }
View Full Code Here

    * If the key does not exist or previous was null, value length would be 0. Otherwise, if no ForceReturnPreviousValue
    * was sent, the response would be empty.
    */
   public VersionedOperationResponse replaceIfUnmodified(byte[] key, byte[] value, int lifespan, int maxIdle, long version, Flag... flags) {
      for (int i = 0; i < transportFactory.getTransportCount(); i++) {
         Transport transport = getTransport(key, i == 0);
         try {
            // 1) write header
            long messageId = HotRodOperationsHelper.writeHeader(transport, REPLACE_IF_UNMODIFIED_REQUEST, cacheName, topologyId, flags);

            //2) write message body
            transport.writeArray(key);
            transport.writeVInt(lifespan);
            transport.writeVInt(maxIdle);
            transport.writeLong(version);
            transport.writeArray(value);
            return returnVersionedOperationResponse(transport, messageId, REPLACE_IF_UNMODIFIED_RESPONSE, flags);
         } catch (TransportException te) {
            logErrorAndThrowExceptionIfNeeded(i, te);
         }
         finally {
View Full Code Here

   /**
    * Request: [header][key length][key][entry_version]
    */
   public VersionedOperationResponse removeIfUnmodified(byte[] key, long version, Flag... flags) {
      for (int i = 0; i < transportFactory.getTransportCount(); i++) {
         Transport transport = getTransport(key, i == 0);
         try {
            // 1) write header
            long messageId = HotRodOperationsHelper.writeHeader(transport, REMOVE_IF_UNMODIFIED_REQUEST, cacheName, topologyId, flags);

            //2) write message body
            transport.writeArray(key);
            transport.writeLong(version);

            //process response and return
            return returnVersionedOperationResponse(transport, messageId, REMOVE_IF_UNMODIFIED_RESPONSE, flags);

         } catch (TransportException te) {
View Full Code Here

      throw new IllegalStateException("Should not reach this point!");
   }

   public void clear(Flag... flags) {
      for (int i = 0; i < transportFactory.getTransportCount(); i++) {
         Transport transport = transportFactory.getTransport();
         try {
            // 1) write header
            long messageId = HotRodOperationsHelper.writeHeader(transport, CLEAR_REQUEST, cacheName, topologyId, flags);
            HotRodOperationsHelper.readHeaderAndValidate(transport, messageId, CLEAR_RESPONSE, topologyId);
         } catch (TransportException te) {
View Full Code Here

TOP

Related Classes of org.infinispan.client.hotrod.impl.transport.Transport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.