Skip to content

Commit 9fbb738

Browse files
committed
Merge remote-tracking branch 'origin/trunk' into distributor-retry
Signed-off-by: Viet Nguyen Duc <[email protected]> # Conflicts: # java/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java
2 parents 4bec6a1 + 2dad5fa commit 9fbb738

File tree

11 files changed

+1478
-793
lines changed

11 files changed

+1478
-793
lines changed

java/src/org/openqa/selenium/grid/distributor/GridModel.java

Lines changed: 70 additions & 489 deletions
Large diffs are not rendered by default.
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
// Licensed to the Software Freedom Conservancy (SFC) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The SFC licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.openqa.selenium.grid.distributor;
19+
20+
import java.io.Closeable;
21+
import java.net.URI;
22+
import java.util.Set;
23+
import org.openqa.selenium.grid.data.Availability;
24+
import org.openqa.selenium.grid.data.DistributorStatus;
25+
import org.openqa.selenium.grid.data.NodeId;
26+
import org.openqa.selenium.grid.data.NodeStatus;
27+
import org.openqa.selenium.grid.data.Session;
28+
import org.openqa.selenium.grid.data.SlotId;
29+
import org.openqa.selenium.grid.node.Node;
30+
import org.openqa.selenium.status.HasReadyState;
31+
32+
/**
33+
* Maintains a registry of the nodes available for a {@link
34+
* org.openqa.selenium.grid.distributor.Distributor}. Implementations may store nodes in memory or
35+
* in an external data store to allow for high availability configurations.
36+
*/
37+
public interface NodeRegistry extends HasReadyState, Closeable {
38+
39+
/**
40+
* Register a node status received from an event.
41+
*
42+
* @param status The node status to register.
43+
*/
44+
void register(NodeStatus status);
45+
46+
/**
47+
* Add a node to this registry.
48+
*
49+
* @param node The node to add.
50+
*/
51+
void add(Node node);
52+
53+
/**
54+
* Removes a node from this registry.
55+
*
56+
* @param nodeId The id of the node to remove.
57+
*/
58+
void remove(NodeId nodeId);
59+
60+
/**
61+
* Set a node to draining state.
62+
*
63+
* @param nodeId The id of the node to drain.
64+
* @return true if the node was set to draining, false otherwise.
65+
*/
66+
boolean drain(NodeId nodeId);
67+
68+
/**
69+
* Updates a node's availability status.
70+
*
71+
* @param nodeUri The URI of the node.
72+
* @param id The id of the node.
73+
* @param availability The new availability status.
74+
*/
75+
void updateNodeAvailability(URI nodeUri, NodeId id, Availability availability);
76+
77+
/** Refreshes all nodes by running a health check on each one. */
78+
void refresh();
79+
80+
/**
81+
* Gets a snapshot of all registered nodes.
82+
*
83+
* @return The current status of the distributor.
84+
*/
85+
DistributorStatus getStatus();
86+
87+
/**
88+
* Gets all available nodes that are not DOWN or DRAINING.
89+
*
90+
* @return Set of available node statuses.
91+
*/
92+
Set<NodeStatus> getAvailableNodes();
93+
94+
/**
95+
* Gets a node by its ID.
96+
*
97+
* @param id The node ID to look up.
98+
* @return The node, or null if not found.
99+
*/
100+
Node getNode(NodeId id);
101+
102+
/**
103+
* Gets the total number of nodes that are UP.
104+
*
105+
* @return The number of UP nodes.
106+
*/
107+
long getUpNodeCount();
108+
109+
/**
110+
* Gets the total number of nodes that are DOWN.
111+
*
112+
* @return The number of DOWN nodes.
113+
*/
114+
long getDownNodeCount();
115+
116+
/** Run health checks on all nodes. */
117+
void runHealthChecks();
118+
119+
/**
120+
* Reserve a slot for a session.
121+
*
122+
* @param slotId The slot ID to reserve.
123+
* @return Whether the reservation was successful.
124+
*/
125+
boolean reserve(SlotId slotId);
126+
127+
/**
128+
* Set a session for a particular slot.
129+
*
130+
* @param slotId The slot ID.
131+
* @param session The session to associate with the slot, or null to clear.
132+
*/
133+
void setSession(SlotId slotId, Session session);
134+
135+
/** Get the number of active slots. */
136+
int getActiveSlots();
137+
138+
/** Get the number of idle slots. */
139+
int getIdleSlots();
140+
141+
/**
142+
* Get node by URI.
143+
*
144+
* @param uri The node URI to look up.
145+
* @return The node if found, null otherwise.
146+
*/
147+
Node getNode(URI uri);
148+
}

0 commit comments

Comments
 (0)