Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
os: [ ubuntu-latest, windows-latest, macos-latest ]
java: [ 17 ]
steps:
- name: Checkout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
public class ChartManager {
private final Map<String, AtomicInteger> requestCounts;
private final Map<String, AtomicInteger> sessionCounts;
private final Map<String, Integer> lastRequestCounts = new HashMap<String, Integer>();
private final Map<String, XYSeries> requestSeries = new HashMap<String, XYSeries>();
private final Map<String, XYSeries> sessionSeries = new HashMap<String, XYSeries>();
private final Map<String, Integer> lastRequestCounts = new HashMap<>();
private final Map<String, XYSeries> requestSeries = new HashMap<>();
private final Map<String, XYSeries> sessionSeries = new HashMap<>();
private final XYSeriesCollection requestSeriesCollection = new XYSeriesCollection();
private final XYSeriesCollection sessionSeriesCollection = new XYSeriesCollection();
private final JFreeChart requestBalancingChart;
Expand Down Expand Up @@ -81,7 +81,7 @@ public void updateStats() {
last = 0;
}

int perSec = (int) ((current.intValue() - last.intValue()) / elapsed);
int perSec = (int) ((current - last) / elapsed);

XYSeries series = requestSeries.get(key);
if (series == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ public void windowClosed(WindowEvent e) {
public void stateChanged(ChangeEvent e) {
if (loadPanel.equals(tabbedPane.getSelectedComponent())) {
String text = targetHostNameField.getText();
if (text == null || text.length() == 0)
if (text == null || text.isEmpty())
targetHostNameField.setText(proxyHostNameField.getText());
text = targetPortField.getText();
if (text == null || text.length() == 0)
if (text == null || text.isEmpty())
targetPortField.setText(proxyPortField.getText());
}
}
Expand All @@ -172,8 +172,8 @@ public void stateChanged(ChangeEvent e) {
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, 7, 0 };
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};
controlPanel.setLayout(gridBagLayout);

JLabel label = new JLabel();
Expand Down Expand Up @@ -279,7 +279,7 @@ private JPanel createClientControlPanel() {
controlPanel.add(sessionTimeoutLabel, gridBagConstraints);

sessionTimeoutField = new JTextField();
sessionTimeoutField.setText(String.valueOf(DEFAULT_SESSION_TIMEOUT));
sessionTimeoutField.setText(DEFAULT_SESSION_TIMEOUT);
sessionTimeoutField.setEnabled(destroySessionField.isSelected());
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 4;
Expand Down Expand Up @@ -382,8 +382,8 @@ public void actionPerformed(final ActionEvent e) {
controlPanel.add(statusPanel, gridBagConstraints);

gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[] { 0, 0, 7 };
gridBagLayout.rowHeights = new int[] { 0, 7, 0, 0 };
gridBagLayout.columnWidths = new int[] {0, 0, 7};
gridBagLayout.rowHeights = new int[] {0, 7, 0, 0};
statusPanel.setLayout(gridBagLayout);

label = new JLabel();
Expand All @@ -405,7 +405,7 @@ public void actionPerformed(final ActionEvent e) {
statusPanel.add(label, gridBagConstraints);

totalClientsLabel = new JLabel();
totalClientsLabel.setText(String.valueOf("0"));
totalClientsLabel.setText("0");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 2;
gridBagConstraints.gridx = 3;
Expand All @@ -421,7 +421,7 @@ public void actionPerformed(final ActionEvent e) {
statusPanel.add(label, gridBagConstraints);

liveClientsLabel = new JLabel();
liveClientsLabel.setText(String.valueOf("0"));
liveClientsLabel.setText("0");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 3;
gridBagConstraints.gridx = 3;
Expand All @@ -437,7 +437,7 @@ public void actionPerformed(final ActionEvent e) {
statusPanel.add(label, gridBagConstraints);

failedClientsLabel = new JLabel();
failedClientsLabel.setText(String.valueOf("0"));
failedClientsLabel.setText("0");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 4;
gridBagConstraints.gridx = 3;
Expand All @@ -450,8 +450,8 @@ public void actionPerformed(final ActionEvent e) {
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 };
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();
Expand Down Expand Up @@ -603,8 +603,8 @@ public void actionPerformed(final ActionEvent e) {
private JPanel createRequestBalancingPanel() {
final JPanel requestBalancingPanel = new JPanel();
GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[] { 0 };
gridBagLayout.rowHeights = new int[] { 0, 0 };
gridBagLayout.columnWidths = new int[] {0};
gridBagLayout.rowHeights = new int[] {0, 0};
requestBalancingPanel.setLayout(gridBagLayout);

final JPanel requestChart = new ChartPanel(this.chartManager.getRequestBalancingChart(), true);
Expand All @@ -618,8 +618,8 @@ private JPanel createRequestBalancingPanel() {

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 };
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();
Expand All @@ -638,7 +638,7 @@ private JPanel createRequestBalancingPanel() {
clientStatusPanel.add(label, gridBagConstraints);

totalClientsLabelReq = new JLabel();
totalClientsLabelReq.setText(String.valueOf("0"));
totalClientsLabelReq.setText("0");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 0;
gridBagConstraints.gridx = 3;
Expand All @@ -654,7 +654,7 @@ private JPanel createRequestBalancingPanel() {
clientStatusPanel.add(label, gridBagConstraints);

liveClientsLabelReq = new JLabel();
liveClientsLabelReq.setText(String.valueOf("0"));
liveClientsLabelReq.setText("0");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 0;
gridBagConstraints.gridx = 7;
Expand All @@ -670,7 +670,7 @@ private JPanel createRequestBalancingPanel() {
clientStatusPanel.add(label, gridBagConstraints);

failedClientsLabelReq = new JLabel();
failedClientsLabelReq.setText(String.valueOf("0"));
failedClientsLabelReq.setText("0");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 0;
gridBagConstraints.gridx = 11;
Expand All @@ -683,8 +683,8 @@ private JPanel createRequestBalancingPanel() {
private JPanel createSessionBalancingPanel() {
final JPanel sessionBalancingPanel = new JPanel();
GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[] { 0 };
gridBagLayout.rowHeights = new int[] { 0, 0 };
gridBagLayout.columnWidths = new int[] {0};
gridBagLayout.rowHeights = new int[] {0, 0};
sessionBalancingPanel.setLayout(gridBagLayout);

JPanel sessionBalancingChart = new ChartPanel(this.chartManager.getSessionBalancingChart(), true);
Expand All @@ -699,8 +699,8 @@ private JPanel createSessionBalancingPanel() {

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 };
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();
Expand All @@ -719,7 +719,7 @@ private JPanel createSessionBalancingPanel() {
clientStatusPanel.add(label, gridBagConstraints);

totalClientsLabelSess = new JLabel();
totalClientsLabelSess.setText(String.valueOf("0"));
totalClientsLabelSess.setText("0");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 0;
gridBagConstraints.gridx = 3;
Expand All @@ -735,7 +735,7 @@ private JPanel createSessionBalancingPanel() {
clientStatusPanel.add(label, gridBagConstraints);

liveClientsLabelSess = new JLabel();
liveClientsLabelSess.setText(String.valueOf("0"));
liveClientsLabelSess.setText("0");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 0;
gridBagConstraints.gridx = 7;
Expand All @@ -751,7 +751,7 @@ private JPanel createSessionBalancingPanel() {
clientStatusPanel.add(label, gridBagConstraints);

failedClientsLabelSess = new JLabel();
failedClientsLabelSess.setText(String.valueOf("0"));
failedClientsLabelSess.setText("0");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 0;
gridBagConstraints.gridx = 11;
Expand All @@ -770,7 +770,7 @@ private JPanel createSessionBalancingPanel() {
private void start() {
String sessionTimeoutText = sessionTimeoutField.getText();
int sessionTimeout = -1;
if (sessionTimeoutText != null && sessionTimeoutText.trim().length() > 0) {
if (sessionTimeoutText != null && !sessionTimeoutText.trim().isEmpty()) {
try {
sessionTimeout = Integer.parseInt(sessionTimeoutText);
} catch (NumberFormatException e) {
Expand All @@ -787,7 +787,7 @@ private void start() {
requestURL = new URL(tmp);
destroyURL = new URL(tmp + "?destroy=true");
} else {
String timeoutParam = (sessionTimeout > 0) ? "?timeout=" + String.valueOf(sessionTimeout) : "";
String timeoutParam = (sessionTimeout > 0) ? "?timeout=" + sessionTimeout : "";
requestURL = new URL(tmp + timeoutParam);
destroyURL = requestURL;
}
Expand All @@ -798,25 +798,25 @@ private void start() {

int num_threads = DEFAULT_NUM_THREADS;
String numT = numThreadsField.getText();
if (numT != null && numT.trim().length() > 0) {
if (numT != null && !numT.trim().isEmpty()) {
num_threads = Integer.parseInt(numT);
}

int session_life = DEFAULT_SESSION_LIFE;
String sessL = sessionLifeField.getText();
if (sessL != null && sessL.trim().length() > 0) {
if (sessL != null && !sessL.trim().isEmpty()) {
session_life = Integer.parseInt(sessL);
}

int sleep_time = DEFAULT_SLEEP_TIME;
String sleepT = sleepTimeField.getText();
if (sleepT != null && sleepT.trim().length() > 0) {
if (sleepT != null && !sleepT.trim().isEmpty()) {
sleep_time = Integer.parseInt(sleepT);
}

int startup_time = DEFAULT_STARTUP_TIME;
String startT = startupTimeField.getText();
if (startT != null && startT.trim().length() > 0) {
if (startT != null && !startT.trim().isEmpty()) {
startup_time = Integer.parseInt(startT);
}

Expand All @@ -842,7 +842,7 @@ private void createLoad() {
String tmp = createBaseURL(targetHostNameField.getText(), targetPortField.getText())
+ selectedLoadServlet.getServletPath();
List<ServerLoadParam> params = selectedLoadServlet.getParams();
if (params.size() > 0) {
if (!params.isEmpty()) {
String val = targetServletParamField1.getText();
params.get(0).setValue(val);
tmp += "?" + params.get(0).getName() + "=" + val;
Expand Down Expand Up @@ -887,17 +887,17 @@ public void run() {
}

private String createBaseURL(String hostText, String portText) {
if (portText == null || portText.trim().length() == 0)
if (portText == null || portText.trim().isEmpty())
portText = "80";
portText = portText.trim();

String contextPath = contextPathField.getText();
if (contextPath == null)
contextPath = "";
contextPath = contextPath.trim();
if (contextPath.length() > 0 && '/' == contextPath.charAt(0))
if (!contextPath.isEmpty() && '/' == contextPath.charAt(0))
contextPath = contextPath.length() == 1 ? "" : contextPath.substring(1);
if (contextPath.length() > 0 && '/' == contextPath.charAt(contextPath.length() - 1))
if (!contextPath.isEmpty() && '/' == contextPath.charAt(contextPath.length() - 1))
contextPath = contextPath.length() == 1 ? "" : contextPath.substring(0, contextPath.length() - 1);

return "http://" + hostText + ":" + portText + "/" + contextPath + "/";
Expand Down Expand Up @@ -938,7 +938,7 @@ private class ServerLoadServletCellRenderer extends JLabel implements ListCellRe
@Override
public Component getListCellRendererComponent(JList<? extends ServerLoadServlets> list, ServerLoadServlets value, int index, boolean isSelected, boolean cellHasFocus) {
this.setText(value.toString());
this.setToolTipText(((ServerLoadServlets) value).getDescription());
this.setToolTipText(value.getDescription());
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
public class RequestDriver {
private Client[] clients;

private final ConcurrentMap<String, AtomicInteger> requestCounts = new ConcurrentHashMap<String, AtomicInteger>();
private final ConcurrentMap<String, AtomicInteger> sessionCounts = new ConcurrentHashMap<String, AtomicInteger>();
private final ConcurrentMap<String, AtomicInteger> requestCounts = new ConcurrentHashMap<>();
private final ConcurrentMap<String, AtomicInteger> sessionCounts = new ConcurrentHashMap<>();

private final AtomicBoolean stopped = new AtomicBoolean(false);
private Thread startThread;
Expand Down Expand Up @@ -66,7 +66,8 @@ public void stop() {
if (this.startThread != null && this.startThread.isAlive()) {
try {
this.startThread.join(2000);
} catch (InterruptedException e) {
} catch (InterruptedException ignored) {
// Ignored.
}

if (this.startThread.isAlive()) {
Expand Down Expand Up @@ -162,7 +163,8 @@ public void run() {
if (cookie != null && destroy_url != null) {
executeRequest(destroy_url);
}
} catch (IOException e) {
} catch (IOException ignored) {
// Ignored.
} finally {
// If we haven't already cleaned up this thread's
// session info, do so now
Expand All @@ -182,7 +184,8 @@ private void terminate() {
if (this.isAlive()) {
this.interrupt();
}
} catch (InterruptedException e) {
} catch (InterruptedException ignored) {
// Ignored.
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
package org.jboss.modcluster.demo.client.load;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

Expand All @@ -24,7 +23,7 @@ public enum ServerLoadServlets {
"Number of seconds to hold the connections before returning to datasource", "15")),

CONNECTOR_THREAD_USAGE("Connector Thread Use",
"Generates server load by tieing up threads in the webserver connections pool for a period", "connectors",
"Generates server load by tying 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")),

Expand All @@ -49,7 +48,7 @@ public enum ServerLoadServlets {

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"));
"requests", new ServerLoadParam("count", "Number of Requests", "Number of requests to make", "50"));

private final String label;
private final String description;
Expand All @@ -61,7 +60,7 @@ public enum ServerLoadServlets {
this.description = description;
this.servletPath = servletPath;
if (params != null) {
this.params = Collections.unmodifiableList(Arrays.asList(params));
this.params = List.of(params);
} else {
this.params = Collections.emptyList();
}
Expand Down
Loading
Loading