Examples of MemcachedException


Examples of net.rubyeye.xmemcached.exception.MemcachedException

    CountDownLatch latch = new CountDownLatch(1);

    Queue<Session> sessionQueue = this.connector
        .getSessionByAddress(address);
    if (sessionQueue == null || sessionQueue.peek() == null) {
      throw new MemcachedException("could not find session for "
          + SystemUtils.getRawAddress(address) + ":"
          + address.getPort() + ",maybe it have not been connected");
    }
    Command command = this.commandFactory.createStatsCommand(address,
        latch, null);
View Full Code Here

Examples of net.rubyeye.xmemcached.exception.MemcachedException

    if (!command.isNoreply()) {
      this.latchWait(command, operationTimeout, session);
      command.getIoBuffer().free();
      this.checkException(command);
      if (command.getResult() == null) {
        throw new MemcachedException(
            "Operation fail,may be caused by networking or timeout");
      }
      final Object result = command.getResult();
      if (result instanceof String) {
        if (((String) result).equals("NOT_FOUND")) {
          if (this.add0(key, exp, String.valueOf(initValue),
              this.transcoder, this.opTimeout)) {
            return initValue;
          } else {
            return this.sendIncrOrDecrCommand(key, delta,
                initValue, cmdType, noreply, operationTimeout,
                exp);
          }
        } else {
          throw new MemcachedException(
              "Unknown result type for incr/decr:"
                  + result.getClass() + ",result=" + result);
        }
      } else {
        return (Long) command.getResult();
View Full Code Here

Examples of net.rubyeye.xmemcached.exception.MemcachedException

    if (!command.isNoreply()) {
      this.latchWait(command, timeout, session);
      command.getIoBuffer().free();
      this.checkException(command);
      if (command.getResult() == null) {
        throw new MemcachedException(
            "Operation fail,may be caused by networking or timeout");
      }
    } else {
      return false;
    }
View Full Code Here

Examples of net.rubyeye.xmemcached.exception.MemcachedException

  private String decodeKey(String key) throws MemcachedException,
      InterruptedException, TimeoutException {
    try {
      key = this.sanitizeKeys ? URLDecoder.decode(key, "UTF-8") : key;
    } catch (UnsupportedEncodingException e) {
      throw new MemcachedException(
          "Unsupport encoding utf-8 when decodeKey", e);
    }
    String ns = NAMESPACE_LOCAL.get();
    if (ns != null && ns.trim().length() > 0) {
      String nsValue = this.getNamespace(ns);
      try {
        if (nsValue != null && key.startsWith(nsValue)) {
          //The extra length of ':'
          key = key.substring(nsValue.length() + 1);
        } else {
          return null;
        }
      } catch (Exception e) {
        throw new MemcachedException(
            "Exception occured when decode key.", e);
      }
    }
    return key;
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.exception.MemcachedException

      InterruptedException {
    key = this.keyProvider.process(key);
    try {
      key = this.sanitizeKeys ? URLEncoder.encode(key, "UTF-8") : key;
    } catch (UnsupportedEncodingException e) {
      throw new MemcachedException(
          "Unsupport encoding utf-8 when sanitize key", e);
    }
    String ns = NAMESPACE_LOCAL.get();
    if (ns != null && ns.trim().length() > 0) {
      try {
        key = this.getNamespace(ns) + ":" + key;
      } catch (TimeoutException e) {
        throw new MemcachedException(
            "Timeout occured when gettting namespace value.", e);
      }
    }
    return key;
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.exception.MemcachedException

    if (address == null) {
      throw new IllegalArgumentException("null address");
    }
    Queue<Session> sessions = this.connector.getSessionByAddress(address);
    if (sessions == null || sessions.size() == 0) {
      throw new MemcachedException(
          "The special memcached server has not been connected,"
              + address);
    }
    Session session = sessions.peek();
    CountDownLatch latch = new CountDownLatch(1);
    Command command = this.commandFactory.createStatsCommand(
        session.getRemoteSocketAddress(), latch, "items");
    session.write(command);
    if (!latch.await(5000, TimeUnit.MILLISECONDS)) {
      throw new TimeoutException("Operation timeout");
    }
    if (command.getException() != null) {
      if (command.getException() instanceof MemcachedException) {
        throw (MemcachedException) command.getException();
      } else {
        throw new MemcachedException("stats items failed",
            command.getException());
      }
    }
    Map<String, String> result = (Map<String, String>) command.getResult();
    LinkedList<Integer> itemNumberList = new LinkedList<Integer>();
View Full Code Here

Examples of net.rubyeye.xmemcached.exception.MemcachedException

    return result;
  }

  private final void sendCommand(final Command cmd) throws MemcachedException {
    if (this.shutdown) {
      throw new MemcachedException("Xmemcached is stopped");
    }
    this.connector.send(cmd);
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.exception.MemcachedException

    byte[] keyBytes = this.checkStoreArguments(key, exp, value);
    try {
      this.sendStoreCommand(this.commandFactory.createSetCommand(key,
          keyBytes, exp, value, true, transcoder), this.opTimeout);
    } catch (TimeoutException e) {
      throw new MemcachedException(e);
    }
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.exception.MemcachedException

    byte[] keyBytes = this.checkStoreArguments(key, exp, value);
    try {
      this.sendStoreCommand(this.commandFactory.createAddCommand(key,
          keyBytes, exp, value, true, transcoder), this.opTimeout);
    } catch (TimeoutException e) {
      throw new MemcachedException(e);
    }

  }
View Full Code Here

Examples of net.rubyeye.xmemcached.exception.MemcachedException

    byte[] keyBytes = this.checkStoreArguments(key, exp, value);
    try {
      this.sendStoreCommand(this.commandFactory.createReplaceCommand(key,
          keyBytes, exp, value, true, transcoder), this.opTimeout);
    } catch (TimeoutException e) {
      throw new MemcachedException(e);
    }

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.