Skip to content

Commit fc54974

Browse files
authored
Merge pull request #9 from rhusar/jakarta
MODCLUSTER-741 Jakarta EE 10 support for the load demo + MODCLUSTER-512 Load demo does not work with Undertow: ServletException: Failed to locate jvm route!
2 parents 2dc84c4 + 84039ac commit fc54974

21 files changed

+339
-323
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
matrix:
14-
os: [ ubuntu-latest ]
14+
os: [ ubuntu-latest, windows-latest, macos-latest ]
1515
java: [ 17 ]
1616
steps:
1717
- name: Checkout

load-balancing-demo/client/src/main/java/org/jboss/modcluster/demo/client/ChartManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
public class ChartManager {
2121
private final Map<String, AtomicInteger> requestCounts;
2222
private final Map<String, AtomicInteger> sessionCounts;
23-
private final Map<String, Integer> lastRequestCounts = new HashMap<String, Integer>();
24-
private final Map<String, XYSeries> requestSeries = new HashMap<String, XYSeries>();
25-
private final Map<String, XYSeries> sessionSeries = new HashMap<String, XYSeries>();
23+
private final Map<String, Integer> lastRequestCounts = new HashMap<>();
24+
private final Map<String, XYSeries> requestSeries = new HashMap<>();
25+
private final Map<String, XYSeries> sessionSeries = new HashMap<>();
2626
private final XYSeriesCollection requestSeriesCollection = new XYSeriesCollection();
2727
private final XYSeriesCollection sessionSeriesCollection = new XYSeriesCollection();
2828
private final JFreeChart requestBalancingChart;
@@ -81,7 +81,7 @@ public void updateStats() {
8181
last = 0;
8282
}
8383

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

8686
XYSeries series = requestSeries.get(key);
8787
if (series == null) {

load-balancing-demo/client/src/main/java/org/jboss/modcluster/demo/client/ModClusterDemo.java

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ public void windowClosed(WindowEvent e) {
159159
public void stateChanged(ChangeEvent e) {
160160
if (loadPanel.equals(tabbedPane.getSelectedComponent())) {
161161
String text = targetHostNameField.getText();
162-
if (text == null || text.length() == 0)
162+
if (text == null || text.isEmpty())
163163
targetHostNameField.setText(proxyHostNameField.getText());
164164
text = targetPortField.getText();
165-
if (text == null || text.length() == 0)
165+
if (text == null || text.isEmpty())
166166
targetPortField.setText(proxyPortField.getText());
167167
}
168168
}
@@ -172,8 +172,8 @@ public void stateChanged(ChangeEvent e) {
172172
private JPanel createClientControlPanel() {
173173
final JPanel controlPanel = new JPanel();
174174
GridBagLayout gridBagLayout = new GridBagLayout();
175-
gridBagLayout.columnWidths = new int[] { 7, 0, 7, 0, 7, 0, 7, 7, 0, 0, 7 };
176-
gridBagLayout.rowHeights = new int[] { 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0 };
175+
gridBagLayout.columnWidths = new int[] {7, 0, 7, 0, 7, 0, 7, 7, 0, 0, 7};
176+
gridBagLayout.rowHeights = new int[] {0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0};
177177
controlPanel.setLayout(gridBagLayout);
178178

179179
JLabel label = new JLabel();
@@ -279,7 +279,7 @@ private JPanel createClientControlPanel() {
279279
controlPanel.add(sessionTimeoutLabel, gridBagConstraints);
280280

281281
sessionTimeoutField = new JTextField();
282-
sessionTimeoutField.setText(String.valueOf(DEFAULT_SESSION_TIMEOUT));
282+
sessionTimeoutField.setText(DEFAULT_SESSION_TIMEOUT);
283283
sessionTimeoutField.setEnabled(destroySessionField.isSelected());
284284
gridBagConstraints = new GridBagConstraints();
285285
gridBagConstraints.gridy = 4;
@@ -382,8 +382,8 @@ public void actionPerformed(final ActionEvent e) {
382382
controlPanel.add(statusPanel, gridBagConstraints);
383383

384384
gridBagLayout = new GridBagLayout();
385-
gridBagLayout.columnWidths = new int[] { 0, 0, 7 };
386-
gridBagLayout.rowHeights = new int[] { 0, 7, 0, 0 };
385+
gridBagLayout.columnWidths = new int[] {0, 0, 7};
386+
gridBagLayout.rowHeights = new int[] {0, 7, 0, 0};
387387
statusPanel.setLayout(gridBagLayout);
388388

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

407407
totalClientsLabel = new JLabel();
408-
totalClientsLabel.setText(String.valueOf("0"));
408+
totalClientsLabel.setText("0");
409409
gridBagConstraints = new GridBagConstraints();
410410
gridBagConstraints.gridy = 2;
411411
gridBagConstraints.gridx = 3;
@@ -421,7 +421,7 @@ public void actionPerformed(final ActionEvent e) {
421421
statusPanel.add(label, gridBagConstraints);
422422

423423
liveClientsLabel = new JLabel();
424-
liveClientsLabel.setText(String.valueOf("0"));
424+
liveClientsLabel.setText("0");
425425
gridBagConstraints = new GridBagConstraints();
426426
gridBagConstraints.gridy = 3;
427427
gridBagConstraints.gridx = 3;
@@ -437,7 +437,7 @@ public void actionPerformed(final ActionEvent e) {
437437
statusPanel.add(label, gridBagConstraints);
438438

439439
failedClientsLabel = new JLabel();
440-
failedClientsLabel.setText(String.valueOf("0"));
440+
failedClientsLabel.setText("0");
441441
gridBagConstraints = new GridBagConstraints();
442442
gridBagConstraints.gridy = 4;
443443
gridBagConstraints.gridx = 3;
@@ -450,8 +450,8 @@ public void actionPerformed(final ActionEvent e) {
450450
private JPanel createServerLoadControlPanel() {
451451
final JPanel loadPanel = new JPanel();
452452
GridBagLayout gridBagLayout = new GridBagLayout();
453-
gridBagLayout.columnWidths = new int[] { 7, 0, 7, 0, 7, 0, 7, 7, 0, 0, 7 };
454-
gridBagLayout.rowHeights = new int[] { 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0 };
453+
gridBagLayout.columnWidths = new int[] {7, 0, 7, 0, 7, 0, 7, 7, 0, 0, 7};
454+
gridBagLayout.rowHeights = new int[] {0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0};
455455
loadPanel.setLayout(gridBagLayout);
456456

457457
JLabel label = new JLabel();
@@ -603,8 +603,8 @@ public void actionPerformed(final ActionEvent e) {
603603
private JPanel createRequestBalancingPanel() {
604604
final JPanel requestBalancingPanel = new JPanel();
605605
GridBagLayout gridBagLayout = new GridBagLayout();
606-
gridBagLayout.columnWidths = new int[] { 0 };
607-
gridBagLayout.rowHeights = new int[] { 0, 0 };
606+
gridBagLayout.columnWidths = new int[] {0};
607+
gridBagLayout.rowHeights = new int[] {0, 0};
608608
requestBalancingPanel.setLayout(gridBagLayout);
609609

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

619619
JPanel clientStatusPanel = new JPanel();
620620
gridBagLayout = new GridBagLayout();
621-
gridBagLayout.columnWidths = new int[] { 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7 };
622-
gridBagLayout.rowHeights = new int[] { 7, 0 };
621+
gridBagLayout.columnWidths = new int[] {7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7};
622+
gridBagLayout.rowHeights = new int[] {7, 0};
623623
clientStatusPanel.setLayout(gridBagLayout);
624624

625625
gridBagConstraints = new GridBagConstraints();
@@ -638,7 +638,7 @@ private JPanel createRequestBalancingPanel() {
638638
clientStatusPanel.add(label, gridBagConstraints);
639639

640640
totalClientsLabelReq = new JLabel();
641-
totalClientsLabelReq.setText(String.valueOf("0"));
641+
totalClientsLabelReq.setText("0");
642642
gridBagConstraints = new GridBagConstraints();
643643
gridBagConstraints.gridy = 0;
644644
gridBagConstraints.gridx = 3;
@@ -654,7 +654,7 @@ private JPanel createRequestBalancingPanel() {
654654
clientStatusPanel.add(label, gridBagConstraints);
655655

656656
liveClientsLabelReq = new JLabel();
657-
liveClientsLabelReq.setText(String.valueOf("0"));
657+
liveClientsLabelReq.setText("0");
658658
gridBagConstraints = new GridBagConstraints();
659659
gridBagConstraints.gridy = 0;
660660
gridBagConstraints.gridx = 7;
@@ -670,7 +670,7 @@ private JPanel createRequestBalancingPanel() {
670670
clientStatusPanel.add(label, gridBagConstraints);
671671

672672
failedClientsLabelReq = new JLabel();
673-
failedClientsLabelReq.setText(String.valueOf("0"));
673+
failedClientsLabelReq.setText("0");
674674
gridBagConstraints = new GridBagConstraints();
675675
gridBagConstraints.gridy = 0;
676676
gridBagConstraints.gridx = 11;
@@ -683,8 +683,8 @@ private JPanel createRequestBalancingPanel() {
683683
private JPanel createSessionBalancingPanel() {
684684
final JPanel sessionBalancingPanel = new JPanel();
685685
GridBagLayout gridBagLayout = new GridBagLayout();
686-
gridBagLayout.columnWidths = new int[] { 0 };
687-
gridBagLayout.rowHeights = new int[] { 0, 0 };
686+
gridBagLayout.columnWidths = new int[] {0};
687+
gridBagLayout.rowHeights = new int[] {0, 0};
688688
sessionBalancingPanel.setLayout(gridBagLayout);
689689

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

700700
JPanel clientStatusPanel = new JPanel();
701701
gridBagLayout = new GridBagLayout();
702-
gridBagLayout.columnWidths = new int[] { 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7 };
703-
gridBagLayout.rowHeights = new int[] { 7, 0 };
702+
gridBagLayout.columnWidths = new int[] {7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7};
703+
gridBagLayout.rowHeights = new int[] {7, 0};
704704
clientStatusPanel.setLayout(gridBagLayout);
705705

706706
gridBagConstraints = new GridBagConstraints();
@@ -719,7 +719,7 @@ private JPanel createSessionBalancingPanel() {
719719
clientStatusPanel.add(label, gridBagConstraints);
720720

721721
totalClientsLabelSess = new JLabel();
722-
totalClientsLabelSess.setText(String.valueOf("0"));
722+
totalClientsLabelSess.setText("0");
723723
gridBagConstraints = new GridBagConstraints();
724724
gridBagConstraints.gridy = 0;
725725
gridBagConstraints.gridx = 3;
@@ -735,7 +735,7 @@ private JPanel createSessionBalancingPanel() {
735735
clientStatusPanel.add(label, gridBagConstraints);
736736

737737
liveClientsLabelSess = new JLabel();
738-
liveClientsLabelSess.setText(String.valueOf("0"));
738+
liveClientsLabelSess.setText("0");
739739
gridBagConstraints = new GridBagConstraints();
740740
gridBagConstraints.gridy = 0;
741741
gridBagConstraints.gridx = 7;
@@ -751,7 +751,7 @@ private JPanel createSessionBalancingPanel() {
751751
clientStatusPanel.add(label, gridBagConstraints);
752752

753753
failedClientsLabelSess = new JLabel();
754-
failedClientsLabelSess.setText(String.valueOf("0"));
754+
failedClientsLabelSess.setText("0");
755755
gridBagConstraints = new GridBagConstraints();
756756
gridBagConstraints.gridy = 0;
757757
gridBagConstraints.gridx = 11;
@@ -770,7 +770,7 @@ private JPanel createSessionBalancingPanel() {
770770
private void start() {
771771
String sessionTimeoutText = sessionTimeoutField.getText();
772772
int sessionTimeout = -1;
773-
if (sessionTimeoutText != null && sessionTimeoutText.trim().length() > 0) {
773+
if (sessionTimeoutText != null && !sessionTimeoutText.trim().isEmpty()) {
774774
try {
775775
sessionTimeout = Integer.parseInt(sessionTimeoutText);
776776
} catch (NumberFormatException e) {
@@ -787,7 +787,7 @@ private void start() {
787787
requestURL = new URL(tmp);
788788
destroyURL = new URL(tmp + "?destroy=true");
789789
} else {
790-
String timeoutParam = (sessionTimeout > 0) ? "?timeout=" + String.valueOf(sessionTimeout) : "";
790+
String timeoutParam = (sessionTimeout > 0) ? "?timeout=" + sessionTimeout : "";
791791
requestURL = new URL(tmp + timeoutParam);
792792
destroyURL = requestURL;
793793
}
@@ -798,25 +798,25 @@ private void start() {
798798

799799
int num_threads = DEFAULT_NUM_THREADS;
800800
String numT = numThreadsField.getText();
801-
if (numT != null && numT.trim().length() > 0) {
801+
if (numT != null && !numT.trim().isEmpty()) {
802802
num_threads = Integer.parseInt(numT);
803803
}
804804

805805
int session_life = DEFAULT_SESSION_LIFE;
806806
String sessL = sessionLifeField.getText();
807-
if (sessL != null && sessL.trim().length() > 0) {
807+
if (sessL != null && !sessL.trim().isEmpty()) {
808808
session_life = Integer.parseInt(sessL);
809809
}
810810

811811
int sleep_time = DEFAULT_SLEEP_TIME;
812812
String sleepT = sleepTimeField.getText();
813-
if (sleepT != null && sleepT.trim().length() > 0) {
813+
if (sleepT != null && !sleepT.trim().isEmpty()) {
814814
sleep_time = Integer.parseInt(sleepT);
815815
}
816816

817817
int startup_time = DEFAULT_STARTUP_TIME;
818818
String startT = startupTimeField.getText();
819-
if (startT != null && startT.trim().length() > 0) {
819+
if (startT != null && !startT.trim().isEmpty()) {
820820
startup_time = Integer.parseInt(startT);
821821
}
822822

@@ -842,7 +842,7 @@ private void createLoad() {
842842
String tmp = createBaseURL(targetHostNameField.getText(), targetPortField.getText())
843843
+ selectedLoadServlet.getServletPath();
844844
List<ServerLoadParam> params = selectedLoadServlet.getParams();
845-
if (params.size() > 0) {
845+
if (!params.isEmpty()) {
846846
String val = targetServletParamField1.getText();
847847
params.get(0).setValue(val);
848848
tmp += "?" + params.get(0).getName() + "=" + val;
@@ -887,17 +887,17 @@ public void run() {
887887
}
888888

889889
private String createBaseURL(String hostText, String portText) {
890-
if (portText == null || portText.trim().length() == 0)
890+
if (portText == null || portText.trim().isEmpty())
891891
portText = "80";
892892
portText = portText.trim();
893893

894894
String contextPath = contextPathField.getText();
895895
if (contextPath == null)
896896
contextPath = "";
897897
contextPath = contextPath.trim();
898-
if (contextPath.length() > 0 && '/' == contextPath.charAt(0))
898+
if (!contextPath.isEmpty() && '/' == contextPath.charAt(0))
899899
contextPath = contextPath.length() == 1 ? "" : contextPath.substring(1);
900-
if (contextPath.length() > 0 && '/' == contextPath.charAt(contextPath.length() - 1))
900+
if (!contextPath.isEmpty() && '/' == contextPath.charAt(contextPath.length() - 1))
901901
contextPath = contextPath.length() == 1 ? "" : contextPath.substring(0, contextPath.length() - 1);
902902

903903
return "http://" + hostText + ":" + portText + "/" + contextPath + "/";
@@ -938,7 +938,7 @@ private class ServerLoadServletCellRenderer extends JLabel implements ListCellRe
938938
@Override
939939
public Component getListCellRendererComponent(JList<? extends ServerLoadServlets> list, ServerLoadServlets value, int index, boolean isSelected, boolean cellHasFocus) {
940940
this.setText(value.toString());
941-
this.setToolTipText(((ServerLoadServlets) value).getDescription());
941+
this.setToolTipText(value.getDescription());
942942
return this;
943943
}
944944
}

load-balancing-demo/client/src/main/java/org/jboss/modcluster/demo/client/RequestDriver.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
public class RequestDriver {
2222
private Client[] clients;
2323

24-
private final ConcurrentMap<String, AtomicInteger> requestCounts = new ConcurrentHashMap<String, AtomicInteger>();
25-
private final ConcurrentMap<String, AtomicInteger> sessionCounts = new ConcurrentHashMap<String, AtomicInteger>();
24+
private final ConcurrentMap<String, AtomicInteger> requestCounts = new ConcurrentHashMap<>();
25+
private final ConcurrentMap<String, AtomicInteger> sessionCounts = new ConcurrentHashMap<>();
2626

2727
private final AtomicBoolean stopped = new AtomicBoolean(false);
2828
private Thread startThread;
@@ -66,7 +66,8 @@ public void stop() {
6666
if (this.startThread != null && this.startThread.isAlive()) {
6767
try {
6868
this.startThread.join(2000);
69-
} catch (InterruptedException e) {
69+
} catch (InterruptedException ignored) {
70+
// Ignored.
7071
}
7172

7273
if (this.startThread.isAlive()) {
@@ -162,7 +163,8 @@ public void run() {
162163
if (cookie != null && destroy_url != null) {
163164
executeRequest(destroy_url);
164165
}
165-
} catch (IOException e) {
166+
} catch (IOException ignored) {
167+
// Ignored.
166168
} finally {
167169
// If we haven't already cleaned up this thread's
168170
// session info, do so now
@@ -182,7 +184,8 @@ private void terminate() {
182184
if (this.isAlive()) {
183185
this.interrupt();
184186
}
185-
} catch (InterruptedException e) {
187+
} catch (InterruptedException ignored) {
188+
// Ignored.
186189
}
187190
}
188191
}

load-balancing-demo/client/src/main/java/org/jboss/modcluster/demo/client/load/ServerLoadServlets.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55
package org.jboss.modcluster.demo.client.load;
66

7-
import java.util.Arrays;
87
import java.util.Collections;
98
import java.util.List;
109

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

2625
CONNECTOR_THREAD_USAGE("Connector Thread Use",
27-
"Generates server load by tieing up threads in the webserver connections pool for a period", "connectors",
26+
"Generates server load by tying up threads in the webserver connections pool for a period", "connectors",
2827
new ServerLoadParam("count", "Number of Connections", "Number of connection pool threads to tie up", "50"),
2928
new ServerLoadParam("duration", "Duration", "Number of seconds to tie up the connections", "15")),
3029

@@ -49,7 +48,7 @@ public enum ServerLoadServlets {
4948

5049
REQUEST_COUNT_USAGE("Request Count",
5150
"Generates server load by making numerous requests, increasing the request count on the target server.",
52-
"requests", new ServerLoadParam("count", "Number of Requests", "Number of requestss to make", "50"));
51+
"requests", new ServerLoadParam("count", "Number of Requests", "Number of requests to make", "50"));
5352

5453
private final String label;
5554
private final String description;
@@ -61,7 +60,7 @@ public enum ServerLoadServlets {
6160
this.description = description;
6261
this.servletPath = servletPath;
6362
if (params != null) {
64-
this.params = Collections.unmodifiableList(Arrays.asList(params));
63+
this.params = List.of(params);
6564
} else {
6665
this.params = Collections.emptyList();
6766
}

0 commit comments

Comments
 (0)