public class AbstractConnectionHandler extends java.lang.Object implements IAbstractConnectionHandler
Modifier and Type | Class and Description |
---|---|
static class |
AbstractConnectionHandler.SendInfo
Struct class that holds send information.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ACKCLOSE
Acknowledge the close message.
|
static byte |
ACKCLOSE_INPUT_INITIATOR
Ack for close - from initiator .
|
static byte |
ACKCLOSE_OUTPUT_PARTICIPANT
Ack data/close - from participant .
|
static java.lang.String |
ACKCLOSEREQ
Acknowledge the close request.
|
static byte |
ACKCLOSEREQ_INPUT_PARTICIPANT
Ack for close request - from initiator .
|
static byte |
ACKCLOSEREQ_OUTPUT_INITIATOR
Ack for close request - from initiator .
|
static java.lang.String |
ACKDATA
Acknowledge data message.
|
static byte |
ACKDATA_INPUT_INITIATOR
Ack data - from participant .
|
static byte |
ACKDATA_OUTPUT_PARTICIPANT
Ack data/close - from participant .
|
static java.lang.String |
ACKINIT
Acknowledge init.
|
static byte |
ACKINIT_INPUT_PARTICIPANT
Ack the init - from participant.
|
static byte |
ACKINIT_OUTPUT_PARTICIPANT
Ack the init - from initiator.
|
protected long |
acktimeout
The max delay before an acknowledgement is received.
|
static java.lang.String |
ALIVE
The alive message.
|
static byte |
ALIVE_INITIATOR
Alive message - from initiator.
|
static byte |
ALIVE_PARTICIPANT
Alive message - from participant.
|
protected long |
alivetime
The latest alive time.
|
static java.lang.String |
CLOSE
Close the connection.
|
static byte |
CLOSE_INPUT_PARTICIPANT
Close connection - from participant.
|
static byte |
CLOSE_OUTPUT_INITIATOR
Close connection - from initiator.
|
static java.lang.String |
CLOSEREQ
Close request (from participant which cannot close itself).
|
static byte |
CLOSEREQ_INPUT_INITIATOR
Close request connection - from initiator.
|
static byte |
CLOSEREQ_OUTPUT_PARTICIPANT
Request close connection - from participant.
|
protected IInternalAccess |
component
The message service.
|
protected AbstractConnection |
con
The connection.
|
static java.lang.String |
DATA
Send data message.
|
static byte |
DATA_INPUT_PARTICIPANT
Send data - from participant.
|
static byte |
DATA_OUTPUT_INITIATOR
Send data - from initiator.
|
static byte[] |
EMPTY_BYTE_ARRAY |
static java.lang.String |
INIT
Init a connection.
|
static byte |
INIT_INPUT_INITIATOR
Create virtual input connection - from initiator.
|
static byte |
INIT_OUTPUT_INITIATOR
Create virtual output connection - from initiator.
|
protected long |
leasetime
The lease time.
|
protected int |
maxresends
The maximum number of resends.
|
static byte |
MESSAGE_TYPE_STREAM
The message type for streams.
|
static java.util.Map<Tuple,java.lang.Byte> |
MESSAGETYPES
String type, boolean input, boolean initiator.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
nonfunc
The non-functional properties.
|
protected java.util.Timer |
timer
The timer.
|
protected java.util.Map<java.lang.Object,AbstractConnectionHandler.SendInfo> |
unacked
The unacknowledged messages.
|
Constructor and Description |
---|
AbstractConnectionHandler(IInternalAccess component,
java.util.Map<java.lang.String,java.lang.Object> nonfunc)
Create a new connection handler.
|
AbstractConnectionHandler(IInternalAccess component,
java.util.Map<java.lang.String,java.lang.Object> nonfunc,
int maxresends,
long acktimeout,
long leasetime)
Create a new connection handler.
|
Modifier and Type | Method and Description |
---|---|
void |
ackReceived(java.lang.Object id,
java.lang.Object content)
Called when an ack was received.
|
void |
close()
Close the connection.
|
protected java.util.TimerTask |
createAckTimer(java.lang.Object id)
Triggers resends of packets if no ack has been received in acktimeout.
|
protected StreamPacket |
createTask(java.lang.String type,
byte[] content,
java.lang.Integer seqnumber,
java.util.Map<java.lang.String,java.lang.Object> nonfunc)
Create a new task.
|
protected StreamPacket |
createTask(java.lang.String type,
java.lang.Object content,
boolean useserializer,
java.lang.Integer seqnumber,
java.util.Map<java.lang.String,java.lang.Object> nonfunc)
Create a new task.
|
IFuture<java.lang.Void> |
doClose()
Called from connection.
|
IInternalAccess |
getComponent()
Get the component.
|
protected AbstractConnection |
getConnection()
Get the connection.
|
int |
getConnectionId()
Get the id.
|
IExecutionFeature |
getExecutionFeature()
Get the execution feature.
|
protected long |
getLeasetime()
Get the leasetime.
|
IMessageFeature |
getMessageFeature()
Get the message feature.
|
protected byte |
getMessageType(java.lang.String type)
Get the message type for a given type, e.g.
|
static byte |
getMessageType(java.lang.String type,
boolean input,
boolean initiator)
Get the message type.
|
java.util.Map<java.lang.String,java.lang.Object> |
getNonFunctionalProperties()
Get the non-functional properties.
|
void |
initReceived()
Received the init message.
|
boolean |
isClosed()
Get the closed.
|
boolean |
isConnectionAlive()
Test if the connection is alive.
|
void |
notifyInited() |
protected <E> IFuture<E> |
scheduleStep(IComponentStep<E> step)
Schedule a step on the message service component.
|
protected IFuture<java.lang.Object> |
sendAcknowledgedMessage(StreamPacket task,
java.lang.Object id)
Send a message and wait for an ack.
|
IFuture<java.lang.Void> |
sendAlive()
Send alive message.
|
IFuture<java.lang.Void> |
sendInit()
Send init message.
|
protected IFuture<java.lang.Void> |
sendTask(StreamPacket task)
Send a task.
|
void |
setAliveTime(long alivetime)
Set the alive time of the other connection side.
|
void |
setConnection(AbstractConnection con)
Set the connection (needed as connection and handler need each other).
|
void |
setNonFunctionalProperties(java.util.Map<java.lang.String,java.lang.Object> nonfunc)
Set the non-functional properties.
|
java.util.TimerTask |
waitForRealDelay(long delay,
IComponentStep<?> step)
Wait for a time delay on the (real) system clock.
|
public static final byte MESSAGE_TYPE_STREAM
public static final java.lang.String INIT
public static final java.lang.String ACKINIT
public static final java.lang.String DATA
public static final java.lang.String ACKDATA
public static final java.lang.String CLOSE
public static final java.lang.String ACKCLOSE
public static final java.lang.String CLOSEREQ
public static final java.lang.String ACKCLOSEREQ
public static final java.lang.String ALIVE
public static final byte INIT_OUTPUT_INITIATOR
public static final byte ACKINIT_OUTPUT_PARTICIPANT
public static final byte DATA_OUTPUT_INITIATOR
public static final byte ACKDATA_OUTPUT_PARTICIPANT
public static final byte CLOSEREQ_OUTPUT_PARTICIPANT
public static final byte ACKCLOSEREQ_OUTPUT_INITIATOR
public static final byte CLOSE_OUTPUT_INITIATOR
public static final byte ACKCLOSE_OUTPUT_PARTICIPANT
public static final byte INIT_INPUT_INITIATOR
public static final byte ACKINIT_INPUT_PARTICIPANT
public static final byte DATA_INPUT_PARTICIPANT
public static final byte ACKDATA_INPUT_INITIATOR
public static final byte CLOSEREQ_INPUT_INITIATOR
public static final byte ACKCLOSEREQ_INPUT_PARTICIPANT
public static final byte CLOSE_INPUT_PARTICIPANT
public static final byte ACKCLOSE_INPUT_INITIATOR
public static final byte ALIVE_INITIATOR
public static final byte ALIVE_PARTICIPANT
public static final java.util.Map<Tuple,java.lang.Byte> MESSAGETYPES
public static final byte[] EMPTY_BYTE_ARRAY
protected IInternalAccess component
protected AbstractConnection con
protected long alivetime
protected long leasetime
protected java.util.Map<java.lang.Object,AbstractConnectionHandler.SendInfo> unacked
protected int maxresends
protected long acktimeout
protected java.util.Map<java.lang.String,java.lang.Object> nonfunc
protected java.util.Timer timer
public AbstractConnectionHandler(IInternalAccess component, java.util.Map<java.lang.String,java.lang.Object> nonfunc)
public AbstractConnectionHandler(IInternalAccess component, java.util.Map<java.lang.String,java.lang.Object> nonfunc, int maxresends, long acktimeout, long leasetime)
public static byte getMessageType(java.lang.String type, boolean input, boolean initiator)
type
- The type.input
- Flag if in input connection.initiator
- Flag if is initiator side.public void setConnection(AbstractConnection con)
setConnection
in interface IAbstractConnectionHandler
public void initReceived()
public void ackReceived(java.lang.Object id, java.lang.Object content)
public void close()
public void setAliveTime(long alivetime)
alivetime
- The alive time.public boolean isConnectionAlive()
public boolean isClosed()
public int getConnectionId()
public IFuture<java.lang.Void> doClose()
doClose
in interface IAbstractConnectionHandler
public IFuture<java.lang.Void> sendInit()
sendInit
in interface IAbstractConnectionHandler
public IFuture<java.lang.Void> sendAlive()
public void notifyInited()
notifyInited
in interface IAbstractConnectionHandler
protected AbstractConnection getConnection()
public java.util.Map<java.lang.String,java.lang.Object> getNonFunctionalProperties()
getNonFunctionalProperties
in interface IAbstractConnectionHandler
public void setNonFunctionalProperties(java.util.Map<java.lang.String,java.lang.Object> nonfunc)
nonfunc
- The non-functional properties.protected byte getMessageType(java.lang.String type)
type
- The message type.protected StreamPacket createTask(java.lang.String type, byte[] content, java.lang.Integer seqnumber, java.util.Map<java.lang.String,java.lang.Object> nonfunc)
type
- The message type.content
- The content.seqnumber
- The sequence number.protected StreamPacket createTask(java.lang.String type, java.lang.Object content, boolean useserializer, java.lang.Integer seqnumber, java.util.Map<java.lang.String,java.lang.Object> nonfunc)
type
- The message type.content
- The content.usecodecs
- Flag if codecs should be used to encode the content.seqnumber
- The sequence number.protected IFuture<java.lang.Void> sendTask(StreamPacket task)
task
- The task.protected IFuture<java.lang.Object> sendAcknowledgedMessage(StreamPacket task, java.lang.Object id)
task
- The send task.id
- The id of the call (e.g. sequence number).protected long getLeasetime()
protected <E> IFuture<E> scheduleStep(IComponentStep<E> step)
protected java.util.TimerTask createAckTimer(java.lang.Object id)
id
- The message id.public java.util.TimerTask waitForRealDelay(long delay, IComponentStep<?> step)
public IInternalAccess getComponent()
public IMessageFeature getMessageFeature()
public IExecutionFeature getExecutionFeature()