Skip to content

Commit 681eae6

Browse files
committed
Add jmx info for OneShotNode
1 parent 59055b3 commit 681eae6

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

java/src/org/openqa/selenium/grid/node/k8s/OneShotNode.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.openqa.selenium.events.EventBus;
3030
import org.openqa.selenium.grid.config.Config;
3131
import org.openqa.selenium.grid.config.ConfigException;
32+
import org.openqa.selenium.grid.data.Availability;
3233
import org.openqa.selenium.grid.data.CreateSessionRequest;
3334
import org.openqa.selenium.grid.data.CreateSessionResponse;
3435
import org.openqa.selenium.grid.data.NodeDrainComplete;
@@ -39,6 +40,9 @@
3940
import org.openqa.selenium.grid.data.SessionClosedEvent;
4041
import org.openqa.selenium.grid.data.Slot;
4142
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;
4246
import org.openqa.selenium.grid.log.LoggingOptions;
4347
import org.openqa.selenium.grid.node.HealthCheck;
4448
import org.openqa.selenium.grid.node.Node;
@@ -82,6 +86,8 @@
8286
* appropriately configured Kubernetes cluster to start a new node once the
8387
* session is finished.
8488
*/
89+
@ManagedService(objectName = "org.seleniumhq.grid:type=Node,name=OneShotNode",
90+
description = "Node for running a single webdriver session.")
8591
public class OneShotNode extends Node {
8692

8793
private static final Logger LOG = Logger.getLogger(OneShotNode.class.getName());
@@ -116,6 +122,8 @@ private OneShotNode(
116122
this.gridUri = Require.nonNull("Public Grid URI", gridUri);
117123
this.stereotype = ImmutableCapabilities.copyOf(Require.nonNull("Stereotype", stereotype));
118124
this.driverInfo = Require.nonNull("Driver info", driverInfo);
125+
126+
new JMXHelper().register(this);
119127
}
120128

121129
public static Node create(Config config) {
@@ -365,4 +373,44 @@ public HealthCheck getHealthCheck() {
365373
public boolean isReady() {
366374
return events.isReady();
367375
}
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+
}
368416
}

0 commit comments

Comments
 (0)