Codota Logo
SessionTrackerImpl$SessionImpl
Code IndexAdd Codota to your IDE (free)

How to use
SessionTrackerImpl$SessionImpl
in
org.apache.zookeeper.server

Best Java code snippets using org.apache.zookeeper.server.SessionTrackerImpl$SessionImpl (Showing top 10 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
List l =
  • Codota Iconnew LinkedList()
  • Codota IconCollections.emptyList()
  • Codota Iconnew ArrayList()
  • Smart code suggestions by Codota
}
origin: apache/zookeeper

@Override
public synchronized boolean trackSession(long id, int sessionTimeout) {
  boolean added = false;
  SessionImpl session = sessionsById.get(id);
  if (session == null){
    session = new SessionImpl(id, sessionTimeout);
  }
  // findbugs2.0.3 complains about get after put.
  // long term strategy would be use computeIfAbsent after JDK 1.8
  SessionImpl existedSession = sessionsById.putIfAbsent(id, session);
  if (existedSession != null) {
    session = existedSession;
  } else {
    added = true;
    LOG.debug("Adding session 0x" + Long.toHexString(id));
  }
  if (LOG.isTraceEnabled()) {
    String actionStr = added ? "Adding" : "Existing";
    ZooTrace.logTraceMessage(LOG, ZooTrace.SESSION_TRACE_MASK,
        "SessionTrackerImpl --- " + actionStr + " session 0x"
        + Long.toHexString(id) + " " + sessionTimeout);
  }
  updateSessionExpiry(session, sessionTimeout);
  return added;
}
origin: apache/zookeeper

synchronized public void setOwner(long id, Object owner) throws SessionExpiredException {
  SessionImpl session = sessionsById.get(id);
  if (session == null || session.isClosing()) {
    throw new KeeperException.SessionExpiredException();
  }
  session.owner = owner;
}
origin: apache/zookeeper

synchronized public boolean touchSession(long sessionId, int timeout) {
  SessionImpl s = sessionsById.get(sessionId);
  if (s == null) {
    logTraceTouchInvalidSession(sessionId, timeout);
    return false;
  }
  if (s.isClosing()) {
    logTraceTouchClosingSession(sessionId, timeout);
    return false;
  }
  updateSessionExpiry(s, timeout);
  return true;
}
origin: apache/zookeeper

public synchronized void checkSession(long sessionId, Object owner)
    throws KeeperException.SessionExpiredException,
    KeeperException.SessionMovedException,
    KeeperException.UnknownSessionException {
  LOG.debug("Checking session 0x" + Long.toHexString(sessionId));
  SessionImpl session = sessionsById.get(sessionId);
  if (session == null) {
    throw new KeeperException.UnknownSessionException();
  }
  if (session.isClosing()) {
    throw new KeeperException.SessionExpiredException();
  }
  if (session.owner == null) {
    session.owner = owner;
  } else if (session.owner != owner) {
    throw new KeeperException.SessionMovedException();
  }
}
origin: org.apache.zookeeper/zookeeper

synchronized public void checkSession(long sessionId, Object owner) throws KeeperException.SessionExpiredException, KeeperException.SessionMovedException {
  SessionImpl session = sessionsById.get(sessionId);
  if (session == null || session.isClosing()) {
    throw new KeeperException.SessionExpiredException();
  }
  if (session.owner == null) {
    session.owner = owner;
  } else if (session.owner != owner) {
    throw new KeeperException.SessionMovedException();
  }
}
origin: org.apache.zookeeper/zookeeper

  synchronized public void setOwner(long id, Object owner) throws SessionExpiredException {
    SessionImpl session = sessionsById.get(id);
    if (session == null || session.isClosing()) {
      throw new KeeperException.SessionExpiredException();
    }
    session.owner = owner;
  }
}
origin: apache/zookeeper

Assert.assertTrue("Session didn't expired", sessionImpl.isClosing());
Assert.assertFalse("Session didn't expired", sessionTrackerImpl
    .touchSession(sessionId, sessionTimeout));
origin: org.apache.zookeeper/zookeeper

synchronized public void addSession(long id, int sessionTimeout) {
  sessionsWithTimeout.put(id, sessionTimeout);
  if (sessionsById.get(id) == null) {
    SessionImpl s = new SessionImpl(id, sessionTimeout, 0);
    sessionsById.put(id, s);
    if (LOG.isTraceEnabled()) {
      ZooTrace.logTraceMessage(LOG, ZooTrace.SESSION_TRACE_MASK,
          "SessionTrackerImpl --- Adding session 0x"
          + Long.toHexString(id) + " " + sessionTimeout);
    }
  } else {
    if (LOG.isTraceEnabled()) {
      ZooTrace.logTraceMessage(LOG, ZooTrace.SESSION_TRACE_MASK,
          "SessionTrackerImpl --- Existing session 0x"
          + Long.toHexString(id) + " " + sessionTimeout);
    }
  }
  touchSession(id, sessionTimeout);
}
origin: org.apache.zookeeper/zookeeper

synchronized public boolean touchSession(long sessionId, int timeout) {
  if (LOG.isTraceEnabled()) {
    ZooTrace.logTraceMessage(LOG,
                 ZooTrace.CLIENT_PING_TRACE_MASK,
                 "SessionTrackerImpl --- Touch session: 0x"
        + Long.toHexString(sessionId) + " with timeout " + timeout);
  }
  SessionImpl s = sessionsById.get(sessionId);
  // Return false, if the session doesn't exists or marked as closing
  if (s == null || s.isClosing()) {
    return false;
  }
  long expireTime = roundToInterval(Time.currentElapsedTime() + timeout);
  if (s.tickTime >= expireTime) {
    // Nothing needs to be done
    return true;
  }
  SessionSet set = sessionSets.get(s.tickTime);
  if (set != null) {
    set.sessions.remove(s);
  }
  s.tickTime = expireTime;
  set = sessionSets.get(s.tickTime);
  if (set == null) {
    set = new SessionSet();
    sessionSets.put(expireTime, set);
  }
  set.sessions.add(s);
  return true;
}
origin: org.apache.hadoop/zookeeper

synchronized public void addSession(long id, int sessionTimeout) {
  sessionsWithTimeout.put(id, sessionTimeout);
  if (sessionsById.get(id) == null) {
    SessionImpl s = new SessionImpl(id, sessionTimeout, 0);
    sessionsById.put(id, s);
    if (LOG.isTraceEnabled()) {
      ZooTrace.logTraceMessage(LOG, ZooTrace.SESSION_TRACE_MASK,
          "SessionTrackerImpl --- Adding session 0x"
          + Long.toHexString(id) + " " + sessionTimeout);
    }
  } else {
    if (LOG.isTraceEnabled()) {
      ZooTrace.logTraceMessage(LOG, ZooTrace.SESSION_TRACE_MASK,
          "SessionTrackerImpl --- Existing session 0x"
          + Long.toHexString(id) + " " + sessionTimeout);
    }
  }
  touchSession(id, sessionTimeout);
}
org.apache.zookeeper.serverSessionTrackerImpl$SessionImpl

Most used methods

  • <init>
  • isClosing

Popular in Java

  • Updating database using SQL prepared statement
  • getSystemService (Context)
  • onRequestPermissionsResult (Fragment)
  • startActivity (Activity)
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • PriorityQueue (java.util)
    An unbounded priority Queue based on a priority heap. The elements of the priority queue are ordered
  • Stack (java.util)
    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with
  • JPanel (javax.swing)
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • IsNull (org.hamcrest.core)
    Is the value null?
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now