You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by zm...@apache.org on 2015/08/31 19:09:42 UTC
aurora git commit: Remove barely used commons classes.
Repository: aurora
Updated Branches:
refs/heads/master 68447b385 -> f94e5c271
Remove barely used commons classes.
This patch removes a few barely used or duplicate classes from commons.
Testing Done:
./gradlew -Pq
Reviewed at https://reviews.apache.org/r/37937/
Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/f94e5c27
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/f94e5c27
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/f94e5c27
Branch: refs/heads/master
Commit: f94e5c27102b0f820e3a64a007235a8270ac2486
Parents: 68447b3
Author: Zameer Manji <zm...@apache.org>
Authored: Mon Aug 31 10:09:36 2015 -0700
Committer: Zameer Manji <zm...@apache.org>
Committed: Mon Aug 31 10:09:36 2015 -0700
----------------------------------------------------------------------
.../apache/aurora/common/args/OptionInfo.java | 2 +-
.../aurora/common/base/ExceptionalFunction.java | 37 --
.../org/apache/aurora/common/base/Function.java | 29 --
.../aurora/common/base/MoreSuppliers.java | 1 +
.../org/apache/aurora/common/base/Supplier.java | 28 --
.../org/apache/aurora/common/io/FileUtils.java | 193 ---------
.../org/apache/aurora/common/logging/Log.java | 45 --
.../common/net/http/handlers/HealthHandler.java | 6 +-
.../common/net/http/handlers/LogPrinter.java | 427 -------------------
.../common/testing/junit/rules/Retry.java | 158 -------
.../apache/aurora/common/util/StartWatch.java | 48 ---
.../aurora/common/zookeeper/ServerSetImpl.java | 7 +-
.../aurora/common/zookeeper/ServerSets.java | 8 +-
.../zookeeper/testing/ZooKeeperTestServer.java | 4 +-
.../aurora/common/args/ArgScannerTest.java | 2 +-
.../aurora/common/base/MoreSuppliersTest.java | 1 +
.../apache/aurora/common/io/FileUtilsTest.java | 118 -----
.../net/http/handlers/LogPrinterTest.java | 87 ----
.../apache/aurora/common/stats/RateTest.java | 3 +-
.../common/testing/junit/rules/RetryTest.java | 230 ----------
.../aurora/common/util/BackoffHelperTest.java | 16 +-
.../aurora/common/zookeeper/GroupTest.java | 2 +-
.../scheduler/cron/quartz/AuroraCronJob.java | 4 +-
.../cron/quartz/CronSchedulerImpl.java | 2 +-
.../scheduler/http/JettyServerModule.java | 4 +-
.../aurora/scheduler/log/mesos/MesosLog.java | 2 +-
.../scheduler/mesos/MesosTaskFactory.java | 2 +-
.../apache/aurora/scheduler/sla/SlaGroup.java | 2 +-
.../cron/quartz/AuroraCronJobTest.java | 4 +-
29 files changed, 38 insertions(+), 1434 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/main/java/org/apache/aurora/common/args/OptionInfo.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/args/OptionInfo.java b/commons/src/main/java/org/apache/aurora/common/args/OptionInfo.java
index 2e22a92..c1fe1c7 100644
--- a/commons/src/main/java/org/apache/aurora/common/args/OptionInfo.java
+++ b/commons/src/main/java/org/apache/aurora/common/args/OptionInfo.java
@@ -24,6 +24,7 @@ import java.util.regex.Pattern;
import javax.annotation.Nullable;
import com.google.common.base.Charsets;
+import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicates;
@@ -32,7 +33,6 @@ import com.google.common.io.Files;
import com.google.common.reflect.TypeToken;
import org.apache.aurora.common.args.apt.Configuration;
-import org.apache.aurora.common.base.Function;
import static com.google.common.base.Preconditions.checkArgument;
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/main/java/org/apache/aurora/common/base/ExceptionalFunction.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/base/ExceptionalFunction.java b/commons/src/main/java/org/apache/aurora/common/base/ExceptionalFunction.java
deleted file mode 100644
index f867c35..0000000
--- a/commons/src/main/java/org/apache/aurora/common/base/ExceptionalFunction.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Licensed 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.apache.aurora.common.base;
-
-/**
- * An interface that captures a unit of work against an item.
- *
- * @param <S> The argument type for the function.
- * @param <T> The return type for the function.
- * @param <E> The exception type that the function throws.
- *
- * @author John Sirois
- */
-public interface ExceptionalFunction<S, T, E extends Exception> {
-
- /**
- * Performs a unit of work on item, possibly throwing {@code E} in the process.
- *
- * <p>TODO(John Sirois): consider supporting @Nullable
- *
- * @param item The item to perform work against.
- * @return The result of the computation.
- * @throws E if there was a problem performing the work.
- */
- T apply(S item) throws E;
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/main/java/org/apache/aurora/common/base/Function.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/base/Function.java b/commons/src/main/java/org/apache/aurora/common/base/Function.java
deleted file mode 100644
index d089eb8..0000000
--- a/commons/src/main/java/org/apache/aurora/common/base/Function.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Licensed 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.apache.aurora.common.base;
-
-/**
- * A convenience typedef that also ties into google's {@code Function}.
- *
- * @param <S> The argument type for the function.
- * @param <T> The return type for the function.
- *
- * @author John Sirois
- */
-public interface Function<S, T>
- extends ExceptionalFunction<S, T, RuntimeException>, com.google.common.base.Function<S, T> {
-
- @Override
- T apply(S item);
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/main/java/org/apache/aurora/common/base/MoreSuppliers.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/base/MoreSuppliers.java b/commons/src/main/java/org/apache/aurora/common/base/MoreSuppliers.java
index 9ab877d..c120d1d 100644
--- a/commons/src/main/java/org/apache/aurora/common/base/MoreSuppliers.java
+++ b/commons/src/main/java/org/apache/aurora/common/base/MoreSuppliers.java
@@ -20,6 +20,7 @@ import java.lang.reflect.Modifier;
import javax.annotation.Nullable;
import com.google.common.base.Preconditions;
+import com.google.common.base.Supplier;
/**
* Utility methods for working with Suppliers.
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/main/java/org/apache/aurora/common/base/Supplier.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/base/Supplier.java b/commons/src/main/java/org/apache/aurora/common/base/Supplier.java
deleted file mode 100644
index cb6e86a..0000000
--- a/commons/src/main/java/org/apache/aurora/common/base/Supplier.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Licensed 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.apache.aurora.common.base;
-
-/**
- * A convenience typedef that also ties into google's {@code Supplier}.
- *
- * @param <T> The supplied type.
- *
- * @author John Sirois
- */
-public interface Supplier<T>
- extends ExceptionalSupplier<T, RuntimeException>, com.google.common.base.Supplier<T> {
-
- @Override
- T get();
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/main/java/org/apache/aurora/common/io/FileUtils.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/io/FileUtils.java b/commons/src/main/java/org/apache/aurora/common/io/FileUtils.java
deleted file mode 100644
index 348e859..0000000
--- a/commons/src/main/java/org/apache/aurora/common/io/FileUtils.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/**
- * Licensed 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.apache.aurora.common.io;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.UUID;
-
-import com.google.common.base.Preconditions;
-
-import org.apache.commons.lang.SystemUtils;
-
-import org.apache.aurora.common.base.ExceptionalClosure;
-import org.apache.aurora.common.base.ExceptionalFunction;
-
-/**
- * Utility methods for working with files and directories.
- *
- * @author John Sirois
- */
-public final class FileUtils {
-
- /**
- * A utility for creating and working with temporary files and directories.
- */
- public static class Temporary {
- private static final int MAX_TMP_DIR_TRIES = 5;
-
- private final File basedir;
-
- /**
- * Creates a new temporary utility that creates files and directories rooted at {@code basedir}.
- *
- * @param basedir The base directory to generate temporary files and directories in.
- */
- public Temporary(File basedir) {
- Preconditions.checkNotNull(basedir);
- this.basedir = basedir;
- }
-
- /**
- * Returns a new empty temporary directory.
- *
- * @return a file representing the newly created directory.
- * @throws IllegalStateException if a new temporary directory could not be created
- */
- public File createDir() {
- File tempDir;
- int tries = 0;
- do {
- // For sanity sake, die eventually if we keep failing to pick a new unique directory name.
- if (++tries > MAX_TMP_DIR_TRIES) {
- throw new IllegalStateException("Failed to create a new temp directory in "
- + MAX_TMP_DIR_TRIES + " attempts, giving up");
- }
- tempDir = new File(basedir, UUID.randomUUID().toString());
- } while (!tempDir.mkdir());
- return tempDir;
- }
-
- /**
- * Creates a new empty temporary file.
- *
- * @return a new empty temporary file
- * @throws IOException if there was a problem creating a new temporary file
- */
- public File createFile() throws IOException {
- return createFile(".tempfile");
- }
-
- /**
- * Creates a new empty temporary file with the given filename {@code suffix}.
- *
- * @param suffix The suffix for the temporary file name
- * @return a new empty temporary file
- * @throws IOException if there was a problem creating a new temporary file
- */
- public File createFile(String suffix) throws IOException {
- return File.createTempFile(FileUtils.class.getName(), suffix, basedir);
- }
-
- /**
- * Creates a new temporary directory and executes the unit of {@code work} against it ensuring
- * the directory and its contents are removed after the work completes normally or abnormally.
- *
- * @param work The unit of work to execute against the new temporary directory.
- * @param <E> The type of exception this unit of work can throw.
- * @throws E bubbled transparently when the unit of work throws
- */
- public <E extends Exception> void doWithDir(final ExceptionalClosure<File, E> work)
- throws E {
- Preconditions.checkNotNull(work);
- doWithDir(new ExceptionalFunction<File, Void, E>() {
- @Override public Void apply(File dir) throws E {
- work.execute(dir);
- return null;
- }
- });
- }
-
- /**
- * Creates a new temporary directory and executes the unit of {@code work} against it ensuring
- * the directory and its contents are removed after the work completes normally or abnormally.
- *
- * @param work The unit of work to execute against the new temporary directory.
- * @param <T> The type of result this unit of work produces.
- * @param <E> The type of exception this unit of work can throw.
- * @return the result when the unit of work completes successfully
- * @throws E bubbled transparently when the unit of work throws
- */
- public <T, E extends Exception> T doWithDir(ExceptionalFunction<File, T, E> work)
- throws E {
- Preconditions.checkNotNull(work);
- return doWithTemp(createDir(), work);
- }
-
- /**
- * Creates a new temporary file and executes the unit of {@code work} against it ensuring
- * the file is removed after the work completes normally or abnormally.
- *
- * @param work The unit of work to execute against the new temporary file.
- * @param <E> The type of exception this unit of work can throw.
- * @throws E bubbled transparently when the unit of work throws
- * @throws IOException if there was a problem creating a new temporary file
- */
- public <E extends Exception> void doWithFile(final ExceptionalClosure<File, E> work)
- throws E, IOException {
- Preconditions.checkNotNull(work);
- doWithFile(new ExceptionalFunction<File, Void, E>() {
- @Override public Void apply(File dir) throws E {
- work.execute(dir);
- return null;
- }
- });
- }
-
- /**
- * Creates a new temporary file and executes the unit of {@code work} against it ensuring
- * the file is removed after the work completes normally or abnormally.
- *
- * @param work The unit of work to execute against the new temporary file.
- * @param <T> The type of result this unit of work produces.
- * @param <E> The type of exception this unit of work can throw.
- * @return the result when the unit of work completes successfully
- * @throws E bubbled transparently when the unit of work throws
- * @throws IOException if there was a problem creating a new temporary file
- */
- public <T, E extends Exception> T doWithFile(ExceptionalFunction<File, T, E> work)
- throws E, IOException {
- Preconditions.checkNotNull(work);
- return doWithTemp(createFile(), work);
- }
-
- private static <T, E extends Exception> T doWithTemp(File file,
- ExceptionalFunction<File, T, E> work) throws E {
- try {
- return work.apply(file);
- } finally {
- org.apache.commons.io.FileUtils.deleteQuietly(file);
- }
- }
- }
-
- /**
- * A temporary based at the default system temporary directory.
- */
- public static final Temporary SYSTEM_TMP = new Temporary(SystemUtils.getJavaIoTmpDir());
-
- /**
- * Returns a new empty temporary directory.
- *
- * @return a file representing the newly created directory.
- * @throws IllegalStateException if a new temporary directory could not be created
- */
- public static File createTempDir() {
- return SYSTEM_TMP.createDir();
- }
-
- private FileUtils() {
- // utility
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/main/java/org/apache/aurora/common/logging/Log.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/logging/Log.java b/commons/src/main/java/org/apache/aurora/common/logging/Log.java
deleted file mode 100644
index 3f045f7..0000000
--- a/commons/src/main/java/org/apache/aurora/common/logging/Log.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed 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.apache.aurora.common.logging;
-
-import java.util.List;
-
-/**
- * Logs messages to scribe.
- *
- * @author William Farner
- */
-public interface Log<T, R> {
-
- /**
- * Submits a log message.
- *
- * @param entry Entry to log.
- * @return The result of the log request.
- */
- public R log(T entry);
-
- /**
- * Batch version of log.
- *
- * @param entries Entries to log.
- * @return The result of the log request.
- */
- public R log(List<T> entries);
-
- /**
- * Flushes the log, attempting to purge any state that is only stored locally.
- */
- public void flush();
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/main/java/org/apache/aurora/common/net/http/handlers/HealthHandler.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/net/http/handlers/HealthHandler.java b/commons/src/main/java/org/apache/aurora/common/net/http/handlers/HealthHandler.java
index 9d9fb9b..cc5ad4d 100644
--- a/commons/src/main/java/org/apache/aurora/common/net/http/handlers/HealthHandler.java
+++ b/commons/src/main/java/org/apache/aurora/common/net/http/handlers/HealthHandler.java
@@ -14,9 +14,9 @@
package org.apache.aurora.common.net.http.handlers;
import com.google.common.base.Preconditions;
+import com.google.common.base.Supplier;
import com.google.inject.Inject;
import com.google.inject.name.Named;
-import org.apache.aurora.common.base.ExceptionalSupplier;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -51,7 +51,7 @@ public class HealthHandler extends HttpServlet {
private static final Logger LOG = Logger.getLogger(HealthHandler.class.getName());
- private final ExceptionalSupplier<Boolean, ?> healthChecker;
+ private final Supplier<Boolean> healthChecker;
/**
* Constructs a new Healthz that uses the given {@code healthChecker} to determine current health
@@ -62,7 +62,7 @@ public class HealthHandler extends HttpServlet {
* @param healthChecker a supplier that is called to perform a health check
*/
@Inject
- public HealthHandler(@Named(HEALTH_CHECKER_KEY) ExceptionalSupplier<Boolean, ?> healthChecker) {
+ public HealthHandler(@Named(HEALTH_CHECKER_KEY) Supplier<Boolean> healthChecker) {
this.healthChecker = Preconditions.checkNotNull(healthChecker);
}
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/main/java/org/apache/aurora/common/net/http/handlers/LogPrinter.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/net/http/handlers/LogPrinter.java b/commons/src/main/java/org/apache/aurora/common/net/http/handlers/LogPrinter.java
deleted file mode 100644
index b014e41..0000000
--- a/commons/src/main/java/org/apache/aurora/common/net/http/handlers/LogPrinter.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/**
- * Licensed 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.apache.aurora.common.net.http.handlers;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.RandomAccessFile;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.regex.Pattern;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
-import com.google.common.base.Joiner;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.io.Files;
-import com.google.inject.Inject;
-import com.google.inject.name.Named;
-
-import org.antlr.stringtemplate.StringTemplate;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
-
-import org.apache.aurora.common.base.Closure;
-import org.apache.aurora.common.base.MorePreconditions;
-import org.apache.aurora.common.quantity.Amount;
-import org.apache.aurora.common.quantity.Data;
-
-/**
- * HTTP handler to page through log files. Supports GET and POST requests. GET requests are
- * responsible for fetching chrome and javascript, while the POST requests are used to fetch actual
- * log data.
- */
-public class LogPrinter extends StringTemplateServlet {
- private static final Logger LOG = Logger.getLogger(LogPrinter.class.getName());
-
- /**
- * A {@literal @Named} binding key for the log directory to display by default.
- */
- public static final String LOG_DIR_KEY =
- "com.twitter.common.net.http.handlers.LogPrinter.log_dir";
-
- private static final int DEFAULT_PAGE = 0;
-
- private static final int PAGE_CHUNK_SIZE_BYTES = Amount.of(512, Data.KB).as(Data.BYTES);
- private static final int TAIL_START_BYTES = Amount.of(10, Data.KB).as(Data.BYTES);
- private static final int PAGE_END_BUFFER_SIZE_BYTES = Amount.of(1, Data.KB).as(Data.BYTES);
-
- private static final String XML_RESP_FORMAT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
- + "<logchunk text=\"%s\""
- + " end_pos=\"%d\">"
- + "</logchunk>";
- private final File logDir;
-
- @Inject
- public LogPrinter(@Named(LOG_DIR_KEY) File logDir, @CacheTemplates boolean cacheTemplates) {
- super("logprinter", cacheTemplates);
- this.logDir = Preconditions.checkNotNull(logDir);
- }
-
- /**
- * A POST request is made from javascript, to request the contents of a log file. In order to
- * fulfill the request, the 'file' parameter must be set in the request.
- *
- * If file starts with a '/' then the file parameter will be treated as an absolute file path.
- * If file does not start with a '/' then the path will be assumed to be
- * relative to the log directory.
- *
- * @param req Servlet request.
- * @param resp Servlet response.
- * @throws ServletException If there is a problem with the servlet.
- * @throws IOException If there is a problem reading/writing data to the client.
- */
- @Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
- resp.setContentType("text/xml; charset=utf-8");
-
- try {
- LogViewRequest request = new LogViewRequest(req);
-
- if (request.file == null) {
- // The log file is a required parameter for POST requests.
- resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- return;
- }
-
- resp.setStatus(HttpServletResponse.SC_OK);
- PrintWriter responseBody = resp.getWriter();
-
- String responseXml = fetchXmlLogContents(request);
- responseBody.write(responseXml);
- responseBody.close();
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Unknown exception.", e);
- resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- }
- }
-
- /**
- * Fetches the chrome for the page. If a file is requested, a page will be returned that uses an
- * AJAX request to fetch the log contents. If no file is specified, then a file listing is
- * displayed.
- *
- * @param req Servlet request.
- * @param resp Servlet response.
- * @throws ServletException If there is a problem with the servlet.
- * @throws IOException If there is a problem reading/writing data to the client.
- */
- @Override
- protected void doGet(final HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
- final LogViewRequest request = new LogViewRequest(req);
-
- if (request.download) {
- if (request.file == null) {
- resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "No file requested for download.");
- return;
- }
-
- if (!request.file.isRegularFile()) {
- resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Only regular files may be downloaded.");
- return;
- }
-
- try {
- OutputStream out = resp.getOutputStream();
- ServletContext context = getServletConfig().getServletContext();
- String mimetype = context.getMimeType(request.file.getName());
-
- resp.setContentType(mimetype != null ? mimetype : "application/octet-stream" );
- resp.setContentLength((int) request.file.getFile().length());
- resp.setHeader("Content-Disposition", String.format("attachment; filename=\"%s\"",
- request.file.getName()));
-
- Files.copy(request.file.getFile(), out);
- } catch (Exception e) {
- resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Failed to fetch file.");
- LOG.warning("Failed to download file " + request.file.getPath() + ": " + e.getMessage());
- }
- } else {
- writeTemplate(resp, new Closure<StringTemplate>() {
- @Override public void execute(StringTemplate template) {
-
- // TODO(William Farner): Consider using unix file utility to check if the requested file is a
- // text file, and allow the user to download the file if it is not.
- if (request.isFileViewRequest()) {
- request.sendToTemplate(template);
-
- if (!request.tailing) {
- long readStartPos = getReadStartPos(request.file.getFile(), request.page);
-
- if (readStartPos > 0) template.setAttribute("prev", request.page + 1);
- if (request.page > 0) template.setAttribute("next", request.page - 1);
- }
- } else {
- // If a file was not requested, show a list of files.
- File dir = request.getListingDir();
-
- List<LogFile> logFiles = Lists.newArrayList();
- for (File file : dir.listFiles()) {
- logFiles.add(new LogFile(file));
- }
-
- // Sort by dir/file, subsort by name.
- Collections.sort(logFiles, new Comparator<LogFile>() {
- @Override public int compare(LogFile fileA, LogFile fileB) {
- if (fileA.isDir() == fileB.isDir()) {
- return fileA.file.getName().compareTo(fileB.file.getName());
- } else {
- return fileA.isDir() ? -1 : 1;
- }
- }
- });
-
- template.setAttribute("dir", dir);
- template.setAttribute("parent", dir.getParentFile());
- template.setAttribute("files", logFiles);
- }
- }
- });
- }
- }
-
- /**
- * Gets the starting position for reading a page from a file.
- *
- * @param file The file to find a page within.
- * @param page The page index, where page 0 is the last page (at the end of the file).
- * @return The byte index that the page begins on, or 0 if an invalid page number was provided.
- */
- private long getReadStartPos(File file, int page) {
- return page < 0 ? 0 : Math.max(0, file.length() - (page + 1) * PAGE_CHUNK_SIZE_BYTES);
- }
-
- /**
- * Stores request parameters and assigns default values.
- */
- private class LogViewRequest {
- public static final String DIR_PARAM = "dir";
- public static final String FILE_PARAM = "file";
- public static final String PAGE_PARAM = "page";
- public static final String FILTER_PARAM = "filter";
- public static final String TAIL_PARAM = "tail";
- public static final String START_POS_PARAM = "start_pos";
- public static final String DOWNLOAD_PARAM = "download";
-
- public final File dir;
- public final LogFile file;
- public final boolean download;
- public final int page;
- public final long startPos;
- public final String filter;
- public final boolean tailing;
-
- public LogViewRequest(HttpServletRequest req) {
- dir = req.getParameter(DIR_PARAM) == null ? null : new File(req.getParameter(DIR_PARAM));
- file = req.getParameter(FILE_PARAM) == null ? null
- : new LogFile(req.getParameter(FILE_PARAM));
- download = HttpServletRequestParams.getBool(req, DOWNLOAD_PARAM, false);
- tailing = HttpServletRequestParams.getBool(req, TAIL_PARAM, false);
- page = HttpServletRequestParams.getInt(req, PAGE_PARAM, DEFAULT_PAGE);
- Preconditions.checkArgument(page >= 0);
-
- startPos = HttpServletRequestParams.getLong(req, START_POS_PARAM, -1);
- if (file != null) {
- Preconditions.checkArgument(startPos >= -1 && startPos <= file.getFile().length());
- }
- filter = HttpServletRequestParams.getString(req, FILTER_PARAM, "");
- }
-
- public boolean isFileViewRequest() {
- return file != null && file.isRegularFile();
- }
-
- public File getListingDir() {
- if (file != null && file.getFile().isDirectory()) {
- return file.getFile();
- } else if (dir != null) {
- return dir;
- } else {
- return logDir;
- }
- }
-
- public void sendToTemplate(StringTemplate template) {
- template.setAttribute(FILE_PARAM, file);
- template.setAttribute(PAGE_PARAM, page);
- template.setAttribute(FILTER_PARAM, filter);
- template.setAttribute(TAIL_PARAM, tailing);
- }
- }
-
- /**
- * Class to wrap a log file and offer functions to StringTemplate via reflection.
- */
- @VisibleForTesting
- class LogFile {
- private final File file;
-
- public LogFile(File file) {
- this.file = file;
- }
-
- public LogFile(String filePath) {
- MorePreconditions.checkNotBlank(filePath, "filePath must not be null or empty");
- this.file = filePath.startsWith("/") ? new File(filePath) : new File(logDir, filePath);
- }
-
- public File getFile() {
- return file;
- }
-
- public boolean isDir() {
- return !isRegularFile();
- }
-
- public boolean isRegularFile() {
- return file.isFile();
- }
-
- public String getPath() {
- return file.getAbsolutePath();
- }
-
- public String getName() {
- return file.getName();
- }
-
- public String getUrlpath() throws UnsupportedEncodingException {
- return URLEncoder.encode(getPath(), Charsets.UTF_8.name());
- }
-
- public String getSize() {
- Amount<Long, Data> length = Amount.of(file.length(), Data.BYTES);
-
- if (length.as(Data.GB) > 0) {
- return length.as(Data.GB) + " GB";
- } else if (length.as(Data.MB) > 0) {
- return length.as(Data.MB) + " MB";
- } else if (length.as(Data.KB) > 0) {
- return length.as(Data.KB) + " KB";
- } else {
- return length.getValue() + " bytes";
- }
- }
- }
-
- /**
- * Reads data from a log file and prepares an XML response which includes the (sanitized) log text
- * and the last position read from the file.
- *
- * @param request The request parameters.
- * @return A string containing the XML-formatted response.
- * @throws IOException If there was a problem reading the file.
- */
- private String fetchXmlLogContents(LogViewRequest request) throws IOException {
- RandomAccessFile seekFile = new RandomAccessFile(request.file.getFile(), "r");
- try {
- // Move to the approximate start of the page.
- if (!request.tailing) {
- seekFile.seek(getReadStartPos(request.file.getFile(), request.page));
- } else {
- if (request.startPos < 0) {
- seekFile.seek(Math.max(0, request.file.getFile().length() - TAIL_START_BYTES));
- } else {
- seekFile.seek(request.startPos);
- }
- }
-
- byte[] buffer = new byte[PAGE_CHUNK_SIZE_BYTES];
- int bytesRead = seekFile.read(buffer);
- long chunkStop = seekFile.getFilePointer();
- StringBuilder fileChunk = new StringBuilder();
- if (bytesRead > 0) {
- fileChunk.append(new String(buffer, 0, bytesRead));
-
- // Read at most 1 KB more while searching for another line break.
- buffer = new byte[PAGE_END_BUFFER_SIZE_BYTES];
- int newlinePos = 0;
- bytesRead = seekFile.read(buffer);
- if (bytesRead > 0) {
- for (byte b : buffer) {
- newlinePos++;
- if (b == '\n') break;
- }
-
- fileChunk.append(new String(buffer, 0, newlinePos));
- chunkStop = seekFile.getFilePointer() - (bytesRead - newlinePos);
- }
- }
-
- return logChunkXml(filterLines(fileChunk.toString(), request.filter), chunkStop);
- } finally {
- seekFile.close();
- }
- }
-
- private static String sanitize(String text) {
- text = StringEscapeUtils.escapeHtml(text);
-
- StringBuilder newString = new StringBuilder();
- for (char ch : text.toCharArray()) {
- if ((ch > 0x001F && ch < 0x00FD) || ch == '\t' || ch == '\r') {
- // Directly include anything from 0x1F (SPACE) to 0xFD (tilde)
- // as well as tab and carriage-return.
- newString.append(ch);
- } else {
- // Encode everything else.
- newString.append("&#").append((int) ch).append(";");
- }
- }
- return StringEscapeUtils.escapeXml(newString.toString());
- }
-
- private String logChunkXml(String text, long lastBytePosition) {
- return String.format(XML_RESP_FORMAT, sanitize(text) , lastBytePosition);
- }
-
- @VisibleForTesting
- protected static String filterLines(String text, String filterRegexp) {
- if (StringUtils.isEmpty(filterRegexp)) return text;
-
- List<String> lines = Lists.newArrayList(text.split("\n"));
- final Pattern pattern = Pattern.compile(filterRegexp);
-
- Iterable<String> filtered = Iterables.filter(lines, new Predicate<String>() {
- @Override public boolean apply(String line) {
- return pattern.matcher(line).matches();
- }
- });
-
- return Joiner.on("\n").join(filtered);
- }
-
- private class LogConfigException extends Exception {
- public LogConfigException(String message) {
- super(message);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/main/java/org/apache/aurora/common/testing/junit/rules/Retry.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/testing/junit/rules/Retry.java b/commons/src/main/java/org/apache/aurora/common/testing/junit/rules/Retry.java
deleted file mode 100644
index 3b97118..0000000
--- a/commons/src/main/java/org/apache/aurora/common/testing/junit/rules/Retry.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * Licensed 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.apache.aurora.common.testing.junit.rules;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Objects;
-
-import org.junit.rules.MethodRule;
-import org.junit.runners.model.FrameworkMethod;
-import org.junit.runners.model.Statement;
-
-/**
- * A test method annotation useful for smoking out flaky behavior in tests.
- *
- * @see Retry.Rule RetryRule needed to enable this annotation in a test class.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface Retry {
-
- /**
- * The number of times to retry the test.
- *
- * When a {@link Retry.Rule} is installed and a test method is annotated for {@literal @Retry},
- * it will be retried 0 to N times. If times is negative, it is treated as 0 and no retries are
- * performed. If times is >= 1 then a successful execution of the annotated test method is
- * retried until the 1st error, failure or otherwise up to {@code times} times.
- */
- int times() default 1;
-
- /**
- * Enables {@link Retry @Retry}able tests.
- */
- class Rule implements MethodRule {
- private interface ThrowableFactory {
- Throwable create(String message, Throwable cause);
- }
-
- private static Throwable annotate(
- int tryNumber,
- final int maxRetries,
- Throwable cause,
- String prefix,
- ThrowableFactory throwableFactory) {
-
- Throwable annotated =
- throwableFactory.create(
- String.format("%s on try %d of %d: %s", prefix, tryNumber, maxRetries + 1,
- Objects.firstNonNull(cause.getMessage(), "")), cause);
- annotated.setStackTrace(cause.getStackTrace());
- return annotated;
- }
-
- static class RetriedAssertionError extends AssertionError {
- private final int tryNumber;
- private final int maxRetries;
-
- RetriedAssertionError(int tryNumber, int maxRetries, String message, Throwable cause) {
- // We do a manual initCause here to be compatible with the Java 1.6 AssertionError
- // constructors.
- super(message);
- initCause(cause);
-
- this.tryNumber = tryNumber;
- this.maxRetries = maxRetries;
- }
-
- @VisibleForTesting
- int getTryNumber() {
- return tryNumber;
- }
-
- @VisibleForTesting
- int getMaxRetries() {
- return maxRetries;
- }
- }
-
- private static Throwable annotate(final int tryNumber, final int maxRetries, AssertionError e) {
- return annotate(tryNumber, maxRetries, e, "Failure", new ThrowableFactory() {
- @Override public Throwable create(String message, Throwable cause) {
- return new RetriedAssertionError(tryNumber, maxRetries, message, cause);
- }
- });
- }
-
- static class RetriedException extends Exception {
- private final int tryNumber;
- private final int maxRetries;
-
- RetriedException(int tryNumber, int maxRetries, String message, Throwable cause) {
- super(message, cause);
- this.tryNumber = tryNumber;
- this.maxRetries = maxRetries;
- }
-
- @VisibleForTesting
- int getTryNumber() {
- return tryNumber;
- }
-
- @VisibleForTesting
- int getMaxRetries() {
- return maxRetries;
- }
- }
-
- private static Throwable annotate(final int tryNumber, final int maxRetries, Exception e) {
- return annotate(tryNumber, maxRetries, e, "Error", new ThrowableFactory() {
- @Override public Throwable create(String message, Throwable cause) {
- return new RetriedException(tryNumber, maxRetries, message, cause);
- }
- });
- }
-
- @Override
- public Statement apply(final Statement statement, FrameworkMethod method, Object receiver) {
- Retry retry = method.getAnnotation(Retry.class);
- if (retry == null || retry.times() <= 0) {
- return statement;
- } else {
- final int times = retry.times();
- return new Statement() {
- @Override public void evaluate() throws Throwable {
- for (int i = 0; i <= times; i++) {
- try {
- statement.evaluate();
- } catch (AssertionError e) {
- throw annotate(i + 1, times, e);
- // We purposefully catch any non-assertion exceptions in order to tag the try count
- // for erroring (as opposed to failing) tests.
- // SUPPRESS CHECKSTYLE RegexpSinglelineJava
- } catch (Exception e) {
- throw annotate(i + 1, times, e);
- }
- }
- }
- };
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/main/java/org/apache/aurora/common/util/StartWatch.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/util/StartWatch.java b/commons/src/main/java/org/apache/aurora/common/util/StartWatch.java
deleted file mode 100644
index 4d19ed6..0000000
--- a/commons/src/main/java/org/apache/aurora/common/util/StartWatch.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Licensed 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.
- */
-//************************************************************************
-//
-// Summize
-//
-// This work protected by US Copyright Law and contains proprietary and
-// confidential trade secrets.
-//
-// (c) Copyright 2007 Summize, ALL RIGHTS RESERVED.
-//
-//************************************************************************
-
-package org.apache.aurora.common.util;
-
-import org.apache.commons.lang.time.StopWatch;
-
-public class StartWatch extends StopWatch {
- public StartWatch() {
- super();
- }
-
- public void start() {
- _started = true;
- super.start();
- }
-
- public void resume() {
- if (!_started) {
- start();
- } else {
- super.resume();
- }
- }
-
- private boolean _started = false;
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/main/java/org/apache/aurora/common/zookeeper/ServerSetImpl.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/zookeeper/ServerSetImpl.java b/commons/src/main/java/org/apache/aurora/common/zookeeper/ServerSetImpl.java
index cb0f3ec..07ae383 100644
--- a/commons/src/main/java/org/apache/aurora/common/zookeeper/ServerSetImpl.java
+++ b/commons/src/main/java/org/apache/aurora/common/zookeeper/ServerSetImpl.java
@@ -30,10 +30,12 @@ import javax.annotation.Nullable;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Charsets;
+import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicates;
+import com.google.common.base.Supplier;
import com.google.common.base.Throwables;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
@@ -49,8 +51,7 @@ import com.google.common.util.concurrent.UncheckedExecutionException;
import com.google.gson.Gson;
import org.apache.aurora.common.base.Command;
-import org.apache.aurora.common.base.Function;
-import org.apache.aurora.common.base.Supplier;
+import org.apache.aurora.common.base.ExceptionalSupplier;
import org.apache.aurora.common.io.Codec;
import org.apache.aurora.common.thrift.Endpoint;
import org.apache.aurora.common.thrift.ServiceInstance;
@@ -308,7 +309,7 @@ public class ServerSetImpl implements ServerSet {
private ServiceInstance getServiceInstance(final String nodePath) {
try {
- return backoffHelper.doUntilResult(new Supplier<ServiceInstance>() {
+ return backoffHelper.doUntilResult(new ExceptionalSupplier<ServiceInstance, RuntimeException>() {
@Override public ServiceInstance get() {
try {
byte[] data = zkClient.get().getData(nodePath, false, null);
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/main/java/org/apache/aurora/common/zookeeper/ServerSets.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/zookeeper/ServerSets.java b/commons/src/main/java/org/apache/aurora/common/zookeeper/ServerSets.java
index 18aff9f..01a54a5 100644
--- a/commons/src/main/java/org/apache/aurora/common/zookeeper/ServerSets.java
+++ b/commons/src/main/java/org/apache/aurora/common/zookeeper/ServerSets.java
@@ -19,9 +19,9 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Map;
+import com.google.common.base.Function;
import com.google.common.base.Preconditions;
-import org.apache.aurora.common.base.Function;
import org.apache.aurora.common.base.MorePreconditions;
import org.apache.aurora.common.io.Codec;
import org.apache.aurora.common.thrift.Endpoint;
@@ -42,11 +42,7 @@ public class ServerSets {
* A function that invokes {@link #toEndpoint(InetSocketAddress)}.
*/
public static final Function<InetSocketAddress, Endpoint> TO_ENDPOINT =
- new Function<InetSocketAddress, Endpoint>() {
- @Override public Endpoint apply(InetSocketAddress address) {
- return ServerSets.toEndpoint(address);
- }
- };
+ ServerSets::toEndpoint;
/**
* Creates a server set that registers at a single path applying the given ACL to all nodes
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/ZooKeeperTestServer.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/ZooKeeperTestServer.java b/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/ZooKeeperTestServer.java
index db9e5ca..afd2315 100644
--- a/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/ZooKeeperTestServer.java
+++ b/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/ZooKeeperTestServer.java
@@ -20,6 +20,7 @@ import java.util.Arrays;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
+import com.google.common.io.Files;
import org.apache.aurora.common.zookeeper.ZooKeeperClient;
import org.apache.zookeeper.server.NIOServerCnxn;
@@ -30,7 +31,6 @@ import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
import org.apache.aurora.common.application.ShutdownRegistry;
import org.apache.aurora.common.base.Command;
import org.apache.aurora.common.base.ExceptionalCommand;
-import org.apache.aurora.common.io.FileUtils;
import org.apache.aurora.common.quantity.Amount;
import org.apache.aurora.common.quantity.Time;
@@ -210,7 +210,7 @@ public class ZooKeeperTestServer {
}
private File createTempDir() {
- final File tempDir = FileUtils.createTempDir();
+ final File tempDir = Files.createTempDir();
shutdownRegistry.addAction(new ExceptionalCommand<IOException>() {
@Override public void execute() throws IOException {
org.apache.commons.io.FileUtils.deleteDirectory(tempDir);
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/test/java/org/apache/aurora/common/args/ArgScannerTest.java
----------------------------------------------------------------------
diff --git a/commons/src/test/java/org/apache/aurora/common/args/ArgScannerTest.java b/commons/src/test/java/org/apache/aurora/common/args/ArgScannerTest.java
index dc83f74..de04304 100644
--- a/commons/src/test/java/org/apache/aurora/common/args/ArgScannerTest.java
+++ b/commons/src/test/java/org/apache/aurora/common/args/ArgScannerTest.java
@@ -27,6 +27,7 @@ import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
+import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
@@ -48,7 +49,6 @@ import org.junit.Test;
import org.apache.aurora.common.args.ArgScannerTest.StandardArgs.Optimizations;
import org.apache.aurora.common.args.constraints.NotEmpty;
import org.apache.aurora.common.base.Command;
-import org.apache.aurora.common.base.Function;
import org.apache.aurora.common.base.MorePreconditions;
import org.apache.aurora.common.collections.Pair;
import org.apache.aurora.common.quantity.Amount;
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/test/java/org/apache/aurora/common/base/MoreSuppliersTest.java
----------------------------------------------------------------------
diff --git a/commons/src/test/java/org/apache/aurora/common/base/MoreSuppliersTest.java b/commons/src/test/java/org/apache/aurora/common/base/MoreSuppliersTest.java
index a655f59..7c67dee 100644
--- a/commons/src/test/java/org/apache/aurora/common/base/MoreSuppliersTest.java
+++ b/commons/src/test/java/org/apache/aurora/common/base/MoreSuppliersTest.java
@@ -14,6 +14,7 @@
package org.apache.aurora.common.base;
import com.google.common.base.Preconditions;
+import com.google.common.base.Supplier;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/test/java/org/apache/aurora/common/io/FileUtilsTest.java
----------------------------------------------------------------------
diff --git a/commons/src/test/java/org/apache/aurora/common/io/FileUtilsTest.java b/commons/src/test/java/org/apache/aurora/common/io/FileUtilsTest.java
deleted file mode 100644
index a043451..0000000
--- a/commons/src/test/java/org/apache/aurora/common/io/FileUtilsTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * Licensed 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.apache.aurora.common.io;
-
-import java.io.File;
-import java.io.IOException;
-
-import com.google.common.io.Files;
-
-import org.apache.aurora.common.base.ExceptionalClosure;
-import org.apache.aurora.common.base.ExceptionalFunction;
-import org.apache.aurora.common.base.Function;
-import org.apache.aurora.common.testing.TearDownTestCase;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author John Sirois
- */
-public class FileUtilsTest extends TearDownTestCase {
-
- private FileUtils.Temporary temporary;
-
- @Before
- public void setUp() {
- final File tmpDir = FileUtils.createTempDir();
- addTearDown(new TearDown() {
- @Override public void tearDown() throws Exception {
- org.apache.commons.io.FileUtils.deleteDirectory(tmpDir);
- }
- });
- assertEmptyDir(tmpDir);
-
- temporary = new FileUtils.Temporary(tmpDir);
- }
-
- @Test
- public void testCreateDir() {
- File tmpDir = temporary.createDir();
- assertEmptyDir(tmpDir);
- }
-
- @Test
- public void testCreateFile() throws IOException {
- File tmpFile = temporary.createFile(".jake");
- assertEmptyFile(tmpFile);
- assertTrue(tmpFile.getName().matches(".+\\.jake$"));
- }
-
- @Test
- public void testDoWithDir() {
- assertEquals("42", temporary.doWithDir(new Function<File, String>() {
- @Override public String apply(File dir) {
- assertEmptyDir(dir);
- return "42";
- }
- }));
- }
-
- static class MarkerException extends Exception {}
-
- @Test(expected = MarkerException.class)
- public void testDoWithDir_bubbles() throws MarkerException {
- temporary.doWithDir(new ExceptionalClosure<File, MarkerException>() {
- @Override public void execute (File dir) throws MarkerException {
- throw new MarkerException();
- }
- });
- }
-
- @Test
- public void testDoWithFile() throws IOException {
- assertEquals("37", temporary.doWithFile(new ExceptionalFunction<File, String, IOException>() {
- @Override public String apply(File file) throws IOException {
- assertEmptyFile(file);
- return "37";
- }
- }));
- }
-
- @Test(expected = MarkerException.class)
- public void testDoWithFile_bubbles() throws MarkerException, IOException {
- temporary.doWithFile(new ExceptionalClosure<File, MarkerException>() {
- @Override public void execute(File dir) throws MarkerException {
- throw new MarkerException();
- }
- });
- }
-
- private void assertEmptyDir(File dir) {
- assertNotNull(dir);
- assertTrue(dir.exists());
- assertTrue(dir.isDirectory());
- assertEquals(0, dir.list().length);
- }
-
- private void assertEmptyFile(File file) throws IOException {
- assertNotNull(file);
- assertTrue(file.exists());
- assertTrue(file.isFile());
- assertEquals(0, Files.toByteArray(file).length);
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/test/java/org/apache/aurora/common/net/http/handlers/LogPrinterTest.java
----------------------------------------------------------------------
diff --git a/commons/src/test/java/org/apache/aurora/common/net/http/handlers/LogPrinterTest.java b/commons/src/test/java/org/apache/aurora/common/net/http/handlers/LogPrinterTest.java
deleted file mode 100644
index 2422d7d..0000000
--- a/commons/src/test/java/org/apache/aurora/common/net/http/handlers/LogPrinterTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Licensed 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.apache.aurora.common.net.http.handlers;
-
-import java.io.File;
-import java.util.List;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.Lists;
-
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
-/**
- * Test for the LogPrinter.
- *
- * @author William Farner
- */
-public class LogPrinterTest {
-
- @Test
- public void testRelativeFileHandling() {
- LogPrinter printer = new LogPrinter(new File("/this/is/the/log/dir"), true);
- LogPrinter.LogFile absFile = printer.new LogFile("/absolute/path.log");
- assertEquals("/absolute/path.log", absFile.getPath());
- LogPrinter.LogFile relFile = printer.new LogFile("relative/file.log");
- assertEquals("/this/is/the/log/dir/relative/file.log", relFile.getPath());
- }
-
- @Test
- public void testFilterLines() {
- testFilterLinesHelper(TEST_LINES, FILTER0, FILTERED_LINES0);
- testFilterLinesHelper(TEST_LINES, FILTER1, FILTERED_LINES1);
- testFilterLinesHelper(TEST_LINES, FILTER2, FILTERED_LINES2);
- testFilterLinesHelper(TEST_LINES, FILTER3, FILTERED_LINES3);
- }
-
- private void testFilterLinesHelper(List<String> testLines,
- String filter,
- List<String> expectedLines) {
-
- List<String> filteredLines = Lists.newArrayList(
- LogPrinter.filterLines(Joiner.on("\n").join(testLines), filter).split("\n"));
-
- assertThat(filteredLines, is(expectedLines));
- }
-
- private static final List<String> TEST_LINES = Lists.newArrayList(
- "Matching line 1 twittttter",
- "Matching line 2 twitter",
- "Not matching line 1 twiter",
- "Matching line 3"
- );
-
- private static final String FILTER0 = "";
- private static final List<String> FILTERED_LINES0 = TEST_LINES;
-
- private static final String FILTER1 = "Matching.*";
- private static final List<String> FILTERED_LINES1 = Lists.newArrayList(
- "Matching line 1 twittttter",
- "Matching line 2 twitter",
- "Matching line 3"
- );
-
- private static final String FILTER2 = "^.*twitt+er$";
- private static final List<String> FILTERED_LINES2 = Lists.newArrayList(
- "Matching line 1 twittttter",
- "Matching line 2 twitter"
- );
-
- private static final String FILTER3 = "^.*\\d.*$";
- private static final List<String> FILTERED_LINES3 = TEST_LINES;
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/test/java/org/apache/aurora/common/stats/RateTest.java
----------------------------------------------------------------------
diff --git a/commons/src/test/java/org/apache/aurora/common/stats/RateTest.java b/commons/src/test/java/org/apache/aurora/common/stats/RateTest.java
index 15bd65b..46081a0 100644
--- a/commons/src/test/java/org/apache/aurora/common/stats/RateTest.java
+++ b/commons/src/test/java/org/apache/aurora/common/stats/RateTest.java
@@ -13,7 +13,6 @@
*/
package org.apache.aurora.common.stats;
-import org.apache.aurora.common.base.Supplier;
import org.apache.aurora.common.util.testing.FakeTicker;
import org.easymock.IMocksControl;
import org.junit.After;
@@ -22,6 +21,8 @@ import org.junit.Test;
import java.util.concurrent.atomic.AtomicLong;
+import com.google.common.base.Supplier;
+
import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/test/java/org/apache/aurora/common/testing/junit/rules/RetryTest.java
----------------------------------------------------------------------
diff --git a/commons/src/test/java/org/apache/aurora/common/testing/junit/rules/RetryTest.java b/commons/src/test/java/org/apache/aurora/common/testing/junit/rules/RetryTest.java
deleted file mode 100644
index 43be9df..0000000
--- a/commons/src/test/java/org/apache/aurora/common/testing/junit/rules/RetryTest.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/**
- * Licensed 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.apache.aurora.common.testing.junit.rules;
-
-import java.io.IOException;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.annotation.Nullable;
-
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.MethodRule;
-import org.junit.runners.model.FrameworkMethod;
-import org.junit.runners.model.Statement;
-
-// SUPPRESS CHECKSTYLE:OFF IllegalThrows
-public class RetryTest {
-
- public abstract static class RetryTrackingTestBase {
- private static int tries;
-
- @BeforeClass
- public static void resetTries() {
- tries = 0;
- }
-
- enum Result {
- FAILURE() {
- @Override void execute() throws Throwable {
- Assert.fail("Simulated assertion failure.");
- }
- },
- ERROR() {
- @Override void execute() throws Throwable {
- throw new IOException("Simulated unexpected error.");
- }
- },
- SUCCESS() {
- @Override void execute() throws Throwable {
- Assert.assertTrue("Simulated successful assertion.", true);
- }
- };
-
- abstract void execute() throws Throwable;
- }
-
- @Rule public Retry.Rule retry = new Retry.Rule();
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.METHOD)
- @interface AssertRetries {
- int expectedTries();
- int expectedMaxRetries();
- Result expectedResult();
- }
-
- @Rule
- public MethodRule testRetries = new MethodRule() {
- @Override
- public Statement apply(final Statement statement, FrameworkMethod method, Object receiver) {
- final AssertRetries assertRetries = method.getAnnotation(AssertRetries.class);
- Assert.assertNotNull(assertRetries);
- return new Statement() {
- @Override public void evaluate() throws Throwable {
- try {
- statement.evaluate();
- if (assertRetries.expectedResult() == Result.SUCCESS) {
- Assert.assertEquals(assertRetries.expectedTries(), tries);
- } else {
- Assert.fail("Expected success, found " + assertRetries.expectedResult());
- }
- } catch (Retry.Rule.RetriedAssertionError e) {
- if (assertRetries.expectedResult() == Result.FAILURE) {
- Assert.assertEquals(assertRetries.expectedTries(), tries);
- Assert.assertEquals(assertRetries.expectedMaxRetries(), e.getMaxRetries());
- Assert.assertEquals(assertRetries.expectedTries(), e.getTryNumber());
- } else {
- Assert.fail("Expected failure, found " + assertRetries.expectedResult());
- }
- } catch (Retry.Rule.RetriedException e) {
- if (assertRetries.expectedResult() == Result.ERROR) {
- Assert.assertEquals(assertRetries.expectedTries(), tries);
- Assert.assertEquals(assertRetries.expectedMaxRetries(), e.getMaxRetries());
- Assert.assertEquals(assertRetries.expectedTries(), e.getTryNumber());
- } else {
- Assert.fail("Expected error, found " + assertRetries.expectedResult());
- }
- }
- }
- };
- }
- };
-
- protected void doTest(int successfulTries) throws Throwable {
- doTest(successfulTries, null);
- }
-
- protected void doTest(int successfulTries, @Nullable Result lastResult) throws Throwable {
- tries++;
- if (lastResult != null && tries > successfulTries) {
- lastResult.execute();
- }
- }
- }
-
- public static class DefaultRetrySuccessTest extends RetryTrackingTestBase {
- @Test
- @Retry
- @AssertRetries(expectedTries = 2, expectedMaxRetries = 1, expectedResult = Result.SUCCESS)
- public void test() throws Throwable {
- doTest(2);
- }
- }
-
- public static class DefaultRetryFailFastTest extends RetryTrackingTestBase {
- @Test
- @Retry
- @AssertRetries(expectedTries = 1, expectedMaxRetries = 1, expectedResult = Result.FAILURE)
- public void test() throws Throwable {
- doTest(0, Result.FAILURE);
- }
- }
-
- public static class DefaultRetryFailLastTest extends RetryTrackingTestBase {
- @Test
- @Retry
- @AssertRetries(expectedTries = 2, expectedMaxRetries = 1, expectedResult = Result.FAILURE)
- public void test() throws Throwable {
- doTest(1, Result.FAILURE);
- }
- }
-
- public static class DefaultRetryErrorFastTest extends RetryTrackingTestBase {
- @Test
- @Retry
- @AssertRetries(expectedTries = 1, expectedMaxRetries = 1, expectedResult = Result.ERROR)
- public void test() throws Throwable {
- doTest(0, Result.ERROR);
- }
- }
-
- public static class DefaultRetryErrorLastTest extends RetryTrackingTestBase {
- @Test
- @Retry
- @AssertRetries(expectedTries = 2, expectedMaxRetries = 1, expectedResult = Result.ERROR)
- public void test() throws Throwable {
- doTest(1, Result.ERROR);
- }
- }
-
- public static class ZeroRetrySuccessTest extends RetryTrackingTestBase {
- @Test
- @Retry(times = 0)
- @AssertRetries(expectedTries = 1, expectedMaxRetries = 0, expectedResult = Result.SUCCESS)
- public void test() throws Throwable {
- doTest(1, Result.SUCCESS);
- }
- }
-
- public static class NegativeRetrySuccessTest extends RetryTrackingTestBase {
- @Test
- @Retry(times = -1)
- @AssertRetries(expectedTries = 1, expectedMaxRetries = 0, expectedResult = Result.SUCCESS)
- public void test() throws Throwable {
- doTest(1, Result.SUCCESS);
- }
- }
-
- public static class PositiveRetrySuccessTest extends RetryTrackingTestBase {
- @Test
- @Retry(times = 2)
- @AssertRetries(expectedTries = 3, expectedMaxRetries = 2, expectedResult = Result.SUCCESS)
- public void test() throws Throwable {
- doTest(3, Result.SUCCESS);
- }
- }
-
- public static class PositiveRetryFailFastTest extends RetryTrackingTestBase {
- @Test
- @Retry(times = 2)
- @AssertRetries(expectedTries = 1, expectedMaxRetries = 2, expectedResult = Result.FAILURE)
- public void test() throws Throwable {
- doTest(0, Result.FAILURE);
- }
- }
-
- public static class PositiveRetryFailLastTest extends RetryTrackingTestBase {
- @Test
- @Retry(times = 2)
- @AssertRetries(expectedTries = 2, expectedMaxRetries = 2, expectedResult = Result.FAILURE)
- public void test() throws Throwable {
- doTest(1, Result.FAILURE);
- }
- }
-
- public static class PositiveRetryErrorFastTest extends RetryTrackingTestBase {
- @Test
- @Retry(times = 2)
- @AssertRetries(expectedTries = 1, expectedMaxRetries = 2, expectedResult = Result.ERROR)
- public void test() throws Throwable {
- doTest(0, Result.ERROR);
- }
- }
-
- public static class PositiveRetryErrorLastTest extends RetryTrackingTestBase {
- @Test
- @Retry(times = 2)
- @AssertRetries(expectedTries = 2, expectedMaxRetries = 2, expectedResult = Result.ERROR)
- public void test() throws Throwable {
- doTest(1, Result.ERROR);
- }
- }
-}
-// SUPPRESS CHECKSTYLE:ON IllegalThrows
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/test/java/org/apache/aurora/common/util/BackoffHelperTest.java
----------------------------------------------------------------------
diff --git a/commons/src/test/java/org/apache/aurora/common/util/BackoffHelperTest.java b/commons/src/test/java/org/apache/aurora/common/util/BackoffHelperTest.java
index 6bf71cf..78ba8fe 100644
--- a/commons/src/test/java/org/apache/aurora/common/util/BackoffHelperTest.java
+++ b/commons/src/test/java/org/apache/aurora/common/util/BackoffHelperTest.java
@@ -14,7 +14,6 @@
package org.apache.aurora.common.util;
import org.apache.aurora.common.base.ExceptionalSupplier;
-import org.apache.aurora.common.base.Supplier;
import org.apache.aurora.common.testing.easymock.EasyMockTest;
import org.junit.Before;
@@ -43,7 +42,8 @@ public class BackoffHelperTest extends EasyMockTest {
@Test
public void testDoUntilSuccess() throws Exception {
- Supplier<Boolean> task = createMock(new Clazz<Supplier<Boolean>>() { });
+ ExceptionalSupplier<Boolean, RuntimeException> task =
+ createMock(new Clazz<ExceptionalSupplier<Boolean, RuntimeException>>() { });
expect(task.get()).andReturn(false);
expect(backoffStrategy.shouldContinue(0L)).andReturn(true);
@@ -60,7 +60,8 @@ public class BackoffHelperTest extends EasyMockTest {
@Test
public void testDoUntilResult() throws Exception {
- Supplier<String> task = createMock(new Clazz<Supplier<String>>() { });
+ ExceptionalSupplier<String, RuntimeException> task =
+ createMock(new Clazz<ExceptionalSupplier<String, RuntimeException>>() { });
expect(task.get()).andReturn(null);
expect(backoffStrategy.shouldContinue(0)).andReturn(true);
@@ -101,7 +102,8 @@ public class BackoffHelperTest extends EasyMockTest {
@Test
public void testDoUntilResultMaxSuccess() throws Exception {
- Supplier<String> task = createMock(new Clazz<Supplier<String>>() { });
+ ExceptionalSupplier<String, RuntimeException> task =
+ createMock(new Clazz<ExceptionalSupplier<String, RuntimeException>>() { });
BackoffHelper maxBackoffHelper = new BackoffHelper(clock, backoffStrategy);
@@ -124,7 +126,8 @@ public class BackoffHelperTest extends EasyMockTest {
@Test
public void testDoUntilResultMaxReached() throws Exception {
- Supplier<String> task = createMock(new Clazz<Supplier<String>>() { });
+ ExceptionalSupplier<String, RuntimeException> task =
+ createMock(new Clazz<ExceptionalSupplier<String, RuntimeException>>() { });
BackoffHelper maxBackoffHelper = new BackoffHelper(clock, backoffStrategy);
@@ -153,7 +156,8 @@ public class BackoffHelperTest extends EasyMockTest {
@Test
public void testDoUntilSuccessTransparentException() throws Exception {
- Supplier<Boolean> task = createMock(new Clazz<Supplier<Boolean>>() { });
+ ExceptionalSupplier<Boolean, RuntimeException> task =
+ createMock(new Clazz<ExceptionalSupplier<Boolean, RuntimeException>>() { });
IllegalArgumentException thrown = new IllegalArgumentException();
expect(task.get()).andThrow(thrown);
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/commons/src/test/java/org/apache/aurora/common/zookeeper/GroupTest.java
----------------------------------------------------------------------
diff --git a/commons/src/test/java/org/apache/aurora/common/zookeeper/GroupTest.java b/commons/src/test/java/org/apache/aurora/common/zookeeper/GroupTest.java
index 09d9016..edfc109 100644
--- a/commons/src/test/java/org/apache/aurora/common/zookeeper/GroupTest.java
+++ b/commons/src/test/java/org/apache/aurora/common/zookeeper/GroupTest.java
@@ -16,6 +16,7 @@ package org.apache.aurora.common.zookeeper;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
+import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
@@ -25,7 +26,6 @@ import org.junit.Before;
import org.junit.Test;
import org.apache.aurora.common.base.Command;
-import org.apache.aurora.common.base.Supplier;
import org.apache.aurora.common.quantity.Amount;
import org.apache.aurora.common.quantity.Time;
import org.apache.aurora.common.testing.easymock.EasyMockTest;
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/src/main/java/org/apache/aurora/scheduler/cron/quartz/AuroraCronJob.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/cron/quartz/AuroraCronJob.java b/src/main/java/org/apache/aurora/scheduler/cron/quartz/AuroraCronJob.java
index 6778822..9b71802 100644
--- a/src/main/java/org/apache/aurora/scheduler/cron/quartz/AuroraCronJob.java
+++ b/src/main/java/org/apache/aurora/scheduler/cron/quartz/AuroraCronJob.java
@@ -25,7 +25,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
import com.google.common.collect.Iterables;
-import org.apache.aurora.common.base.Supplier;
+import org.apache.aurora.common.base.ExceptionalSupplier;
import org.apache.aurora.common.stats.Stats;
import org.apache.aurora.common.util.BackoffHelper;
import org.apache.aurora.gen.CronCollisionPolicy;
@@ -197,7 +197,7 @@ class AuroraCronJob implements Job {
try {
// NOTE: We block the quartz execution thread here until we've successfully killed our
// ancestor. We mitigate this by using a cached thread pool for quartz.
- delayedStartBackoff.doUntilSuccess(new Supplier<Boolean>() {
+ delayedStartBackoff.doUntilSuccess(new ExceptionalSupplier<Boolean, RuntimeException>() {
@Override
public Boolean get() {
if (Iterables.isEmpty(Storage.Util.fetchTasks(storage, query))) {
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/src/main/java/org/apache/aurora/scheduler/cron/quartz/CronSchedulerImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/cron/quartz/CronSchedulerImpl.java b/src/main/java/org/apache/aurora/scheduler/cron/quartz/CronSchedulerImpl.java
index 0c59b2d..a71676e 100644
--- a/src/main/java/org/apache/aurora/scheduler/cron/quartz/CronSchedulerImpl.java
+++ b/src/main/java/org/apache/aurora/scheduler/cron/quartz/CronSchedulerImpl.java
@@ -18,11 +18,11 @@ import java.util.logging.Logger;
import javax.inject.Inject;
+import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterables;
-import org.apache.aurora.common.base.Function;
import org.apache.aurora.scheduler.base.JobKeys;
import org.apache.aurora.scheduler.cron.CronScheduler;
import org.apache.aurora.scheduler.cron.CrontabEntry;
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/src/main/java/org/apache/aurora/scheduler/http/JettyServerModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/JettyServerModule.java b/src/main/java/org/apache/aurora/scheduler/http/JettyServerModule.java
index 05af127..0a7163b 100644
--- a/src/main/java/org/apache/aurora/scheduler/http/JettyServerModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/http/JettyServerModule.java
@@ -29,6 +29,7 @@ import javax.servlet.http.HttpServlet;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
+import com.google.common.base.Supplier;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
import com.google.common.net.HostAndPort;
@@ -49,7 +50,6 @@ import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
import org.apache.aurora.common.args.Arg;
import org.apache.aurora.common.args.CmdLine;
-import org.apache.aurora.common.base.ExceptionalSupplier;
import org.apache.aurora.common.base.MoreSuppliers;
import org.apache.aurora.common.net.http.handlers.AbortHandler;
import org.apache.aurora.common.net.http.handlers.ContentionPrinter;
@@ -139,7 +139,7 @@ public class JettyServerModule extends AbstractModule {
bind(Runnable.class).annotatedWith(Names.named(QuitHandler.QUIT_HANDLER_KEY))
.to(QuitCallback.class);
bind(QuitCallback.class).in(Singleton.class);
- bind(new TypeLiteral<ExceptionalSupplier<Boolean, ?>>() { })
+ bind(new TypeLiteral<Supplier<Boolean>>() { })
.annotatedWith(Names.named(HealthHandler.HEALTH_CHECKER_KEY))
.toInstance(MoreSuppliers.ofInstance(true));
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/src/main/java/org/apache/aurora/scheduler/log/mesos/MesosLog.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/log/mesos/MesosLog.java b/src/main/java/org/apache/aurora/scheduler/log/mesos/MesosLog.java
index 906f3e6..9726a09 100644
--- a/src/main/java/org/apache/aurora/scheduler/log/mesos/MesosLog.java
+++ b/src/main/java/org/apache/aurora/scheduler/log/mesos/MesosLog.java
@@ -30,6 +30,7 @@ import javax.inject.Provider;
import javax.inject.Qualifier;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
@@ -37,7 +38,6 @@ import com.google.common.collect.UnmodifiableIterator;
import com.google.common.primitives.Longs;
import org.apache.aurora.common.application.Lifecycle;
-import org.apache.aurora.common.base.Function;
import org.apache.aurora.common.base.MorePreconditions;
import org.apache.aurora.common.inject.TimedInterceptor.Timed;
import org.apache.aurora.common.quantity.Amount;
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java b/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java
index ed639b6..f6ba2c4 100644
--- a/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java
+++ b/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java
@@ -20,13 +20,13 @@ import java.util.logging.Logger;
import javax.inject.Inject;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Function;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.protobuf.ByteString;
import org.apache.aurora.Protobufs;
import org.apache.aurora.codec.ThriftBinaryCodec;
-import org.apache.aurora.common.base.Function;
import org.apache.aurora.common.quantity.Amount;
import org.apache.aurora.common.quantity.Data;
import org.apache.aurora.scheduler.ResourceSlot;
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/src/main/java/org/apache/aurora/scheduler/sla/SlaGroup.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/sla/SlaGroup.java b/src/main/java/org/apache/aurora/scheduler/sla/SlaGroup.java
index cc74d97..4827a0d 100644
--- a/src/main/java/org/apache/aurora/scheduler/sla/SlaGroup.java
+++ b/src/main/java/org/apache/aurora/scheduler/sla/SlaGroup.java
@@ -15,6 +15,7 @@ package org.apache.aurora.scheduler.sla;
import java.util.Map;
+import com.google.common.base.Function;
import com.google.common.base.Functions;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableListMultimap;
@@ -24,7 +25,6 @@ import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.Range;
-import org.apache.aurora.common.base.Function;
import org.apache.aurora.scheduler.base.JobKeys;
import org.apache.aurora.scheduler.base.Tasks;
import org.apache.aurora.scheduler.storage.entities.IJobKey;
http://git-wip-us.apache.org/repos/asf/aurora/blob/f94e5c27/src/test/java/org/apache/aurora/scheduler/cron/quartz/AuroraCronJobTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/cron/quartz/AuroraCronJobTest.java b/src/test/java/org/apache/aurora/scheduler/cron/quartz/AuroraCronJobTest.java
index 6ac0696..be921c3 100644
--- a/src/test/java/org/apache/aurora/scheduler/cron/quartz/AuroraCronJobTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/cron/quartz/AuroraCronJobTest.java
@@ -16,7 +16,7 @@ package org.apache.aurora.scheduler.cron.quartz;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
-import org.apache.aurora.common.base.Supplier;
+import org.apache.aurora.common.base.ExceptionalSupplier;
import org.apache.aurora.common.testing.easymock.EasyMockTest;
import org.apache.aurora.common.util.BackoffHelper;
import org.apache.aurora.gen.AssignedTask;
@@ -98,7 +98,7 @@ public class AuroraCronJobTest extends EasyMockTest {
@Test
public void testKillExisting() throws Exception {
- Capture<Supplier<Boolean>> capture = createCapture();
+ Capture<ExceptionalSupplier<Boolean, RuntimeException>> capture = createCapture();
expect(stateManager.changeState(
EasyMock.anyObject(),