6767import org .openqa .selenium .grid .data .Availability ;
6868import org .openqa .selenium .grid .data .CreateSessionRequest ;
6969import org .openqa .selenium .grid .data .CreateSessionResponse ;
70- import org .openqa .selenium .grid .data .DefaultSlotMatcher ;
7170import org .openqa .selenium .grid .data .DistributorStatus ;
7271import org .openqa .selenium .grid .data .NodeAddedEvent ;
7372import org .openqa .selenium .grid .data .NodeDrainComplete ;
8180import org .openqa .selenium .grid .data .SessionRequestCapability ;
8281import org .openqa .selenium .grid .data .Slot ;
8382import org .openqa .selenium .grid .data .SlotId ;
83+ import org .openqa .selenium .grid .data .SlotMatcher ;
8484import org .openqa .selenium .grid .data .TraceSessionRequest ;
8585import org .openqa .selenium .grid .distributor .Distributor ;
8686import org .openqa .selenium .grid .distributor .GridModel ;
@@ -135,6 +135,7 @@ public class LocalDistributor extends Distributor implements AutoCloseable {
135135 private final ReadWriteLock lock = new ReentrantReadWriteLock (/* fair */ true );
136136 private final GridModel model ;
137137 private final Map <NodeId , Node > nodes ;
138+ private final SlotMatcher slotMatcher ;
138139
139140 private final ScheduledExecutorService newSessionService =
140141 Executors .newSingleThreadScheduledExecutor (
@@ -180,7 +181,8 @@ public LocalDistributor(
180181 Duration healthcheckInterval ,
181182 boolean rejectUnsupportedCaps ,
182183 Duration sessionRequestRetryInterval ,
183- int newSessionThreadPoolSize ) {
184+ int newSessionThreadPoolSize ,
185+ SlotMatcher slotMatcher ) {
184186 super (tracer , clientFactory , registrationSecret );
185187 this .tracer = Require .nonNull ("Tracer" , tracer );
186188 this .bus = Require .nonNull ("Event bus" , bus );
@@ -193,6 +195,7 @@ public LocalDistributor(
193195 this .model = new GridModel (bus );
194196 this .nodes = new ConcurrentHashMap <>();
195197 this .rejectUnsupportedCaps = rejectUnsupportedCaps ;
198+ this .slotMatcher = slotMatcher ;
196199 Require .nonNull ("Session request interval" , sessionRequestRetryInterval );
197200
198201 bus .addListener (NodeStatusEvent .listener (this ::register ));
@@ -264,7 +267,8 @@ public static Distributor create(Config config) {
264267 distributorOptions .getHealthCheckInterval (),
265268 distributorOptions .shouldRejectUnsupportedCaps (),
266269 newSessionQueueOptions .getSessionRequestRetryInterval (),
267- distributorOptions .getNewSessionThreadPoolSize ());
270+ distributorOptions .getNewSessionThreadPoolSize (),
271+ distributorOptions .getSlotMatcher ());
268272 }
269273
270274 @ Override
@@ -662,8 +666,7 @@ private SlotId reserveSlot(RequestId requestId, Capabilities caps) {
662666 Lock writeLock = lock .writeLock ();
663667 writeLock .lock ();
664668 try {
665- Set <SlotId > slotIds =
666- slotSelector .selectSlot (caps , getAvailableNodes (), new DefaultSlotMatcher ());
669+ Set <SlotId > slotIds = slotSelector .selectSlot (caps , getAvailableNodes (), slotMatcher );
667670 if (slotIds .isEmpty ()) {
668671 LOG .log (
669672 getDebugLogLevel (),
@@ -684,8 +687,7 @@ private SlotId reserveSlot(RequestId requestId, Capabilities caps) {
684687 }
685688
686689 private boolean isNotSupported (Capabilities caps ) {
687- return getAvailableNodes ().stream ()
688- .noneMatch (node -> node .hasCapability (caps , new DefaultSlotMatcher ()));
690+ return getAvailableNodes ().stream ().noneMatch (node -> node .hasCapability (caps , slotMatcher ));
689691 }
690692
691693 private boolean reserve (SlotId id ) {
0 commit comments