Package net.rubyeye.xmemcached.networking

Examples of net.rubyeye.xmemcached.networking.MemcachedSession


  protected MemcachedSessionLocator sessionLocator;

  protected final ConcurrentHashMap<InetSocketAddress, Queue<Session>> sessionMap = new ConcurrentHashMap<InetSocketAddress, Queue<Session>>();

  public synchronized void addSession(Session session) {
    MemcachedSession tcpSession = (MemcachedSession) session;
    InetSocketAddressWrapper addrWrapper = tcpSession
        .getInetSocketAddressWrapper();

    InetSocketAddress mainNodeAddress = addrWrapper.getMainNodeAddress();
    if (mainNodeAddress != null) {
      // It is a standby session
View Full Code Here


  }

  private final Random random = new Random();

  public void send(final Command msg) throws MemcachedException {
    MemcachedSession session = (MemcachedSession) this
        .findSessionByKey(msg.getKey());
    if (session == null) {
      throw new MemcachedException(
          "There is no available connection at this moment");
    }
    // If session was closed,try to use standby memcached node
    if (session.isClosed()) {
      session = this.findStandbySession(session);
    }
    if (session.isClosed()) {
      throw new MemcachedException("Session("
          + SystemUtils.getRawAddress(session
              .getRemoteSocketAddress()) + ":"
          + session.getRemoteSocketAddress().getPort()
          + ") has been closed");
    }
    if (session.isAuthFailed()) {
      throw new MemcachedException("Auth failed to connection "
          + session.getRemoteSocketAddress());
    }
    session.write(msg);
  }
View Full Code Here

        if (!session.isAllowReconnect()) {
          return;
        }
        session.setAllowReconnect(false);
      }
      MemcachedSession memcachedTCPSession = session;
      InetSocketAddressWrapper inetSocketAddressWrapper = memcachedTCPSession
          .getInetSocketAddressWrapper();
      this.client.getConnector().addToWatingQueue(
          new ReconnectRequest(inetSocketAddressWrapper, 0,
              this.client.getHealSessionInterval()));
    }
View Full Code Here


  protected final ConcurrentHashMap<InetSocketAddress, Queue<Session>> sessionMap = new ConcurrentHashMap<InetSocketAddress, Queue<Session>>();

  public synchronized void addSession(Session session) {
    MemcachedSession tcpSession = (MemcachedSession) session;

    InetSocketAddressWrapper addrWrapper = tcpSession
        .getInetSocketAddressWrapper();
    // Remember the first time address resolved and use it in all
    // application lifecycle.
    if (addrWrapper.getRemoteAddressStr() == null) {
      addrWrapper.setRemoteAddressStr(String.valueOf(session
View Full Code Here

  }

  private final Random random = new Random();

  public Session send(final Command msg) throws MemcachedException {
    MemcachedSession session = (MemcachedSession) this.findSessionByKey(msg
        .getKey());
    if (session == null) {
      throw new MemcachedException(
          "There is no available connection at this moment");
    }
    // If session was closed,try to use standby memcached node
    if (session.isClosed()) {
      session = this.findStandbySession(session);
    }
    if (session.isClosed()) {
      throw new MemcachedException("Session("
          + SystemUtils.getRawAddress(session
              .getRemoteSocketAddress()) + ":"
              + session.getRemoteSocketAddress().getPort()
              + ") has been closed");
    }
    if (session.isAuthFailed()) {
      throw new MemcachedException("Auth failed to connection "
          + session.getRemoteSocketAddress());
    }
    session.write(msg);
    return session;
  }
View Full Code Here

        if (!session.isAllowReconnect()) {
          return;
        }
        session.setAllowReconnect(false);
      }
      MemcachedSession memcachedTCPSession = session;
      InetSocketAddressWrapper inetSocketAddressWrapper = memcachedTCPSession
          .getInetSocketAddressWrapper();
      this.client.getConnector().addToWatingQueue(
          new ReconnectRequest(inetSocketAddressWrapper, 0,
              this.client.getHealSessionInterval()));
    }
View Full Code Here

public class MemcachedSessionComparator implements Comparator<Session>,
    Serializable {
  static final long serialVersionUID = -1L;

  public int compare(Session o1, Session o2) {
    MemcachedSession session1 = (MemcachedSession) o1;
    MemcachedSession session2 = (MemcachedSession) o2;
    if (session1 == null) {
      return -1;
    }
    if (session2 == null) {
      return 1;
    }
    return session1.getInetSocketAddressWrapper().getOrder()
        - session2.getInetSocketAddressWrapper().getOrder();
  }
View Full Code Here

    Session result = null;
    long highScore = 0;
    for (Session session : copySessionList) {
      long hash = 0;
      if (session instanceof MemcachedTCPSession) {
        MemcachedSession tcpSession = (MemcachedSession) session;
        for (int i = 0; i < tcpSession.getWeight(); i++) {
          hash = this.hashAlgorithm.hash(session
              .getRemoteSocketAddress().toString()
              + "-" + i + key);
          if (hash > highScore) {
            highScore = hash;
View Full Code Here

TOP

Related Classes of net.rubyeye.xmemcached.networking.MemcachedSession

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.