JBoss Native SVN: r2004 - in trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client: load and 1 other directory.
by jbossnative-commits@lists.jboss.org
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
15 years, 10 months
JBoss Native SVN: r2003 - trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client.
by jbossnative-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-10-26 02:15:19 -0400 (Sun, 26 Oct 2008)
New Revision: 2003
Modified:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/RequestDriver.java
Log:
Minor diagnostics
Modified: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/RequestDriver.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/RequestDriver.java 2008-10-26 02:37:37 UTC (rev 2002)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/RequestDriver.java 2008-10-26 06:15:19 UTC (rev 2003)
@@ -39,6 +39,8 @@
this.stopped.set(false);
final int startupPause = startup_time > 0 ? (startup_time * 1000 / num_threads) : 0;
+ System.out.println("Request URL is " + request_url);
+ System.out.println("Terminal URL is " + destroy_url);
System.out.println("Starting " + num_threads + " clients");
Runnable r = new Runnable()
{
15 years, 10 months
JBoss Native SVN: r2002 - trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet.
by jbossnative-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-10-25 22:37:37 -0400 (Sat, 25 Oct 2008)
New Revision: 2002
Modified:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/HeapMemoryLoadServlet.java
Log:
Run qc before filling memory
Modified: trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/HeapMemoryLoadServlet.java
===================================================================
--- trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/HeapMemoryLoadServlet.java 2008-10-25 04:57:27 UTC (rev 2001)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/servlet/HeapMemoryLoadServlet.java 2008-10-26 02:37:37 UTC (rev 2002)
@@ -44,6 +44,8 @@
{
int duration = Integer.parseInt(this.getParameter(request, DURATION, DEFAULT_DURATION));
+ System.gc();
+
long free = Runtime.getRuntime().freeMemory() / 2;
@SuppressWarnings("unused")
15 years, 10 months
JBoss Native SVN: r2001 - trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client.
by jbossnative-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-10-25 00:57:27 -0400 (Sat, 25 Oct 2008)
New Revision: 2001
Modified:
trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/ModClusterDemo.java
Log:
Show client status on chart panels
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-24 17:51:24 UTC (rev 2000)
+++ trunk/mod_cluster/src/demo/java/org/jboss/modcluster/demo/client/ModClusterDemo.java 2008-10-25 04:57:27 UTC (rev 2001)
@@ -55,6 +55,12 @@
private JLabel totalClientsLabel;
private JLabel liveClientsLabel;
private JLabel failedClientsLabel;
+ private JLabel totalClientsLabelReq;
+ private JLabel liveClientsLabelReq;
+ private JLabel failedClientsLabelReq;
+ private JLabel totalClientsLabelSess;
+ private JLabel liveClientsLabelSess;
+ private JLabel failedClientsLabelSess;
/**
* Launch the application
@@ -121,17 +127,175 @@
controlPanel.setLayout(gridBagLayout);
tabbedPane.addTab("Control", null, controlPanel, null);
- final JPanel requestBalancingPanel = new ChartPanel(this.chartManager.getRequestBalancingChart(), true);
+ 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);
+ 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);
+
tabbedPane.addTab("Request Balancing", null, requestBalancingPanel, null);
- final JPanel sessionBalancingPanel = new ChartPanel(this.chartManager.getSessionBalancingChart(), true);
+ 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);
+
+ 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:");
+ 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
- JLabel label = new JLabel();
+ label = new JLabel();
label.setText("Host name:");
- GridBagConstraints gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 0;
gridBagConstraints.gridx = 1;
gridBagConstraints.weighty = 1;
@@ -428,9 +592,17 @@
ClientStatus status = requestDriver.getClientStatus();
totalClientsLabel.setText(String.valueOf(status.clientCount));
liveClientsLabel.setText(String.valueOf(status.liveClientCount));
+ totalClientsLabelReq.setText(String.valueOf(status.clientCount));
+ liveClientsLabelReq.setText(String.valueOf(status.liveClientCount));
+ totalClientsLabelSess.setText(String.valueOf(status.clientCount));
+ liveClientsLabelSess.setText(String.valueOf(status.liveClientCount));
int failedCount = status.clientCount - status.successfulClientCount;
failedClientsLabel.setText(String.valueOf(failedCount));
failedClientsLabel.setForeground(failedCount == 0 ? Color.BLACK : Color.RED);
+ failedClientsLabelReq.setText(String.valueOf(failedCount));
+ failedClientsLabelReq.setForeground(failedCount == 0 ? Color.BLACK : Color.RED);
+ failedClientsLabelSess.setText(String.valueOf(failedCount));
+ failedClientsLabelSess.setForeground(failedCount == 0 ? Color.BLACK : Color.RED);
}
private class GUIUpdateTimerTask extends TimerTask
15 years, 10 months
JBoss Native SVN: r2000 - trunk/mod_cluster/src/main/resources.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-24 13:51:24 -0400 (Fri, 24 Oct 2008)
New Revision: 2000
Modified:
trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml
Log:
Change default history=9
Modified: trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml
===================================================================
--- trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml 2008-10-24 17:50:17 UTC (rev 1999)
+++ trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml 2008-10-24 17:51:24 UTC (rev 2000)
@@ -59,7 +59,7 @@
</parameter>
</constructor>
<!-- The number of historical load values used to determine load factor -->
- <!--property name="history">10</property-->
+ <!--property name="history">9</property-->
<!-- The exponential decay factor for historical load values -->
<!--property name="decayFactor">2</property-->
</bean>
15 years, 10 months
JBoss Native SVN: r1999 - in trunk/mod_cluster/src: test/java/org/jboss/modcluster/load and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-24 13:50:17 -0400 (Fri, 24 Oct 2008)
New Revision: 1999
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProvider.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProviderMBean.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/DynamicLoadBalanceFactorProviderTestCase.java
Log:
Change meaning of history property to only encompass old values. i.e. history=0 means no decay.
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProvider.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProvider.java 2008-10-24 16:24:07 UTC (rev 1998)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProvider.java 2008-10-24 17:50:17 UTC (rev 1999)
@@ -29,9 +29,7 @@
import java.util.Map;
import java.util.Set;
-import org.apache.catalina.util.StringManager;
import org.jboss.logging.Logger;
-import org.jboss.modcluster.Constants;
import org.jboss.modcluster.load.LoadBalanceFactorProvider;
import org.jboss.modcluster.load.metric.LoadContext;
import org.jboss.modcluster.load.metric.LoadMetric;
@@ -45,13 +43,12 @@
public class DynamicLoadBalanceFactorProvider implements LoadBalanceFactorProvider, DynamicLoadBalanceFactorProviderMBean
{
private final Logger log = Logger.getLogger(this.getClass());
- private final StringManager sm = StringManager.getManager(Constants.Package);
private final Map<LoadMetricSource<LoadContext>, Collection<LoadMetric<LoadContext>>> metrics = new LinkedHashMap<LoadMetricSource<LoadContext>, Collection<LoadMetric<LoadContext>>>();
private final Map<LoadMetric<LoadContext>, List<Double>> loadHistory = new HashMap<LoadMetric<LoadContext>, List<Double>>();
private volatile int decayFactor = 2;
- private volatile int history = 10;
+ private volatile int history = 9;
public DynamicLoadBalanceFactorProvider(Set<LoadMetric<LoadContext>> metrics)
{
@@ -139,18 +136,20 @@
if (queue == null)
{
- queue = new ArrayList<Double>(this.history);
+ queue = new ArrayList<Double>(this.history + 1);
this.loadHistory.put(metric, queue);
}
else
{
- for (int i = queue.size(); i >= this.history; --i)
+ // History could have changed, so prune queue accordingly
+ for (int i = (queue.size() - 1); i >= this.history; --i)
{
- queue.remove(i - 1);
+ queue.remove(i);
}
}
+ // Add new load to the front
queue.add(0, new Double(load));
return queue;
@@ -196,12 +195,7 @@
*/
public void setDecayFactor(int decayFactor)
{
- if (decayFactor <= 0)
- {
- throw new IllegalArgumentException(this.sm.getString("modcluster.error.nonPositiveAttribute", "decayFactor", String.valueOf(decayFactor)));
- }
-
- this.decayFactor = decayFactor;
+ this.decayFactor = Math.max(1, decayFactor);
}
/**
@@ -219,11 +213,6 @@
*/
public void setHistory(int history)
{
- if (history <= 0)
- {
- throw new IllegalArgumentException(this.sm.getString("modcluster.error.nonPositiveAttribute", "history", String.valueOf(history)));
- }
-
- this.history = history;
+ this.history = Math.max(0, history);
}
}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProviderMBean.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProviderMBean.java 2008-10-24 16:24:07 UTC (rev 1998)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProviderMBean.java 2008-10-24 17:50:17 UTC (rev 1999)
@@ -36,7 +36,6 @@
/**
* Sets the number of historical load values to consider when calculating the load balance factor.
* @param history
- * @throws IllegalArgumentException if specified value is not a positive number
*/
void setHistory(int history);
@@ -49,7 +48,6 @@
/**
* Sets the exponential decay factor to be applied to historical load values.
* @param decayFactor the new decay factor
- * @throws IllegalArgumentException if specified value is not a positive number
*/
void setDecayFactor(int decayFactor);
}
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/DynamicLoadBalanceFactorProviderTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/DynamicLoadBalanceFactorProviderTestCase.java 2008-10-24 16:24:07 UTC (rev 1998)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/DynamicLoadBalanceFactorProviderTestCase.java 2008-10-24 17:50:17 UTC (rev 1999)
@@ -63,7 +63,7 @@
EasyMock.verify(this.metric1, this.metric2, this.metric3);
EasyMock.reset(this.metric1, this.metric2, this.metric3);
- this.provider.setHistory(2);
+ this.provider.setHistory(1);
}
@Test
15 years, 10 months
JBoss Native SVN: r1998 - trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-24 12:24:07 -0400 (Fri, 24 Oct 2008)
New Revision: 1998
Removed:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadCountLoadMetric.java
Log:
Obsolete
Deleted: trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadCountLoadMetric.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadCountLoadMetric.java 2008-10-24 15:08:55 UTC (rev 1997)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadCountLoadMetric.java 2008-10-24 16:24:07 UTC (rev 1998)
@@ -1,55 +0,0 @@
-/*
- * 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.load.metric.impl;
-
-import java.lang.management.ManagementFactory;
-import java.lang.management.ThreadMXBean;
-
-import org.jboss.modcluster.load.metric.LoadContext;
-
-/**
- * @author Paul Ferraro
- *
- */
-public class ThreadCountLoadMetric extends SelfSourcedLoadMetric
-{
- private final ThreadMXBean bean;
-
- public ThreadCountLoadMetric()
- {
- this(ManagementFactory.getThreadMXBean());
- }
-
- public ThreadCountLoadMetric(ThreadMXBean bean)
- {
- this.bean = bean;
- }
-
- /**
- * @{inheritDoc}
- * @see org.jboss.modcluster.load.metric.LoadMetric#getLoad()
- */
- public double getLoad(LoadContext context)
- {
- return this.bean.getThreadCount();
- }
-}
15 years, 10 months
JBoss Native SVN: r1997 - in trunk/mod_cluster/src: test/java/org/jboss/modcluster/ha and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-24 11:08:55 -0400 (Fri, 24 Oct 2008)
New Revision: 1997
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceImpl.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java
Log:
Duh - remote getResetRequests was using old method signature
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceImpl.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceImpl.java 2008-10-24 14:38:11 UTC (rev 1996)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceImpl.java 2008-10-24 15:08:55 UTC (rev 1997)
@@ -53,8 +53,7 @@
public class HASingletonAwareResetRequestSourceImpl implements HASingletonAwareResetRequestSource
{
static final String METHOD_NAME = "getResetRequests";
- static final Object[] ARGS = new Object[0];
- static final Class<?>[] TYPES = new Class[0];
+ static final Class<?>[] TYPES = new Class[] { Map.class };
private static final Logger log = Logger.getLogger(HASingletonAwareResetRequestSourceImpl.class);
@@ -156,7 +155,7 @@
{
try
{
- return this.serviceKeyProvider.getHAPartition().callMethodOnCluster(this.serviceKeyProvider.getHAServiceKey(), METHOD_NAME, ARGS, TYPES, true);
+ return this.serviceKeyProvider.getHAPartition().callMethodOnCluster(this.serviceKeyProvider.getHAServiceKey(), METHOD_NAME, new Object[] { response }, TYPES, true);
}
catch (Exception e)
{
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java 2008-10-24 14:38:11 UTC (rev 1996)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java 2008-10-24 15:08:55 UTC (rev 1997)
@@ -67,6 +67,7 @@
public void getResetRequests() throws Exception
{
Map<String, String> emptyMap = Collections.emptyMap();
+ Map<String, ResetRequestSource.EngineStatus> emptyResponseMap = Collections.emptyMap();
MCMPRequest request1 = new MCMPRequest(MCMPRequestType.ENABLE_APP, false, "host1", emptyMap);
MCMPRequest request2 = new MCMPRequest(MCMPRequestType.REMOVE_APP, false, "host2", emptyMap);
@@ -78,11 +79,10 @@
EasyMock.expect(this.key.getHAPartition()).andReturn(this.partition);
EasyMock.expect(this.key.getHAServiceKey()).andReturn("service:domain");
- EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq("service:domain"), EasyMock.eq("getResetRequests"), EasyMock.aryEq(new Object[0]), EasyMock.aryEq(new Class[0]), EasyMock.eq(true))).andReturn(new ArrayList<ResetRequestGroupRpcResponse>(Arrays.asList(response1, response2)));
+ EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq("service:domain"), EasyMock.eq("getResetRequests"), EasyMock.aryEq(new Object[] { emptyResponseMap }), EasyMock.aryEq(new Class[] { Map.class }), EasyMock.eq(true))).andReturn(new ArrayList<ResetRequestGroupRpcResponse>(Arrays.asList(response1, response2)));
EasyMock.replay(this.singleton, this.key, this.partition);
- Map<String, ResetRequestSource.EngineStatus> emptyResponseMap = Collections.emptyMap();
List<MCMPRequest> results = this.source.getResetRequests(emptyResponseMap);
EasyMock.verify(this.singleton, this.key, this.partition);
@@ -109,7 +109,7 @@
EasyMock.expect(this.key.getHAPartition()).andReturn(this.partition);
EasyMock.expect(this.key.getHAServiceKey()).andReturn("service:domain");
- EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq("service:domain"), EasyMock.eq("getResetRequests"), EasyMock.aryEq(new Object[0]), EasyMock.aryEq(new Class[0]), EasyMock.eq(true))).andReturn(new ArrayList<ResetRequestGroupRpcResponse>(Arrays.asList(response1, response2)));
+ EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq("service:domain"), EasyMock.eq("getResetRequests"), EasyMock.aryEq(new Object[] { emptyResponseMap }), EasyMock.aryEq(new Class[] { Map.class }), EasyMock.eq(true))).andReturn(new ArrayList<ResetRequestGroupRpcResponse>(Arrays.asList(response1, response2)));
EasyMock.expect(server.findServices()).andReturn(new Service[] { service });
EasyMock.expect(service.getContainer()).andReturn(engine);
15 years, 10 months
JBoss Native SVN: r1996 - trunk/mod_cluster/src/main/java/org/jboss/modcluster/config.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-24 10:38:11 -0400 (Fri, 24 Oct 2008)
New Revision: 1996
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/config/ModClusterConfig.java
Log:
Fixed javabean-ness of masterPerDomain property
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/config/ModClusterConfig.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/config/ModClusterConfig.java 2008-10-24 14:37:04 UTC (rev 1995)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/config/ModClusterConfig.java 2008-10-24 14:38:11 UTC (rev 1996)
@@ -93,6 +93,13 @@
private int socketTimeout = 20000;
public int getSocketTimeout() { return this.socketTimeout; }
public void setSocketTimeout(int socketTimeout) { this.socketTimeout = socketTimeout; }
+
+ /**
+ * Should clustered service use a singleton master per domain.
+ */
+ private boolean masterPerDomain = false;
+ public boolean isMasterPerDomain() { return this.masterPerDomain; }
+ public void setMasterPerDomain(boolean masterPerDomain) { this.masterPerDomain = masterPerDomain; }
// ----------------------------------------------------- SSLConfiguration
@@ -331,8 +338,4 @@
private int maxAttempts = -1;
public int getMaxAttempts() { return this.maxAttempts; }
public void setMaxAttempts(int maxAttempts) { this.maxAttempts = maxAttempts; }
-
- private boolean servicePerDomain = false;
- public boolean isMasterPerDomain() { return this.servicePerDomain; }
- public void setServicePerDomain(boolean servicePerDomain) { this.servicePerDomain = servicePerDomain; }
}
15 years, 10 months
JBoss Native SVN: r1995 - trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-24 10:37:04 -0400 (Fri, 24 Oct 2008)
New Revision: 1995
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java
Log:
Send REMOVE-APP requests before CONFIG
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java 2008-10-23 15:34:18 UTC (rev 1994)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java 2008-10-24 14:37:04 UTC (rev 1995)
@@ -29,6 +29,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -265,16 +266,14 @@
public static List<MCMPRequest> getResetRequests(Map<String, ResetRequestSource.EngineStatus> response, Server server, NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig)
{
List<MCMPRequest> requests = new ArrayList<MCMPRequest>();
- Set<String> jvmRoutes = new HashSet<String>(response.keySet());
+ List<MCMPRequest> engineRequests = new LinkedList<MCMPRequest>();
for (Service service: server.findServices())
{
Engine engine = (Engine) service.getContainer();
String jvmRoute = engine.getJvmRoute();
- jvmRoutes.remove(jvmRoute);
-
- requests.add(createConfigRequest(jvmRoute, service.findConnectors(), nodeConfig, balancerConfig));
+ engineRequests.add(createConfigRequest(jvmRoute, service.findConnectors(), nodeConfig, balancerConfig));
ResetRequestSource.EngineStatus engineStatus = response.get(jvmRoute);
Map<String, ResetRequestSource.Status> contexts = Collections.emptyMap();
@@ -300,36 +299,46 @@
{
if (status != ResetRequestSource.Status.ENABLED)
{
- requests.add(createContextRequest(MCMPRequestType.ENABLE_APP, jvmRoute, Utils.getAliases(context), path));
+ engineRequests.add(createContextRequest(MCMPRequestType.ENABLE_APP, jvmRoute, Utils.getAliases(context), path));
}
}
else
{
if (status == ResetRequestSource.Status.ENABLED)
{
- requests.add(createContextRequest(MCMPRequestType.STOP_APP, jvmRoute, Utils.getAliases(context), path));
+ engineRequests.add(createContextRequest(MCMPRequestType.STOP_APP, jvmRoute, Utils.getAliases(context), path));
}
}
}
}
- // Send REMOVE-APP requests for contexts that don't exist
if (engineStatus != null)
{
- if (oldContexts.size() == contexts.size())
+ if (!contexts.isEmpty())
{
- requests.add(createEngineRequest(MCMPRequestType.REMOVE_APP, jvmRoute));
- }
- else
- {
- Set<String> aliases = engineStatus.getAliases();
-
- for (String context: contexts.keySet())
+ // If all old contexts no longer exist - remove all
+ if (oldContexts.size() == contexts.size())
{
- requests.add(createContextRequest(MCMPRequestType.REMOVE_APP, jvmRoute, aliases, context));
+ // Send REMOVE-APP * request first
+ engineRequests.add(0, createEngineRequest(MCMPRequestType.REMOVE_APP, jvmRoute));
}
+ // otherwise only remove those that no longer exist
+ else
+ {
+ Set<String> aliases = engineStatus.getAliases();
+
+ for (String context: contexts.keySet())
+ {
+ // Send REMOVE-APP requests first
+ engineRequests.add(0, createContextRequest(MCMPRequestType.REMOVE_APP, jvmRoute, aliases, context));
+ }
+ }
}
}
+
+ requests.addAll(engineRequests);
+
+ engineRequests.clear();
}
return requests;
15 years, 10 months