Author: bstansberry(a)jboss.com
Date: 2008-10-26 02:27:15 -0400 (Sun, 26 Oct 2008)
New Revision: 2004
Added:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/load/
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/load/ServerLoadParam.java
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/load/ServerLoadServlets.java
Modified:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/ModClusterDemo.java
Log:
Add controlling server load generation to demo gui
Modified:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/ModClusterDemo.java
===================================================================
---
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/ModClusterDemo.java 2008-10-26
06:15:19 UTC (rev 2003)
+++
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/ModClusterDemo.java 2008-10-26
06:27:15 UTC (rev 2004)
@@ -2,26 +2,45 @@
import java.awt.BorderLayout;
import java.awt.Color;
+import java.awt.Component;
import java.awt.EventQueue;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.EnumSet;
+import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
+import java.util.Vector;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
+import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
+import javax.swing.ListCellRenderer;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import org.jboss.modcluster.demo.client.RequestDriver.ClientStatus;
+import org.jboss.modcluster.demo.client.load.ServerLoadParam;
+import org.jboss.modcluster.demo.client.load.ServerLoadServlets;
import org.jfree.chart.ChartPanel;
/**
@@ -32,9 +51,10 @@
*/
public class ModClusterDemo
{
- private static final String DEFAULT_HOST_NAME = "localhost:8888";
- private static final String DEFAULT_REQUEST_URL = "demo/record?timeout=10";
- private static final String DEFAULT_DESTROY_URL =
"demo/record?destroy=true";
+ private static final String DEFAULT_HOST_NAME =
System.getProperty("mod_cluster.proxy.host", "localhost");
+ private static final String DEFAULT_PROXY_PORT =
System.getProperty("mod_cluster.proxy.port", "8000");
+ private static final String DEFAULT_CONTEXT_PATH = "demo";
+ private static final String DEFAULT_SESSION_TIMEOUT = "20";
private static final int DEFAULT_NUM_THREADS = 200;
private static final int DEFAULT_SESSION_LIFE = 10;
private static final int DEFAULT_SLEEP_TIME = 0;
@@ -45,13 +65,18 @@
private final Timer timer;
private TimerTask currentTask;
private JFrame frame;
- private JTextField hostNameField;
- private JTextField requestUrlField;
- private JTextField destroyUrlField;
+ private JTextField proxyHostNameField;
+ private JTextField proxyPortField;
+ private JTextField contextPathField;
+ private JCheckBox destroySessionField;
private JTextField numThreadsField;
private JTextField sessionLifeField;
+ private JLabel sessionTimeoutLabel;
+ private JTextField sessionTimeoutField;
private JTextField sleepTimeField;
private JTextField startupTimeField;
+ private JTextField targetHostNameField;
+ private JTextField targetPortField;
private JLabel totalClientsLabel;
private JLabel liveClientsLabel;
private JLabel failedClientsLabel;
@@ -62,6 +87,12 @@
private JLabel liveClientsLabelSess;
private JLabel failedClientsLabelSess;
+ private ServerLoadServlets selectedLoadServlet;
+ private JLabel targetServletParamLabel1;
+ private JTextField targetServletParamField1;
+ private JLabel targetServletParamLabel2;
+ private JTextField targetServletParamField2;
+
/**
* Launch the application
* @param args
@@ -120,296 +151,206 @@
final JTabbedPane tabbedPane = new JTabbedPane();
frame.getContentPane().add(tabbedPane, BorderLayout.CENTER);
+ tabbedPane.addTab("Client Control", null, createClientControlPanel(),
null);
+
+ final JPanel loadPanel = createServerLoadControlPanel();
+ tabbedPane.addTab("Server Load Control", null, loadPanel, null);
+
+ tabbedPane.addTab("Request Balancing", null,
createRequestBalancingPanel(), null);
+
+ tabbedPane.addTab("Session Balancing", null,
createSessionBalancingPanel(), null);
+
+ // Load the target host/proxy fields from the client control panel
+ // the first time their panel gets focus
+ tabbedPane.addChangeListener(new ChangeListener()
+ {
+ public void stateChanged(ChangeEvent e)
+ {
+ if (loadPanel.equals(tabbedPane.getSelectedComponent()))
+ {
+ String text = targetHostNameField.getText();
+ if (text == null || text.length() == 0)
+ targetHostNameField.setText(proxyHostNameField.getText());
+ text = targetPortField.getText();
+ if (text == null || text.length() == 0)
+ targetPortField.setText(proxyPortField.getText());
+ }
+ }
+ });
+ }
+
+ private JPanel createClientControlPanel()
+ {
final JPanel controlPanel = new JPanel();
GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[] {7,0,7,0,7,0,7,7,0,0,7};
- gridBagLayout.rowHeights = new int[] {0,7,0,7,0,7,0,7, 0};
+ gridBagLayout.rowHeights = new int[] {0,7,0,7,0,7,0,7,0,7, 0};
controlPanel.setLayout(gridBagLayout);
- tabbedPane.addTab("Control", null, controlPanel, null);
- final JPanel requestBalancingPanel = new JPanel();
- gridBagLayout = new GridBagLayout();
- gridBagLayout.columnWidths = new int[] {0};
- gridBagLayout.rowHeights = new int[] {0, 0};
- requestBalancingPanel.setLayout(gridBagLayout);
-
- final JPanel requestChart = new
ChartPanel(this.chartManager.getRequestBalancingChart(), true);
+ JLabel label = new JLabel();
+ label.setText("Proxy Hostname:");
+ label.setToolTipText("Hostname clients should request");
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 0;
- gridBagConstraints.gridx = 0;
- gridBagConstraints.weightx = 1;
+ gridBagConstraints.gridx = 1;
gridBagConstraints.weighty = 1;
- gridBagConstraints.fill = GridBagConstraints.BOTH;
- requestBalancingPanel.add(requestChart, gridBagConstraints);
+ gridBagConstraints.anchor = GridBagConstraints.SOUTH;
+ controlPanel.add(label, gridBagConstraints);
- JPanel clientStatusPanel = new JPanel();
- gridBagLayout = new GridBagLayout();
- gridBagLayout.columnWidths = new int[] {7,0,7,0,7,0,7,0,7,0,7,0,7};
- gridBagLayout.rowHeights = new int[] {7,0};
- clientStatusPanel.setLayout(gridBagLayout);
-
+ proxyHostNameField = new JTextField();
+ proxyHostNameField.setText(DEFAULT_HOST_NAME);
gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 1;
- gridBagConstraints.gridx = 0;
- gridBagConstraints.weightx = 1;
- gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
- requestBalancingPanel.add(clientStatusPanel, gridBagConstraints);
-
- JLabel label = new JLabel();
- label.setText("Total clients:");
- gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 0;
- gridBagConstraints.gridx = 1;
- gridBagConstraints.anchor = GridBagConstraints.WEST;
- clientStatusPanel.add(label, gridBagConstraints);
-
- totalClientsLabelReq = new JLabel();
- totalClientsLabelReq.setText(String.valueOf("0"));
- gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 0;
gridBagConstraints.gridx = 3;
- gridBagConstraints.anchor = GridBagConstraints.WEST;
- clientStatusPanel.add(totalClientsLabelReq, gridBagConstraints);
-
- label = new JLabel();
- label.setText("Live clients:");
- gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 0;
- gridBagConstraints.gridx = 5;
- gridBagConstraints.anchor = GridBagConstraints.WEST;
- clientStatusPanel.add(label, gridBagConstraints);
-
- liveClientsLabelReq = new JLabel();
- liveClientsLabelReq.setText(String.valueOf("0"));
- gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 0;
- gridBagConstraints.gridx = 7;
- gridBagConstraints.anchor = GridBagConstraints.WEST;
- clientStatusPanel.add(liveClientsLabelReq, gridBagConstraints);
-
- label = new JLabel();
- label.setText("Failed clients:");
- gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 0;
- gridBagConstraints.gridx = 9;
- gridBagConstraints.anchor = GridBagConstraints.WEST;
- clientStatusPanel.add(label, gridBagConstraints);
-
- failedClientsLabelReq = new JLabel();
- failedClientsLabelReq.setText(String.valueOf("0"));
- gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 0;
- gridBagConstraints.gridx = 11;
- gridBagConstraints.anchor = GridBagConstraints.WEST;
- clientStatusPanel.add(failedClientsLabelReq, gridBagConstraints);
-
- tabbedPane.addTab("Request Balancing", null, requestBalancingPanel,
null);
-
- final JPanel sessionBalancingPanel = new JPanel();
- gridBagLayout = new GridBagLayout();
- gridBagLayout.columnWidths = new int[] {0};
- gridBagLayout.rowHeights = new int[] {0, 0};
- sessionBalancingPanel.setLayout(gridBagLayout);
-
- tabbedPane.addTab("Session Balancing", null, sessionBalancingPanel,
null);
-
- JPanel sessionBalancingChart = new
ChartPanel(this.chartManager.getSessionBalancingChart(), true);
-
- gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 0;
- gridBagConstraints.gridx = 0;
gridBagConstraints.weightx = 1;
gridBagConstraints.weighty = 1;
- gridBagConstraints.fill = GridBagConstraints.BOTH;
- sessionBalancingPanel.add(sessionBalancingChart, gridBagConstraints);
+ gridBagConstraints.anchor = GridBagConstraints.SOUTH;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+ controlPanel.add(proxyHostNameField, gridBagConstraints);
- clientStatusPanel = new JPanel();
- gridBagLayout = new GridBagLayout();
- gridBagLayout.columnWidths = new int[] {7,0,7,0,7,0,7,0,7,0,7,0,7};
- gridBagLayout.rowHeights = new int[] {7,0};
- clientStatusPanel.setLayout(gridBagLayout);
-
- gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 1;
- gridBagConstraints.gridx = 0;
- gridBagConstraints.weightx = 1;
- gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
- requestBalancingPanel.add(clientStatusPanel, gridBagConstraints);
-
label = new JLabel();
- label.setText("Total clients:");
+ label.setText("Proxy Port:");
+ label.setToolTipText("Port clients should request");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 0;
- gridBagConstraints.gridx = 1;
- gridBagConstraints.anchor = GridBagConstraints.WEST;
- clientStatusPanel.add(label, gridBagConstraints);
-
- totalClientsLabelSess = new JLabel();
- totalClientsLabelSess.setText(String.valueOf("0"));
- gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 0;
- gridBagConstraints.gridx = 3;
- gridBagConstraints.anchor = GridBagConstraints.WEST;
- clientStatusPanel.add(totalClientsLabelSess, gridBagConstraints);
-
- label = new JLabel();
- label.setText("Live clients:");
- gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 0;
- gridBagConstraints.gridx = 5;
- gridBagConstraints.anchor = GridBagConstraints.WEST;
- clientStatusPanel.add(label, gridBagConstraints);
-
- liveClientsLabelSess = new JLabel();
- liveClientsLabelSess.setText(String.valueOf("0"));
- gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 0;
- gridBagConstraints.gridx = 7;
- gridBagConstraints.anchor = GridBagConstraints.WEST;
- clientStatusPanel.add(liveClientsLabelSess, gridBagConstraints);
-
- label = new JLabel();
- label.setText("Failed clients:");
- gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 0;
- gridBagConstraints.gridx = 9;
- gridBagConstraints.anchor = GridBagConstraints.WEST;
- clientStatusPanel.add(label, gridBagConstraints);
-
- failedClientsLabelSess = new JLabel();
- failedClientsLabelSess.setText(String.valueOf("0"));
- gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 0;
- gridBagConstraints.gridx = 11;
- gridBagConstraints.anchor = GridBagConstraints.WEST;
- clientStatusPanel.add(failedClientsLabelSess, gridBagConstraints);
-
- gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 1;
- gridBagConstraints.gridx = 0;
- gridBagConstraints.weightx = 1;
- gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
- sessionBalancingPanel.add(clientStatusPanel, gridBagConstraints);
-
- // Control panel contents
-
- label = new JLabel();
- label.setText("Host name:");
- gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 0;
- gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridx = 6;
gridBagConstraints.weighty = 1;
gridBagConstraints.anchor = GridBagConstraints.SOUTH;
controlPanel.add(label, gridBagConstraints);
- hostNameField = new JTextField();
- hostNameField.setText(DEFAULT_HOST_NAME);
+ proxyPortField = new JTextField();
+ proxyPortField.setText(DEFAULT_PROXY_PORT);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 0;
- gridBagConstraints.gridx = 3;
- gridBagConstraints.gridwidth = 7;
+ gridBagConstraints.gridx = 9;
gridBagConstraints.weightx = 1;
gridBagConstraints.weighty = 1;
gridBagConstraints.anchor = GridBagConstraints.SOUTH;
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
- controlPanel.add(hostNameField, gridBagConstraints);
+ controlPanel.add(proxyPortField, gridBagConstraints);
label = new JLabel();
- label.setText("Request URL:");
+ label.setText("Context Path:");
+ label.setToolTipText("Context path of the demo war");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 2;
gridBagConstraints.gridx = 1;
controlPanel.add(label, gridBagConstraints);
- requestUrlField = new JTextField();
- requestUrlField.setText(DEFAULT_REQUEST_URL);
+ contextPathField = new JTextField();
+ contextPathField.setText(DEFAULT_CONTEXT_PATH);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 2;
gridBagConstraints.gridx = 3;
gridBagConstraints.weightx = 1;
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
- controlPanel.add(requestUrlField, gridBagConstraints);
+ controlPanel.add(contextPathField, gridBagConstraints);
label = new JLabel();
- label.setText("Destroy URL:");
+ label.setText("Session Life (s):");
+ label.setToolTipText("Number of seconds client should use session before
invalidating or abandoning it");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 2;
gridBagConstraints.gridx = 6;
controlPanel.add(label, gridBagConstraints);
- destroyUrlField = new JTextField();
- destroyUrlField.setText(DEFAULT_DESTROY_URL);
+ sessionLifeField = new JTextField();
+ sessionLifeField.setText(String.valueOf(DEFAULT_SESSION_LIFE));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 2;
gridBagConstraints.gridx = 9;
gridBagConstraints.weightx = 1;
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
- controlPanel.add(destroyUrlField, gridBagConstraints);
+ controlPanel.add(sessionLifeField, gridBagConstraints);
label = new JLabel();
- label.setText("Num threads:");
+ label.setText("Invalidate:");
+ label.setToolTipText("Check if session should be invalidated at end of life;
uncheck to abandon session");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 4;
gridBagConstraints.gridx = 1;
controlPanel.add(label, gridBagConstraints);
- numThreadsField = new JTextField();
- numThreadsField.setText(String.valueOf(DEFAULT_NUM_THREADS));
+ destroySessionField = new JCheckBox();
+ destroySessionField.setSelected(true);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 4;
gridBagConstraints.gridx = 3;
gridBagConstraints.weightx = 1;
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
- controlPanel.add(numThreadsField, gridBagConstraints);
+ controlPanel.add(destroySessionField, gridBagConstraints);
- label = new JLabel();
- label.setText("Session Life (s):");
+ sessionTimeoutLabel = new JLabel();
+ sessionTimeoutLabel.setText("Session timeout (s):");
+ sessionTimeoutLabel.setToolTipText("Session maxInactiveInterval if abandoned,
in seconds");
+ sessionTimeoutLabel.setEnabled(destroySessionField.isSelected());
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 4;
gridBagConstraints.gridx = 6;
- controlPanel.add(label, gridBagConstraints);
+ controlPanel.add(sessionTimeoutLabel, gridBagConstraints);
- sessionLifeField = new JTextField();
- sessionLifeField.setText(String.valueOf(DEFAULT_SESSION_LIFE));
+ sessionTimeoutField = new JTextField();
+ sessionTimeoutField.setText(String.valueOf(DEFAULT_SESSION_TIMEOUT));
+ sessionTimeoutField.setEnabled(destroySessionField.isSelected());
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 4;
gridBagConstraints.gridx = 9;
gridBagConstraints.weightx = 1;
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
- controlPanel.add(sessionLifeField, gridBagConstraints);
+ controlPanel.add(sessionTimeoutField, gridBagConstraints);
label = new JLabel();
- label.setText("Sleep time (ms):");
+ label.setText("Num threads:");
+ label.setToolTipText("Number of client threads to launch; max number of
concurrent requests");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 6;
gridBagConstraints.gridx = 1;
controlPanel.add(label, gridBagConstraints);
+ numThreadsField = new JTextField();
+ numThreadsField.setText(String.valueOf(DEFAULT_NUM_THREADS));
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 6;
+ gridBagConstraints.gridx = 3;
+ gridBagConstraints.weightx = 1;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+ controlPanel.add(numThreadsField, gridBagConstraints);
+
+ label = new JLabel();
+ label.setText("Sleep time (ms):");
+ label.setToolTipText("Number of ms each client should sleep between
requests");
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 6;
+ gridBagConstraints.gridx = 6;
+ controlPanel.add(label, gridBagConstraints);
+
sleepTimeField = new JTextField();
sleepTimeField.setText(String.valueOf(DEFAULT_SLEEP_TIME));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 6;
- gridBagConstraints.gridx = 3;
+ gridBagConstraints.gridx = 9;
gridBagConstraints.weightx = 1;
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
controlPanel.add(sleepTimeField, gridBagConstraints);
label = new JLabel();
label.setText("Startup time (s):");
+ label.setToolTipText("Number of seconds over which client threads should be
launched");
gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 6;
- gridBagConstraints.gridx = 6;
+ gridBagConstraints.gridy = 8;
+ gridBagConstraints.gridx = 1;
controlPanel.add(label, gridBagConstraints);
startupTimeField = new JTextField();
startupTimeField.setText(String.valueOf(DEFAULT_STARTUP_TIME));
gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 6;
- gridBagConstraints.gridx = 9;
+ gridBagConstraints.gridy = 8;
+ gridBagConstraints.gridx = 3;
gridBagConstraints.weightx = 1;
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
controlPanel.add(startupTimeField, gridBagConstraints);
+
JButton startButton = new JButton();
startButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e)
@@ -419,7 +360,7 @@
});
startButton.setText("Start");
gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 8;
+ gridBagConstraints.gridy = 10;
gridBagConstraints.gridx = 1;
gridBagConstraints.weighty = 3;
gridBagConstraints.weightx = 1;
@@ -436,7 +377,7 @@
});
stopButton.setText("Stop");
gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 8;
+ gridBagConstraints.gridy = 10;
gridBagConstraints.gridx = 6;
gridBagConstraints.weighty = 2;
gridBagConstraints.weightx = 1;
@@ -446,7 +387,7 @@
JPanel statusPanel = new JPanel();
gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridy = 9;
+ gridBagConstraints.gridy = 11;
gridBagConstraints.gridx = 1;
gridBagConstraints.weighty = 2;
gridBagConstraints.weightx = 1;
@@ -517,21 +458,376 @@
gridBagConstraints.anchor = GridBagConstraints.WEST;
statusPanel.add(failedClientsLabel, gridBagConstraints);
+
+ return controlPanel;
}
+ private JPanel createServerLoadControlPanel()
+ {
+ final JPanel loadPanel = new JPanel();
+ GridBagLayout gridBagLayout = new GridBagLayout();
+ gridBagLayout.columnWidths = new int[] {7,0,7,0,7,0,7,7,0,0,7};
+ gridBagLayout.rowHeights = new int[] {0,7,0,7,0,7,0,7,0,7,0};
+ loadPanel.setLayout(gridBagLayout);
+
+ JLabel label = new JLabel();
+ label.setText("Target Hostname:");
+ label.setToolTipText("Hostname clients should request");
+ GridBagConstraints gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.weighty = 1;
+ gridBagConstraints.anchor = GridBagConstraints.SOUTH;
+ loadPanel.add(label, gridBagConstraints);
+
+ targetHostNameField = new JTextField();
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 3;
+ gridBagConstraints.weightx = 1;
+ gridBagConstraints.weighty = 1;
+ gridBagConstraints.anchor = GridBagConstraints.SOUTH;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+ loadPanel.add(targetHostNameField, gridBagConstraints);
+
+ label = new JLabel();
+ label.setText("Target Port:");
+ label.setToolTipText("Port clients should request");
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 6;
+ gridBagConstraints.weighty = 1;
+ gridBagConstraints.anchor = GridBagConstraints.SOUTH;
+ loadPanel.add(label, gridBagConstraints);
+
+ targetPortField = new JTextField();
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 9;
+ gridBagConstraints.weightx = 1;
+ gridBagConstraints.weighty = 1;
+ gridBagConstraints.anchor = GridBagConstraints.SOUTH;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+ loadPanel.add(targetPortField, gridBagConstraints);
+
+ label = new JLabel();
+ label.setText("Load Creation Action:");
+ label.setToolTipText("Action to invoke on target server to simulate server
load");
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 2;
+ gridBagConstraints.gridx = 1;
+ loadPanel.add(label, gridBagConstraints);
+
+ EnumSet<ServerLoadServlets> es = EnumSet.allOf(ServerLoadServlets.class);
+ Vector<ServerLoadServlets> v = new Vector<ServerLoadServlets>(es);
+ final JComboBox targetLoadServletCombo = new JComboBox(v);
+ targetLoadServletCombo.setRenderer(new ServerLoadServletCellRenderer());
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 2;
+ gridBagConstraints.gridx = 3;
+ gridBagConstraints.weightx = 1;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+ loadPanel.add(targetLoadServletCombo, gridBagConstraints);
+
+ targetLoadServletCombo.setSelectedItem(ServerLoadServlets.CONNECTION_POOL_USAGE);
+ selectedLoadServlet = ServerLoadServlets.CONNECTION_POOL_USAGE;
+
+ ServerLoadParam param =
ServerLoadServlets.CONNECTION_POOL_USAGE.getParams().get(0);
+
+ targetServletParamLabel1 = new JLabel();
+ targetServletParamLabel1.setText(param.getLabel());
+ targetServletParamLabel1.setToolTipText(param.getDescription());
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 4;
+ gridBagConstraints.gridx = 1;
+ loadPanel.add(targetServletParamLabel1, gridBagConstraints);
+
+ targetServletParamField1 = new JTextField();
+ targetServletParamField1.setText(param.getValue());
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 4;
+ gridBagConstraints.gridx = 3;
+ gridBagConstraints.weightx = 1;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+ loadPanel.add(targetServletParamField1, gridBagConstraints);
+
+ param = ServerLoadServlets.CONNECTION_POOL_USAGE.getParams().get(1);
+
+ targetServletParamLabel2 = new JLabel();
+ targetServletParamLabel2.setText(param.getLabel());
+ targetServletParamLabel2.setToolTipText(param.getDescription());
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 6;
+ gridBagConstraints.gridx = 1;
+ loadPanel.add(targetServletParamLabel2, gridBagConstraints);
+
+ targetServletParamField2 = new JTextField();
+ targetServletParamField2.setText(param.getValue());
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 6;
+ gridBagConstraints.gridx = 3;
+ gridBagConstraints.weightx = 1;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+ loadPanel.add(targetServletParamField2, gridBagConstraints);
+
+ targetLoadServletCombo.addItemListener(new ItemListener()
+ {
+ public void itemStateChanged(ItemEvent e)
+ {
+ if (ItemEvent.SELECTED == e.getStateChange())
+ {
+ selectedLoadServlet = (ServerLoadServlets) e.getItem();
+ List<ServerLoadParam> params = selectedLoadServlet.getParams();
+ if (params.size() > 0)
+ {
+ targetServletParamLabel1.setText(params.get(0).getLabel() +
":");
+
targetServletParamLabel1.setToolTipText(params.get(0).getDescription());
+ targetServletParamField1.setVisible(true);
+ targetServletParamField1.setText(params.get(0).getValue());
+ }
+ else
+ {
+ targetServletParamLabel1.setText(" ");
+ targetServletParamField1.setVisible(false);
+ }
+ if (params.size() > 1)
+ {
+ targetServletParamLabel2.setText(params.get(1).getLabel()
+":");
+
targetServletParamLabel2.setToolTipText(params.get(1).getDescription());
+ targetServletParamField2.setVisible(true);
+ targetServletParamField2.setText(params.get(1).getValue());
+ }
+ else
+ {
+ targetServletParamLabel2.setText(" ");
+ targetServletParamField2.setVisible(false);
+ }
+ }
+ }
+ });
+
+ JButton createLoadButton = new JButton();
+ createLoadButton.addActionListener(new ActionListener() {
+ public void actionPerformed(final ActionEvent e)
+ {
+ createLoad();
+ }
+ });
+ createLoadButton.setText("Create Load");
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 8;
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.weighty = 3;
+ gridBagConstraints.weightx = 1;
+ gridBagConstraints.gridwidth = 9;
+ gridBagConstraints.anchor = GridBagConstraints.NORTH;
+ loadPanel.add(createLoadButton, gridBagConstraints);
+
+ return loadPanel;
+ }
+
+ private JPanel createRequestBalancingPanel()
+ {
+ final JPanel requestBalancingPanel = new JPanel();
+ GridBagLayout gridBagLayout = new GridBagLayout();
+ gridBagLayout.columnWidths = new int[] {0};
+ gridBagLayout.rowHeights = new int[] {0, 0};
+ requestBalancingPanel.setLayout(gridBagLayout);
+
+ final JPanel requestChart = new
ChartPanel(this.chartManager.getRequestBalancingChart(), true);
+ GridBagConstraints gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.weightx = 1;
+ gridBagConstraints.weighty = 1;
+ gridBagConstraints.fill = GridBagConstraints.BOTH;
+ requestBalancingPanel.add(requestChart, gridBagConstraints);
+
+ JPanel clientStatusPanel = new JPanel();
+ gridBagLayout = new GridBagLayout();
+ gridBagLayout.columnWidths = new int[] {7,0,7,0,7,0,7,0,7,0,7,0,7};
+ gridBagLayout.rowHeights = new int[] {7,0};
+ clientStatusPanel.setLayout(gridBagLayout);
+
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.weightx = 1;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+ requestBalancingPanel.add(clientStatusPanel, gridBagConstraints);
+
+ JLabel label = new JLabel();
+ label.setText("Total clients:");
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.anchor = GridBagConstraints.WEST;
+ clientStatusPanel.add(label, gridBagConstraints);
+
+ totalClientsLabelReq = new JLabel();
+ totalClientsLabelReq.setText(String.valueOf("0"));
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 3;
+ gridBagConstraints.anchor = GridBagConstraints.WEST;
+ clientStatusPanel.add(totalClientsLabelReq, gridBagConstraints);
+
+ label = new JLabel();
+ label.setText("Live clients:");
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 5;
+ gridBagConstraints.anchor = GridBagConstraints.WEST;
+ clientStatusPanel.add(label, gridBagConstraints);
+
+ liveClientsLabelReq = new JLabel();
+ liveClientsLabelReq.setText(String.valueOf("0"));
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 7;
+ gridBagConstraints.anchor = GridBagConstraints.WEST;
+ clientStatusPanel.add(liveClientsLabelReq, gridBagConstraints);
+
+ label = new JLabel();
+ label.setText("Failed clients:");
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 9;
+ gridBagConstraints.anchor = GridBagConstraints.WEST;
+ clientStatusPanel.add(label, gridBagConstraints);
+
+ failedClientsLabelReq = new JLabel();
+ failedClientsLabelReq.setText(String.valueOf("0"));
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 11;
+ gridBagConstraints.anchor = GridBagConstraints.WEST;
+ clientStatusPanel.add(failedClientsLabelReq, gridBagConstraints);
+
+ return requestBalancingPanel;
+ }
+
+ private JPanel createSessionBalancingPanel()
+ {
+ final JPanel sessionBalancingPanel = new JPanel();
+ GridBagLayout gridBagLayout = new GridBagLayout();
+ gridBagLayout.columnWidths = new int[] {0};
+ gridBagLayout.rowHeights = new int[] {0, 0};
+ sessionBalancingPanel.setLayout(gridBagLayout);
+
+ JPanel sessionBalancingChart = new
ChartPanel(this.chartManager.getSessionBalancingChart(), true);
+
+ GridBagConstraints gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.weightx = 1;
+ gridBagConstraints.weighty = 1;
+ gridBagConstraints.fill = GridBagConstraints.BOTH;
+ sessionBalancingPanel.add(sessionBalancingChart, gridBagConstraints);
+
+ JPanel clientStatusPanel = new JPanel();
+ gridBagLayout = new GridBagLayout();
+ gridBagLayout.columnWidths = new int[] {7,0,7,0,7,0,7,0,7,0,7,0,7};
+ gridBagLayout.rowHeights = new int[] {7,0};
+ clientStatusPanel.setLayout(gridBagLayout);
+
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.weightx = 1;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+ sessionBalancingPanel.add(clientStatusPanel, gridBagConstraints);
+
+ JLabel label = new JLabel();
+ label.setText("Total clients:");
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.anchor = GridBagConstraints.WEST;
+ clientStatusPanel.add(label, gridBagConstraints);
+
+ totalClientsLabelSess = new JLabel();
+ totalClientsLabelSess.setText(String.valueOf("0"));
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 3;
+ gridBagConstraints.anchor = GridBagConstraints.WEST;
+ clientStatusPanel.add(totalClientsLabelSess, gridBagConstraints);
+
+ label = new JLabel();
+ label.setText("Live clients:");
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 5;
+ gridBagConstraints.anchor = GridBagConstraints.WEST;
+ clientStatusPanel.add(label, gridBagConstraints);
+
+ liveClientsLabelSess = new JLabel();
+ liveClientsLabelSess.setText(String.valueOf("0"));
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 7;
+ gridBagConstraints.anchor = GridBagConstraints.WEST;
+ clientStatusPanel.add(liveClientsLabelSess, gridBagConstraints);
+
+ label = new JLabel();
+ label.setText("Failed clients:");
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 9;
+ gridBagConstraints.anchor = GridBagConstraints.WEST;
+ clientStatusPanel.add(label, gridBagConstraints);
+
+ failedClientsLabelSess = new JLabel();
+ failedClientsLabelSess.setText(String.valueOf("0"));
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridx = 11;
+ gridBagConstraints.anchor = GridBagConstraints.WEST;
+ clientStatusPanel.add(failedClientsLabelSess, gridBagConstraints);
+
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.weightx = 1;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+ sessionBalancingPanel.add(clientStatusPanel, gridBagConstraints);
+ return sessionBalancingPanel;
+ }
+
private void start()
{
- // Extract the Control panel contents
- String host = hostNameField.getText();
- String request_url = requestUrlField.getText();
- String destroy_url = destroyUrlField.getText();
-
- String tmp = "http://" + host + "/";
+ String sessionTimeoutText = sessionTimeoutField.getText();
+ int sessionTimeout = -1;
+ if (sessionTimeoutText != null && sessionTimeoutText.trim().length() >
0)
+ {
+ try
+ {
+ sessionTimeout = Integer.parseInt(sessionTimeoutText);
+ }
+ catch (NumberFormatException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ boolean invalidate = destroySessionField.isSelected();
+
+ String tmp = createBaseURL(proxyHostNameField.getText(),proxyPortField.getText()) +
"record";
URL requestURL, destroyURL;
try
{
- requestURL = new URL(tmp + request_url);
- destroyURL = new URL(tmp + destroy_url);
+ if (invalidate)
+ {
+ requestURL = new URL(tmp);
+ destroyURL = new URL(tmp + "?destroy=true");
+ }
+ else
+ {
+ String timeoutParam = (sessionTimeout > 0) ? "?timeout=" +
String.valueOf(sessionTimeout) : "";
+ requestURL = new URL(tmp + timeoutParam);
+ destroyURL = requestURL;
+ }
}
catch (MalformedURLException e)
{
@@ -586,6 +882,83 @@
// Update the client status panel
updateStatusPanel();
}
+
+ private void createLoad()
+ {
+ String tmp = createBaseURL(targetHostNameField.getText(),
targetPortField.getText()) + selectedLoadServlet.getServletPath();
+ List<ServerLoadParam> params = selectedLoadServlet.getParams();
+ if (params.size() > 0)
+ {
+ String val = targetServletParamField1.getText();
+ params.get(0).setValue(val);
+ tmp += "?" + params.get(0).getName() + "=" + val;
+ }
+ if (params.size() > 1)
+ {
+ String val = targetServletParamField2.getText();
+ params.get(1).setValue(val);
+ tmp += "&" + params.get(1).getName() + "=" + val;
+ }
+
+ final URL requestURL;
+ try
+ {
+ requestURL = new URL(tmp);
+ }
+ catch (MalformedURLException e)
+ {
+ e.printStackTrace(System.err);
+ return;
+ }
+
+ // Send the request in another thread
+ Runnable r = new Runnable()
+ {
+ private final byte[] buffer = new byte[1024];
+ public void run()
+ {
+ System.out.println("Sending load generation request " +
requestURL);
+ InputStream input = null;
+ HttpURLConnection conn = null;
+ try
+ {
+ conn = (HttpURLConnection) requestURL.openConnection(); // not yet
connected
+ input = conn.getInputStream(); // NOW it is connected
+ while (input.read(buffer) > 0)
+ {
+ ;
+ }
+ input.close(); // discard data
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ ExecutorService exec = Executors.newSingleThreadExecutor();
+ exec.execute(r);
+ exec.shutdown();
+ }
+
+ private String createBaseURL(String hostText, String portText)
+ {
+ if (portText == null || portText.trim().length() == 0)
+ portText = "80";
+ portText = portText.trim();
+
+ String contextPath = contextPathField.getText();
+ if (contextPath == null)
+ contextPath = "";
+ contextPath.trim();
+ if (contextPath.length() > 0 && '/' == contextPath.charAt(0))
+ contextPath = contextPath.length() == 1 ? "" :
contextPath.substring(1);
+ if (contextPath.length() > 0 && '/' ==
contextPath.charAt(contextPath.length() -1))
+ contextPath = contextPath.length() == 1 ? "" :
contextPath.substring(0, contextPath.length() -1);
+
+ return "http://" + hostText + ":" + portText + "/" +
contextPath + "/";
+ }
private void updateStatusPanel()
{
@@ -618,5 +991,23 @@
}
}
+
+ private class ServerLoadServletCellRenderer extends JLabel implements ListCellRenderer
+ {
+ private static final long serialVersionUID = -8010662328204072428L;
+
+ public Component getListCellRendererComponent(
+ JList list,
+ Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus)
+ {
+ setText(value.toString());
+ setToolTipText(((ServerLoadServlets) value).getDescription());
+ return this;
+ }
+ }
+
}
Added:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/load/ServerLoadParam.java
===================================================================
---
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/load/ServerLoadParam.java
(rev 0)
+++
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/load/ServerLoadParam.java 2008-10-26
06:27:15 UTC (rev 2004)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.modcluster.demo.client.load;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class ServerLoadParam
+{
+ private final String name;
+ private final String label;
+ private final String description;
+ private String value;
+
+ public ServerLoadParam(String name, String label, String description, String value)
+ {
+ this.name = name;
+ this.label = label;
+ this.description = description;
+ this.value = value;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getLabel()
+ {
+ return label;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+}
Property changes on:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/load/ServerLoadParam.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/load/ServerLoadServlets.java
===================================================================
---
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/load/ServerLoadServlets.java
(rev 0)
+++
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/load/ServerLoadServlets.java 2008-10-26
06:27:15 UTC (rev 2004)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.modcluster.demo.client.load;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public enum ServerLoadServlets
+{
+ ACTIVE_SESSIONS("Active Sessions",
+ "Generates server load by causing session creation on the target
server.",
+ "sessions",
+ new ServerLoadParam("count", "Number of Sessions",
+ "Number of sessions to create",
"20")),
+
+ DATASOURCE_USAGE("Datasource Use",
+ "Generates server load by taking connections from the
java:DefaultDS datasource for a period",
+ "database",
+ new ServerLoadParam("count", "Number of
Connections",
+ "Number of connections to request from the
datasource", "20"),
+ new ServerLoadParam("duration", "Duration",
+ "Number of seconds to hold the connections
before returning to datasource", "15")),
+
+ CONNECTION_POOL_USAGE("Connection Pool Use",
+ "Generates server load by tieing up threads in the
webserver connections pool for a period",
+ "connectors",
+ new ServerLoadParam("count", "Number of
Connections",
+ "Number of connection pool threads to
tie up", "50"),
+ new ServerLoadParam("duration", "Duration",
+ "Number of seconds to tie up the
connections", "15")),
+
+ HEAP_MEMORY_USAGE("Heap Memory Pool Use",
+ "Generates server load by filling 50% of free heap memory for a
period",
+ "heap",
+ new ServerLoadParam("duration", "Duration",
+ "Number of seconds to maintain memory
usage", "15")),
+
+ CPU_USAGE("CPU Use",
+ "Generates server CPU load by initiating a tight loop in on
thread",
+ "cpu",
+ new ServerLoadParam("duration", "Duration",
+ "Number of seconds to maintain CPU usage",
"15")),
+
+ THREAD_USAGE("Thread Use",
+ "Generates server load by spawning threads (which do nothing but
sleep)",
+ "database",
+ new ServerLoadParam("count", "Number of Threads",
+ "Number of threads to spawn",
"50"),
+ new ServerLoadParam("duration", "Duration",
+ "Number of seconds threads should live before
exiting", "15")),
+
+ RECEIVE_TRAFFIC_USAGE("Server Receive Traffic",
+ "Generates server traffic receipt load by POSTing a large
byte array to the server once per second for a period",
+ "receive",
+ new ServerLoadParam("size", "POST size",
+ "Number of bytes to POST, divided by
1000", "100"),
+ new ServerLoadParam("duration", "Duration",
+ "Number of seconds to continue
POSTing", "15")),
+
+ SEND_TRAFFIC_USAGE("Server Send Traffic",
+ "Generates server traffic send load by making a request once
per second to which the server responds with a large byte array",
+ "send",
+ new ServerLoadParam("size", "Response size",
+ "Size of the server response in bytes,
divided by 1000", "100"),
+ new ServerLoadParam("duration", "Duration",
+ "Number of seconds to continue
POSTing", "15")),
+
+ REQUEST_COUNT_USAGE("Request Count",
+ "Generates server load by making numerous requests,
increasing the request count on the target server.",
+ "requests",
+ new ServerLoadParam("count", "Number of
Requests",
+ "Number of requestss to make",
"50"));
+
+ private final String label;
+ private final String description;
+ private final String servletPath;
+ private final List<ServerLoadParam> params;
+
+ private ServerLoadServlets(String label, String description, String servletPath,
ServerLoadParam... params)
+ {
+ this.label = label;
+ this.description = description;
+ this.servletPath = servletPath;
+ if (params != null)
+ {
+ List<ServerLoadParam> asList = Arrays.asList(params);
+ this.params = Collections.unmodifiableList(asList);
+ }
+ else
+ {
+ @SuppressWarnings("unchecked")
+ List<ServerLoadParam> unchecked = Collections.EMPTY_LIST;
+ this.params = unchecked;
+ }
+ }
+
+ public String getLabel()
+ {
+ return label;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public String getServletPath()
+ {
+ return servletPath;
+ }
+
+ public List<ServerLoadParam> getParams()
+ {
+ return params;
+ }
+
+ @Override
+ public String toString()
+ {
+ return label;
+ }
+
+}
Property changes on:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/load/ServerLoadServlets.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native