Skip to content

Commit

Permalink
NodeStatus is data about a node, move to the data package
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Feb 2, 2019
1 parent a4fa9a6 commit 70ba11f
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 11 deletions.
1 change: 1 addition & 0 deletions java/server/src/org/openqa/selenium/grid/data/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ java_library(
srcs = glob(["*.java"]),
deps = [
"//java/client/src/org/openqa/selenium/remote:remote",
"//java/server/src/org/openqa/selenium/events:events",
"//third_party/java/guava:guava",
],
visibility = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.grid.node;
package org.openqa.selenium.grid.data;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
Expand Down Expand Up @@ -63,6 +63,10 @@ public boolean hasCapacity(Capabilities caps) {
return available.getOrDefault(caps, 0) > 0;
}

public UUID getNodeId() {
return nodeId;
}

public URI getUri() {
return externalUri;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

import org.openqa.selenium.grid.node.NodeStatus;
import org.openqa.selenium.grid.data.NodeStatus;

import java.util.Collection;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.openqa.selenium.grid.component.HealthCheck;
import org.openqa.selenium.grid.data.Session;
import org.openqa.selenium.grid.node.Node;
import org.openqa.selenium.grid.node.NodeStatus;
import org.openqa.selenium.grid.data.NodeStatus;

import java.util.List;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import org.openqa.selenium.SessionNotCreatedException;
import org.openqa.selenium.concurrent.Regularly;
import org.openqa.selenium.events.EventBus;
import org.openqa.selenium.grid.data.NodeStatus;
import org.openqa.selenium.grid.data.Session;
import org.openqa.selenium.grid.distributor.Distributor;
import org.openqa.selenium.grid.distributor.DistributorStatus;
import org.openqa.selenium.grid.node.Node;
import org.openqa.selenium.grid.node.NodeStatus;
import org.openqa.selenium.json.Json;
import org.openqa.selenium.json.JsonOutput;
import org.openqa.selenium.remote.NewSessionPayload;
Expand Down
2 changes: 1 addition & 1 deletion java/server/src/org/openqa/selenium/grid/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.NoSuchSessionException;
import org.openqa.selenium.grid.component.HealthCheck;
import org.openqa.selenium.grid.data.NodeStatus;
import org.openqa.selenium.grid.data.Session;
import org.openqa.selenium.grid.web.CommandHandler;
import org.openqa.selenium.grid.web.HandlerNotFoundException;
Expand All @@ -36,7 +37,6 @@
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.http.HttpResponse;
import org.openqa.selenium.remote.tracing.DistributedTracer;
import org.openqa.selenium.remote.tracing.Span;

import java.io.IOException;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.google.common.collect.ImmutableMap;

import org.openqa.selenium.grid.data.NodeStatus;
import org.openqa.selenium.grid.web.CommandHandler;
import org.openqa.selenium.json.Json;
import org.openqa.selenium.remote.http.HttpRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
import org.openqa.selenium.concurrent.Regularly;
import org.openqa.selenium.events.EventBus;
import org.openqa.selenium.grid.component.HealthCheck;
import org.openqa.selenium.grid.data.NodeStatus;
import org.openqa.selenium.grid.data.Session;
import org.openqa.selenium.grid.node.Node;
import org.openqa.selenium.grid.node.NodeStatus;
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.remote.SessionId;
import org.openqa.selenium.remote.http.HttpClient;
Expand Down Expand Up @@ -65,7 +65,7 @@ public class LocalNode extends Node {
private final int maxSessionCount;
private final List<SessionFactory> factories;
private final Cache<SessionId, SessionAndHandler> currentSessions;
private final Regularly cleanUp;
private final Regularly regularly;

private LocalNode(
DistributedTracer tracer,
Expand Down Expand Up @@ -97,8 +97,8 @@ private LocalNode(
})
.build();

this.cleanUp = new Regularly("Node cleanup: " + externalUri);
cleanUp.submit(currentSessions::cleanUp, Duration.ofSeconds(30), Duration.ofSeconds(30));
this.regularly = new Regularly("Local Node: " + externalUri);
regularly.submit(currentSessions::cleanUp, Duration.ofSeconds(30), Duration.ofSeconds(30));
}

@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.openqa.selenium.grid.component.HealthCheck;
import org.openqa.selenium.grid.data.Session;
import org.openqa.selenium.grid.node.Node;
import org.openqa.selenium.grid.node.NodeStatus;
import org.openqa.selenium.grid.data.NodeStatus;
import org.openqa.selenium.grid.web.Values;
import org.openqa.selenium.json.Json;
import org.openqa.selenium.json.JsonInput;
Expand Down
14 changes: 14 additions & 0 deletions java/server/test/org/openqa/selenium/grid/data/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
java_test(
name = "data",
labels = [
"small",
],
srcs = glob(["*.java"]),
deps = [
"//java/client/src/org/openqa/selenium/remote:remote",
"//java/server/src/org/openqa/selenium/grid/data:data",
"//third_party/java/assertj:assertj",
"//third_party/java/guava:guava",
"//third_party/java/junit:junit",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.grid.node;
package org.openqa.selenium.grid.data;

import static org.assertj.core.api.Assertions.assertThat;

import com.google.common.collect.ImmutableMap;

import org.junit.Test;
import org.openqa.selenium.ImmutableCapabilities;
import org.openqa.selenium.grid.data.NodeStatus;
import org.openqa.selenium.json.Json;

import java.net.URI;
Expand Down

0 comments on commit 70ba11f

Please sign in to comment.