| 69 | } |
| 70 | |
| 71 | public List<Node> getNodes() { |
| 72 | return distributorStatus.getNodes().stream() |
| 73 | .map( |
| 74 | (NodeStatus status) -> { |
| 75 | Map<Capabilities, Integer> stereotypes = new HashMap<>(); |
| 76 | Map<org.openqa.selenium.grid.data.Session, Slot> sessions = new HashMap<>(); |
| 77 | |
| 78 | for (Slot slot : status.getSlots()) { |
| 79 | org.openqa.selenium.grid.data.Session session = slot.getSession(); |
| 80 | if (session != null) { |
| 81 | sessions.put(session, slot); |
| 82 | } |
| 83 | |
| 84 | int count = stereotypes.getOrDefault(slot.getStereotype(), 0); |
| 85 | count++; |
| 86 | stereotypes.put(slot.getStereotype(), count); |
| 87 | } |
| 88 | |
| 89 | OsInfo osInfo = |
| 90 | new OsInfo( |
| 91 | status.getOsInfo().get("arch"), |
| 92 | status.getOsInfo().get("name"), |
| 93 | status.getOsInfo().get("version")); |
| 94 | |
| 95 | return new Node( |
| 96 | status.getNodeId(), |
| 97 | status.getExternalUri(), |
| 98 | status.getAvailability(), |
| 99 | status.getMaxSessionCount(), |
| 100 | status.getSessionTimeout(), |
| 101 | status.getSlots().size(), |
| 102 | stereotypes, |
| 103 | sessions, |
| 104 | status.getVersion(), |
| 105 | osInfo); |
| 106 | }) |
| 107 | .collect(toUnmodifiableList()); |
| 108 | } |
| 109 | |
| 110 | public int getNodeCount() { |
| 111 | return distributorStatus.getNodes().size(); |