17
17
18
18
package org .openqa .selenium .grid .graphql ;
19
19
20
- import com .google .common .base .Suppliers ;
21
20
import com .google .common .collect .ImmutableList ;
22
21
import org .openqa .selenium .Capabilities ;
23
22
import org .openqa .selenium .ImmutableCapabilities ;
37
36
import java .util .List ;
38
37
import java .util .Map ;
39
38
import java .util .Set ;
40
- import java .util .function .Supplier ;
41
39
import java .util .stream .Collectors ;
42
40
43
41
public class Grid {
44
42
45
43
private static final Json JSON = new Json ();
46
44
private final URI uri ;
47
- private final Supplier < DistributorStatus > distributorStatus ;
45
+ private final DistributorStatus distributorStatus ;
48
46
private final List <Set <Capabilities >> queueInfoList ;
49
47
private final String version ;
50
48
@@ -61,7 +59,7 @@ public Grid(
61
59
.stream ()
62
60
.map (SessionRequestCapability ::getDesiredCapabilities )
63
61
.collect (Collectors .toList ());
64
- this .distributorStatus = Suppliers . memoize ( distributor :: getStatus );
62
+ this .distributorStatus = distributor . getStatus ( );
65
63
this .version = Require .nonNull ("Grid's version" , version );
66
64
}
67
65
@@ -76,7 +74,7 @@ public String getVersion() {
76
74
public List <Node > getNodes () {
77
75
ImmutableList .Builder <Node > toReturn = ImmutableList .builder ();
78
76
79
- for (NodeStatus status : distributorStatus .get (). getNodes ()) {
77
+ for (NodeStatus status : distributorStatus .getNodes ()) {
80
78
Map <Capabilities , Integer > stereotypes = new HashMap <>();
81
79
Map <org .openqa .selenium .grid .data .Session , Slot > sessions = new HashMap <>();
82
80
@@ -112,11 +110,11 @@ public List<Node> getNodes() {
112
110
}
113
111
114
112
public int getNodeCount () {
115
- return distributorStatus .get (). getNodes ().size ();
113
+ return distributorStatus .getNodes ().size ();
116
114
}
117
115
118
116
public int getSessionCount () {
119
- return distributorStatus .get (). getNodes ().stream ()
117
+ return distributorStatus .getNodes ().stream ()
120
118
.map (NodeStatus ::getSlots )
121
119
.flatMap (Collection ::stream )
122
120
.filter (slot -> slot .getSession ()!=null )
@@ -125,13 +123,13 @@ public int getSessionCount() {
125
123
}
126
124
127
125
public int getTotalSlots () {
128
- return distributorStatus .get (). getNodes ().stream ()
126
+ return distributorStatus .getNodes ().stream ()
129
127
.mapToInt (status -> status .getSlots ().size ())
130
128
.sum ();
131
129
}
132
130
133
131
public int getMaxSession () {
134
- return distributorStatus .get (). getNodes ().stream ()
132
+ return distributorStatus .getNodes ().stream ()
135
133
.mapToInt (NodeStatus ::getMaxSessionCount )
136
134
.sum ();
137
135
}
@@ -150,7 +148,7 @@ public List<String> getSessionQueueRequests() {
150
148
151
149
public List <Session > getSessions () {
152
150
List <Session > sessions = new ArrayList <>();
153
- for (NodeStatus status : distributorStatus .get (). getNodes ()) {
151
+ for (NodeStatus status : distributorStatus .getNodes ()) {
154
152
for (Slot slot : status .getSlots ()) {
155
153
if (slot .getSession ()!=null ) {
156
154
org .openqa .selenium .grid .data .Session session = slot .getSession ();
0 commit comments