Tabnine Logo
SessionTrackerImpl$SessionImpl
Code IndexAdd Tabnine 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)

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);
}
origin: apache/zookeeper

Assert.assertTrue("Session didn't expired", sessionImpl.isClosing());
Assert.assertFalse("Session didn't expired", sessionTrackerImpl
    .touchSession(sessionId, sessionTimeout));
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: 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: 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: 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: 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;
}
org.apache.zookeeper.serverSessionTrackerImpl$SessionImpl

Most used methods

  • <init>
  • isClosing

Popular in Java

  • Reactive rest calls using spring rest template
  • notifyDataSetChanged (ArrayAdapter)
  • getSystemService (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • String (java.lang)
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now