|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectserver.framework.network.ServerSocketCommunicator
server.testmodules.TestModule
public abstract class TestModule
An abstract class containing common methods for test-classes. Such methods can be measurement and report generating methods.
Nested Class Summary | |
---|---|
protected class |
TestModule.Sender
The internal class responsible for sending messages from the server. |
static class |
TestModule.TestType
Enumeration determining the test type. |
protected class |
TestModule.Timer
The internal class that times the time a message takes to go from the server to the client and back. |
Nested classes/interfaces inherited from class server.framework.network.ServerSocketCommunicator |
---|
ServerSocketCommunicator.ReceiverThread, ServerSocketCommunicator.SenderThread |
Field Summary | |
---|---|
protected java.util.ArrayList<java.util.HashMap<java.lang.Integer,TestModule.Timer>> |
allTests
|
protected int |
currentRun
|
protected long |
interval
|
protected java.lang.String |
message
|
static java.lang.String |
NETWORK
|
static int |
NOF_INTERVALS
|
static int |
NOF_PACKETS
|
static int |
NOF_RUNS
|
static java.lang.String |
PROVIDER
|
int |
random
|
Fields inherited from class server.framework.network.ServerSocketCommunicator |
---|
receiverThread, senderThread, server, socket |
Constructor Summary | |
---|---|
TestModule(SocketWrapper socket,
AbstractServer server)
Creates a TestModule object with the specified
attributes. |
Method Summary | |
---|---|
protected abstract java.lang.Number[] |
calculateValues(TestModule.Timer[] timers,
int interval_no)
Calculates values from the Timers. |
void |
close()
Closes the connection. |
boolean |
connect(java.lang.String[] addresses)
Uses the parent class implementation. |
void |
disconnect(java.lang.String[] addresses)
Uses the parent class implementation. |
protected abstract java.lang.String |
findIdString(java.lang.String message)
Finds the id of a message. |
protected long[] |
getAllValues(TestModule.Timer[] timers)
Gets all values from the Timer s'. |
protected abstract java.lang.String[] |
getHeaders()
Gets the headers for the coloumns in the report. |
int |
getId()
Generates an id from the counter before the counter is incremented. |
protected abstract long |
getInitialInterval()
Gets the initial interval to use between sends. |
protected abstract java.lang.String |
getInitialMessage()
Gets the initial message to send. |
int |
getLastId()
Gets the previous id. |
java.lang.String |
getReport(boolean printAllTimers)
Generates and returns the test report from the test results. |
protected abstract java.lang.String |
getStringToSend(int id)
Gets the String to send. |
protected static java.lang.String |
getThreeDigitString(long number)
Converts from a number to a string of three digits by filling in zeros before the number. |
protected static java.lang.String |
getTimeInSeconds(long nanos)
Converts from nanoseconds to seconds. |
protected abstract java.lang.String |
getTitle()
Gets the title for the report. |
protected abstract void |
notifyAboutIntervalComplete()
Notifies the TestModules that the interval is complete. |
void |
notifyAboutMessageReceived(java.lang.Object message)
Method that is called when the receiver thread receives a new message. |
protected void |
notifyAboutRunComplete()
Notifies the TestModule that the run is completed
and the next run can be started. |
void |
runTest()
Starts the test and initialize import variables. |
void |
searchForNodes()
Uses the parent class implementation. |
void |
sendMessage(java.lang.Object message,
boolean confirm)
Notifies the sender thread that a new message is to be sent. |
Methods inherited from class server.framework.network.ServerSocketCommunicator |
---|
getSocket |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NOF_PACKETS
public static final int NOF_INTERVALS
public static final int NOF_RUNS
public static final java.lang.String PROVIDER
public static final java.lang.String NETWORK
public int random
protected java.lang.String message
protected java.util.ArrayList<java.util.HashMap<java.lang.Integer,TestModule.Timer>> allTests
protected int currentRun
protected long interval
Constructor Detail |
---|
public TestModule(SocketWrapper socket, AbstractServer server)
TestModule
object with the specified
attributes. Calls the parent constructor and initialize the
ArrayList of the tests and the currentRun to zero.
socket
- The test client's SocketWrapper
object.server
- The test server.Method Detail |
---|
public boolean connect(java.lang.String[] addresses)
connect
in interface Communicator
connect
in class ServerSocketCommunicator
addresses
- See parent class.
public void disconnect(java.lang.String[] addresses)
disconnect
in interface Communicator
disconnect
in class ServerSocketCommunicator
addresses
- See parent class.public void sendMessage(java.lang.Object message, boolean confirm)
sendMessage
in interface Communicator
sendMessage
in class ServerSocketCommunicator
message
- The message to send.confirm
- Not used in this implementation.public void close()
close
in interface Communicator
close
in class ServerSocketCommunicator
public void searchForNodes()
searchForNodes
in interface Communicator
searchForNodes
in class ServerSocketCommunicator
public java.lang.String getReport(boolean printAllTimers)
printAllTimers
- Whether all results should be printed or just the main results.
public void notifyAboutMessageReceived(java.lang.Object message)
notifyAboutMessageReceived
in interface Communicator
notifyAboutMessageReceived
in class ServerSocketCommunicator
message
- The message that has been received.protected abstract java.lang.String findIdString(java.lang.String message)
message
- The message to find an id from.
protected abstract java.lang.Number[] calculateValues(TestModule.Timer[] timers, int interval_no)
timers
- The Timers to calculate from.interval_no
- The interval number to calculate.
protected long[] getAllValues(TestModule.Timer[] timers)
Timer
s'.
timers
- The array of Timer
s to retrived the values from.
public void runTest()
protected void notifyAboutRunComplete()
TestModule
that the run is completed
and the next run can be started. If the last run is completed,
the programs sleeps to ensure that the last messages arrive before
the report is printed.
public int getId()
public int getLastId()
protected static java.lang.String getTimeInSeconds(long nanos)
nanos
- The amount of nanoseconds to convert.
protected static java.lang.String getThreeDigitString(long number)
number
- The number to be converted.
protected abstract void notifyAboutIntervalComplete()
TestModules
that the interval is complete.
protected abstract long getInitialInterval()
protected abstract java.lang.String getInitialMessage()
protected abstract java.lang.String[] getHeaders()
protected abstract java.lang.String getTitle()
protected abstract java.lang.String getStringToSend(int id)
id
- The id of the message to send.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |