org.openqa.selenium.grid.graphql.Node Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of selenium-grid Show documentation
Show all versions of selenium-grid Show documentation
Selenium automates browsers. That's it! What you do with that power is entirely up to you.
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.openqa.selenium.grid.graphql;
import com.google.common.collect.ImmutableList;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.grid.data.Availability;
import org.openqa.selenium.grid.data.NodeId;
import org.openqa.selenium.grid.data.Session;
import org.openqa.selenium.grid.data.Slot;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.json.Json;
public class Node {
private static final Json JSON = new Json();
private final NodeId id;
private final URI uri;
private final Availability status;
private final int maxSession;
private final Map stereotypes;
private final Map activeSessions;
private final String version;
private final OsInfo osInfo;
private final int slotCount;
public Node(
NodeId id,
URI uri,
Availability status,
int maxSession,
int slotCount,
Map stereotypes,
Map activeSessions,
String version,
OsInfo osInfo) {
this.id = Require.nonNull("Node id", id);
this.uri = Require.nonNull("Node uri", uri);
this.status = status;
this.maxSession = maxSession;
this.slotCount = slotCount;
this.stereotypes = Require.nonNull("Node stereotypes", stereotypes);
this.activeSessions = Require.nonNull("Active sessions", activeSessions);
this.version = Require.nonNull("Grid Node version", version);
this.osInfo = Require.nonNull("Grid Node OS info", osInfo);
}
public List getSessions() {
return activeSessions.entrySet().stream()
.map(this::createGraphqlSession)
.collect(ImmutableList.toImmutableList());
}
public int getSlotCount() {
return slotCount;
}
public int getSessionCount() {
return activeSessions.size();
}
public NodeId getId() {
return id;
}
public URI getUri() {
return uri;
}
public int getMaxSession() {
return maxSession;
}
public List getActiveSessionIds() {
return activeSessions.keySet().stream()
.map(session -> session.getId().toString())
.collect(ImmutableList.toImmutableList());
}
public String getStereotypes() {
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy