Skip to content

Commit

Permalink
Rename "token" to "worker" or "workerName" (#138)
Browse files Browse the repository at this point in the history
* Rename "token" to worker / workerName

* Fix token->worker renaming
  • Loading branch information
hevrard committed Nov 27, 2018
1 parent afc6ff1 commit ce30f40
Show file tree
Hide file tree
Showing 34 changed files with 429 additions and 425 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

public abstract class CommonClientTest {

static final String TOKEN = "test_worker";
static final String WORKERNAME = "test_worker";
static Process worker;
static Thread server;
static final ShaderJobFileOperations fileOps = new ShaderJobFileOperations();
Expand Down Expand Up @@ -124,7 +124,7 @@ static File runShader(String fragmentShader)
final File outputDir = temporaryFolder.newFolder();
String[] args = {
FilenameUtils.removeExtension(Paths.get(getTestShadersDirectory(), fragmentShader).toString()) + ".json",
"--token", TOKEN, "--server", "http://localhost:8080", "--output",
"--worker", WORKERNAME, "--server", "http://localhost:8080", "--output",
outputDir.getAbsolutePath()};
RunShaderFamily.mainHelper(
args, null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ public static void startServerAndWorker() throws Exception {
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);

FileUtils.writeStringToFile(new File(temporaryFolder.getRoot(), "token.txt"),
TOKEN, StandardCharsets.UTF_8);
FileUtils.writeStringToFile(new File(temporaryFolder.getRoot(), "worker-name.txt"),
WORKERNAME, StandardCharsets.UTF_8);

worker = pb.start();

int exceptionCount = 0;
final int limit = 1000;
File workerDirectory = Paths.get(serverWorkDir.getAbsolutePath(), "processing", TOKEN)
File workerDirectory = Paths.get(serverWorkDir.getAbsolutePath(), "processing", WORKERNAME)
.toFile();
while (true) {
Thread.sleep(10);
Expand All @@ -92,7 +92,7 @@ public static void startServerAndWorker() throws Exception {
}
exceptionCount++;
}
System.out.println("Got token after " + exceptionCount + " tries");
System.out.println("Got worker name after " + exceptionCount + " tries");
}

@AfterClass
Expand Down Expand Up @@ -180,7 +180,7 @@ static File runComputeShader(String computeShader, TemporaryFolder temporaryFold
String[] args = {
FilenameUtils.removeExtension(
Paths.get(getTestShadersDirectory(), computeShader).toString()) + ".json",
"--token", TOKEN, "--server", "http://localhost:8080", "--output",
"--worker", WORKERNAME, "--server", "http://localhost:8080", "--output",
outputDir.getAbsolutePath()
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void startServerAndWorker() throws Exception {
Thread.sleep(5000);

final List<String> command = Arrays.asList(
"firefox", "-new-instance", "http://localhost:8080/static/runner.html?context=webgl2&token=" + TOKEN);
"firefox", "-new-instance", "http://localhost:8080/static/runner.html?context=webgl2&worker=" + WORKERNAME);
final ProcessBuilder pb =
new ProcessBuilder()
.command(command)
Expand All @@ -56,7 +56,7 @@ public static void startServerAndWorker() throws Exception {

int exceptionCount = 0;
final int limit = 1000;
File workerDirectory = Paths.get(serverWorkDir.getAbsolutePath(), "processing", TOKEN)
File workerDirectory = Paths.get(serverWorkDir.getAbsolutePath(), "processing", WORKERNAME)
.toFile();
while (true) {
Thread.sleep(10);
Expand All @@ -68,7 +68,7 @@ public static void startServerAndWorker() throws Exception {
}
exceptionCount++;
}
System.out.println("Got token after " + exceptionCount + " tries");
System.out.println("Got worker name after " + exceptionCount + " tries");
}

@AfterClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class RemoteShaderDispatcher implements IShaderDispatcher {
private static final Logger LOGGER = LoggerFactory.getLogger(RemoteShaderDispatcher.class);

private final String url;
private final String token;
private final String worker;
private final FuzzerServiceManager.Iface fuzzerServiceManager;

private final AtomicLong jobCounter;
Expand All @@ -49,27 +49,27 @@ public class RemoteShaderDispatcher implements IShaderDispatcher {

public RemoteShaderDispatcher(
String url,
String token,
String worker,
Iface fuzzerServiceManager,
AtomicLong jobCounter) {
this(url, token, fuzzerServiceManager, jobCounter, DEFAULT_RETRY_LIMIT);
this(url, worker, fuzzerServiceManager, jobCounter, DEFAULT_RETRY_LIMIT);
}

public RemoteShaderDispatcher(
String url,
String token,
String worker,
Iface fuzzerServiceManager,
AtomicLong jobCounter,
int retryLimit) {
this.url = url;
this.token = token;
this.worker = worker;
this.fuzzerServiceManager = fuzzerServiceManager;
this.jobCounter = jobCounter;
this.retryLimit = retryLimit;
}

public RemoteShaderDispatcher(String url, String token) {
this(url, token, null, new AtomicLong(), DEFAULT_RETRY_LIMIT);
public RemoteShaderDispatcher(String url, String worker) {
this(url, worker, null, new AtomicLong(), DEFAULT_RETRY_LIMIT);
}

@Override
Expand Down Expand Up @@ -107,7 +107,7 @@ private ImageJobResult getImageHelper(
.setJobId(jobCounter.incrementAndGet())
.setImageJob(imageJob);

return fuzzerServiceManagerProxy.submitJob(job, token, retryLimit)
return fuzzerServiceManagerProxy.submitJob(job, worker, retryLimit)
.getImageJob()
.getResult();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public static void mainHelper(
"URL of server to use for sending get image requests.")
.type(String.class);

parser.addArgument("--token")
.help("The token of the client used for get image requests. Used with --server.")
parser.addArgument("--worker")
.help("The worker used for get image requests. Used with --server.")
.type(String.class);

parser.addArgument("--output")
Expand All @@ -86,18 +86,18 @@ public static void mainHelper(
final boolean verbose = ns.get("verbose");
final File shaderFamily = ns.get("shader_family");
final String server = ns.get("server");
final String token = ns.get("token");
final String worker = ns.get("worker");
final File outputDir = ns.get("output");

if (managerOverride != null && (server == null || token == null)) {
if (managerOverride != null && (server == null || worker == null)) {
throw new ArgumentParserException(
"Must supply server (dummy string) and token when executing in server process.",
"Must supply server (dummy string) and worker name when executing in server process.",
parser);
}

if (server != null) {
if (token == null) {
throw new ArgumentParserException("Must supply token with server.", parser);
if (worker == null) {
throw new ArgumentParserException("Must supply worker name with server.", parser);
}
}

Expand All @@ -108,7 +108,7 @@ public static void mainHelper(
? new LocalShaderDispatcher(false, fileOps, new File(outputDir, "temp"))
: new RemoteShaderDispatcher(
server + "/manageAPI",
token,
worker,
managerOverride,
new AtomicLong());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.graphicsfuzz.server;

import static com.graphicsfuzz.server.thrift.FuzzerServiceConstants.DOWNLOAD_FIELD_NAME_TOKEN;
import static com.graphicsfuzz.server.thrift.FuzzerServiceConstants.DOWNLOAD_FIELD_NAME_WORKER;

import java.io.File;
import java.io.FileInputStream;
Expand All @@ -43,7 +43,7 @@ public interface DownloadProcessor {
/**
* @return The file to write to.
*/
File processDownload(String pathInfo, String token) throws DownloadException;
File processDownload(String pathInfo, String worker) throws DownloadException;
}

private final DownloadProcessor downloadProcessor;
Expand All @@ -69,9 +69,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
}
pathInfo = pathInfo.substring(1);
File file = null;
String token = request.getParameter(DOWNLOAD_FIELD_NAME_TOKEN);
String worker = request.getParameter(DOWNLOAD_FIELD_NAME_WORKER);
try {
file = downloadProcessor.processDownload(pathInfo, token);
file = downloadProcessor.processDownload(pathInfo, worker);
} catch (DownloadException exception) {
throw new ServletException(exception);
}
Expand Down
Loading

0 comments on commit ce30f40

Please sign in to comment.