public class NetworkHelper extends Object
It is illegal to stop network traffic to or from the master host. Tests using this API must therefore use at least three hosts, including the master host.
Hosts for which network traffic will be configured must be reserved for
exclusive use. It is the responsibility of the user to ensure that all
connections have been restored when the reservation is complete. The
script netclean.sh generated in the test result directory
can be used for this. It is invoked automatically by batterytest after
the test completes, regardless of the test outcome.
| Modifier and Type | Field and Description |
|---|---|
protected static int |
CLEAR |
protected static int |
DROP |
protected static int |
RESTORE |
protected static int |
SHOW |
| Constructor and Description |
|---|
NetworkHelper() |
| Modifier and Type | Method and Description |
|---|---|
protected static void |
configure(String source,
String target,
int op,
int way)
Runs on master, using ProcessMgr to execute the command on the source.
|
static void |
dropConnectionOneWay(String source,
String target)
Simulates a one-way dropped connection by stopping all network packets
from the source host to the target host.
|
static void |
dropConnectionTwoWay(String source,
String target)
Simulates a two-way dropped connection by stopping all network packets
between the source host and the target host.
|
static Map |
getConnectionState()
Returns the current state of network connections, as viewed by hydra,
mapping each source to its list of dropped targets.
|
protected static Map |
getState()
Runs on master.
|
static void |
printConnectionState()
Prints the current state of network connections, as viewed by hydra.
|
static void |
restoreConnectionOneWay(String source,
String target)
Restores a previously dropped one-way connection by allowing all network
packets from the source host to the target host.
|
static void |
restoreConnectionTwoWay(String source,
String target)
Restores a previously dropped two-way connection by allowing all network
packets between the source host and the target host.
|
static void |
showConnectionState()
Shows the current state of network connections, as viewed by iptables,
for each host used in the test.
|
protected static void |
showState()
Runs on master.
|
protected static final int DROP
protected static final int RESTORE
protected static final int CLEAR
protected static final int SHOW
public static void dropConnectionOneWay(String source, String target)
HydraRuntimeException - if the required network control script is
not available on the source host or there is an RMI exception.IllegalArgumentException - if an argument is null, or the master
host, or not in use by this test, or if the source and target are equal.IllegalStateException - if any part of the network is already in
the desired state.public static void dropConnectionTwoWay(String source, String target)
This is equivalent to invoking two mirror-image one-way calls, except that the two-way call will drop both directions under synchronization. It is possible for one direction to succeed and the other fail, resulting in an exception.
HydraRuntimeException - if the required network control script is
not available on the source host or there is an RMI exception.IllegalArgumentException - if an argument is null, or the master
host, or not in use by this test, or if the source and target are equal.IllegalStateException - if any part of the network is already in
the desired state.public static void restoreConnectionOneWay(String source, String target)
HydraRuntimeException - if the required network control script is
not available on the source host or there is an RMI exception.IllegalArgumentException - if an argument is null, or the master
host, or not in use by this test, or if the source and target are equal.IllegalStateException - if any part of the network is already in
the desired state.public static void restoreConnectionTwoWay(String source, String target)
This is equivalent to invoking two mirror-image one-way calls, except that the two-way call will restore both directions under synchronization. It is possible for one direction to succeed and the other fail, resulting in an exception.
HydraRuntimeException - if the required network control script is
not available on the source host or there is an RMI exception.IllegalArgumentException - if an argument is null, or the master
host, or not in use by this test, or if the source and target are equal.IllegalStateException - if any part of the network is already in
the desired state.public static Map getConnectionState()
HydraRuntimeException - if there is an RMI exception.public static void printConnectionState()
public static void showConnectionState()
HydraRuntimeException - if there is an RMI exception.protected static void configure(String source, String target, int op, int way)
protected static Map getState()
protected static void showState()
Copyright © 2010-2015 Pivotal Software, Inc. All rights reserved.