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