appl.parallel.thread
Class ExecutionThread

java.lang.Object
  extended by appl.parallel.thread.ExecutionThread
All Implemented Interfaces:
Callable
Direct Known Subclasses:
ComputingResourceThread, DataServerThread

public abstract class ExecutionThread
extends Object
implements Callable

A simple helper class for more easy Thread handling with anonymous classes.

Author:
Dominik Appl
See Also:
DataServerThread, ComputingResourceThread

Field Summary
protected  Object argument
           
protected  CommEvent.CommType commType
           
protected  boolean disableTransferEvents
           
protected  CommEventSink eventSink
           
protected  Object server
           
protected  ComputingResourceProperties serverInfos
           
 
Constructor Summary
ExecutionThread(Object server, ComputingResourceProperties serverInfos, Object argument, CommEvent.CommType type, CommEventSink sink, boolean disableTransferEvents)
          creates a new thread
 
Method Summary
 Object call()
          Sends standard CommEvents to the CommEventSink given with the constructor.
protected  void fireTimeEvents(long execTime, Object result)
          Sends the time events for this execution.
protected  void fireTransferEvent(Object result)
          The TransferEvents for this execution.
protected  int getIntArgument()
           
protected  Object getObjectArgument()
           
protected  Object[] getObjectArrayArgument()
           
protected  Object getServer()
           
protected abstract  Object run()
          This method should implement the real running code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

protected final Object server

argument

protected final Object argument

commType

protected final CommEvent.CommType commType

serverInfos

protected final ComputingResourceProperties serverInfos

eventSink

protected final CommEventSink eventSink

disableTransferEvents

protected boolean disableTransferEvents
Constructor Detail

ExecutionThread

public ExecutionThread(Object server,
                       ComputingResourceProperties serverInfos,
                       Object argument,
                       CommEvent.CommType type,
                       CommEventSink sink,
                       boolean disableTransferEvents)
creates a new thread

Parameters:
server - the server which is accessed with this thread
serverInfos - the serverinfos (used for event info)
argument - an argument which can be used inside the anonymous class
type - the type of the communication
sink - events are submitted to this sink
disableTransferEvents - says whether to ignore transfer events (if the transfer volume is to low to be counted))
Method Detail

getServer

protected Object getServer()
Returns:
the server given the constructor (should be overwrited by a subclass)

getIntArgument

protected int getIntArgument()
Returns:
the argument given in the constructor as int value

getObjectArgument

protected Object getObjectArgument()
Returns:
the argument given in the constructor as object value

getObjectArrayArgument

protected Object[] getObjectArrayArgument()
Returns:
the argument given in the constructor as array value

call

public Object call()
            throws Exception
Sends standard CommEvents to the CommEventSink given with the constructor. Executes the run() method and returns its result.

Specified by:
call in interface Callable
Returns:
the result of run().
Throws:
Exception
See Also:
Callable.call()

fireTimeEvents

protected void fireTimeEvents(long execTime,
                              Object result)
Sends the time events for this execution. Method generates only the event of this execution. If you want more events (e.g. details from a remote execution) you can overwrite this method. This method is only called if time monitoring is enabled

Parameters:
execTime - the time of THIS execution
result - the result of the computation (may be of use when overwriting)

fireTransferEvent

protected void fireTransferEvent(Object result)
The TransferEvents for this execution. Method generates only the event out of the size of getObjectArgument().If you want more events (e.g. details from a remote execution) you can overwrite this method. This method is only called if time monitoring is enabled. Notice that this will be very slow for large Data!!

Parameters:
result - the result of the execution (per default not needed)

run

protected abstract Object run()
                       throws Exception
This method should implement the real running code.

Returns:
the result you want to retrieve later
Throws:
Exception - the exceptions thrown by your code