You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by wf...@apache.org on 2015/08/28 20:33:39 UTC
[21/21] aurora git commit: Remove unused classes from commons fork.
Remove unused classes from commons fork.
Reviewed at https://reviews.apache.org/r/37872/
Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/356eeac9
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/356eeac9
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/356eeac9
Branch: refs/heads/master
Commit: 356eeac974bdf2d57399ab082e1419cf0dd7c24d
Parents: 06ddaad
Author: Bill Farner <wf...@apache.org>
Authored: Fri Aug 28 11:32:58 2015 -0700
Committer: Bill Farner <wf...@apache.org>
Committed: Fri Aug 28 11:32:58 2015 -0700
----------------------------------------------------------------------
build.gradle | 4 -
.../application/http/DefaultQuitHandler.java | 43 -
.../common/application/http/GraphViewer.java | 50 -
.../application/http/HttpAssetConfig.java | 51 -
.../application/http/HttpFilterConfig.java | 39 -
.../application/http/HttpServletConfig.java | 65 -
.../common/application/http/Registration.java | 155 --
.../application/modules/LifecycleModule.java | 26 -
.../common/application/modules/LogModule.java | 117 --
.../application/modules/StatsExportModule.java | 85 -
.../application/modules/ThriftModule.java | 41 -
.../aurora/common/base/CachingSupplier.java | 68 -
.../base/CallableExceptionalSupplier.java | 32 -
.../org/apache/aurora/common/base/Either.java | 358 ----
.../common/base/ExceptionTransporter.java | 84 -
.../common/base/ExceptionalFunctions.java | 153 --
.../apache/aurora/common/base/SupplierE.java | 25 -
.../apache/aurora/common/collections/Bits.java | 116 --
.../webassets/bootstrap/BootstrapModule.java | 90 -
.../common/webassets/jquery/JQueryModule.java | 36 -
.../aurora/common/inject/DefaultProvider.java | 166 --
.../common/inject/ProviderMethodModule.java | 32 -
.../aurora/common/io/Base64ZlibCodec.java | 169 --
.../org/apache/aurora/common/io/JsonCodec.java | 124 --
.../org/apache/aurora/common/io/Streamer.java | 54 -
.../aurora/common/logging/BufferedLog.java | 278 ---
.../apache/aurora/common/logging/LogUtil.java | 90 -
.../logging/julbridge/JULBridgeHandler.java | 196 --
.../julbridge/JULBridgeLevelConverter.java | 99 -
.../logging/julbridge/JULBridgeLogManager.java | 87 -
.../aurora/common/net/ProxyAuthorizer.java | 41 -
.../apache/aurora/common/net/ProxyConfig.java | 30 -
.../org/apache/aurora/common/net/UrlHelper.java | 156 --
.../apache/aurora/common/net/UrlResolver.java | 446 ----
.../aurora/common/net/UrlResolverUtil.java | 148 --
.../aurora/common/net/UrlTokenizerUtil.java | 1905 ------------------
.../common/net/http/GuiceServletConfig.java | 41 -
.../common/net/http/HttpServerDispatch.java | 123 --
.../net/http/JettyHttpServerDispatch.java | 283 ---
.../aurora/common/net/http/RequestLogger.java | 130 --
.../net/http/filters/AbstractHttpFilter.java | 63 -
.../net/http/filters/HttpStatsFilter.java | 158 --
.../common/net/http/handlers/ThriftServlet.java | 70 -
.../loadbalancing/LeastConnectedStrategy.java | 170 --
.../common/net/loadbalancing/LoadBalancer.java | 76 -
.../net/loadbalancing/LoadBalancerImpl.java | 122 --
.../loadbalancing/LoadBalancingStrategy.java | 79 -
.../net/loadbalancing/MarkDeadStrategy.java | 220 --
.../MarkDeadStrategyWithHostCheck.java | 98 -
.../net/loadbalancing/RandomStrategy.java | 57 -
.../net/loadbalancing/RequestTracker.java | 37 -
.../net/loadbalancing/RoundRobinStrategy.java | 49 -
.../StaticLoadBalancingStrategy.java | 61 -
.../net/loadbalancing/SubsetStrategy.java | 89 -
.../loadbalancing/TrafficMonitorAdapter.java | 68 -
.../net/monitoring/ConnectionMonitor.java | 36 -
.../common/net/monitoring/TrafficMonitor.java | 259 ---
.../common/net/pool/ConnectionFactory.java | 56 -
.../aurora/common/net/pool/ConnectionPool.java | 334 ---
.../common/net/pool/DynamicHostSetUtil.java | 46 -
.../aurora/common/net/pool/DynamicPool.java | 170 --
.../apache/aurora/common/net/pool/MetaPool.java | 339 ----
.../aurora/common/net/pool/ObjectPool.java | 82 -
.../net/pool/ResourceExhaustedException.java | 27 -
.../common/objectsize/ObjectSizeCalculator.java | 427 ----
.../common/stats/ApproximateHistogram.java | 563 ------
.../apache/aurora/common/stats/CounterMap.java | 138 --
.../common/stats/CounterMapWithTopKey.java | 89 -
.../org/apache/aurora/common/stats/Elapsed.java | 81 -
.../org/apache/aurora/common/stats/Entropy.java | 51 -
.../apache/aurora/common/stats/Histogram.java | 43 -
.../apache/aurora/common/stats/Histograms.java | 39 -
.../aurora/common/stats/MovingAverage.java | 68 -
.../aurora/common/stats/MovingWindowDelta.java | 96 -
.../common/stats/NumericStatExporter.java | 125 --
.../aurora/common/stats/PipelineStats.java | 134 --
.../apache/aurora/common/stats/Precision.java | 50 -
.../aurora/common/stats/PrintableHistogram.java | 90 -
.../aurora/common/stats/ReservoirSampler.java | 97 -
.../aurora/common/stats/Significance.java | 59 -
.../apache/aurora/common/stats/Statistics.java | 93 -
.../common/stats/StatisticsInterface.java | 70 -
.../apache/aurora/common/stats/Windowed.java | 136 --
.../common/stats/WindowedApproxHistogram.java | 153 --
.../aurora/common/stats/WindowedHistogram.java | 110 -
.../aurora/common/stats/WindowedStatistics.java | 173 --
.../common/stats/testing/RealHistogram.java | 42 -
.../aurora/common/testing/TearDownRegistry.java | 51 -
.../common/testing/mockito/MockitoTest.java | 31 -
.../org/apache/aurora/common/thrift/Config.java | 302 ---
.../thrift/TResourceExhaustedException.java | 39 -
.../aurora/common/thrift/TTimeoutException.java | 38 -
.../common/thrift/TTransportConnection.java | 70 -
.../org/apache/aurora/common/thrift/Thrift.java | 390 ----
.../common/thrift/ThriftConnectionFactory.java | 366 ----
.../aurora/common/thrift/ThriftException.java | 26 -
.../aurora/common/thrift/ThriftFactory.java | 653 ------
.../aurora/common/thrift/callers/Caller.java | 99 -
.../common/thrift/callers/CallerDecorator.java | 78 -
.../common/thrift/callers/DeadlineCaller.java | 93 -
.../common/thrift/callers/DebugCaller.java | 73 -
.../common/thrift/callers/RetryingCaller.java | 224 --
.../thrift/callers/StatTrackingCaller.java | 103 -
.../common/thrift/callers/ThriftCaller.java | 157 --
.../TMonitoredNonblockingServerSocket.java | 80 -
.../thrift/monitoring/TMonitoredProcessor.java | 62 -
.../monitoring/TMonitoredServerSocket.java | 111 -
.../common/thrift/testing/MockTSocket.java | 45 -
.../common/thrift/testing/TestThriftTypes.java | 7 +-
.../apache/aurora/common/util/DateUtils.java | 57 -
.../apache/aurora/common/util/FileUtils.java | 51 -
.../apache/aurora/common/util/LowResClock.java | 108 -
.../apache/aurora/common/util/ParsingUtil.java | 53 -
.../apache/aurora/common/util/QueueDrainer.java | 53 -
.../aurora/common/util/RangeNormalizer.java | 88 -
.../common/util/RateLimitedCommandExecutor.java | 88 -
.../aurora/common/util/RetryingRunnable.java | 131 --
.../aurora/common/util/caching/Cache.java | 46 -
.../common/util/caching/CachingMethodProxy.java | 262 ---
.../aurora/common/util/caching/LRUCache.java | 170 --
.../util/concurrent/BackingOffFutureTask.java | 56 -
.../util/concurrent/RetryingFutureTask.java | 81 -
.../logging/ResourceLoggingConfigurator.java | 49 -
.../util/logging/UnresettableLogManager.java | 48 -
.../common/zookeeper/CompoundServerSet.java | 224 --
.../common/zookeeper/DistributedLock.java | 39 -
.../common/zookeeper/DistributedLockImpl.java | 286 ---
.../aurora/common/zookeeper/Partitioner.java | 172 --
.../aurora/common/zookeeper/ServerSets.java | 32 +-
.../common/zookeeper/StaticServerSet.java | 145 --
.../aurora/common/zookeeper/ZooKeeperMap.java | 411 ----
.../aurora/common/zookeeper/ZooKeeperNode.java | 349 ----
.../http/graphview/dygraph-combined.js | 14 -
.../application/http/graphview/dygraph-extra.js | 367 ----
.../application/http/graphview/grapher.js | 365 ----
.../application/http/graphview/graphview.html | 84 -
.../common/application/http/graphview/parser.js | 337 ----
.../2.1.1/css/bootstrap-responsive.min.css | 14 -
.../bootstrap/2.1.1/css/bootstrap.min.css | 14 -
.../2.1.1/img/glyphicons-halflings-white.png | Bin 8777 -> 0 bytes
.../2.1.1/img/glyphicons-halflings.png | Bin 12799 -> 0 bytes
.../bootstrap/2.1.1/js/bootstrap.min.js | 19 -
.../2.3.2/css/bootstrap-responsive.min.css | 14 -
.../bootstrap/2.3.2/css/bootstrap.min.css | 14 -
.../2.3.2/img/glyphicons-halflings-white.png | Bin 8777 -> 0 bytes
.../2.3.2/img/glyphicons-halflings.png | Bin 12799 -> 0 bytes
.../bootstrap/2.3.2/js/bootstrap.min.js | 19 -
.../webassets/jquery/js/jquery-1.8.2.min.js | 15 -
.../modules/LifecycleModuleTest.java | 33 +-
.../aurora/common/base/CachingSupplierTest.java | 64 -
.../apache/aurora/common/base/EitherTest.java | 263 ---
.../common/base/ExceptionTransporterTest.java | 57 -
.../common/base/ExceptionalFunctionsTest.java | 166 --
.../aurora/common/collections/BitsTest.java | 299 ---
.../common/inject/DefaultProviderTest.java | 65 -
.../aurora/common/io/Base64ZlibCodecTest.java | 91 -
.../apache/aurora/common/io/JsonCodecTest.java | 104 -
.../aurora/common/logging/BufferedLogTest.java | 141 --
.../aurora/common/logging/LogUtilTest.java | 61 -
.../logging/julbridge/JULBridgeHandlerTest.java | 94 -
.../julbridge/JULBridgeLevelConverterTest.java | 94 -
.../julbridge/JULBridgeLogManagerTest.java | 75 -
.../apache/aurora/common/net/UrlHelperTest.java | 120 --
.../aurora/common/net/UrlResolverTest.java | 171 --
.../aurora/common/net/UrlResolverUtilTest.java | 162 --
.../aurora/common/net/UrlTokenizerUtilTest.java | 94 -
.../common/net/http/RequestLoggerTest.java | 102 -
.../filters/HttpStatsFilterIntegrationTest.java | 165 --
.../net/http/filters/HttpStatsFilterTest.java | 227 ---
.../LeastConnectedStrategyTest.java | 286 ---
.../net/loadbalancing/LoadBalancerImplTest.java | 141 --
.../net/loadbalancing/MarkDeadStrategyTest.java | 332 ---
.../MarkDeadStrategyWithHostCheckTest.java | 146 --
.../net/loadbalancing/RandomStrategyTest.java | 97 -
.../loadbalancing/RoundRobinStrategyTest.java | 104 -
.../net/loadbalancing/SubsetStrategyTest.java | 98 -
.../net/monitoring/TrafficMonitorTest.java | 122 --
.../common/net/pool/ConnectionPoolTest.java | 255 ---
.../common/net/pool/DynamicHostSetUtilTest.java | 57 -
.../aurora/common/net/pool/DynamicPoolTest.java | 168 --
.../objectsize/ObjectSizeCalculatorTest.java | 211 --
.../common/stats/ApproximateHistogramTest.java | 321 ---
.../apache/aurora/common/stats/ElapsedTest.java | 83 -
.../apache/aurora/common/stats/EntropyTest.java | 58 -
.../common/stats/MergedHistogramTest.java | 94 -
.../aurora/common/stats/MovingAverageTest.java | 83 -
.../common/stats/MovingWindowDeltaTest.java | 91 -
.../common/stats/NumericStatExporterTest.java | 144 --
.../aurora/common/stats/PipelineStatsTest.java | 147 --
.../common/stats/PrintableHistogramTest.java | 27 -
.../common/stats/ReservoirSamplerTest.java | 75 -
.../aurora/common/stats/StatisticsTest.java | 116 --
.../common/stats/WindowedHistogramTest.java | 234 ---
.../aurora/common/stats/WindowedStatsTest.java | 202 --
.../aurora/common/stats/WindowedTest.java | 110 -
.../common/testing/TearDownRegistryTest.java | 46 -
.../thrift/ThriftConnectionFactoryTest.java | 140 --
.../aurora/common/thrift/ThriftFactoryTest.java | 242 ---
.../apache/aurora/common/thrift/ThriftTest.java | 931 ---------
.../thrift/callers/AbstractCallerTest.java | 56 -
.../thrift/callers/DeadlineCallerTest.java | 119 --
.../thrift/callers/RetryingCallerTest.java | 150 --
.../aurora/common/util/LowResClockTest.java | 169 --
.../aurora/common/util/QueueDrainerTest.java | 59 -
.../util/RateLimitedCommandExecutorTest.java | 115 --
.../util/caching/CachingMethodProxyTest.java | 257 ---
.../common/util/caching/LRUCacheTest.java | 81 -
.../common/zookeeper/CompoundServerSetTest.java | 233 ---
.../common/zookeeper/DistributedLockTest.java | 174 --
.../common/zookeeper/PartitionerTest.java | 159 --
.../common/zookeeper/ServerSetImplTest.java | 115 +-
.../common/zookeeper/StaticServerSetTest.java | 85 -
.../common/zookeeper/ZooKeeperMapTest.java | 418 ----
.../common/zookeeper/ZooKeeperNodeTest.java | 297 ---
214 files changed, 18 insertions(+), 29580 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 9444886..05cd36f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -94,8 +94,6 @@ For more details, please see https://issues.apache.org/jira/browse/AURORA-1169
ext.stringTemplateRev = '3.2.1'
ext.zookeeperRev = '3.3.4'
ext.jerseyRev = '1.18.1'
- // This can be removed onced the mockito dep is gone
- ext.objenesisRev = '1.3'
ext.jsrRev = '2.0.1'
ext.commonsLangRev = '2.6'
@@ -116,7 +114,6 @@ For more details, please see https://issues.apache.org/jira/browse/AURORA-1169
force "org.hamcrest:hamcrest-core:1.3"
force "org.apache.thrift:libthrift:${thriftRev}"
force "org.slf4j:slf4j-jdk14:${slf4jRev}"
- force "org.objenesis:objenesis:${objenesisRev}"
}
}
}
@@ -174,7 +171,6 @@ project(':commons') {
compile "org.antlr:stringtemplate:${stringTemplateRev}"
compile "org.apache.zookeeper:zookeeper:${zookeeperRev}"
compile "org.easymock:easymock:3.2"
- compile "org.mockito:mockito-core:1.9.0"
compile "org.slf4j:slf4j-jdk14:${slf4jRev}"
// TODO(zmanji): Remove dependency on this old jetty package
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/application/http/DefaultQuitHandler.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/application/http/DefaultQuitHandler.java b/commons/src/main/java/org/apache/aurora/common/application/http/DefaultQuitHandler.java
deleted file mode 100644
index 6a48b84..0000000
--- a/commons/src/main/java/org/apache/aurora/common/application/http/DefaultQuitHandler.java
+++ /dev/null
@@ -1,43 +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.application.http;
-
-import java.util.logging.Logger;
-
-import com.google.inject.Inject;
-
-import org.apache.aurora.common.application.Lifecycle;
-
-/**
- * The default quit handler to use, which invokes {@link Lifecycle#shutdown()}.
- *
- * @author William Farner
- */
-public class DefaultQuitHandler implements Runnable {
-
- private static final Logger LOG = Logger.getLogger(DefaultQuitHandler.class.getName());
-
- private final Lifecycle lifecycle;
-
- @Inject
- public DefaultQuitHandler(Lifecycle lifecycle) {
- this.lifecycle = lifecycle;
- }
-
- @Override
- public void run() {
- LOG.info("Instructing lifecycle to destroy.");
- lifecycle.shutdown();
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/application/http/GraphViewer.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/application/http/GraphViewer.java b/commons/src/main/java/org/apache/aurora/common/application/http/GraphViewer.java
deleted file mode 100644
index f786f9e..0000000
--- a/commons/src/main/java/org/apache/aurora/common/application/http/GraphViewer.java
+++ /dev/null
@@ -1,50 +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.application.http;
-
-import com.google.inject.Binder;
-
-/**
- * A utility class to register the file resources for the graph viewer.
- */
-public final class GraphViewer {
-
- private GraphViewer() {
- // Utility class.
- }
-
- private static void registerJs(Binder binder, String assetName) {
- Registration.registerHttpAsset(
- binder,
- "/graphview/" + assetName,
- GraphViewer.class,
- "graphview/" + assetName,
- "application/javascript",
- true);
- }
-
- /**
- * Registers required resources with the binder.
- *
- * @param binder Binder to register with.
- */
- public static void registerResources(Binder binder) {
- registerJs(binder, "dygraph-combined.js");
- registerJs(binder, "dygraph-extra.js");
- registerJs(binder, "grapher.js");
- registerJs(binder, "parser.js");
- Registration.registerHttpAsset(binder,
- "/graphview", GraphViewer.class, "graphview/graphview.html", "text/html", false);
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/application/http/HttpAssetConfig.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/application/http/HttpAssetConfig.java b/commons/src/main/java/org/apache/aurora/common/application/http/HttpAssetConfig.java
deleted file mode 100644
index e2160e7..0000000
--- a/commons/src/main/java/org/apache/aurora/common/application/http/HttpAssetConfig.java
+++ /dev/null
@@ -1,51 +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.application.http;
-
-import java.net.URL;
-
-import com.google.common.io.Resources;
-
-import org.apache.aurora.common.net.http.handlers.AssetHandler;
-import org.apache.aurora.common.net.http.handlers.AssetHandler.StaticAsset;
-
-import static org.apache.aurora.common.base.MorePreconditions.checkNotBlank;
-
-/**
- * Configuration for a static HTTP-served asset.
- *
- * TODO(William Farner): Move this to a more appropriate package after initial AppLauncher check-in.
- *
- * @author William Farner
- */
-public class HttpAssetConfig {
- public final String path;
- public final AssetHandler handler;
- public final boolean silent;
-
- /**
- * Creates a new asset configuration.
- *
- * @param path HTTP path the asset should be accessible from.
- * @param asset Asset resource URL.
- * @param contentType HTTP content-type to report for the asset.
- * @param silent Whether the asset should be visible on the default index page.
- */
- public HttpAssetConfig(String path, URL asset, String contentType, boolean silent) {
- this.path = checkNotBlank(path);
- this.handler = new AssetHandler(
- new StaticAsset(Resources.newInputStreamSupplier(asset), contentType, true));
- this.silent = silent;
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/application/http/HttpFilterConfig.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/application/http/HttpFilterConfig.java b/commons/src/main/java/org/apache/aurora/common/application/http/HttpFilterConfig.java
deleted file mode 100644
index d096317..0000000
--- a/commons/src/main/java/org/apache/aurora/common/application/http/HttpFilterConfig.java
+++ /dev/null
@@ -1,39 +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.application.http;
-
-import javax.servlet.Filter;
-
-import org.apache.aurora.common.base.MorePreconditions;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Configuration tuple for an HTTP filter.
- */
-public class HttpFilterConfig {
- public final Class<? extends Filter> filterClass;
- public final String pathSpec;
-
- /**
- * Creates a new filter configuration.
- *
- * @param filterClass Filter class.
- * @param pathSpec Path spec that the filter should match.
- */
- public HttpFilterConfig(Class<? extends Filter> filterClass, String pathSpec) {
- this.pathSpec = MorePreconditions.checkNotBlank(pathSpec);
- this.filterClass = checkNotNull(filterClass);
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/application/http/HttpServletConfig.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/application/http/HttpServletConfig.java b/commons/src/main/java/org/apache/aurora/common/application/http/HttpServletConfig.java
deleted file mode 100644
index 4444e4c..0000000
--- a/commons/src/main/java/org/apache/aurora/common/application/http/HttpServletConfig.java
+++ /dev/null
@@ -1,65 +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.application.http;
-
-import javax.servlet.http.HttpServlet;
-
-import com.google.common.collect.ImmutableMap;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import static org.apache.aurora.common.base.MorePreconditions.checkNotBlank;
-
-/**
- * An {@link javax.servlet.http.HttpServlet} configuration used to mount HTTP handlers via
- * {@link Registration#registerServlet(com.google.inject.Binder, HttpServletConfig)}.
- *
- * TODO(William Farner): Move this to a more appropriate package after initial AppLauncher check-in.
- *
- */
-public class HttpServletConfig {
- public final String path;
- public final Class<? extends HttpServlet> handlerClass;
- public final ImmutableMap<String, String> params;
- public final boolean silent;
-
- /**
- * Creates a new servlet config.
- *
- * @param path the absolute path to mount the handler on
- * @param servletClass the type of servlet that will render pages at {@code path}
- * @param silent whether or not to display a link for this handler on the landing page
- */
- public HttpServletConfig(String path, Class<? extends HttpServlet> servletClass,
- boolean silent) {
- this(path, servletClass, ImmutableMap.<String, String>of(), silent);
- }
-
- /**
- * Registers a new servlet config with servlet initialization parameters.
- *
- * @param path the absolute path to mount the handler on
- * @param servletClass the type of servlet that will render pages at {@code path}
- * @param params a map of servlet init parameters to initialize the servlet with
- * @param silent whether or not to display a link for this handler on the landing page
- */
- public HttpServletConfig(String path, Class<? extends HttpServlet> servletClass,
- ImmutableMap<String, String> params, boolean silent) {
-
- this.path = checkNotBlank(path);
- this.handlerClass = checkNotNull(servletClass);
- this.params = checkNotNull(params);
- this.silent = silent;
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/application/http/Registration.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/application/http/Registration.java b/commons/src/main/java/org/apache/aurora/common/application/http/Registration.java
deleted file mode 100644
index b66c8c8..0000000
--- a/commons/src/main/java/org/apache/aurora/common/application/http/Registration.java
+++ /dev/null
@@ -1,155 +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.application.http;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import java.net.URL;
-
-import javax.servlet.Filter;
-import javax.servlet.http.HttpServlet;
-
-import com.google.common.io.Resources;
-import com.google.inject.Binder;
-import com.google.inject.BindingAnnotation;
-import com.google.inject.multibindings.Multibinder;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Utility class for registering HTTP servlets and assets.
- */
-public final class Registration {
-
- private Registration() {
- // Utility class.
- }
-
- /**
- * Equivalent to
- * {@code registerServlet(binder, new HttpServletConfig(path, servletClass, silent))}.
- */
- public static void registerServlet(Binder binder, String path,
- Class<? extends HttpServlet> servletClass, boolean silent) {
- registerServlet(binder, new HttpServletConfig(path, servletClass, silent));
- }
-
- /**
- * Registers a binding for an {@link javax.servlet.http.HttpServlet} to be exported at a specified
- * path.
- *
- * @param binder a guice binder to register the handler with
- * @param config a servlet mounting specification
- */
- public static void registerServlet(Binder binder, HttpServletConfig config) {
- Multibinder.newSetBinder(binder, HttpServletConfig.class).addBinding().toInstance(config);
- }
-
- /**
- * A binding annotation applied to the set of additional index page links bound via
- * {@link #Registration#registerEndpoint()}
- */
- @BindingAnnotation
- @Target({FIELD, PARAMETER, METHOD})
- @Retention(RUNTIME)
- public @interface IndexLink { }
-
- /**
- * Gets the multibinder used to bind links on the root servlet.
- * The resulting {@link java.util.Set} is bound with the {@link IndexLink} annotation.
- *
- * @param binder a guice binder to associate the multibinder with.
- * @return The multibinder to bind index links against.
- */
- public static Multibinder<String> getEndpointBinder(Binder binder) {
- return Multibinder.newSetBinder(binder, String.class, IndexLink.class);
- }
-
- /**
- * Registers a link to display on the root servlet.
- *
- * @param binder a guice binder to register the link with.
- * @param endpoint Endpoint URI to include.
- */
- public static void registerEndpoint(Binder binder, String endpoint) {
- getEndpointBinder(binder).addBinding().toInstance(endpoint);
- }
-
- /**
- * Registers a binding for a URL asset to be served by the HTTP server, with an optional
- * entity tag for cache control.
- *
- * @param binder a guice binder to register the handler with
- * @param servedPath Path to serve the resource from in the HTTP server.
- * @param asset Resource to be served.
- * @param assetType MIME-type for the asset.
- * @param silent Whether the server should hide this asset on the index page.
- */
- public static void registerHttpAsset(Binder binder, String servedPath, URL asset,
- String assetType, boolean silent) {
- Multibinder.newSetBinder(binder, HttpAssetConfig.class).addBinding().toInstance(
- new HttpAssetConfig(servedPath, asset, assetType, silent));
- }
-
- /**
- * Registers a binding for a classpath resource to be served by the HTTP server, using a resource
- * path relative to a class.
- *
- * @param binder a guice binder to register the handler with
- * @param servedPath Path to serve the asset from in the HTTP server.
- * @param contextClass Context class for defining the relative path to the asset.
- * @param assetRelativePath Path to the served asset, relative to {@code contextClass}.
- * @param assetType MIME-type for the asset.
- * @param silent Whether the server should hide this asset on the index page.
- */
- public static void registerHttpAsset(
- Binder binder,
- String servedPath,
- Class<?> contextClass,
- String assetRelativePath,
- String assetType,
- boolean silent) {
-
- registerHttpAsset(binder, servedPath, Resources.getResource(contextClass, assetRelativePath),
- assetType, silent);
- }
-
- /**
- * Gets the multibinder used to bind HTTP filters.
- *
- * @param binder a guice binder to associate the multibinder with.
- * @return The multibinder to bind HTTP filter configurations against.
- */
- public static Multibinder<HttpFilterConfig> getFilterBinder(Binder binder) {
- return Multibinder.newSetBinder(binder, HttpFilterConfig.class);
- }
-
- /**
- * Registers an HTTP servlet filter.
- *
- * @param binder a guice binder to register the filter with.
- * @param filterClass Filter class to register.
- * @param pathSpec Path spec that the filter should be activated on.
- */
- public static void registerServletFilter(
- Binder binder,
- Class<? extends Filter> filterClass,
- String pathSpec) {
-
- getFilterBinder(binder).addBinding().toInstance(new HttpFilterConfig(filterClass, pathSpec));
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/application/modules/LifecycleModule.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/application/modules/LifecycleModule.java b/commons/src/main/java/org/apache/aurora/common/application/modules/LifecycleModule.java
index b3e59e7..6414208 100644
--- a/commons/src/main/java/org/apache/aurora/common/application/modules/LifecycleModule.java
+++ b/commons/src/main/java/org/apache/aurora/common/application/modules/LifecycleModule.java
@@ -120,32 +120,6 @@ public class LifecycleModule extends AbstractModule {
}
/**
- * Binds a service runner that will start and stop a local service.
- *
- * @param binder Binder to bind against.
- * @param launcher Launcher class for a service.
- */
- public static void bindServiceRunner(Binder binder, Class<? extends ServiceRunner> launcher) {
- runnerBinder(binder).addBinding().to(launcher);
- binder.bind(launcher).in(Singleton.class);
- }
-
- /**
- * Binds a local service instance, without attaching an explicit lifecycle.
- *
- * @param binder Binder to bind against.
- * @param service Local service instance to bind.
- */
- public static void bindLocalService(Binder binder, final LocalServiceRegistry.LocalService service) {
- runnerBinder(binder).addBinding().toInstance(
- new ServiceRunner() {
- @Override public LocalServiceRegistry.LocalService launch() {
- return service;
- }
- });
- }
-
- /**
* Adds a startup action to the startup registry binding.
*
* @param binder Binder to bind against.
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/application/modules/LogModule.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/application/modules/LogModule.java b/commons/src/main/java/org/apache/aurora/common/application/modules/LogModule.java
deleted file mode 100644
index 107e3aa..0000000
--- a/commons/src/main/java/org/apache/aurora/common/application/modules/LogModule.java
+++ /dev/null
@@ -1,117 +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.application.modules;
-
-import java.io.File;
-import java.util.logging.Logger;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.TypeLiteral;
-import com.google.inject.name.Named;
-import com.google.inject.name.Names;
-
-import org.apache.aurora.common.args.Arg;
-import org.apache.aurora.common.args.CmdLine;
-import org.apache.aurora.common.args.constraints.CanRead;
-import org.apache.aurora.common.args.constraints.Exists;
-import org.apache.aurora.common.args.constraints.IsDirectory;
-import org.apache.aurora.common.base.Command;
-import org.apache.aurora.common.logging.LogUtil;
-import org.apache.aurora.common.logging.RootLogConfig;
-import org.apache.aurora.common.logging.RootLogConfig.Configuration;
-import org.apache.aurora.common.net.http.handlers.LogPrinter;
-import org.apache.aurora.common.stats.StatImpl;
-import org.apache.aurora.common.stats.Stats;
-
-/**
- * Binding module for logging-related bindings, such as the log directory.
- *
- * This module uses a single optional command line argument 'log_dir'. If unset, the logging
- * directory will be auto-discovered via:
- * {@link LogUtil#getLogManagerLogDir()}.
- *
- * Bindings provided by this module:
- * <ul>
- * <li>{@code @Named(LogPrinter.LOG_DIR_KEY) File} - Log directory.
- * <li>{@code Optional<RootLogConfig.Configuraton>} - If glog is enabled the configuration
- * used.
- * </ul>
- *
- * Default bindings that may be overridden:
- * <ul>
- * <li>Log directory: directory where application logs are written. May be overridden by binding
- * to: {@code bind(File.class).annotatedWith(Names.named(LogPrinter.LOG_DIR_KEY))}.
- * </ul>
- *
- * @author William Farner
- */
-public class LogModule extends AbstractModule {
-
- private static final Logger LOG = Logger.getLogger(LogModule.class.getName());
-
- @Exists
- @CanRead
- @IsDirectory
- @CmdLine(name = "log_dir",
- help = "The directory where application logs are written.")
- private static final Arg<File> LOG_DIR = Arg.create(null);
-
- @CmdLine(name = "use_glog",
- help = "True to use the new glog-based configuration for the root logger.")
- private static final Arg<Boolean> USE_GLOG = Arg.create(true);
-
- @Override
- protected void configure() {
- // Bind the default log directory.
- bind(File.class).annotatedWith(Names.named(LogPrinter.LOG_DIR_KEY)).toInstance(getLogDir());
-
- LifecycleModule.bindStartupAction(binder(), ExportLogDir.class);
-
- Configuration configuration = null;
- if (USE_GLOG.get()) {
- configuration = RootLogConfig.configurationFromFlags();
- configuration.apply();
- }
- bind(new TypeLiteral<Optional<Configuration>>() { })
- .toInstance(Optional.fromNullable(configuration));
- }
-
- private File getLogDir() {
- File logDir = LOG_DIR.get();
- if (logDir == null) {
- logDir = LogUtil.getLogManagerLogDir();
- LOG.info("From logging properties, parsed log directory " + logDir.getAbsolutePath());
- }
- return logDir;
- }
-
- public static final class ExportLogDir implements Command {
- private final File logDir;
-
- @Inject ExportLogDir(@Named(LogPrinter.LOG_DIR_KEY) final File logDir) {
- this.logDir = Preconditions.checkNotNull(logDir);
- }
-
- @Override public void execute() {
- Stats.exportStatic(new StatImpl<String>("logging_dir") {
- @Override public String read() {
- return logDir.getAbsolutePath();
- }
- });
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/application/modules/StatsExportModule.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/application/modules/StatsExportModule.java b/commons/src/main/java/org/apache/aurora/common/application/modules/StatsExportModule.java
deleted file mode 100644
index ba93d4c..0000000
--- a/commons/src/main/java/org/apache/aurora/common/application/modules/StatsExportModule.java
+++ /dev/null
@@ -1,85 +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.application.modules;
-
-import java.util.Map;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadFactory;
-
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Key;
-import com.google.inject.TypeLiteral;
-
-import org.apache.aurora.common.application.ShutdownRegistry;
-import org.apache.aurora.common.args.Arg;
-import org.apache.aurora.common.args.CmdLine;
-import org.apache.aurora.common.base.Closure;
-import org.apache.aurora.common.base.Command;
-import org.apache.aurora.common.quantity.Amount;
-import org.apache.aurora.common.quantity.Time;
-import org.apache.aurora.common.stats.NumericStatExporter;
-
-/**
- * Module to enable periodic exporting of registered stats to an external service.
- *
- * This modules supports a single command line argument, {@code stat_export_interval}, which
- * controls the export interval (defaulting to 1 minute).
- *
- * Bindings required by this module:
- * <ul>
- * <li>{@code @ShutdownStage ShutdownRegistry} - Shutdown action registry.
- * </ul>
- *
- * @author William Farner
- */
-public class StatsExportModule extends AbstractModule {
-
- @CmdLine(name = "stat_export_interval",
- help = "Amount of time to wait between stat exports.")
- private static final Arg<Amount<Long, Time>> EXPORT_INTERVAL =
- Arg.create(Amount.of(1L, Time.MINUTES));
-
- @Override
- protected void configure() {
- requireBinding(Key.get(new TypeLiteral<Closure<Map<String, ? extends Number>>>() { }));
- LifecycleModule.bindStartupAction(binder(), StartCuckooExporter.class);
- }
-
- public static final class StartCuckooExporter implements Command {
-
- private final Closure<Map<String, ? extends Number>> statSink;
- private final ShutdownRegistry shutdownRegistry;
-
- @Inject StartCuckooExporter(
- Closure<Map<String, ? extends Number>> statSink,
- ShutdownRegistry shutdownRegistry) {
-
- this.statSink = Preconditions.checkNotNull(statSink);
- this.shutdownRegistry = Preconditions.checkNotNull(shutdownRegistry);
- }
-
- @Override public void execute() {
- ThreadFactory threadFactory =
- new ThreadFactoryBuilder().setNameFormat("CuckooExporter-%d").setDaemon(true).build();
-
- final NumericStatExporter exporter = new NumericStatExporter(statSink,
- Executors.newScheduledThreadPool(1, threadFactory), EXPORT_INTERVAL.get());
-
- exporter.start(shutdownRegistry);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/application/modules/ThriftModule.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/application/modules/ThriftModule.java b/commons/src/main/java/org/apache/aurora/common/application/modules/ThriftModule.java
deleted file mode 100644
index 55236df..0000000
--- a/commons/src/main/java/org/apache/aurora/common/application/modules/ThriftModule.java
+++ /dev/null
@@ -1,41 +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.application.modules;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.multibindings.Multibinder;
-import com.google.inject.name.Names;
-
-import org.apache.aurora.common.application.http.Registration;
-import org.apache.aurora.common.net.http.handlers.ThriftServlet;
-import org.apache.aurora.common.net.monitoring.TrafficMonitor;
-
-/**
- * Binding module for thrift traffic monitor servlets, to ensure an empty set is available for
- * the thrift traffic monitor servlet.
- *
- * @author William Farner
- */
-public class ThriftModule extends AbstractModule {
- @Override
- protected void configure() {
- // Make sure that there is at least an empty set bound to client andserver monitors.
- Multibinder.newSetBinder(binder(), TrafficMonitor.class,
- Names.named(ThriftServlet.THRIFT_CLIENT_MONITORS));
- Multibinder.newSetBinder(binder(), TrafficMonitor.class,
- Names.named(ThriftServlet.THRIFT_SERVER_MONITORS));
-
- Registration.registerServlet(binder(), "/thrift", ThriftServlet.class, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/base/CachingSupplier.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/base/CachingSupplier.java b/commons/src/main/java/org/apache/aurora/common/base/CachingSupplier.java
deleted file mode 100644
index 3a1511d..0000000
--- a/commons/src/main/java/org/apache/aurora/common/base/CachingSupplier.java
+++ /dev/null
@@ -1,68 +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;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-
-import org.apache.aurora.common.quantity.Amount;
-import org.apache.aurora.common.quantity.Time;
-import org.apache.aurora.common.util.Clock;
-
-/**
- * A supplier that caches responses from an underling supplier, expiring the cached value after
- * a fixed expiration time.
- *
- * @param <T> Supplied value type.
- *
- * @author William Farner
- */
-public class CachingSupplier<T> implements Supplier<T> {
-
- private final Supplier<T> wrapped;
- private final long expirationNanos;
- private final Clock clock;
-
- private long lastFetchNanos = -1;
- private T cachedValue;
-
- /**
- * Creates a new caching supplier.
- *
- * @param wrapped The supplier to delegate fetches to.
- * @param expiration The maximum amount of time that a response from {@code supplier} will be
- * cached for. The expiration must be positive.
- */
- public CachingSupplier(Supplier<T> wrapped, Amount<Long, Time> expiration) {
- this(wrapped, expiration, Clock.SYSTEM_CLOCK);
- }
-
- @VisibleForTesting
- CachingSupplier(Supplier<T> wrapped, Amount<Long, Time> expiration, Clock clock) {
- this.wrapped = Preconditions.checkNotNull(wrapped);
- this.expirationNanos = Preconditions.checkNotNull(expiration).as(Time.NANOSECONDS);
- Preconditions.checkArgument(expiration.getValue() > 0, "Expiration must be positive.");
- this.clock = Preconditions.checkNotNull(clock);
- }
-
- @Override
- public synchronized T get() {
- if ((lastFetchNanos == -1) || (clock.nowNanos() - lastFetchNanos > expirationNanos)) {
- cachedValue = wrapped.get();
- lastFetchNanos = clock.nowNanos();
- }
-
- return cachedValue;
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/base/CallableExceptionalSupplier.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/base/CallableExceptionalSupplier.java b/commons/src/main/java/org/apache/aurora/common/base/CallableExceptionalSupplier.java
deleted file mode 100644
index b4f2d53..0000000
--- a/commons/src/main/java/org/apache/aurora/common/base/CallableExceptionalSupplier.java
+++ /dev/null
@@ -1,32 +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;
-
-import java.util.concurrent.Callable;
-
-/**
- * A supplier that may also be called.
- *
- * @param <T> The supplier type.
- * @param <E> Supplier exception type.
- *
- * @author John Sirois
- */
-public abstract class CallableExceptionalSupplier<T, E extends Exception>
- implements ExceptionalSupplier<T, E>, Callable<T> {
-
- @Override public T call() throws Exception {
- return get();
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/base/Either.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/base/Either.java b/commons/src/main/java/org/apache/aurora/common/base/Either.java
deleted file mode 100644
index a746e72..0000000
--- a/commons/src/main/java/org/apache/aurora/common/base/Either.java
+++ /dev/null
@@ -1,358 +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;
-
-import javax.annotation.Nullable;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Optional;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
-/**
- * A value of one of two possible types.
- *
- * <p>Often Either processing is used as an alternative exception flow control. In these uses the
- * left type represents failure by convention and the right type the success path result.
- *
- * @param <L> The left type.
- * @param <R> The right type.
- */
-public final class Either<L, R> {
- private final Optional<L> left;
- private final Optional<R> right;
-
- private Either(Optional<L> left, Optional<R> right) {
- this.left = left;
- this.right = right;
- }
-
- /**
- * Turns a left into a right and vice-versa.
- *
- * @return A new swapped either instance.
- */
- public Either<R, L> swap() {
- return new Either<R, L>(right, left);
- }
-
- /**
- * Returns an optional the will be {@link Optional#isPresent() present} is this is a left
- * instance.
- *
- * @return An optional value for the left.
- */
- public Optional<L> left() {
- return left;
- }
-
- /**
- * Returns an optional the will be {@link Optional#isPresent() present} is this is a right
- * instance.
- *
- * @return An optional value for the right.
- */
- public Optional<R> right() {
- return right;
- }
-
- /**
- * Returns {@code true} if this is a left instance.
- *
- * @return {@code true} if this is a left.
- */
- public boolean isLeft() {
- return left().isPresent();
- }
-
- /**
- * Returns {@code true} if this is a right instance.
- *
- * @return {@code true} if this is a right.
- */
- public boolean isRight() {
- return right().isPresent();
- }
-
- /**
- * Returns the underlying value if this is a left; otherwise, throws.
- *
- * @return The underlying value.
- * @throws IllegalStateException if this is a right instance.
- */
- public L getLeft() {
- return left().get();
- }
-
- /**
- * Returns the underlying value if this is a right; otherwise, throws.
- *
- * @return The underlying value.
- * @throws IllegalStateException if this is a right instance.
- */
- public R getRight() {
- return right().get();
- }
-
- /**
- * If this is a left, maps its value into a new left; otherwise just returns this right.
- *
- * @param transformer The transformation to apply to the left value.
- * @param <M> The type a left value will be mapped to.
- * @return The mapped left or else the right.
- */
- public <M> Either<M, R> mapLeft(Function<? super L, M> transformer) {
- if (isLeft()) {
- return left(transformer.apply(getLeft()));
- } else {
- @SuppressWarnings("unchecked") // I am a right so my left is never accessible
- Either<M, R> self = (Either<M, R>) this;
- return self;
- }
- }
-
- /**
- * If this is a right, maps its value into a new right; otherwise just returns this left.
- *
- * @param transformer The transformation to apply to the left value.
- * @param <M> The type a right value will be mapped to.
- * @return The mapped right or else the left.
- */
- public <M> Either<L, M> mapRight(Function<? super R, M> transformer) {
- if (isRight()) {
- return right(transformer.apply(getRight()));
- } else {
- @SuppressWarnings("unchecked") // I am a left so my right is never accessible
- Either<L, M> self = (Either<L, M>) this;
- return self;
- }
- }
-
- /**
- * Can transform either a left or a right into a result.
- *
- * @param <L> The left type.
- * @param <R> The right type.
- * @param <T> The transformation result type.
- */
- public abstract static class Transformer<L, R, T> implements Function<Either<L, R>, T> {
-
- /**
- * Maps left values to a result.
- *
- * @param left the left value to map.
- * @return The mapped value.
- */
- public abstract T mapLeft(L left);
-
- /**
- * Maps right values to a result.
- *
- * @param right the right value to map.
- * @return The mapped value.
- */
- public abstract T mapRight(R right);
-
- @Override
- public final T apply(Either<L, R> either) {
- return either.map(this);
- }
- }
-
- /**
- * Creates a transformer from left and right transformation functions.
- *
- * @param leftTransformer A transformer to process left values.
- * @param rightTransformer A transformer to process right values.
- * @param <L> The left type.
- * @param <R> The right type.
- * @param <T> The transformation result type.
- * @return A new transformer composed of left and right transformer functions.
- */
- public static <L, R, T> Transformer<L, R, T> transformer(
- final Function<? super L, T> leftTransformer,
- final Function<? super R, T> rightTransformer) {
-
- return new Transformer<L, R, T>() {
- @Override public T mapLeft(L item) {
- return leftTransformer.apply(item);
- }
- @Override public T mapRight(R item) {
- return rightTransformer.apply(item);
- }
- };
- }
-
- /**
- * Transforms this either instance to a value regardless of whether it is a left or a right.
- *
- * @param transformer The transformer to map this either instance.
- * @param <T> The type the transformer produces.
- * @return A value mapped by the transformer from this left or right instance.
- */
- public <T> T map(final Transformer<? super L, ? super R, T> transformer) {
- if (isLeft()) {
- return transformer.mapLeft(getLeft());
- } else {
- return transformer.mapRight(getRight());
- }
- }
-
- @Override
- public boolean equals(@Nullable Object o) {
- if (!(o instanceof Either)) {
- return false;
- }
- Either<?, ?> other = (Either<?, ?>) o;
- return Objects.equal(left, other.left)
- && Objects.equal(right, other.right);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(left, right);
- }
-
- @Override
- public String toString() {
- if (isLeft()) {
- return String.format("Left(%s)", getLeft());
- } else {
- return String.format("Right(%s)", getRight());
- }
- }
-
- /**
- * Creates a left either instance.
- *
- * @param value The left value to wrap - may not be null.
- * @param <L> The left type.
- * @param <R> The right type.
- * @return A left either instance wrapping {@code value}.
- */
- public static <L, R> Either<L, R> left(L value) {
- return new Either<L, R>(Optional.of(value), Optional.<R>absent());
- }
-
- /**
- * Creates a right either instance.
- *
- * @param value The right value to wrap - may not be null.
- * @param <L> The left type.
- * @param <R> The right type.
- * @return A right either instance wrapping {@code value}.
- */
- public static <L, R> Either<L, R> right(R value) {
- return new Either<L, R>(Optional.<L>absent(), Optional.of(value));
- }
-
- /**
- * Extracts all the lefts from a sequence of eithers lazily.
- *
- * @param results A sequence of either's to process.
- * @param <L> The left type.
- * @param <R> The right type.
- * @return A lazy iterable that will produce the lefts present in results in order.
- */
- public static <L, R> Iterable<L> lefts(Iterable<Either<L, R>> results) {
- return Optional.presentInstances(Iterables.transform(results,
- new Function<Either<L, R>, Optional<L>>() {
- @Override public Optional<L> apply(Either<L, R> item) {
- return item.left();
- }
- }));
- }
-
- /**
- * Extracts all the rights from a sequence of eithers lazily.
- *
- * @param results A sequence of either's to process.
- * @param <L> The left type.
- * @param <R> The right type.
- * @return A lazy iterable that will produce the rights present in results in order.
- */
- public static <L, R> Iterable<R> rights(Iterable<Either<L, R>> results) {
- return Optional.presentInstances(Iterables.transform(results,
- new Function<Either<L, R>, Optional<R>>() {
- @Override public Optional<R> apply(Either<L, R> item) {
- return item.right();
- }
- }));
- }
-
- /**
- * A convenience method equivalent to calling {@code guard(work, exceptionType)}.
- */
- public static <X extends Exception, R> Either<X, R> guard(
- Class<X> exceptionType,
- ExceptionalSupplier<R, X> work) {
-
- @SuppressWarnings("unchecked")
- Either<X, R> either = guard(work, exceptionType);
- return either;
- }
-
- /**
- * A convenience method equivalent to calling
- * {@code guard(Lists.asList(execpetionType, rest), work)}.
- */
- public static <X extends Exception, R> Either<X, R> guard(
- ExceptionalSupplier<R, X> work,
- Class<? extends X> exceptionType,
- Class<? extends X>... rest) {
-
- return guard(Lists.asList(exceptionType, rest), work);
- }
-
- /**
- * Thrown when guarded work throws an unguarded exception. The {@link #getCause() cause} will
- * contain the original unguarded exception.
- */
- public static class UnguardedException extends RuntimeException {
- public UnguardedException(Throwable cause) {
- super(cause);
- }
- }
-
- /**
- * Converts work that can throw exceptions into an either with a left exception base type. This
- * can be useful to fold an exception throwing library call into an either processing style
- * pipeline.
- *
- * @param exceptionTypes The expected exception types.
- * @param work The work to perform to get a result produce an error.
- * @param <X> The base error type.
- * @param <R> The success type.
- * @return An either wrapping the result of performing {@code work}.
- * @throws UnguardedException if work throws an unguarded exception type.
- */
- public static <X extends Exception, R> Either<X, R> guard(
- Iterable<Class<? extends X>> exceptionTypes,
- ExceptionalSupplier<R, X> work) {
-
- try {
- return right(work.get());
- // We're explicitly dealing with generic exception types here by design.
- // SUPPRESS CHECKSTYLE RegexpSinglelineJava
- } catch (Exception e) {
- for (Class<? extends X> exceptionType : exceptionTypes) {
- if (exceptionType.isInstance(e)) {
- X exception = exceptionType.cast(e);
- return left(exception);
- }
- }
- throw new UnguardedException(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/base/ExceptionTransporter.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/base/ExceptionTransporter.java b/commons/src/main/java/org/apache/aurora/common/base/ExceptionTransporter.java
deleted file mode 100644
index e5cb60d..0000000
--- a/commons/src/main/java/org/apache/aurora/common/base/ExceptionTransporter.java
+++ /dev/null
@@ -1,84 +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;
-
-import com.google.common.base.Function;
-
-/**
- * A utility for transporting checked exceptions across boundaries that do not allow for checked
- * exception propagation.
- *
- * @param <E> The type of checked exception the ExceptionTransported can transport
- *
- * @author John Sirois
- */
-public class ExceptionTransporter<E extends Exception> {
-
- /**
- * An exception wrapper used to transport checked exceptions. Never leaves an
- * {@link ExceptionTransporter#guard(com.google.common.base.Function)} call.
- */
- private static final class TransportingException extends RuntimeException {
- private TransportingException(Exception cause) {
- super("It is a usage error to see this message!", cause);
- }
- }
-
- /**
- * Guards a unit of work that internally can generate checked exceptions. Callers wrap up the
- * work in a function that rethrows any checked exceptions using the supplied
- * ExceptionTransporter. Guard will ensure the original exception is unwrapped an re-thrown.
- *
- * @param work The unit of work that guards its checked exceptions.
- * @param <T> The type returned by the unit of work when it successfully completes.
- * @param <X> The type of checked exception that the unit of work wishes to guard.
- * @return the result of the unit of work if no excpetions are thrown
- * @throws X when the unit of work uses the ExceptionTransporter to throw a checked exception
- */
- public static <T, X extends Exception> T guard(Function<ExceptionTransporter<X>, T> work)
- throws X {
-
- try {
- return work.apply(new ExceptionTransporter<X>());
- } catch (TransportingException e) {
- @SuppressWarnings("unchecked")
- X cause = (X) e.getCause();
- throw cause;
- }
- }
-
- /**
- * Throws the given {@code checked} exception across a boundary that does not allow checked
- * exceptions. Although a RuntimeException is returned by this method signature, the method never
- * actually completes normally. The return type does allow the following usage idiom however:
- * <pre>
- * public String apply(ExceptionTransporter transporter) {
- * try {
- * return doChecked();
- * } catch (CheckedException e) {
- * // Although transport internally throws and does not return, we satisfy the compiler that
- * // our method returns a value or throws by pretending to throw the RuntimeException that
- * // never actually gets returned by transporter.transport(...)
- * throw transporter.transport(e);
- * }
- * }
- * </pre>
- *
- * @param checked The checked exception to transport.
- * @return A RuntimeException that can be thrown to satisfy the compiler at the call site
- */
- public RuntimeException transport(E checked) {
- throw new TransportingException(checked);
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/base/ExceptionalFunctions.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/base/ExceptionalFunctions.java b/commons/src/main/java/org/apache/aurora/common/base/ExceptionalFunctions.java
deleted file mode 100644
index f06c66c..0000000
--- a/commons/src/main/java/org/apache/aurora/common/base/ExceptionalFunctions.java
+++ /dev/null
@@ -1,153 +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;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Utility functions for working with exceptional functions.
- *
- * @author John Sirois
- */
-public final class ExceptionalFunctions {
-
- private ExceptionalFunctions() {
- // utility
- }
-
- /**
- * Returns an {@link ExceptionalSupplier}/{@link java.util.concurrent.Callable} object that will
- * return the result of {@code function} applied to {@code argument}. Evaluation is lazy and
- * un-memoized.
- */
- public static <S, T, E extends Exception> CallableExceptionalSupplier<T, E> curry(
- final ExceptionalFunction<S, T, E> function, final S argument) {
-
- return new CallableExceptionalSupplier<T, E>() {
- @Override
- public T get() throws E {
- return function.apply(argument);
- }
- };
- }
-
- /**
- * Returns an ExceptionalFunction that is a composition of multiple ExceptionalFunctions.
- */
- public static <T, E extends Exception> ExceptionalFunction<T, T, E> compose(
- final Iterable<ExceptionalFunction<T, T, E>> functions) {
- return new ExceptionalFunction<T, T, E>() {
- @Override
- public T apply(T input) throws E {
- T result = input;
- for (ExceptionalFunction<T, T, E> f : functions) {
- result = f.apply(result);
- }
- return result;
- }
- };
- }
-
- /**
- * Returns a List of ExceptionalFunctions from variable number of ExceptionalFunctions.
- */
- public static <T, E extends Exception> ExceptionalFunction<T, T, E> compose(
- ExceptionalFunction<T, T, E> function, ExceptionalFunction<T, T, E>... functions) {
- return compose(ImmutableList.<ExceptionalFunction<T, T, E>>builder()
- .add(function)
- .add(functions)
- .build());
- }
-
- /**
- * Returns a new ExceptionalFunction which composes two ExceptionalFunctions of compatible types.
- *
- * @param second function to apply to result of first.
- * @param first function to apply to input item.
- * @param <A> input type of first.
- * @param <B> input type of second.
- * @param <C> output type of second.
- * @param <E> exception type.
- * @return new composed ExceptionalFunction.
- */
- public static <A, B, C, E extends Exception> ExceptionalFunction<A, C, E> compose(
- final ExceptionalFunction<B, C, ? extends E> second,
- final ExceptionalFunction<A, ? extends B, ? extends E> first) {
- return new ExceptionalFunction<A, C, E>() {
- @Override
- public C apply(A item) throws E {
- return second.apply(first.apply(item));
- }
- };
- }
-
- /**
- * Builds an ExceptionalFunction from {@link com.google.common.base.Function}.
- *
- * @param function guava Function.
- * @param <S> input type.
- * @param <T> output type.
- * @param <E> exception type.
- * @return new ExceptionalFunction.
- */
- public static <S, T, E extends Exception> ExceptionalFunction<S, T, E> forFunction(
- final com.google.common.base.Function<S, T> function) {
- return new ExceptionalFunction<S, T, E>() {
- @Override
- public T apply(S item) {
- return function.apply(item);
- }
- };
- }
-
- /**
- * Builds an ExceptionalFunction from a return value. The returned ExceptionalFunction will always
- * return the given value.
- *
- * @param value value to return.
- * @param <S> input type.
- * @param <T> output type.
- * @param <E> exception type.
- * @return new ExceptionalFunction.
- */
- public static <S, T, E extends Exception> ExceptionalFunction<S, T, E> constant(
- final T value) {
- return new ExceptionalFunction<S, T, E>() {
- @Override
- public T apply(S item) throws E {
- return value;
- }
- };
- }
-
- /**
- * Builds an ExceptionalFunction from an Exception. The returned ExceptionalFunction will always
- * throw the given Exception.
- *
- * @param exception exception to throw.
- * @param <S> input type.
- * @param <T> output type.
- * @param <E> exception type.
- * @return new ExceptionalFunction.
- */
- public static <S, T, E extends Exception> ExceptionalFunction<S, T, E> forException(
- final E exception) {
- return new ExceptionalFunction<S, T, E>() {
- @Override
- public T apply(S item) throws E {
- throw exception;
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/base/SupplierE.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/base/SupplierE.java b/commons/src/main/java/org/apache/aurora/common/base/SupplierE.java
deleted file mode 100644
index ecad43e..0000000
--- a/commons/src/main/java/org/apache/aurora/common/base/SupplierE.java
+++ /dev/null
@@ -1,25 +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 for suppliers that throw multiple exception types.
- *
- * @param <T> The supplied type.
- *
- * @author John Sirois
- */
-public interface SupplierE<T> extends ExceptionalSupplier<T, Exception> {
- // typedef
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/collections/Bits.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/collections/Bits.java b/commons/src/main/java/org/apache/aurora/common/collections/Bits.java
deleted file mode 100644
index f07e04a..0000000
--- a/commons/src/main/java/org/apache/aurora/common/collections/Bits.java
+++ /dev/null
@@ -1,116 +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.collections;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Convenience class for doing bit-level operations on ints and longs.
- *
- * @author William Farner
- */
-public final class Bits {
-
- private static final int LSB = 0;
- private static final int INT_MSB = 31;
- private static final int LONG_MSB = 63;
-
- private Bits() {
- // Utility.
- }
-
- /**
- * Tests whether a bit is set in an int value.
- *
- * @param value The bit field to test.
- * @param bit The index of the bit to test, where bit 0 is the LSB.
- * @return {@code true} if the bit is set, {@code false} otherwise.
- */
- public static boolean isBitSet(int value, int bit) {
- Preconditions.checkState(bit >= LSB);
- Preconditions.checkState(bit <= INT_MSB);
- int mask = 1 << bit;
- return (value & mask) != 0;
- }
-
- /**
- * Tests whether a bit is set in a long value.
- *
- * @param value The bit field to test.
- * @param bit The index of the bit to test, where bit 0 is the LSB.
- * @return {@code true} if the bit is set, {@code false} otherwise.
- */
- public static boolean isBitSet(long value, int bit) {
- Preconditions.checkState(bit >= LSB);
- Preconditions.checkState(bit <= LONG_MSB);
- long mask = 1L << bit;
- return (value & mask) != 0;
- }
-
- /**
- * Sets a bit in an int value.
- *
- * @param value The bit field to modify.
- * @param bit The index of the bit to set, where bit 0 is the LSB.
- * @return The original value, with the indexed bit set.
- */
- public static int setBit(int value, int bit) {
- Preconditions.checkState(bit >= LSB);
- Preconditions.checkState(bit <= INT_MSB);
- int mask = 1 << bit;
- return value | mask;
- }
-
- /**
- * Sets a bit in a long value.
- *
- * @param value The bit field to modify.
- * @param bit The index of the bit to set, where bit 0 is the LSB.
- * @return The original value, with the indexed bit set.
- */
- public static long setBit(long value, int bit) {
- Preconditions.checkState(bit >= LSB);
- Preconditions.checkState(bit <= LONG_MSB);
- long mask = 1L << bit;
- return value | mask;
- }
-
- /**
- * Clears a bit in an int value.
- *
- * @param value The bit field to modify.
- * @param bit The index of the bit to clear, where bit 0 is the LSB.
- * @return The original value, with the indexed bit clear.
- */
- public static int clearBit(int value, int bit) {
- Preconditions.checkState(bit >= LSB);
- Preconditions.checkState(bit <= INT_MSB);
- int mask = ~setBit(0, bit);
- return value & mask;
- }
-
- /**
- * Clears a bit in a long value.
- *
- * @param value The bit field to modify.
- * @param bit The index of the bit to clear, where bit 0 is the LSB.
- * @return The original value, with the indexed bit clear.
- */
- public static long clearBit(long value, int bit) {
- Preconditions.checkState(bit >= LSB);
- Preconditions.checkState(bit <= LONG_MSB);
- long mask = ~setBit(0L, bit);
- return value & mask;
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/common/webassets/bootstrap/BootstrapModule.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/common/webassets/bootstrap/BootstrapModule.java b/commons/src/main/java/org/apache/aurora/common/common/webassets/bootstrap/BootstrapModule.java
deleted file mode 100644
index 9cb6f54..0000000
--- a/commons/src/main/java/org/apache/aurora/common/common/webassets/bootstrap/BootstrapModule.java
+++ /dev/null
@@ -1,90 +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.common.webassets.bootstrap;
-
-import com.google.common.io.Resources;
-import com.google.common.net.MediaType;
-import com.google.inject.AbstractModule;
-
-import org.apache.aurora.common.application.http.Registration;
-
-/**
- * A binding module to register bootstrap HTTP assets.
- */
-public final class BootstrapModule extends AbstractModule {
- /**
- * Enum for available Bootstrap versions to choose from.
- */
- public enum BootstrapVersion {
- VERSION_2_1_1 ("2.1.1"),
- VERSION_2_3_2 ("2.3.2");
-
- private final String version;
-
- BootstrapVersion(String s) {
- version = s;
- }
- }
-
- private final String version;
-
- /**
- * Default constructor.
- */
- public BootstrapModule() {
- this(BootstrapVersion.VERSION_2_1_1);
- }
-
- /**
- * BootstrapModule Constructor.
- *
- * @param version supplies the bootstrap version to select.
- */
- public BootstrapModule(BootstrapVersion version) {
- this.version = version.version;
- }
-
- private void register(String mountPath, String resourcePath, String contentType) {
- Registration.registerHttpAsset(
- binder(),
- "/" + mountPath,
- Resources.getResource(BootstrapModule.class, resourcePath),
- contentType,
- true);
- }
-
- @Override
- protected void configure() {
- register(
- "css/bootstrap-responsive.min.css",
- version + "/css/bootstrap-responsive.min.css",
- MediaType.CSS_UTF_8.toString());
- register(
- "css/bootstrap.min.css",
- version + "/css/bootstrap.min.css",
- MediaType.CSS_UTF_8.toString());
- register(
- "img/glyphicons-halflings-white.png",
- version + "/img/glyphicons-halflings-white.png",
- MediaType.PNG.toString());
- register(
- "img/glyphicons-halflings.png",
- version + "/img/glyphicons-halflings.png",
- MediaType.PNG.toString());
- register(
- "js/bootstrap.min.js",
- version + "/js/bootstrap.min.js",
- MediaType.JAVASCRIPT_UTF_8.toString());
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/common/webassets/jquery/JQueryModule.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/common/webassets/jquery/JQueryModule.java b/commons/src/main/java/org/apache/aurora/common/common/webassets/jquery/JQueryModule.java
deleted file mode 100644
index a8e4524..0000000
--- a/commons/src/main/java/org/apache/aurora/common/common/webassets/jquery/JQueryModule.java
+++ /dev/null
@@ -1,36 +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.common.webassets.jquery;
-
-import com.google.common.io.Resources;
-import com.google.common.net.MediaType;
-import com.google.inject.AbstractModule;
-
-import org.apache.aurora.common.application.http.Registration;
-
-/**
- * A binding module to register jQuery HTTP assets.
- */
-public final class JQueryModule extends AbstractModule {
-
- @Override
- protected void configure() {
- Registration.registerHttpAsset(
- binder(),
- "/js/jquery.min.js",
- Resources.getResource(JQueryModule.class, "js/jquery-1.8.2.min.js"),
- MediaType.JAVASCRIPT_UTF_8.toString(),
- true);
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/inject/DefaultProvider.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/inject/DefaultProvider.java b/commons/src/main/java/org/apache/aurora/common/inject/DefaultProvider.java
deleted file mode 100644
index 38fbe4d..0000000
--- a/commons/src/main/java/org/apache/aurora/common/inject/DefaultProvider.java
+++ /dev/null
@@ -1,166 +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.inject;
-
-import com.google.common.base.Preconditions;
-import com.google.inject.AbstractModule;
-import com.google.inject.Binder;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.Provider;
-import com.google.inject.TypeLiteral;
-import com.google.inject.name.Named;
-import com.google.inject.name.Names;
-
-/**
- * Provider that has a default value which can be overridden.
- *
- * The intended use of this class is:
- * <pre>
- * Default installer:
- * bind(DefaultProvider.makeDefaultKey(Runnable.class, "mykey").toInstance(defaultRunnable);
- * DefaultProvider.bindOrElse(Runnable.class, "mykey", binder());
- *
- * Custom override:
- * bind(DefaultProvider.makeCustomKey(Runnable.class, "mykey")).toInstance(myCustomRunnable);
- *
- * Injection:
- * {@literal Inject} Named("myKey") Runnable runnable;
- *
- * </pre>
- *
- * @param <T> the type of object this provides
- *
- * @author William Farner
- * @author John Sirois
- */
-public class DefaultProvider<T> implements Provider<T> {
- private static final String DEFAULT_BINDING_KEY_SUFFIX = "_default";
- private static final String CUSTOM_BINDING_KEY_SUFFIX = "_custom";
-
- private final Key<T> defaultProviderKey;
- private final Key<T> customProviderKey;
-
- private Injector injector;
-
- public DefaultProvider(Key<T> defaultProviderKey, Key<T> customProviderKey) {
- this.defaultProviderKey = Preconditions.checkNotNull(defaultProviderKey);
- this.customProviderKey = Preconditions.checkNotNull(customProviderKey);
- Preconditions.checkArgument(!defaultProviderKey.equals(customProviderKey));
- }
-
- @Inject
- public void setInjector(Injector injector) {
- this.injector = injector;
- }
-
- @Override
- public T get() {
- Preconditions.checkNotNull(injector);
- return injector.getBindings().containsKey(customProviderKey)
- ? injector.getInstance(customProviderKey)
- : injector.getInstance(defaultProviderKey);
- }
-
- /**
- * Creates a DefaultProvider and installs a new module to {@code binder}, which will serve as
- * an indirection layer for swapping the default binding with a custom one.
- *
- * @param customBinding The custom binding key.
- * @param defaultBinding The default binding key.
- * @param exposedBinding The exposed binding key.
- * @param binder The binder to install bindings to.
- * @param <T> The type of binding to make.
- */
- public static <T> void bindOrElse(final Key<T> customBinding, final Key<T> defaultBinding,
- final Key<T> exposedBinding, Binder binder) {
- Preconditions.checkNotNull(customBinding);
- Preconditions.checkNotNull(defaultBinding);
- Preconditions.checkNotNull(exposedBinding);
- Preconditions.checkArgument(!customBinding.equals(defaultBinding)
- && !customBinding.equals(exposedBinding));
-
- binder.install(new AbstractModule() {
- @Override protected void configure() {
- Provider<T> defaultProvider = new DefaultProvider<T>(defaultBinding, customBinding);
- requestInjection(defaultProvider);
- bind(exposedBinding).toProvider(defaultProvider);
- }
- });
- }
-
- /**
- * Convenience function for creating and installing a DefaultProvider. This will use internal
- * suffixes to create names for the custom and default bindings. When bound this way, callers
- * should use one of the functions such as {@link #makeDefaultBindingKey(String)} to set default
- * and custom bindings.
- *
- * @param type The type of object to bind.
- * @param exposedKey The exposed key.
- * @param binder The binder to install to.
- * @param <T> The type of binding to make.
- */
- public static <T> void bindOrElse(TypeLiteral<T> type, String exposedKey, Binder binder) {
- bindOrElse(Key.get(type, Names.named(makeCustomBindingKey(exposedKey))),
- Key.get(type, Names.named(makeDefaultBindingKey(exposedKey))),
- Key.get(type, Names.named(exposedKey)),
- binder);
- }
-
- /**
- * Convenience method for calls to {@link #bindOrElse(TypeLiteral, String, Binder)}, that are not
- * binding a parameterized type.
- *
- * @param type The class of the object to bind.
- * @param exposedKey The exposed key.
- * @param binder The binder to install to.
- * @param <T> The type of binding to make.
- */
- public static <T> void bindOrElse(Class<T> type, String exposedKey, Binder binder) {
- bindOrElse(TypeLiteral.get(type), exposedKey, binder);
- }
-
- public static String makeDefaultBindingKey(String rootKey) {
- return rootKey + DEFAULT_BINDING_KEY_SUFFIX;
- }
-
- public static Named makeDefaultBindingName(String rootKey) {
- return Names.named(makeDefaultBindingKey(rootKey));
- }
-
- public static <T> Key<T> makeDefaultKey(TypeLiteral<T> type, String rootKey) {
- return Key.get(type, makeDefaultBindingName(rootKey));
- }
-
- public static <T> Key<T> makeDefaultKey(Class<T> type, String rootKey) {
- return makeDefaultKey(TypeLiteral.get(type), rootKey);
- }
-
- public static String makeCustomBindingKey(String rootKey) {
- return rootKey + CUSTOM_BINDING_KEY_SUFFIX;
- }
-
- public static Named makeCustomBindingName(String rootKey) {
- return Names.named(makeCustomBindingKey(rootKey));
- }
-
- public static <T> Key<T> makeCustomKey(Class<T> type, String rootKey) {
- return Key.get(type, makeCustomBindingName(rootKey));
- }
-
- public static <T> Key<T> makeCustomKey(TypeLiteral<T> type, String rootKey) {
- return Key.get(type, makeCustomBindingName(rootKey));
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/356eeac9/commons/src/main/java/org/apache/aurora/common/inject/ProviderMethodModule.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/inject/ProviderMethodModule.java b/commons/src/main/java/org/apache/aurora/common/inject/ProviderMethodModule.java
deleted file mode 100644
index 7543ff1..0000000
--- a/commons/src/main/java/org/apache/aurora/common/inject/ProviderMethodModule.java
+++ /dev/null
@@ -1,32 +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.inject;
-
-import com.google.inject.AbstractModule;
-
-/**
- * A convenience base class for modules that do all their binding via provider methods.
- *
- * @author John Sirois
- */
-public abstract class ProviderMethodModule extends AbstractModule {
-
- /**
- * Does no binding; subclasses should implement provider methods.
- */
- @Override
- protected final void configure() {
- // noop
- }
-}