File tree Expand file tree Collapse file tree 4 files changed +356
-5
lines changed
src/org/openqa/selenium/grid
test/org/openqa/selenium/grid/distributor/local Expand file tree Collapse file tree 4 files changed +356
-5
lines changed Original file line number Diff line number Diff line change @@ -539,7 +539,7 @@ public void run() {
539
539
// up starving a session request.
540
540
Map <Capabilities , Long > stereotypes =
541
541
getAvailableNodes ().stream ()
542
- .filter (node -> node . hasCapacity () )
542
+ .filter (NodeStatus :: hasCapacity )
543
543
.flatMap (node -> node .getSlots ().stream ().map (Slot ::getStereotype ))
544
544
.collect (
545
545
Collectors .groupingBy (ImmutableCapabilities ::copyOf , Collectors .counting ()));
Original file line number Diff line number Diff line change @@ -361,9 +361,8 @@ public Set<NodeStatus> getAvailableNodes() {
361
361
readLock .lock ();
362
362
try {
363
363
return model .getSnapshot ().stream ()
364
- .filter (
365
- node ->
366
- !DOWN .equals (node .getAvailability ()) && !DRAINING .equals (node .getAvailability ()))
364
+ // Filter nodes are UP and have capacity (available slots)
365
+ .filter (node -> UP .equals (node .getAvailability ()) && node .hasCapacity ())
367
366
.collect (ImmutableSet .toImmutableSet ());
368
367
} finally {
369
368
readLock .unlock ();
Original file line number Diff line number Diff line change 55
55
import org .openqa .selenium .grid .data .TraceSessionRequest ;
56
56
import org .openqa .selenium .grid .distributor .config .DistributorOptions ;
57
57
import org .openqa .selenium .grid .jmx .JMXHelper ;
58
+ import org .openqa .selenium .grid .jmx .MBean ;
58
59
import org .openqa .selenium .grid .jmx .ManagedAttribute ;
59
60
import org .openqa .selenium .grid .jmx .ManagedService ;
60
61
import org .openqa .selenium .grid .log .LoggingOptions ;
@@ -110,6 +111,7 @@ public class LocalNewSessionQueue extends NewSessionQueue implements Closeable {
110
111
thread .setName (NAME );
111
112
return thread ;
112
113
});
114
+ private final MBean jmxBean ;
113
115
114
116
public LocalNewSessionQueue (
115
117
Tracer tracer ,
@@ -139,7 +141,8 @@ public LocalNewSessionQueue(
139
141
requestTimeoutCheck .toMillis (),
140
142
MILLISECONDS );
141
143
142
- new JMXHelper ().register (this );
144
+ // Manage JMX and unregister on close()
145
+ this .jmxBean = new JMXHelper ().register (this );
143
146
}
144
147
145
148
public static NewSessionQueue create (Config config ) {
@@ -502,6 +505,10 @@ public boolean isReady() {
502
505
@ Override
503
506
public void close () {
504
507
shutdownGracefully (NAME , service );
508
+
509
+ if (jmxBean != null ) {
510
+ new JMXHelper ().unregister (jmxBean .getObjectName ());
511
+ }
505
512
}
506
513
507
514
private void failDueToTimeout (RequestId reqId ) {
You can’t perform that action at this time.
0 commit comments