# Class UpgradeableSessionTracker

java.lang.Object
org.apache.zookeeper.server.quorum.UpgradeableSessionTracker

All Implemented Interfaces:
  `SessionTracker`

Direct Known Subclasses:
  `LeaderSessionTracker, LearnerSessionTracker`

public abstract class UpgradeableSessionTracker extends Object implements SessionTracker
A session tracker that supports upgradeable local sessions.

## Nested Class Summary

### Nested classes/interfaces inherited from interface SessionTracker

`SessionTracker.Session, SessionTracker.SessionExpirer`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected boolean`
`localSessionsEnabled`
`protected LocalSessionTracker`
`localSessionTracker`

## Constructor Summary

Constructors
Constructor
Description
`UpgradeableSessionTracker()`

## Method Summary

Modifier and Type
Method
Description
`void`
`checkGlobalSession(long sessionId, Object owner)`
Strictly check that a given session is a global session or not
`void`
`createLocalSessionTracker(SessionTracker.SessionExpirer expirer, int tickTime, long id, ZooKeeperServerListener listener)`
`void`
`finishedUpgrading(long sessionId)`
`long`
`getLocalSessionCount()`
If this session tracker supports local sessions, return how many.
`abstract boolean`
`isGlobalSession(long sessionId)`
`boolean`
`isLocalSession(long sessionId)`
`boolean`
`isLocalSessionsEnabled()`
`boolean`
`isTrackingSession(long sessionId)`
`boolean`
`isUpgradingSession(long sessionId)`
`Set<Long>`
`localSessions()`
Get a set of local session IDs
`protected void`
`removeLocalSession(long sessionId)`
`void`
`start()`
`int`
`upgradeSession(long sessionId)`
Upgrades the session to a global session.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface SessionTracker

`checkSession, commitSession, createSession, dumpSessions, getSessionExpiryMap, globalSessions, removeSession, setOwner, setSessionClosing, shutdown, touchSession, trackSession`

## Field Details

### localSessionTracker

protected LocalSessionTracker localSessionTracker

### localSessionsEnabled

protected boolean localSessionsEnabled

## Constructor Details

### UpgradeableSessionTracker

public UpgradeableSessionTracker()

## Method Details

### start

public void start()

### createLocalSessionTracker

public void createLocalSessionTracker(SessionTracker.SessionExpirer expirer, int tickTime, long id, ZooKeeperServerListener listener)

### isTrackingSession

public boolean isTrackingSession(long sessionId)

Specified by:
  `isTrackingSession` in interface `SessionTracker`
Parameters:
  `sessionId` -
Returns:
  whether or not the SessionTracker is aware of this session

### isLocalSession

public boolean isLocalSession(long sessionId)

### isLocalSessionsEnabled

public boolean isLocalSessionsEnabled()

Specified by:
  `isLocalSessionsEnabled` in interface `SessionTracker`

### isUpgradingSession

public boolean isUpgradingSession(long sessionId)

### finishedUpgrading

public void finishedUpgrading(long sessionId)

### isGlobalSession

public abstract boolean isGlobalSession(long sessionId)

### upgradeSession

public int upgradeSession(long sessionId)
Upgrades the session to a global session. This simply removes the session from the local tracker and marks it as global. It is up to the caller to actually queue up a transaction for the session.

Parameters:
  `sessionId` -
Returns:
  session timeout (-1 if not a local session)

### removeLocalSession

protected void removeLocalSession(long sessionId)

### checkGlobalSession

public void checkGlobalSession(long sessionId, Object owner) throws KeeperException.SessionExpiredException, KeeperException.SessionMovedException
Description copied from interface: `SessionTracker`
Strictly check that a given session is a global session or not

Specified by:
  `checkGlobalSession` in interface `SessionTracker`
Parameters:
  `sessionId` -
  `owner` -
Throws:
  `KeeperException.SessionExpiredException`
  `KeeperException.SessionMovedException`

### getLocalSessionCount

public long getLocalSessionCount()
Description copied from interface: `SessionTracker`
If this session tracker supports local sessions, return how many. otherwise returns 0;

Specified by:
  `getLocalSessionCount` in interface `SessionTracker`

### localSessions

public Set<Long> localSessions()
Description copied from interface: `SessionTracker`
Get a set of local session IDs

Specified by:
  `localSessions` in interface `SessionTracker`