Skip to content

Commit

Permalink
no logical changes - code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mach6 authored and Doug Simmons committed Oct 1, 2016
1 parent f83d4f2 commit b97704f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;

import com.beust.jcommander.IStringConverter;
import com.beust.jcommander.Parameter;

import org.openqa.grid.common.JSONConfigurationUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Logger;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
Expand All @@ -33,27 +32,25 @@

public class DisplayHelpServlet extends HttpServlet {
private static final long serialVersionUID = 8484071790930378855L;
private static final Logger log = Logger.getLogger(DisplayHelpServlet.class.getName());
private static String coreVersion;

public DisplayHelpServlet() {
coreVersion = new BuildInfo().getReleaseLabel();
}


@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
process(request, response);
process(response);
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
process(request, response);
process(response);
}

protected void process(HttpServletRequest request, HttpServletResponse response)
protected void process(HttpServletResponse response)
throws IOException {
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
Expand All @@ -63,19 +60,16 @@ protected void process(HttpServletRequest request, HttpServletResponse response)

builder.append("<html>");
builder.append("<head>");

builder.append("<title>Selenium Grid ").append(coreVersion).append(" help</title>");


builder.append("</head>");

builder.append("<body>");
builder.append("You are using grid ").append(coreVersion);
builder
.append("<br>Find help on the official selenium wiki : <a href='https://github.com/SeleniumHQ/selenium/wiki/Grid2'>more help here</a>");
builder.append("<br>Find help on the official selenium wiki : "
+ "<a href='https://github.com/SeleniumHQ/selenium/wiki/Grid2'>more help here</a>");
builder.append("<br>default monitoring page : <a href='/grid/console'>console</a>");

builder.append("</body>");

builder.append("</html>");

InputStream in = new ByteArrayInputStream(builder.toString().getBytes("UTF-8"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
// Build up the proxy URL based upon the params the Grid 1.0 node will pass as query params.
Map<String, String[]> queryParams = request.getParameterMap();
String nodeUrl =
String.format("http://%s:%s", queryParams.get("host")[0],
queryParams.get("port")[0]);
String.format("http://%s:%s", queryParams.get("host")[0], queryParams.get("port")[0]);

// Check each registered node and see if the pinging node is in the list.
boolean alreadyRegistered = false;
Expand Down
20 changes: 5 additions & 15 deletions java/server/src/org/openqa/grid/web/servlet/LifecycleServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,33 @@
package org.openqa.grid.web.servlet;

import org.openqa.grid.common.exception.GridException;
import org.openqa.grid.internal.Registry;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* API to manage grid lifecycle
*/
public class LifecycleServlet extends RegistryBasedServlet {

public LifecycleServlet() {
super(null);
}

public LifecycleServlet(Registry registry) {
super(registry);
}
public class LifecycleServlet extends HttpServlet {

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
process(request, response);
}



protected void process(HttpServletRequest request, HttpServletResponse response)
throws IOException {
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
response.setStatus(200);
String action = request.getParameter("action");
if ("shutdown".equals(action)) {
Runnable initiateHubShutDown = new Runnable() {
Runnable initiateShutDown = new Runnable() {
public void run() {
try {
Thread.sleep(500);
Expand All @@ -65,8 +55,8 @@ public void run() {
System.exit(0);
}
};
Thread isd = new Thread(initiateHubShutDown);
isd.setName("initiateHubShutDown");
Thread isd = new Thread(initiateShutDown);
isd.setName("initiateShutDown");
isd.start();
} else {
throw new GridException("Unknown lifecycle action: " + action);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ protected void process(HttpServletRequest request, HttpServletResponse response)
} catch (JsonSyntaxException e) {
throw new GridException(e.getMessage());
}

}

private JsonObject getResponse(HttpServletRequest request) throws IOException {
Expand All @@ -95,7 +94,6 @@ private JsonObject getResponse(HttpServletRequest request) throws IOException {
if (!"".equals(json)) {
requestJSON = new JsonParser().parse(json).getAsJsonObject();
}

}

JsonObject res = new JsonObject();
Expand Down

0 comments on commit b97704f

Please sign in to comment.