public final class Session extends Object
Modifier and Type | Field and Description |
---|---|
protected TargetCapacityInformations |
capacityInformations
This instance contains the informations about the capacity of the connected target.
|
protected org.jscsi.utils.SerialArithmeticNumber |
commandSequenceNumber
The Command Sequence Number of this session.
|
protected Configuration |
configuration
The
Configuration instance for this session. |
protected LinkedBlockingQueue<Connection> |
connections
A List object with all open connections.
|
protected LinkFactory |
factory
The
LinkFactory instance for this session. |
protected InetSocketAddress |
inetSocketAddress
The unique name of the connected iSCSI Target.
|
protected org.jscsi.utils.SerialArithmeticNumber |
initiatorTaskTag
The initiator uses this Initiator Task Tag to relate data to the appropriate command.
|
protected org.jscsi.utils.SerialArithmeticNumber |
maximumCommandSequenceNumber
The Maximum Command Sequence Number of this session.
|
protected short |
nextFreeConnectionID
The index of the next used connection ID.
|
protected IPhase |
phase
The session is in this phase.
|
protected String |
targetName
The unique name of the connected iSCSI Target.
|
protected short |
targetSessionIdentifyingHandle
The Target Session Identifying Handle.
|
protected AbstractTaskBalancer |
taskBalancer
Handles the load balancing of the task distribution to the opened connections.
|
protected boolean |
tsihChanged
Flag to indicate, if the login phase of this session is successfully completed.
|
Constructor and Description |
---|
Session(LinkFactory linkFactory,
Configuration initConfiguration,
String initTargetName,
InetSocketAddress inetAddress,
ExecutorService initExecutor)
Constructor to create a new, empty
AbsSession object with a maximum number of allowed connections to
a given iSCSI Target. |
Modifier and Type | Method and Description |
---|---|
void |
addConnections(int max)
Adds a number of new connections to this session.
|
protected short |
addNewConnection()
Adds a new connection to this session with the next free connection ID (if the maximum number is not reached).
|
void |
addOutstandingTask(Connection connection,
ITask task)
Adds a Task to the outstandingTasks Hashmap.
|
void |
close()
Closes this session instances with all opened connections.
|
void |
finishedTask(ITask ftask)
removes Task from outstandingTasks.
|
long |
getBlockSize()
Returns the used block size of the connected iSCSI Target.
|
long |
getCapacity()
Returns the capacity (in blocks) of the connected iSCSI Target.
|
int |
getCommandSequenceNumber()
Returns the Command Sequence Number of this session.
|
int |
getInitiatorTaskTag()
Returns the Initiator Task Tag of this session.
|
org.jscsi.utils.SerialArithmeticNumber |
getMaximumCommandSequenceNumber()
Returns the Maximum Command Sequence Number of this session.
|
Connection |
getNextFreeConnection()
Returns the next free
Connection object of this Session object. |
org.jscsi.parser.login.LoginStage |
getPhase()
Returns the current
LoginStage object. |
String |
getTargetName()
Returns the name of the iSCSI Target of this session.
|
short |
getTargetSessionIdentifyingHandle()
Returns the Target Session Identifying Handle (TSID) of this
Session object. |
boolean |
hasTargetMoreResources()
Has the iSCSI Target enough resources to accept more incoming PDU?
|
void |
incrementCommandSequenceNumber()
Increments the Command Sequence Number as defined in RFC1982, where
SERIAL_BITS = 32 . |
void |
incrementInitiatorTaskTag()
Increments the Initiator Task Tag as defined in RFC1982 where
SERIAL_BITS = 32 . |
void |
login()
This method invokes the same called method of the current
IPhase instance. |
void |
logout()
This method invokes the same called method of the current
IPhase instance. |
Future<Void> |
read(ByteBuffer dst,
int logicalBlockAddress,
long transferLength)
This method invokes the same called method of the current
IPhase instance. |
void |
releaseUsedConnection(Connection connection)
Adds a Task to the outstandingTasks Hashmap.
|
void |
restartTask(ITask task)
restarts a Task from outstandingTasks.
|
void |
setMaximumCommandSequenceNumber(int newMaximumCommandSequenceNumber)
Sets the Maximum Command Sequence Number to a new value.
|
void |
setPhase(IPhase newPhase)
This method sets the current
IPhase instance to the given value. |
void |
setTargetSessionIdentifyingHandle(short tsih)
Sets the Target Session Identifying Handle (TSIH) to the given value.
|
void |
updateMaxConnections(int max)
Updates the MaxConnection setting, so that it grows/shrinks the Connectionlist.
|
Future<Void> |
write(ByteBuffer src,
int logicalBlockAddress,
long transferLength)
This method invokes the same called method of the current
IPhase instance. |
protected final String targetName
protected final InetSocketAddress inetSocketAddress
protected short nextFreeConnectionID
protected IPhase phase
protected final TargetCapacityInformations capacityInformations
protected final LinkedBlockingQueue<Connection> connections
protected final org.jscsi.utils.SerialArithmeticNumber commandSequenceNumber
protected final org.jscsi.utils.SerialArithmeticNumber maximumCommandSequenceNumber
protected final org.jscsi.utils.SerialArithmeticNumber initiatorTaskTag
protected boolean tsihChanged
targetSessionIdentifyingHandle
.protected short targetSessionIdentifyingHandle
protected final Configuration configuration
Configuration
instance for this session.protected final LinkFactory factory
LinkFactory
instance for this session.protected final AbstractTaskBalancer taskBalancer
public Session(LinkFactory linkFactory, Configuration initConfiguration, String initTargetName, InetSocketAddress inetAddress, ExecutorService initExecutor) throws Exception
AbsSession
object with a maximum number of allowed connections to
a given iSCSI Target. This is the abstract definition for Session implementationslinkFactory
- The LinkFactory which called the ConstructorinitConfiguration
- The configuration to use within this session.initTargetName
- The name of the iSCSI Target.inetAddress
- The InetSocketAddress
of the leading connection of this session.initExecutor
- The ExecutorService
for the Connection ThreadsException
- if anything happenspublic final short getTargetSessionIdentifyingHandle()
Session
object.public final void setTargetSessionIdentifyingHandle(short tsih)
tsih
- The new Target Session Identifying Handle.public final int getCommandSequenceNumber()
public final void setMaximumCommandSequenceNumber(int newMaximumCommandSequenceNumber)
newMaximumCommandSequenceNumber
- The new Maximum Command Sequence Number.public final org.jscsi.utils.SerialArithmeticNumber getMaximumCommandSequenceNumber()
public final int getInitiatorTaskTag()
public final void incrementInitiatorTaskTag()
SERIAL_BITS = 32
.public final boolean hasTargetMoreResources()
true
, if the iSCSI Target has enough resources to accept more incoming PDUs. Else
false
and hold out for sending.public final String getTargetName()
public final void addConnections(int max) throws Exception
max
- The number of Connections to open.Exception
- if any error occurs.protected final short addNewConnection() throws Exception
Exception
- if any error occurs.public void updateMaxConnections(int max)
max
- The maximum number of concurrent Connections
to a target.public final Connection getNextFreeConnection() throws org.jscsi.exception.NoSuchConnectionException
Connection
object of this Session
object.org.jscsi.exception.NoSuchConnectionException
- If there is no such connection.public final void incrementCommandSequenceNumber()
SERIAL_BITS = 32
.public final void close() throws IOException
IOException
- if an I/O error occurs.public final long getBlockSize()
public final long getCapacity()
public final void login() throws Exception
IPhase
instance.Exception
- if any error occurs.public final void logout() throws org.jscsi.exception.TaskExecutionException
IPhase
instance.org.jscsi.exception.TaskExecutionException
- if any error occurs.public final Future<Void> read(ByteBuffer dst, int logicalBlockAddress, long transferLength) throws org.jscsi.exception.TaskExecutionException
IPhase
instance.dst
- Store the read bytes to this buffer.logicalBlockAddress
- The logical block address of the device to begin the read operation.transferLength
- The number of bytes to read from the device.Exception
- if any error occurs.org.jscsi.exception.TaskExecutionException
- if execution failspublic final Future<Void> write(ByteBuffer src, int logicalBlockAddress, long transferLength) throws org.jscsi.exception.TaskExecutionException
IPhase
instance.src
- Write the remaining bytes to the device.logicalBlockAddress
- The logical block address of the device to begin the write operation.transferLength
- The number of bytes to write to the device.Exception
- if any error occurs.org.jscsi.exception.TaskExecutionException
- if execution failspublic final org.jscsi.parser.login.LoginStage getPhase()
LoginStage
object.LoginStage
.public final void setPhase(IPhase newPhase)
IPhase
instance to the given value.newPhase
- The new instance to switch to.public final void finishedTask(ITask ftask)
ftask
- The Task which was finished .public final void restartTask(ITask task) throws ExecutionException
task
- The failed Task.ExecutionException
- for failed restart of the taskpublic final void addOutstandingTask(Connection connection, ITask task)
connection
- The Connection where the Task will be startedtask
- The Task which was started.public final void releaseUsedConnection(Connection connection) throws org.jscsi.exception.NoSuchConnectionException
connection
- The Connection which will be releasedorg.jscsi.exception.NoSuchConnectionException
- if any errors occurCopyright © 2013 University of Konstanz, Distributed Systems Group. All Rights Reserved.