|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectinputOutputHandler.InputOutputHandlerController
public final class InputOutputHandlerController
Controller class of component InputOutputHandler
. Implements
the architecture interface InputOutputHandlerInterface
.
Handles communication with clients, other mixes and receivers.
Waits for new connections from clients or other mixes and accepts messages
using the classes ClientConnectionHandler
,
PreviousMixConnectionHandler
,
NextMixConnectionHandler
and
ProxyConnectionHandler
and stores them in a
ConcurrentLinkedQueue
.
The process of accepting connections and receiving messages works in parallel to the mix operations. Therefore, the mix is capable of taking messages at any time (unless it is overloaded).
Sends (already mixed) messages to their destination using the same classes
mentioned above. The mixed messages are stored in a
ConcurrentLinkedQueue
. The process of sending messages works in
parallel to the mix operations. Therefore, the mix is capable of mixing new
messages while sending the old ones.
This class is thread-safe.
Field Summary | |
---|---|
private ClientConnectionHandler |
clientConnectionHandler
Reference on ClientConnectionHandler . |
private ExternalInformationPortController |
externalInformationPort
Reference on component ExternalInformationPort . |
private static InternalInformationPortController |
internalInformationPort
Reference on component InternalInformationPort . |
protected boolean |
IS_FIRST
Indicates whether this mix is the first of the cascade or not. |
protected boolean |
IS_LAST
Indicates whether this mix is the lost of the cascade or not. |
private static java.util.logging.Logger |
LOGGER
Logger used to log and display information. |
protected int |
NUMBER_OF_FURTHER_HOPS
Number of further mixes between the mix this InputOutputHandler
belongs to and the receiver. |
protected int |
NUMBER_OF_PREVIOUS_HOPS
Number of previous mixes between the mix this InputOutputHandler
belongs to and the sender. |
private OutputStrategyController |
outputStrategy
Reference on component OutputStrategy . |
protected int |
POSITION_OF_MIX_IN_CASCADE
The mix' position in the cascade this object belongs to. "1" means "first mix", "2" means "a middle mix" and "3" means "last mix" of cascade. |
private PreviousMixConnectionHandler |
previousMixConnectionHandler
Reference on PreviousMixConnectionHandler . |
private ReplyDecision |
replyDecision
Reference on ReplyDecision . |
private java.util.concurrent.ConcurrentLinkedQueue<Reply> |
replyInputQueue
A ConcurrentLinkedQueue , that stores Reply ies
until they are processed. |
private java.util.concurrent.ConcurrentLinkedQueue<Reply> |
replyOutputQueue
A ConcurrentLinkedQueue , that stores already processed
Reply ies until they are sent (to the previous mix or
client). |
private java.util.concurrent.ConcurrentLinkedQueue<Request> |
requestInputQueue
A ConcurrentLinkedQueue , that stores Request s
until they are processed. |
private java.util.concurrent.ConcurrentLinkedQueue<Request> |
requestOutputQueue
A ConcurrentLinkedQueue , that stores already processed
Request s until they are sent (to the next mix or server). |
private UserDatabaseController |
userDatabase
Reference on component UserDatabase . |
Constructor Summary | |
---|---|
InputOutputHandlerController()
Creates a new InputOutputHandler component that handles
communication with clients, other mixes and proxies. |
Method Summary | |
---|---|
void |
acceptConnections()
Makes component listen for connections/messages on communication channels. |
void |
addReplies(Reply[] replies)
Adds all the bypassed (already mixed) Reply ies to the
replyOutputQueue (from where they will be sent to their
destination). |
void |
addReply(Reply reply)
Adds the bypassed (already mixed) Reply to the
replyOutputQueue (from where it will be sent to its
destination). |
void |
addRequest(Request request)
Adds the bypassed (already mixed) Request to the
requestOutputQueue (from where it will be sent to its
destination). |
void |
addRequests(Request[] requests)
Adds all the bypassed (already mixed) Request s to the
requestOutputQueue (from where they will be sent to their
destination). |
protected void |
addUnprocessedReply(ReplyMessage message)
Adds the bypassed (just received) Reply to the
replyInputQueue (from where it will be taken by
component MessageProcessor via getReply() ). |
protected void |
addUnprocessedRequest(Request request)
Adds the bypassed (just received) Request to the
requestInputQueue (from where it will be taken by
component MessageProcessor via getRequest() ). |
protected Reply |
getProcessedReply()
Returns an (already mixed) Reply from the
replyOutputQueue . |
protected Request |
getProcessedRequest()
Returns an (already mixed) Request from the
requestOutputQueue . |
private static java.lang.String |
getProperty(java.lang.String key)
Simply used to shorten method calls (calls internalInformationPort.getProperty(key) ). |
Reply |
getReply()
Returns a Reply (previously received, unprocessed) from a
communication partner (e. g. proxy or other mix). |
Request |
getRequest()
Returns a Request (previously received, unprocessed) from a
communication partner (e. g. client or other mix). |
void |
initialize(UserDatabaseController userDatabase,
OutputStrategyController outputStrategy,
ExternalInformationPortController eip)
Initialization method for this component. |
private void |
logInformation()
Logs/displays information about this mix. |
protected static java.net.InetAddress |
tryToGenerateInetAddress(java.lang.String hostName)
Tries to generate an InetAddress from the bypassed host
name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static InternalInformationPortController internalInformationPort
InternalInformationPort
.
Used to display and/or log data and read general settings.
private static final java.util.logging.Logger LOGGER
protected final int NUMBER_OF_FURTHER_HOPS
InputOutputHandler
belongs to and the receiver.
protected final int NUMBER_OF_PREVIOUS_HOPS
InputOutputHandler
belongs to and the sender.
protected final int POSITION_OF_MIX_IN_CASCADE
protected final boolean IS_FIRST
protected final boolean IS_LAST
private java.util.concurrent.ConcurrentLinkedQueue<Request> requestInputQueue
ConcurrentLinkedQueue
, that stores Request
s
until they are processed.
private java.util.concurrent.ConcurrentLinkedQueue<Request> requestOutputQueue
ConcurrentLinkedQueue
, that stores already processed
Request
s until they are sent (to the next mix or server).
private java.util.concurrent.ConcurrentLinkedQueue<Reply> replyInputQueue
ConcurrentLinkedQueue
, that stores Reply
ies
until they are processed.
private java.util.concurrent.ConcurrentLinkedQueue<Reply> replyOutputQueue
ConcurrentLinkedQueue
, that stores already processed
Reply
ies until they are sent (to the previous mix or
client).
private ClientConnectionHandler clientConnectionHandler
ClientConnectionHandler
. Used to exchange
Message
s with Client
s.
private PreviousMixConnectionHandler previousMixConnectionHandler
PreviousMixConnectionHandler
. Used to exchange
Message
s with previous Mix
.
private ReplyDecision replyDecision
ReplyDecision
. Used to determine reply size by
last mix of cascade.
private OutputStrategyController outputStrategy
OutputStrategy
.
private ExternalInformationPortController externalInformationPort
ExternalInformationPort
.
private UserDatabaseController userDatabase
UserDatabase
.
Constructor Detail |
---|
public InputOutputHandlerController()
InputOutputHandler
component that handles
communication with clients, other mixes and proxies.
Component can't be used before calling initialize()
.
initialize( UserDatabaseController,
OutputStrategyController,
ExternalInformationPortController)
Method Detail |
---|
public void initialize(UserDatabaseController userDatabase, OutputStrategyController outputStrategy, ExternalInformationPortController eip)
userDatabase
- Reference on component
UserDatabase
.outputStrategy
- Reference on component
OutputStrategy
.eip
- Reference on component
ExternalInformationPort
.public void acceptConnections()
acceptConnections
in interface InputOutputHandlerInterface
protected static java.net.InetAddress tryToGenerateInetAddress(java.lang.String hostName)
InetAddress
from the bypassed host
name. If an exception occurs, the program exits!
hostName
- Host name to generate InetAddress
from.
InetAddress
representation of the bypassed host
name.private void logInformation()
public void addRequest(Request request)
Request
to the
requestOutputQueue
(from where it will be sent to its
destination).
Returns immediately (asynchronous behavior), the process of sending itself may be deferred (e. g. if communication channel is busy).
Assures order (queuing strategy) and is thread-safe.
Used by component OutputStrategy
.
addRequest
in interface InputOutputHandlerInterface
request
- Already processed message, that shall be sent to the
next communication partner.getProcessedRequest()
,
addRequests(Request[])
public void addRequests(Request[] requests)
Request
s to the
requestOutputQueue
(from where they will be sent to their
destination).
Returns immediately (asynchronous behavior), the process of sending itself may be deferred (e. g. if communication channel is busy).
Assures order (queuing strategy) and is thread-safe.
Used by component OutputStrategy
.
addRequests
in interface InputOutputHandlerInterface
requests
- Already processed messages, that shall be sent to the
next communication partner.getProcessedRequest()
,
addRequest(Request)
protected Request getProcessedRequest()
Request
from the
requestOutputQueue
. If no requests are available, this
method blocks until a new Request
arrives.
Assures order (queuing strategy) and is thread-safe.
Request
.protected void addUnprocessedRequest(Request request)
Request
to the
requestInputQueue
(from where it will be taken by
component MessageProcessor
via getRequest()
).
Assures order (queuing strategy) and is thread-safe.
request
- Just received message, that shall be added.public Request getRequest()
Request
(previously received, unprocessed) from a
communication partner (e. g. client or other mix). If no
Request
s are available, this method blocks until a new
Request
arrives.
Assures order (queuing strategy) and is thread-safe.
getRequest
in interface InputOutputHandlerInterface
Request
.public void addReply(Reply reply)
Reply
to the
replyOutputQueue
(from where it will be sent to its
destination).
Returns immediately (asynchronous behavior), the process of sending itself may be deferred (e. g. if communication channel is busy).
Assures order (queuing strategy) and is thread-safe.
Used by component OutputStrategy
.
addReply
in interface InputOutputHandlerInterface
reply
- Already processed message, that shall be sent to the
next communication partner.getProcessedReply()
,
addReplies(Reply[])
public void addReplies(Reply[] replies)
Reply
ies to the
replyOutputQueue
(from where they will be sent to their
destination).
Returns immediately (asynchronous behavior), the process of sending itself may be deferred (e. g. if communication channel is busy).
Assures order (queuing strategy) and is thread-safe.
Used by component OutputStrategy
.
addReplies
in interface InputOutputHandlerInterface
replies
- Already processed messages, that shall be sent to the
next communication partner.getProcessedReply()
,
addReply(Reply)
protected Reply getProcessedReply()
Reply
from the
replyOutputQueue
. If no replies are available, this
method blocks until a new Reply
arrives.
Assures order (queuing strategy) and is thread-safe.
Reply
.protected void addUnprocessedReply(ReplyMessage message)
Reply
to the
replyInputQueue
(from where it will be taken by
component MessageProcessor
via getReply()
).
Assures order (queuing strategy) and is thread-safe.
message
- Message just received, that shall be added.public Reply getReply()
Reply
(previously received, unprocessed) from a
communication partner (e. g. proxy or other mix). If no
Reply
ies are available, this method blocks until a new
Reply
arrives.
Assures order (queuing strategy) and is thread-safe.
getReply
in interface InputOutputHandlerInterface
Reply
.private static java.lang.String getProperty(java.lang.String key)
internalInformationPort.getProperty(key)
). Returns the
property with the specified key from the property file.
key
- The property key.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |