net.fenyo.gnetwatch.actions
Class ActionHTTP

java.lang.Object
  extended by net.fenyo.gnetwatch.GUI.VisualElement
      extended by net.fenyo.gnetwatch.actions.Action
          extended by net.fenyo.gnetwatch.actions.ActionHTTP

public class ActionHTTP
extends Action

Instances of this action class can load any HTTP server and create events of type EventHTTP to log the throughput.

Version:
$Id: ActionHTTP.java,v 1.14 2008/04/27 21:44:21 fenyo Exp $
Author:
Alexandre Fenyo

Nested Class Summary
 
Nested classes/interfaces inherited from class net.fenyo.gnetwatch.actions.Action
Action.InterruptCause
 
Field Summary
private  java.lang.String error_string
           
private  boolean interrupted
           
private static Log log
           
 
Constructor Summary
ActionHTTP()
          Default constructor.
ActionHTTP(Target target, Background background)
          Constructor.
 
Method Summary
private  int connect(int idx, IPQuerier querier, java.net.URLConnection[] connections, java.io.InputStream[] streams, int[] sizes, java.net.URL url, java.net.Proxy proxy)
          Establishes the connections to the server.
protected  void disposed()
          Called when this element is being removed.
 long getMaxDelay()
          Returns the timeout associated with this action.
 java.lang.String getQueueName()
          Returns the preferred queue.
 void interrupt(Action.InterruptCause reason)
          Asks this action to stop rapidely.
 void invoke()
          Loads the server.
 
Methods inherited from class net.fenyo.gnetwatch.actions.Action
canManageThisChild, getBackground, getTarget, initialize, setBackground, setTarget
 
Methods inherited from class net.fenyo.gnetwatch.GUI.VisualElement
addParent, contains, duplicateTreeItemOnce, expandTreeItems, getAllParents, getChildren, getDescription, getGUI, getId, getItem, getParents, getProgress, getSubElements, getSubElements, getTreeItems, getType, informSelected, isDisposed, isThisOurTreeItem, removeVisualElements, selected, setChildren, setDescription, setGUI, setId, setImage, setImageExec, setImageFolder, setImageHost, setImageHost6, setImageHost6SNMP, setImageHostSNMP, setImageInterface, setImageMultiRow, setImageNetwork, setImageOscillo, setImageQueue, setImageWatch, setItem, setParent, setParent, setProgress, setType, unselected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static Log log

interrupted

private boolean interrupted

error_string

private java.lang.String error_string
Constructor Detail

ActionHTTP

public ActionHTTP(Target target,
                  Background background)
Constructor.

Parameters:
target - target this action works on.
background - queue manager by which this action will add events.

ActionHTTP

public ActionHTTP()
Default constructor.

Parameters:
none. -
Method Detail

getQueueName

public java.lang.String getQueueName()
Returns the preferred queue.

Overrides:
getQueueName in class Action
Parameters:
none. -
Returns:
String preferred queue.

getMaxDelay

public long getMaxDelay()
Returns the timeout associated with this action.

Overrides:
getMaxDelay in class Action
Parameters:
none. -
Returns:
long timeout.

interrupt

public void interrupt(Action.InterruptCause reason)
Asks this action to stop rapidely.

Overrides:
interrupt in class Action
Parameters:
cause - cause.
Throws:
java.io.IOException - IO exception.

connect

private int connect(int idx,
                    IPQuerier querier,
                    java.net.URLConnection[] connections,
                    java.io.InputStream[] streams,
                    int[] sizes,
                    java.net.URL url,
                    java.net.Proxy proxy)
             throws java.io.IOException
Establishes the connections to the server.

Parameters:
idx - number of connections to establish.
querier - http/ftp parameters.
connections - array of connections established.
streams - streams associated to the connections.
sizes - data sizes ready to be read on the connections.
url - url to connect to.
proxy - proxy to use.
Returns:
number of bytes received.
Throws:
java.io.IOException - IO exception.

invoke

public void invoke()
            throws java.io.IOException,
                   java.lang.InterruptedException
Loads the server.

Overrides:
invoke in class Action
Parameters:
none. -
Throws:
java.io.IOException - IO exception.
java.lang.InterruptedException - exception.
See Also:
http://java.sun.com/j2se/1.5.0/docs/guide/net/http-keepalive.html

disposed

protected void disposed()
Called when this element is being removed.

Overrides:
disposed in class Action
Parameters:
none. -