|
29 | 29 | import org.openqa.selenium.events.EventBus;
|
30 | 30 | import org.openqa.selenium.grid.config.Config;
|
31 | 31 | import org.openqa.selenium.grid.config.ConfigException;
|
| 32 | +import org.openqa.selenium.grid.data.Availability; |
32 | 33 | import org.openqa.selenium.grid.data.CreateSessionRequest;
|
33 | 34 | import org.openqa.selenium.grid.data.CreateSessionResponse;
|
34 | 35 | import org.openqa.selenium.grid.data.NodeDrainComplete;
|
|
39 | 40 | import org.openqa.selenium.grid.data.SessionClosedEvent;
|
40 | 41 | import org.openqa.selenium.grid.data.Slot;
|
41 | 42 | import org.openqa.selenium.grid.data.SlotId;
|
| 43 | +import org.openqa.selenium.grid.jmx.JMXHelper; |
| 44 | +import org.openqa.selenium.grid.jmx.ManagedAttribute; |
| 45 | +import org.openqa.selenium.grid.jmx.ManagedService; |
42 | 46 | import org.openqa.selenium.grid.log.LoggingOptions;
|
43 | 47 | import org.openqa.selenium.grid.node.HealthCheck;
|
44 | 48 | import org.openqa.selenium.grid.node.Node;
|
|
82 | 86 | * appropriately configured Kubernetes cluster to start a new node once the
|
83 | 87 | * session is finished.
|
84 | 88 | */
|
| 89 | +@ManagedService(objectName = "org.seleniumhq.grid:type=Node,name=OneShotNode", |
| 90 | + description = "Node for running a single webdriver session.") |
85 | 91 | public class OneShotNode extends Node {
|
86 | 92 |
|
87 | 93 | private static final Logger LOG = Logger.getLogger(OneShotNode.class.getName());
|
@@ -116,6 +122,8 @@ private OneShotNode(
|
116 | 122 | this.gridUri = Require.nonNull("Public Grid URI", gridUri);
|
117 | 123 | this.stereotype = ImmutableCapabilities.copyOf(Require.nonNull("Stereotype", stereotype));
|
118 | 124 | this.driverInfo = Require.nonNull("Driver info", driverInfo);
|
| 125 | + |
| 126 | + new JMXHelper().register(this); |
119 | 127 | }
|
120 | 128 |
|
121 | 129 | public static Node create(Config config) {
|
@@ -365,4 +373,44 @@ public HealthCheck getHealthCheck() {
|
365 | 373 | public boolean isReady() {
|
366 | 374 | return events.isReady();
|
367 | 375 | }
|
| 376 | + |
| 377 | + @ManagedAttribute(name = "MaxSessions") |
| 378 | + public int getMaxSessionCount() { |
| 379 | + return 1; |
| 380 | + } |
| 381 | + |
| 382 | + @ManagedAttribute(name = "Status") |
| 383 | + public Availability getAvailability() { |
| 384 | + return isDraining() ? DRAINING : UP; |
| 385 | + } |
| 386 | + |
| 387 | + @ManagedAttribute(name = "TotalSlots") |
| 388 | + public int getTotalSlots() { |
| 389 | + return 1; |
| 390 | + } |
| 391 | + |
| 392 | + @ManagedAttribute(name = "UsedSlots") |
| 393 | + public long getUsedSlots() { |
| 394 | + return client == null ? 0 : 1; |
| 395 | + } |
| 396 | + |
| 397 | + @ManagedAttribute(name = "Load") |
| 398 | + public float getLoad() { |
| 399 | + return client == null ? 0f : 100f; |
| 400 | + } |
| 401 | + |
| 402 | + @ManagedAttribute(name = "RemoteNodeUri") |
| 403 | + public URI getExternalUri() { |
| 404 | + return this.getUri(); |
| 405 | + } |
| 406 | + |
| 407 | + @ManagedAttribute(name = "GridUri") |
| 408 | + public URI getGridUri() { |
| 409 | + return this.gridUri; |
| 410 | + } |
| 411 | + |
| 412 | + @ManagedAttribute(name = "NodeId") |
| 413 | + public String getNodeId() { |
| 414 | + return getId().toString(); |
| 415 | + } |
368 | 416 | }
|
0 commit comments