You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by ma...@apache.org on 2014/02/28 22:58:27 UTC
[1/2] Renamed Quota to ResourceAggregate.
Repository: incubator-aurora
Updated Branches:
refs/heads/master c2614529b -> 130bc4873
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/test/python/apache/aurora/client/api/test_updater.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/api/test_updater.py b/src/test/python/apache/aurora/client/api/test_updater.py
index 81406a0..c3e259c 100644
--- a/src/test/python/apache/aurora/client/api/test_updater.py
+++ b/src/test/python/apache/aurora/client/api/test_updater.py
@@ -40,7 +40,7 @@ from gen.apache.aurora.ttypes import (
LockValidation,
Package,
PopulateJobResult,
- Quota,
+ ResourceAggregate,
Response,
ResponseCode,
Result,
@@ -220,11 +220,11 @@ class UpdaterTest(TestCase):
def expect_quota_check(self, num_released, num_acquired, response_code=None, prod=True):
response_code = ResponseCode.OK if response_code is None else response_code
response = Response(responseCode=response_code, message='test')
- released = CapacityRequest(Quota(
+ released = CapacityRequest(ResourceAggregate(
numCpus=num_released * self._num_cpus,
ramMb=num_released * self._num_ram,
diskMb=num_released * self._num_disk))
- acquired = CapacityRequest(Quota(
+ acquired = CapacityRequest(ResourceAggregate(
numCpus=num_acquired * self._num_cpus,
ramMb=num_acquired * self._num_ram,
diskMb=num_acquired * self._num_disk))
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/test/python/apache/aurora/client/cli/test_quota.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_quota.py b/src/test/python/apache/aurora/client/cli/test_quota.py
index f7d3585..44afd74 100644
--- a/src/test/python/apache/aurora/client/cli/test_quota.py
+++ b/src/test/python/apache/aurora/client/cli/test_quota.py
@@ -21,7 +21,7 @@ from apache.aurora.client.cli.util import AuroraClientCommandTest, FakeAuroraCom
from gen.apache.aurora.ttypes import (
GetQuotaResult,
- Quota,
+ ResourceAggregate,
)
from mock import patch
@@ -33,7 +33,7 @@ class TestGetQuotaCommand(AuroraClientCommandTest):
api = mock_context.get_api('west')
response = cls.create_simple_success_response()
response.result.getQuotaResult = GetQuotaResult()
- response.result.getQuotaResult.quota = Quota()
+ response.result.getQuotaResult.quota = ResourceAggregate()
response.result.getQuotaResult.quota.numCpus = 5
response.result.getQuotaResult.quota.ramMb = 20480
response.result.getQuotaResult.quota.diskMb = 40960
@@ -45,11 +45,11 @@ class TestGetQuotaCommand(AuroraClientCommandTest):
api = mock_context.get_api('west')
response = cls.create_simple_success_response()
response.result.getQuotaResult = GetQuotaResult()
- response.result.getQuotaResult.quota = Quota()
+ response.result.getQuotaResult.quota = ResourceAggregate()
response.result.getQuotaResult.quota.numCpus = 5
response.result.getQuotaResult.quota.ramMb = 20480
response.result.getQuotaResult.quota.diskMb = 40960
- response.result.getQuotaResult.consumed = Quota()
+ response.result.getQuotaResult.consumed = ResourceAggregate()
response.result.getQuotaResult.consumed.numCpus = 1
response.result.getQuotaResult.consumed.ramMb = 1024
response.result.getQuotaResult.consumed.diskMb = 2048
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/test/resources/org/apache/aurora/gen/api.thrift.md5
----------------------------------------------------------------------
diff --git a/src/test/resources/org/apache/aurora/gen/api.thrift.md5 b/src/test/resources/org/apache/aurora/gen/api.thrift.md5
index fafb510..4e6c51d 100644
--- a/src/test/resources/org/apache/aurora/gen/api.thrift.md5
+++ b/src/test/resources/org/apache/aurora/gen/api.thrift.md5
@@ -1 +1 @@
-cbc45c78b7a0a8f0c7cd0beb153d5b37
+7645e899bf5b7f8ad2dcdbecae7f91e1
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/test/resources/org/apache/aurora/gen/storage.thrift.md5
----------------------------------------------------------------------
diff --git a/src/test/resources/org/apache/aurora/gen/storage.thrift.md5 b/src/test/resources/org/apache/aurora/gen/storage.thrift.md5
index 99ab202..9b94883 100644
--- a/src/test/resources/org/apache/aurora/gen/storage.thrift.md5
+++ b/src/test/resources/org/apache/aurora/gen/storage.thrift.md5
@@ -1 +1 @@
-ea63222d3337666cf221900e4fc8519b
+026d38531456b814c187cc19d7e24396
[2/2] git commit: Renamed Quota to ResourceAggregate.
Posted by ma...@apache.org.
Renamed Quota to ResourceAggregate.
Updated client to use the new struct.
Testing Done:
Successfully ran:
gradle clean build && ./pants src/test/python/apache/aurora/client:all
On a local scheduler tested /scheduler* and /quotas end points.
Will run end to end test tonight.
Bugs closed: AURORA-105
Reviewed at https://reviews.apache.org/r/18546/
Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/130bc487
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/130bc487
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/130bc487
Branch: refs/heads/master
Commit: 130bc487329337f51c63594736c3221e6ad0af3d
Parents: c261452
Author: Suman Karumuri <ma...@apache.org>
Authored: Fri Feb 28 13:51:01 2014 -0800
Committer: Suman Karumuri <sk...@twitter.com>
Committed: Fri Feb 28 13:51:01 2014 -0800
----------------------------------------------------------------------
build.gradle | 2 +-
.../scheduler/configuration/Resources.java | 2 +-
.../apache/aurora/scheduler/http/Quotas.java | 23 +++----
.../local/IsolatedSchedulerModule.java | 4 +-
.../scheduler/quota/QuotaCheckResult.java | 4 +-
.../aurora/scheduler/quota/QuotaInfo.java | 20 +++---
.../aurora/scheduler/quota/QuotaManager.java | 29 +++++----
.../apache/aurora/scheduler/quota/Quotas.java | 65 -------------------
.../scheduler/quota/ResourceAggregates.java | 66 +++++++++++++++++++
.../scheduler/stats/AsyncStatsModule.java | 6 +-
.../aurora/scheduler/stats/ResourceCounter.java | 6 +-
.../aurora/scheduler/stats/SlotSizeCounter.java | 46 ++++++-------
.../scheduler/storage/ForwardingStore.java | 8 +--
.../aurora/scheduler/storage/QuotaStore.java | 10 +--
.../scheduler/storage/log/LogStorage.java | 6 +-
.../storage/log/SnapshotStoreImpl.java | 9 ++-
.../scheduler/storage/mem/MemQuotaStore.java | 10 +--
.../storage/testing/StorageTestUtil.java | 4 +-
.../thrift/SchedulerThriftInterface.java | 14 ++--
.../python/apache/aurora/client/api/__init__.py | 4 +-
.../apache/aurora/client/api/quota_check.py | 8 +--
src/main/python/apache/aurora/client/api/sla.py | 1 -
.../python/apache/aurora/client/api/updater.py | 1 -
.../thrift/org/apache/aurora/gen/api.thrift | 10 ++-
.../thrift/org/apache/aurora/gen/storage.thrift | 4 +-
.../scheduler/quota/QuotaCheckResultTest.java | 68 ++++++++++----------
.../scheduler/quota/QuotaManagerImplTest.java | 42 ++++++------
.../scheduler/stats/SlotSizeCounterTest.java | 26 ++++----
.../storage/backup/StorageBackupTest.java | 4 +-
.../scheduler/storage/log/LogStorageTest.java | 8 ++-
.../storage/log/SnapshotStoreImplTest.java | 9 +--
.../thrift/SchedulerThriftInterfaceTest.java | 34 +++++-----
.../aurora/scheduler/thrift/ThriftIT.java | 7 +-
.../scheduler/thrift/aop/ForwardingThrift.java | 10 +--
.../aurora/client/api/test_quota_check.py | 40 ++++++------
.../aurora/client/api/test_scheduler_client.py | 4 +-
.../python/apache/aurora/client/api/test_sla.py | 1 -
.../apache/aurora/client/api/test_updater.py | 6 +-
.../apache/aurora/client/cli/test_quota.py | 8 +--
.../org/apache/aurora/gen/api.thrift.md5 | 2 +-
.../org/apache/aurora/gen/storage.thrift.md5 | 2 +-
41 files changed, 331 insertions(+), 302 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index e5cd831..5177191 100644
--- a/build.gradle
+++ b/build.gradle
@@ -235,7 +235,7 @@ task generateSources(dependsOn: 'bootstrapThrift') {
}
// These are the 'root' structs, the tool recursively generates all composed structs.
// TODO(wfarner): Change codegen tool to generate for all structs in a thrift file.
- ['JobConfiguration', 'Lock', 'ScheduledTask', 'Quota'].each {
+ ['JobConfiguration', 'Lock', 'ResourceAggregate', 'ScheduledTask'].each {
def structName = it
exec {
executable = 'python'
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/configuration/Resources.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/configuration/Resources.java b/src/main/java/org/apache/aurora/scheduler/configuration/Resources.java
index a200875..5e3015d 100644
--- a/src/main/java/org/apache/aurora/scheduler/configuration/Resources.java
+++ b/src/main/java/org/apache/aurora/scheduler/configuration/Resources.java
@@ -49,7 +49,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* A container for multiple resource vectors.
- * TODO(wfarner): Collapse this in with Quotas.
+ * TODO(wfarner): Collapse this in with ResourceAggregates AURORA-105.
*/
public class Resources {
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/http/Quotas.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/Quotas.java b/src/main/java/org/apache/aurora/scheduler/http/Quotas.java
index 5f7e34e..da02077 100644
--- a/src/main/java/org/apache/aurora/scheduler/http/Quotas.java
+++ b/src/main/java/org/apache/aurora/scheduler/http/Quotas.java
@@ -34,7 +34,7 @@ import com.google.common.collect.Maps;
import org.apache.aurora.scheduler.storage.Storage;
import org.apache.aurora.scheduler.storage.Storage.StoreProvider;
import org.apache.aurora.scheduler.storage.Storage.Work;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.codehaus.jackson.annotate.JsonProperty;
/**
@@ -61,11 +61,11 @@ public class Quotas {
return storage.weaklyConsistentRead(new Work.Quiet<Response>() {
@Override
public Response apply(StoreProvider storeProvider) {
- Map<String, IQuota> quotas;
+ Map<String, IResourceAggregate> quotas;
if (role == null) {
quotas = storeProvider.getQuotaStore().fetchQuotas();
} else {
- Optional<IQuota> quota = storeProvider.getQuotaStore().fetchQuota(role);
+ Optional<IResourceAggregate> quota = storeProvider.getQuotaStore().fetchQuota(role);
if (quota.isPresent()) {
quotas = ImmutableMap.of(role, quota.get());
} else {
@@ -78,19 +78,20 @@ public class Quotas {
});
}
- private static final Function<IQuota, QuotaBean> TO_BEAN = new Function<IQuota, QuotaBean>() {
- @Override
- public QuotaBean apply(IQuota quota) {
- return new QuotaBean(quota.getNumCpus(), quota.getRamMb(), quota.getDiskMb());
- }
- };
+ private static final Function<IResourceAggregate, ResourceAggregateBean> TO_BEAN =
+ new Function<IResourceAggregate, ResourceAggregateBean>() {
+ @Override
+ public ResourceAggregateBean apply(IResourceAggregate quota) {
+ return new ResourceAggregateBean(quota.getNumCpus(), quota.getRamMb(), quota.getDiskMb());
+ }
+ };
- private static final class QuotaBean {
+ private static final class ResourceAggregateBean {
private final double cpu;
private final long ramMb;
private final long diskMb;
- private QuotaBean(double cpu, long ramMb, long diskMb) {
+ private ResourceAggregateBean(double cpu, long ramMb, long diskMb) {
this.cpu = cpu;
this.ramMb = ramMb;
this.diskMb = diskMb;
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/local/IsolatedSchedulerModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/local/IsolatedSchedulerModule.java b/src/main/java/org/apache/aurora/scheduler/local/IsolatedSchedulerModule.java
index 6ff70af..fe2965d 100644
--- a/src/main/java/org/apache/aurora/scheduler/local/IsolatedSchedulerModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/local/IsolatedSchedulerModule.java
@@ -50,7 +50,7 @@ import org.apache.aurora.gen.ExecutorConfig;
import org.apache.aurora.gen.Identity;
import org.apache.aurora.gen.JobConfiguration;
import org.apache.aurora.gen.Package;
-import org.apache.aurora.gen.Quota;
+import org.apache.aurora.gen.ResourceAggregate;
import org.apache.aurora.gen.Response;
import org.apache.aurora.gen.SessionKey;
import org.apache.aurora.gen.TaskConfig;
@@ -180,7 +180,7 @@ public class IsolatedSchedulerModule extends AbstractModule {
try {
thrift.setQuota(
"mesos",
- new Quota(2.0 * 1000000, 100000000, 100000000),
+ new ResourceAggregate(2.0 * 1000000, 100000000, 100000000),
new SessionKey());
} catch (TException e) {
throw Throwables.propagate(e);
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/quota/QuotaCheckResult.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/quota/QuotaCheckResult.java b/src/main/java/org/apache/aurora/scheduler/quota/QuotaCheckResult.java
index c898535..e4c215b 100644
--- a/src/main/java/org/apache/aurora/scheduler/quota/QuotaCheckResult.java
+++ b/src/main/java/org/apache/aurora/scheduler/quota/QuotaCheckResult.java
@@ -18,7 +18,7 @@ package org.apache.aurora.scheduler.quota;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -84,7 +84,7 @@ public class QuotaCheckResult {
return details;
}
- static QuotaCheckResult greaterOrEqual(IQuota a, IQuota b) {
+ static QuotaCheckResult greaterOrEqual(IResourceAggregate a, IResourceAggregate b) {
StringBuilder details = new StringBuilder();
boolean result = compare(a.getNumCpus(), b.getNumCpus(), Resource.CPU, details)
& compare(a.getRamMb(), b.getRamMb(), Resource.RAM, details)
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/quota/QuotaInfo.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/quota/QuotaInfo.java b/src/main/java/org/apache/aurora/scheduler/quota/QuotaInfo.java
index 0e286d8..3e80af4 100644
--- a/src/main/java/org/apache/aurora/scheduler/quota/QuotaInfo.java
+++ b/src/main/java/org/apache/aurora/scheduler/quota/QuotaInfo.java
@@ -15,7 +15,7 @@
*/
package org.apache.aurora.scheduler.quota;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -23,11 +23,15 @@ import static com.google.common.base.Preconditions.checkNotNull;
* Wraps allocated quota and consumption details.
*/
public class QuotaInfo {
- private final IQuota quota;
- private final IQuota prodConsumption;
- private final IQuota nonProdConsumption;
+ private final IResourceAggregate quota;
+ private final IResourceAggregate prodConsumption;
+ private final IResourceAggregate nonProdConsumption;
+
+ QuotaInfo(
+ IResourceAggregate quota,
+ IResourceAggregate prodConsumption,
+ IResourceAggregate nonProdConsumption) {
- QuotaInfo(IQuota quota, IQuota prodConsumption, IQuota nonProdConsumption) {
this.quota = checkNotNull(quota);
this.prodConsumption = checkNotNull(prodConsumption);
this.nonProdConsumption = checkNotNull(nonProdConsumption);
@@ -38,7 +42,7 @@ public class QuotaInfo {
*
* @return Available quota.
*/
- public IQuota guota() {
+ public IResourceAggregate guota() {
return quota;
}
@@ -47,7 +51,7 @@ public class QuotaInfo {
*
* @return Production job consumption.
*/
- public IQuota prodConsumption() {
+ public IResourceAggregate prodConsumption() {
return prodConsumption;
}
@@ -56,7 +60,7 @@ public class QuotaInfo {
*
* @return Non production job consumption.
*/
- public IQuota nonProdConsumption() {
+ public IResourceAggregate nonProdConsumption() {
return nonProdConsumption;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/quota/QuotaManager.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/quota/QuotaManager.java b/src/main/java/org/apache/aurora/scheduler/quota/QuotaManager.java
index 9868abc..56f47b6 100644
--- a/src/main/java/org/apache/aurora/scheduler/quota/QuotaManager.java
+++ b/src/main/java/org/apache/aurora/scheduler/quota/QuotaManager.java
@@ -20,14 +20,14 @@ import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Inject;
-import org.apache.aurora.gen.Quota;
+import org.apache.aurora.gen.ResourceAggregate;
import org.apache.aurora.scheduler.base.JobKeys;
import org.apache.aurora.scheduler.base.Query;
import org.apache.aurora.scheduler.base.Tasks;
import org.apache.aurora.scheduler.storage.Storage;
import org.apache.aurora.scheduler.storage.Storage.StoreProvider;
import org.apache.aurora.scheduler.storage.Storage.Work;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -45,7 +45,7 @@ public interface QuotaManager {
* @param quota Quota to save.
* @throws QuotaException If provided quota specification is invalid.
*/
- void saveQuota(String role, IQuota quota) throws QuotaException;
+ void saveQuota(String role, IResourceAggregate quota) throws QuotaException;
/**
* Gets {@code QuotaInfo} for the specified role.
@@ -86,7 +86,9 @@ public interface QuotaManager {
}
@Override
- public void saveQuota(final String ownerRole, final IQuota quota) throws QuotaException {
+ public void saveQuota(final String ownerRole, final IResourceAggregate quota)
+ throws QuotaException {
+
if (!quota.isSetNumCpus() || !quota.isSetRamMb() || !quota.isSetDiskMb()) {
throw new QuotaException("Missing quota specification(s) in: " + quota.toString());
}
@@ -112,11 +114,12 @@ public interface QuotaManager {
.from(storeProvider.getTaskStore().fetchTasks(Query.roleScoped(role).active()))
.transform(Tasks.SCHEDULED_TO_INFO);
- IQuota prodConsumed = fromTasks(tasks.filter(Tasks.IS_PRODUCTION));
- IQuota nonProdConsumed =
+ IResourceAggregate prodConsumed = fromTasks(tasks.filter(Tasks.IS_PRODUCTION));
+ IResourceAggregate nonProdConsumed =
fromTasks(tasks.filter(Predicates.not(Tasks.IS_PRODUCTION)));
- IQuota quota = storeProvider.getQuotaStore().fetchQuota(role).or(Quotas.noQuota());
+ IResourceAggregate quota =
+ storeProvider.getQuotaStore().fetchQuota(role).or(ResourceAggregates.none());
return new QuotaInfo(quota, prodConsumed, nonProdConsumed);
}
@@ -131,15 +134,15 @@ public interface QuotaManager {
QuotaInfo quotaInfo = getQuotaInfo(JobKeys.from(template).getRole());
- IQuota additionalRequested =
- Quotas.scale(fromTasks(ImmutableSet.of(template)), instances);
+ IResourceAggregate additionalRequested =
+ ResourceAggregates.scale(fromTasks(ImmutableSet.of(template)), instances);
return QuotaCheckResult.greaterOrEqual(
quotaInfo.guota(),
add(quotaInfo.prodConsumption(), additionalRequested));
}
- private static IQuota fromTasks(Iterable<ITaskConfig> tasks) {
+ private static IResourceAggregate fromTasks(Iterable<ITaskConfig> tasks) {
double cpu = 0;
int ramMb = 0;
int diskMb = 0;
@@ -149,14 +152,14 @@ public interface QuotaManager {
diskMb += task.getDiskMb();
}
- return IQuota.build(new Quota()
+ return IResourceAggregate.build(new ResourceAggregate()
.setNumCpus(cpu)
.setRamMb(ramMb)
.setDiskMb(diskMb));
}
- private static IQuota add(IQuota a, IQuota b) {
- return IQuota.build(new Quota()
+ private static IResourceAggregate add(IResourceAggregate a, IResourceAggregate b) {
+ return IResourceAggregate.build(new ResourceAggregate()
.setNumCpus(a.getNumCpus() + b.getNumCpus())
.setRamMb(a.getRamMb() + b.getRamMb())
.setDiskMb(a.getDiskMb() + b.getDiskMb()));
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/quota/Quotas.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/quota/Quotas.java b/src/main/java/org/apache/aurora/scheduler/quota/Quotas.java
deleted file mode 100644
index 9da3c3e..0000000
--- a/src/main/java/org/apache/aurora/scheduler/quota/Quotas.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Copyright 2013 Apache Software Foundation
- *
- * 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.scheduler.quota;
-
-import com.google.common.collect.Ordering;
-
-import org.apache.aurora.gen.Quota;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
-
-/**
- * Convenience class for normalizing resource measures between tasks and offers.
- */
-public final class Quotas {
- private static final IQuota NO_QUOTA = IQuota.build(new Quota(0, 0, 0));
-
- private Quotas() {
- // Utility class.
- }
-
- /**
- * Returns a quota with all resource vectors zeroed.
- *
- * @return A quota with all resource vectors zeroed.
- */
- public static IQuota noQuota() {
- return NO_QUOTA;
- }
-
- /**
- * a * m
- */
- public static IQuota scale(IQuota a, int m) {
- return IQuota.build(new Quota()
- .setNumCpus(a.getNumCpus() * m)
- .setRamMb(a.getRamMb() * m)
- .setDiskMb(a.getDiskMb() * m));
- }
-
- /**
- * a / b
- * <p>
- * This calculates how many times {@code b} "fits into" {@code a}. Behavior is undefined when
- * {@code b} contains resources with a value of zero.
- */
- public static int divide(IQuota a, IQuota b) {
- return Ordering.natural().min(
- a.getNumCpus() / b.getNumCpus(),
- (double) a.getRamMb() / b.getRamMb(),
- (double) a.getDiskMb() / b.getDiskMb()
- ).intValue();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/quota/ResourceAggregates.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/quota/ResourceAggregates.java b/src/main/java/org/apache/aurora/scheduler/quota/ResourceAggregates.java
new file mode 100644
index 0000000..444c287
--- /dev/null
+++ b/src/main/java/org/apache/aurora/scheduler/quota/ResourceAggregates.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2013 Apache Software Foundation
+ *
+ * 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.scheduler.quota;
+
+import com.google.common.collect.Ordering;
+
+import org.apache.aurora.gen.ResourceAggregate;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
+
+/**
+ * Convenience class for normalizing resource measures between tasks and offers.
+ */
+public final class ResourceAggregates {
+ private static final IResourceAggregate EMPTY_RESOURCE_AGGREGATE =
+ IResourceAggregate.build(new ResourceAggregate(0, 0, 0));
+
+ private ResourceAggregates() {
+ // Utility class.
+ }
+
+ /**
+ * Returns a quota with all resource vectors zeroed.
+ *
+ * @return A resource aggregate with all resource vectors zeroed.
+ */
+ public static IResourceAggregate none() {
+ return EMPTY_RESOURCE_AGGREGATE;
+ }
+
+ /**
+ * a * m
+ */
+ public static IResourceAggregate scale(IResourceAggregate a, int m) {
+ return IResourceAggregate.build(new ResourceAggregate()
+ .setNumCpus(a.getNumCpus() * m)
+ .setRamMb(a.getRamMb() * m)
+ .setDiskMb(a.getDiskMb() * m));
+ }
+
+ /**
+ * a / b
+ * <p>
+ * This calculates how many times {@code b} "fits into" {@code a}. Behavior is undefined when
+ * {@code b} contains resources with a value of zero.
+ */
+ public static int divide(IResourceAggregate a, IResourceAggregate b) {
+ return Ordering.natural().min(
+ a.getNumCpus() / b.getNumCpus(),
+ (double) a.getRamMb() / b.getRamMb(),
+ (double) a.getDiskMb() / b.getDiskMb()
+ ).intValue();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/stats/AsyncStatsModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/stats/AsyncStatsModule.java b/src/main/java/org/apache/aurora/scheduler/stats/AsyncStatsModule.java
index e3ab1dd..6c72339 100644
--- a/src/main/java/org/apache/aurora/scheduler/stats/AsyncStatsModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/stats/AsyncStatsModule.java
@@ -37,13 +37,13 @@ import com.twitter.common.quantity.Amount;
import com.twitter.common.quantity.Data;
import com.twitter.common.quantity.Time;
-import org.apache.aurora.gen.Quota;
+import org.apache.aurora.gen.ResourceAggregate;
import org.apache.aurora.scheduler.async.OfferQueue;
import org.apache.aurora.scheduler.base.Conversions;
import org.apache.aurora.scheduler.configuration.Resources;
import org.apache.aurora.scheduler.stats.SlotSizeCounter.MachineResource;
import org.apache.aurora.scheduler.stats.SlotSizeCounter.MachineResourceProvider;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.apache.mesos.Protos.Offer;
import static java.lang.annotation.ElementType.FIELD;
@@ -117,7 +117,7 @@ public class AsyncStatsModule extends AbstractModule {
@Override
public MachineResource apply(Offer offer) {
Resources resources = Resources.from(offer);
- IQuota quota = IQuota.build(new Quota()
+ IResourceAggregate quota = IResourceAggregate.build(new ResourceAggregate()
.setNumCpus(resources.getNumCpus())
.setRamMb(resources.getRam().as(Data.MB))
.setDiskMb(resources.getDisk().as(Data.MB)));
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/stats/ResourceCounter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/stats/ResourceCounter.java b/src/main/java/org/apache/aurora/scheduler/stats/ResourceCounter.java
index 8855bfb..aec43fe 100644
--- a/src/main/java/org/apache/aurora/scheduler/stats/ResourceCounter.java
+++ b/src/main/java/org/apache/aurora/scheduler/stats/ResourceCounter.java
@@ -37,7 +37,7 @@ import org.apache.aurora.scheduler.storage.Storage;
import org.apache.aurora.scheduler.storage.Storage.StorageException;
import org.apache.aurora.scheduler.storage.Storage.StoreProvider;
import org.apache.aurora.scheduler.storage.Storage.Work;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
/**
@@ -89,7 +89,7 @@ public class ResourceCounter {
@Override
public Metric apply(StoreProvider storeProvider) {
Metric allocation = new Metric();
- for (IQuota quota : storeProvider.getQuotaStore().fetchQuotas().values()) {
+ for (IResourceAggregate quota : storeProvider.getQuotaStore().fetchQuotas().values()) {
allocation.accumulate(quota);
}
return allocation;
@@ -191,7 +191,7 @@ public class ResourceCounter {
diskMb += task.getDiskMb();
}
- protected void accumulate(IQuota quota) {
+ protected void accumulate(IResourceAggregate quota) {
cpu += quota.getNumCpus();
ramMb += quota.getRamMb();
diskMb += quota.getDiskMb();
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/stats/SlotSizeCounter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/stats/SlotSizeCounter.java b/src/main/java/org/apache/aurora/scheduler/stats/SlotSizeCounter.java
index e3dffe0..b6610f7 100644
--- a/src/main/java/org/apache/aurora/scheduler/stats/SlotSizeCounter.java
+++ b/src/main/java/org/apache/aurora/scheduler/stats/SlotSizeCounter.java
@@ -26,9 +26,9 @@ import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMap;
-import org.apache.aurora.gen.Quota;
-import org.apache.aurora.scheduler.quota.Quotas;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.gen.ResourceAggregate;
+import org.apache.aurora.scheduler.quota.ResourceAggregates;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -37,19 +37,19 @@ import static com.google.common.base.Preconditions.checkNotNull;
* slot sizes, broken down by dedicated and non-dedicated hosts.
*/
class SlotSizeCounter implements Runnable {
- private static final Map<String, IQuota> SLOT_SIZES = ImmutableMap.of(
- "small", IQuota.build(new Quota(1.0, 1024, 4096)),
- "medium", IQuota.build(new Quota(4.0, 8192, 16384)),
- "large", IQuota.build(new Quota(8.0, 16384, 32768)),
- "xlarge", IQuota.build(new Quota(16.0, 32768, 65536)));
+ private static final Map<String, IResourceAggregate> SLOT_SIZES = ImmutableMap.of(
+ "small", IResourceAggregate.build(new ResourceAggregate(1.0, 1024, 4096)),
+ "medium", IResourceAggregate.build(new ResourceAggregate(4.0, 8192, 16384)),
+ "large", IResourceAggregate.build(new ResourceAggregate(8.0, 16384, 32768)),
+ "xlarge", IResourceAggregate.build(new ResourceAggregate(16.0, 32768, 65536)));
- private final Map<String, IQuota> slotSizes;
+ private final Map<String, IResourceAggregate> slotSizes;
private final MachineResourceProvider machineResourceProvider;
private final CachedCounters cachedCounters;
@VisibleForTesting
SlotSizeCounter(
- final Map<String, IQuota> slotSizes,
+ final Map<String, IResourceAggregate> slotSizes,
MachineResourceProvider machineResourceProvider,
CachedCounters cachedCounters) {
@@ -59,15 +59,15 @@ class SlotSizeCounter implements Runnable {
}
static class MachineResource {
- private final IQuota size;
+ private final IResourceAggregate size;
private final boolean dedicated;
- public MachineResource(IQuota size, boolean dedicated) {
+ public MachineResource(IResourceAggregate size, boolean dedicated) {
this.size = Preconditions.checkNotNull(size);
this.dedicated = dedicated;
}
- public IQuota getSize() {
+ public IResourceAggregate getSize() {
return size;
}
@@ -94,11 +94,11 @@ class SlotSizeCounter implements Runnable {
}
}
- private int countSlots(Iterable<IQuota> slots, final IQuota slotSize) {
- Function<IQuota, Integer> counter = new Function<IQuota, Integer>() {
+ private int countSlots(Iterable<IResourceAggregate> slots, final IResourceAggregate slotSize) {
+ Function<IResourceAggregate, Integer> counter = new Function<IResourceAggregate, Integer>() {
@Override
- public Integer apply(IQuota machineSlack) {
- return Quotas.divide(machineSlack, slotSize);
+ public Integer apply(IResourceAggregate machineSlack) {
+ return ResourceAggregates.divide(machineSlack, slotSize);
}
};
@@ -118,10 +118,10 @@ class SlotSizeCounter implements Runnable {
};
}
- private static final Function<MachineResource, IQuota> GET_SIZE =
- new Function<MachineResource, IQuota>() {
+ private static final Function<MachineResource, IResourceAggregate> GET_SIZE =
+ new Function<MachineResource, IResourceAggregate>() {
@Override
- public IQuota apply(MachineResource slot) {
+ public IResourceAggregate apply(MachineResource slot) {
return slot.getSize();
}
};
@@ -130,9 +130,9 @@ class SlotSizeCounter implements Runnable {
String name,
boolean dedicated,
Iterable<MachineResource> slots,
- IQuota slotSize) {
+ IResourceAggregate slotSize) {
- Iterable<IQuota> sizes =
+ Iterable<IResourceAggregate> sizes =
FluentIterable.from(slots).filter(isDedicated(dedicated)).transform(GET_SIZE);
cachedCounters.get(getStatName(name, dedicated)).set(countSlots(sizes, slotSize));
}
@@ -140,7 +140,7 @@ class SlotSizeCounter implements Runnable {
@Override
public void run() {
Iterable<MachineResource> slots = machineResourceProvider.get();
- for (Map.Entry<String, IQuota> entry : slotSizes.entrySet()) {
+ for (Map.Entry<String, IResourceAggregate> entry : slotSizes.entrySet()) {
updateStats(entry.getKey(), false, slots, entry.getValue());
updateStats(entry.getKey(), true, slots, entry.getValue());
}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/storage/ForwardingStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/ForwardingStore.java b/src/main/java/org/apache/aurora/scheduler/storage/ForwardingStore.java
index 34d39f2..8758eb7 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/ForwardingStore.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/ForwardingStore.java
@@ -31,7 +31,7 @@ import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
import org.apache.aurora.scheduler.storage.entities.IJobKey;
import org.apache.aurora.scheduler.storage.entities.ILock;
import org.apache.aurora.scheduler.storage.entities.ILockKey;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
@@ -205,7 +205,7 @@ public class ForwardingStore implements
}
@Override
- public Map<String, IQuota> fetchQuotas() {
+ public Map<String, IResourceAggregate> fetchQuotas() {
return quotaStore.fetchQuotas();
}
@@ -220,12 +220,12 @@ public class ForwardingStore implements
}
@Override
- public void saveQuota(String role, IQuota quota) {
+ public void saveQuota(String role, IResourceAggregate quota) {
quotaStore.saveQuota(role, quota);
}
@Override
- public Optional<IQuota> fetchQuota(String role) {
+ public Optional<IResourceAggregate> fetchQuota(String role) {
return quotaStore.fetchQuota(role);
}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/storage/QuotaStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/QuotaStore.java b/src/main/java/org/apache/aurora/scheduler/storage/QuotaStore.java
index 42c405a..6b9e653 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/QuotaStore.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/QuotaStore.java
@@ -19,7 +19,7 @@ import java.util.Map;
import com.google.common.base.Optional;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
/**
* Point of storage for quota records.
@@ -31,14 +31,14 @@ public interface QuotaStore {
* @param role Role to fetch quota for.
* @return Optional quota associated with {@code role}.
*/
- Optional<IQuota> fetchQuota(String role);
+ Optional<IResourceAggregate> fetchQuota(String role);
/**
* Fetches all allocated quotas.
*
* @return All allocated quotas.
*/
- Map<String, IQuota> fetchQuotas();
+ Map<String, IResourceAggregate> fetchQuotas();
public interface Mutable extends QuotaStore {
@@ -58,8 +58,8 @@ public interface QuotaStore {
* Saves a quota record for a role.
*
* @param role Role to create or update a quota record for.
- * @param quota Quota to save.
+ * @param quota ResourceAggregate to save.
*/
- void saveQuota(String role, IQuota quota);
+ void saveQuota(String role, IResourceAggregate quota);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorage.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorage.java b/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorage.java
index 1842210..3ccf800 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorage.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorage.java
@@ -83,7 +83,7 @@ import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
import org.apache.aurora.scheduler.storage.entities.IJobKey;
import org.apache.aurora.scheduler.storage.entities.ILock;
import org.apache.aurora.scheduler.storage.entities.ILockKey;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
import org.apache.aurora.scheduler.storage.log.LogManager.StreamManager;
@@ -412,7 +412,7 @@ public class LogStorage extends ForwardingStore
case SAVE_QUOTA:
SaveQuota saveQuota = op.getSaveQuota();
- saveQuota(saveQuota.getRole(), IQuota.build(saveQuota.getQuota()));
+ saveQuota(saveQuota.getRole(), IResourceAggregate.build(saveQuota.getQuota()));
break;
case REMOVE_QUOTA:
@@ -622,7 +622,7 @@ public class LogStorage extends ForwardingStore
@Timed("scheduler_log_quota_save")
@Override
- public void saveQuota(final String role, final IQuota quota) {
+ public void saveQuota(final String role, final IResourceAggregate quota) {
checkNotNull(role);
checkNotNull(quota);
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImpl.java b/src/main/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImpl.java
index cb0ba50..eaf628a 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImpl.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImpl.java
@@ -43,7 +43,7 @@ import org.apache.aurora.scheduler.storage.Storage.Volatile;
import org.apache.aurora.scheduler.storage.Storage.Work;
import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
import org.apache.aurora.scheduler.storage.entities.ILock;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -150,7 +150,9 @@ public class SnapshotStoreImpl implements SnapshotStore<Snapshot> {
@Override
public void saveToSnapshot(StoreProvider store, Snapshot snapshot) {
ImmutableSet.Builder<QuotaConfiguration> quotas = ImmutableSet.builder();
- for (Map.Entry<String, IQuota> entry : store.getQuotaStore().fetchQuotas().entrySet()) {
+ for (Map.Entry<String, IResourceAggregate> entry
+ : store.getQuotaStore().fetchQuotas().entrySet()) {
+
quotas.add(new QuotaConfiguration(entry.getKey(), entry.getValue().newBuilder()));
}
@@ -163,7 +165,8 @@ public class SnapshotStoreImpl implements SnapshotStore<Snapshot> {
if (snapshot.isSetQuotaConfigurations()) {
for (QuotaConfiguration quota : snapshot.getQuotaConfigurations()) {
- store.getQuotaStore().saveQuota(quota.getRole(), IQuota.build(quota.getQuota()));
+ store.getQuotaStore()
+ .saveQuota(quota.getRole(), IResourceAggregate.build(quota.getQuota()));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/storage/mem/MemQuotaStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/mem/MemQuotaStore.java b/src/main/java/org/apache/aurora/scheduler/storage/mem/MemQuotaStore.java
index b9bb4bb..9c6da08 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/mem/MemQuotaStore.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/mem/MemQuotaStore.java
@@ -22,7 +22,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import org.apache.aurora.scheduler.storage.QuotaStore;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -31,7 +31,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
class MemQuotaStore implements QuotaStore.Mutable {
- private final Map<String, IQuota> quotas = Maps.newConcurrentMap();
+ private final Map<String, IResourceAggregate> quotas = Maps.newConcurrentMap();
@Override
public void deleteQuotas() {
@@ -46,7 +46,7 @@ class MemQuotaStore implements QuotaStore.Mutable {
}
@Override
- public void saveQuota(String role, IQuota quota) {
+ public void saveQuota(String role, IResourceAggregate quota) {
checkNotNull(role);
checkNotNull(quota);
@@ -54,13 +54,13 @@ class MemQuotaStore implements QuotaStore.Mutable {
}
@Override
- public Optional<IQuota> fetchQuota(String role) {
+ public Optional<IResourceAggregate> fetchQuota(String role) {
checkNotNull(role);
return Optional.fromNullable(quotas.get(role));
}
@Override
- public Map<String, IQuota> fetchQuotas() {
+ public Map<String, IResourceAggregate> fetchQuotas() {
return ImmutableMap.copyOf(quotas);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/storage/testing/StorageTestUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/testing/StorageTestUtil.java b/src/main/java/org/apache/aurora/scheduler/storage/testing/StorageTestUtil.java
index 043dae6..5435363 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/testing/StorageTestUtil.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/testing/StorageTestUtil.java
@@ -31,7 +31,7 @@ import org.apache.aurora.scheduler.storage.Storage.NonVolatileStorage;
import org.apache.aurora.scheduler.storage.Storage.StoreProvider;
import org.apache.aurora.scheduler.storage.Storage.Work;
import org.apache.aurora.scheduler.storage.TaskStore;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
import org.easymock.Capture;
import org.easymock.IAnswer;
@@ -137,7 +137,7 @@ public class StorageTestUtil {
return expectTaskFetch(query, ImmutableSet.<IScheduledTask>builder().add(result).build());
}
- public IExpectationSetters<?> expectQuotaFetch(String role, Optional<IQuota> result) {
+ public IExpectationSetters<?> expectQuotaFetch(String role, Optional<IResourceAggregate> result) {
return expect(quotaStore.fetchQuota(role)).andReturn(result);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
index dccae15..7b9f185 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
@@ -76,7 +76,7 @@ import org.apache.aurora.gen.LockValidation;
import org.apache.aurora.gen.MaintenanceStatusResult;
import org.apache.aurora.gen.PopulateJobResult;
import org.apache.aurora.gen.QueryRecoveryResult;
-import org.apache.aurora.gen.Quota;
+import org.apache.aurora.gen.ResourceAggregate;
import org.apache.aurora.gen.Response;
import org.apache.aurora.gen.ResponseCode;
import org.apache.aurora.gen.Result;
@@ -117,7 +117,7 @@ import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
import org.apache.aurora.scheduler.storage.entities.IJobKey;
import org.apache.aurora.scheduler.storage.entities.ILock;
import org.apache.aurora.scheduler.storage.entities.ILockKey;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
import org.apache.aurora.scheduler.thrift.auth.DecoratedThrift;
@@ -609,14 +609,18 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
@Requires(whitelist = Capability.PROVISIONER)
@Override
- public Response setQuota(final String ownerRole, final Quota quota, SessionKey session) {
+ public Response setQuota(
+ final String ownerRole,
+ final ResourceAggregate resourceAggregate,
+ SessionKey session) {
+
checkNotBlank(ownerRole);
- checkNotNull(quota);
+ checkNotNull(resourceAggregate);
checkNotNull(session);
Response response = new Response();
try {
- quotaManager.saveQuota(ownerRole, IQuota.build(quota));
+ quotaManager.saveQuota(ownerRole, IResourceAggregate.build(resourceAggregate));
return response.setResponseCode(OK).setMessage("Quota applied.");
} catch (QuotaException e) {
return response.setResponseCode(ResponseCode.INVALID_REQUEST).setMessage(e.getMessage());
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/python/apache/aurora/client/api/__init__.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/__init__.py b/src/main/python/apache/aurora/client/api/__init__.py
index 37b7f42..9d9ff66 100644
--- a/src/main/python/apache/aurora/client/api/__init__.py
+++ b/src/main/python/apache/aurora/client/api/__init__.py
@@ -24,7 +24,7 @@ from gen.apache.aurora.constants import LIVE_STATES
from gen.apache.aurora.ttypes import (
Response,
Identity,
- Quota,
+ ResourceAggregate,
ResponseCode,
TaskQuery)
@@ -162,7 +162,7 @@ class AuroraClientAPI(object):
def set_quota(self, role, cpu, ram, disk):
log.info("Setting quota for user:%s cpu:%f ram:%d disk: %d"
% (role, cpu, ram, disk))
- return self._scheduler_proxy.setQuota(role, Quota(cpu, ram, disk))
+ return self._scheduler_proxy.setQuota(role, ResourceAggregate(cpu, ram, disk))
def force_task_state(self, task_id, status):
log.info("Requesting that task %s transition to state %s" % (task_id, status))
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/python/apache/aurora/client/api/quota_check.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/quota_check.py b/src/main/python/apache/aurora/client/api/quota_check.py
index 7de02c4..6e818a2 100644
--- a/src/main/python/apache/aurora/client/api/quota_check.py
+++ b/src/main/python/apache/aurora/client/api/quota_check.py
@@ -18,7 +18,7 @@ import operator
from copy import deepcopy
-from gen.apache.aurora.ttypes import Quota, Response, ResponseCode
+from gen.apache.aurora.ttypes import ResourceAggregate, Response, ResponseCode
from twitter.common import log
@@ -28,10 +28,10 @@ class CapacityRequest(object):
@classmethod
def from_task(cls, task):
- return cls(Quota(numCpus=task.numCpus, ramMb=task.ramMb, diskMb=task.diskMb))
+ return cls(ResourceAggregate(numCpus=task.numCpus, ramMb=task.ramMb, diskMb=task.diskMb))
def __init__(self, quota=None):
- self._quota = quota or Quota(numCpus=0.0, ramMb=0, diskMb=0)
+ self._quota = quota or ResourceAggregate(numCpus=0.0, ramMb=0, diskMb=0)
def __add__(self, other):
return self._op(operator.__add__, other)
@@ -50,7 +50,7 @@ class CapacityRequest(object):
return self
return CapacityRequest(
- Quota(numCpus=op(self._quota.numCpus, other._quota.numCpus),
+ ResourceAggregate(numCpus=op(self._quota.numCpus, other._quota.numCpus),
ramMb=op(self._quota.ramMb, other._quota.ramMb),
diskMb=op(self._quota.diskMb, other._quota.diskMb)))
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/python/apache/aurora/client/api/sla.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/sla.py b/src/main/python/apache/aurora/client/api/sla.py
index 131c357..a7c3158 100644
--- a/src/main/python/apache/aurora/client/api/sla.py
+++ b/src/main/python/apache/aurora/client/api/sla.py
@@ -26,7 +26,6 @@ from apache.aurora.common.aurora_job_key import AuroraJobKey
from gen.apache.aurora.constants import LIVE_STATES
from gen.apache.aurora.ttypes import (
Identity,
- Quota,
Response,
ResponseCode,
ScheduleStatus,
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/python/apache/aurora/client/api/updater.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/updater.py b/src/main/python/apache/aurora/client/api/updater.py
index 924e6d6..9739af0 100644
--- a/src/main/python/apache/aurora/client/api/updater.py
+++ b/src/main/python/apache/aurora/client/api/updater.py
@@ -26,7 +26,6 @@ from gen.apache.aurora.ttypes import (
Lock,
LockKey,
LockValidation,
- Quota,
Response,
ResponseCode,
TaskQuery,
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/thrift/org/apache/aurora/gen/api.thrift
----------------------------------------------------------------------
diff --git a/src/main/thrift/org/apache/aurora/gen/api.thrift b/src/main/thrift/org/apache/aurora/gen/api.thrift
index cd60f47..3ee24c7 100644
--- a/src/main/thrift/org/apache/aurora/gen/api.thrift
+++ b/src/main/thrift/org/apache/aurora/gen/api.thrift
@@ -49,9 +49,7 @@ struct SessionKey {
5: optional binary data // A blob of data that the server may use for authentication.
}
-// Quota entry associated with a role.
-// In order for a user to launch a production job, they must have sufficient quota.
-struct Quota {
+struct ResourceAggregate {
1: double numCpus // Number of CPU cores allotted.
2: i64 ramMb // Megabytes of RAM allotted.
3: i64 diskMb // Megabytes of disk space allotted.
@@ -216,8 +214,8 @@ struct PopulateJobResult {
}
struct GetQuotaResult {
- 1: Quota quota // Total allocated quota.
- 2: optional Quota consumed // Amount of quota already consumed by a role.
+ 1: ResourceAggregate quota // Total allocated quota.
+ 2: optional ResourceAggregate consumed // Amount of quota already consumed by a role.
}
// Wraps return results for the acquireLock API.
@@ -515,7 +513,7 @@ struct RewriteConfigsRequest {
// https://issues.apache.org/jira/browse/THRIFT-66 is resolved.
service AuroraAdmin extends AuroraSchedulerManager {
// Assign quota to a user. This will overwrite any pre-existing quota for the user.
- Response setQuota(1: string ownerRole, 2: Quota quota, 3: SessionKey session)
+ Response setQuota(1: string ownerRole, 2: ResourceAggregate quota, 3: SessionKey session)
// Forces a task into a specific state. This does not guarantee the task will enter the given
// state, as the task must still transition within the bounds of the state machine. However,
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/main/thrift/org/apache/aurora/gen/storage.thrift
----------------------------------------------------------------------
diff --git a/src/main/thrift/org/apache/aurora/gen/storage.thrift b/src/main/thrift/org/apache/aurora/gen/storage.thrift
index f138c74..b1d1c1f 100644
--- a/src/main/thrift/org/apache/aurora/gen/storage.thrift
+++ b/src/main/thrift/org/apache/aurora/gen/storage.thrift
@@ -58,7 +58,7 @@ struct RemoveTasks {
struct SaveQuota {
1: string role
- 2: api.Quota quota
+ 2: api.ResourceAggregate quota
}
struct RemoveQuota {
@@ -116,7 +116,7 @@ struct SchedulerMetadata {
struct QuotaConfiguration {
1: string role
- 2: api.Quota quota
+ 2: api.ResourceAggregate quota
}
// Represents a complete snapshot of local storage data suitable for restoring the local storage
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/test/java/org/apache/aurora/scheduler/quota/QuotaCheckResultTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/quota/QuotaCheckResultTest.java b/src/test/java/org/apache/aurora/scheduler/quota/QuotaCheckResultTest.java
index e366026..e43922b 100644
--- a/src/test/java/org/apache/aurora/scheduler/quota/QuotaCheckResultTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/quota/QuotaCheckResultTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.aurora.scheduler.quota;
-import org.apache.aurora.gen.Quota;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.gen.ResourceAggregate;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.junit.Test;
import static org.apache.aurora.scheduler.quota.QuotaCheckResult.Result.INSUFFICIENT_QUOTA;
@@ -28,27 +28,27 @@ public class QuotaCheckResultTest {
@Test
public void testGreaterOrEqualPass() {
- IQuota quota = IQuota.build(new Quota()
- .setNumCpus(1.0)
- .setRamMb(256L)
- .setDiskMb(512L));
- IQuota request = IQuota.build(new Quota()
- .setNumCpus(1.0)
- .setRamMb(256L)
- .setDiskMb(512L));
+ IResourceAggregate quota = IResourceAggregate.build(new ResourceAggregate()
+ .setNumCpus(1.0)
+ .setRamMb(256L)
+ .setDiskMb(512L));
+ IResourceAggregate request = IResourceAggregate.build(new ResourceAggregate()
+ .setNumCpus(1.0)
+ .setRamMb(256L)
+ .setDiskMb(512L));
assertEquals(SUFFICIENT_QUOTA, QuotaCheckResult.greaterOrEqual(quota, request).getResult());
}
@Test
public void testGreaterOrEqualFailsCpu() {
- IQuota quota = IQuota.build(new Quota()
- .setNumCpus(1.0)
- .setRamMb(256L)
- .setDiskMb(512L));
- IQuota request = IQuota.build(new Quota()
- .setNumCpus(2.0)
- .setRamMb(256L)
- .setDiskMb(512L));
+ IResourceAggregate quota = IResourceAggregate.build(new ResourceAggregate()
+ .setNumCpus(1.0)
+ .setRamMb(256L)
+ .setDiskMb(512L));
+ IResourceAggregate request = IResourceAggregate.build(new ResourceAggregate()
+ .setNumCpus(2.0)
+ .setRamMb(256L)
+ .setDiskMb(512L));
QuotaCheckResult result = QuotaCheckResult.greaterOrEqual(quota, request);
assertEquals(INSUFFICIENT_QUOTA, result.getResult());
assertTrue(result.getDetails().get().contains("CPU"));
@@ -56,14 +56,14 @@ public class QuotaCheckResultTest {
@Test
public void testGreaterOrEqualFailsRam() {
- IQuota quota = IQuota.build(new Quota()
- .setNumCpus(1.0)
- .setRamMb(256L)
- .setDiskMb(512L));
- IQuota request = IQuota.build(new Quota()
- .setNumCpus(1.0)
- .setRamMb(512L)
- .setDiskMb(512L));
+ IResourceAggregate quota = IResourceAggregate.build(new ResourceAggregate()
+ .setNumCpus(1.0)
+ .setRamMb(256L)
+ .setDiskMb(512L));
+ IResourceAggregate request = IResourceAggregate.build(new ResourceAggregate()
+ .setNumCpus(1.0)
+ .setRamMb(512L)
+ .setDiskMb(512L));
QuotaCheckResult result = QuotaCheckResult.greaterOrEqual(quota, request);
assertEquals(INSUFFICIENT_QUOTA, result.getResult());
assertTrue(result.getDetails().get().length() > 0);
@@ -72,14 +72,14 @@ public class QuotaCheckResultTest {
@Test
public void testGreaterOrEqualFailsDisk() {
- IQuota quota = IQuota.build(new Quota()
- .setNumCpus(1.0)
- .setRamMb(256L)
- .setDiskMb(512L));
- IQuota request = IQuota.build(new Quota()
- .setNumCpus(1.0)
- .setRamMb(256L)
- .setDiskMb(1024L));
+ IResourceAggregate quota = IResourceAggregate.build(new ResourceAggregate()
+ .setNumCpus(1.0)
+ .setRamMb(256L)
+ .setDiskMb(512L));
+ IResourceAggregate request = IResourceAggregate.build(new ResourceAggregate()
+ .setNumCpus(1.0)
+ .setRamMb(256L)
+ .setDiskMb(1024L));
QuotaCheckResult result = QuotaCheckResult.greaterOrEqual(quota, request);
assertEquals(INSUFFICIENT_QUOTA, result.getResult());
assertTrue(result.getDetails().get().length() > 0);
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/test/java/org/apache/aurora/scheduler/quota/QuotaManagerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/quota/QuotaManagerImplTest.java b/src/test/java/org/apache/aurora/scheduler/quota/QuotaManagerImplTest.java
index 82e17df..14af68f 100644
--- a/src/test/java/org/apache/aurora/scheduler/quota/QuotaManagerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/quota/QuotaManagerImplTest.java
@@ -20,14 +20,14 @@ import com.twitter.common.testing.easymock.EasyMockTest;
import org.apache.aurora.gen.AssignedTask;
import org.apache.aurora.gen.Identity;
-import org.apache.aurora.gen.Quota;
+import org.apache.aurora.gen.ResourceAggregate;
import org.apache.aurora.gen.ScheduleStatus;
import org.apache.aurora.gen.ScheduledTask;
import org.apache.aurora.gen.TaskConfig;
import org.apache.aurora.scheduler.base.Query;
import org.apache.aurora.scheduler.quota.QuotaManager.QuotaException;
import org.apache.aurora.scheduler.quota.QuotaManager.QuotaManagerImpl;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
import org.apache.aurora.scheduler.storage.testing.StorageTestUtil;
@@ -44,7 +44,7 @@ import static org.junit.Assert.assertTrue;
public class QuotaManagerImplTest extends EasyMockTest {
private static final String ROLE = "test";
private static final String ENV = "test_env";
- private static final IQuota QUOTA = IQuota.build(new Quota()
+ private static final IResourceAggregate QUOTA = IResourceAggregate.build(new ResourceAggregate()
.setNumCpus(1.0)
.setRamMb(100L)
.setDiskMb(200L));
@@ -63,7 +63,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
public void testGetQuotaInfo() {
IScheduledTask prodTask = createTask("foo", "id1", 3, 3, 3, true);
IScheduledTask nonProdTask = createTask("bar", "id1", 2, 2, 2, false);
- IQuota quota = IQuota.build(new Quota(4, 4, 4));
+ IResourceAggregate quota = IResourceAggregate.build(new ResourceAggregate(4, 4, 4));
expectQuota(quota);
expectTasks(prodTask, nonProdTask);
@@ -73,13 +73,15 @@ public class QuotaManagerImplTest extends EasyMockTest {
QuotaInfo quotaInfo = quotaManager.getQuotaInfo(ROLE);
assertEquals(quota, quotaInfo.guota());
- assertEquals(IQuota.build(new Quota(3, 3, 3)), quotaInfo.prodConsumption());
- assertEquals(IQuota.build(new Quota(2, 2, 2)), quotaInfo.nonProdConsumption());
+ assertEquals(
+ IResourceAggregate.build(new ResourceAggregate(3, 3, 3)), quotaInfo.prodConsumption());
+ assertEquals(
+ IResourceAggregate.build(new ResourceAggregate(2, 2, 2)), quotaInfo.nonProdConsumption());
}
@Test
public void testGetQuotaInfoNoTasks() {
- IQuota quota = IQuota.build(new Quota(4, 4, 4));
+ IResourceAggregate quota = IResourceAggregate.build(new ResourceAggregate(4, 4, 4));
expectQuota(quota);
expectNoTasks();
@@ -89,13 +91,13 @@ public class QuotaManagerImplTest extends EasyMockTest {
QuotaInfo quotaInfo = quotaManager.getQuotaInfo(ROLE);
assertEquals(quota, quotaInfo.guota());
- assertEquals(Quotas.noQuota(), quotaInfo.prodConsumption());
- assertEquals(Quotas.noQuota(), quotaInfo.nonProdConsumption());
+ assertEquals(ResourceAggregates.none(), quotaInfo.prodConsumption());
+ assertEquals(ResourceAggregates.none(), quotaInfo.nonProdConsumption());
}
@Test
public void testCheckQuotaPasses() {
- expectQuota(IQuota.build(new Quota(4, 4, 4)));
+ expectQuota(IResourceAggregate.build(new ResourceAggregate(4, 4, 4)));
expectTasks(createTask("foo", "id1", 3, 3, 3, true));
storageUtil.expectOperations();
@@ -107,7 +109,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
@Test
public void testCheckQuotaPassesNoTasks() {
- expectQuota(IQuota.build(new Quota(4, 4, 4)));
+ expectQuota(IResourceAggregate.build(new ResourceAggregate(4, 4, 4)));
expectNoTasks();
storageUtil.expectOperations();
@@ -119,7 +121,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
@Test
public void testCheckQuotaPassesNonProdUnaccounted() {
- expectQuota(IQuota.build(new Quota(4, 4, 4)));
+ expectQuota(IResourceAggregate.build(new ResourceAggregate(4, 4, 4)));
expectTasks(createTask("foo", "id1", 3, 3, 3, true), createTask("bar", "id2", 5, 5, 5, false));
storageUtil.expectOperations();
@@ -139,7 +141,9 @@ public class QuotaManagerImplTest extends EasyMockTest {
@Test
public void testCheckQuotaNoQuotaSet() {
- expect(storageUtil.quotaStore.fetchQuota(ROLE)).andReturn(Optional.<IQuota>absent());
+ expect(storageUtil.quotaStore.fetchQuota(ROLE))
+ .andReturn(Optional.<IResourceAggregate>absent());
+
expectNoTasks();
storageUtil.expectOperations();
@@ -150,7 +154,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
@Test
public void testCheckQuotaExceedsCpu() {
- expectQuota(IQuota.build(new Quota(4, 4, 4)));
+ expectQuota(IResourceAggregate.build(new ResourceAggregate(4, 4, 4)));
expectTasks(createTask("foo", "id1", 3, 3, 3, true));
storageUtil.expectOperations();
@@ -162,7 +166,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
@Test
public void testCheckQuotaExceedsRam() {
- expectQuota(IQuota.build(new Quota(4, 4, 4)));
+ expectQuota(IResourceAggregate.build(new ResourceAggregate(4, 4, 4)));
expectTasks(createTask("foo", "id1", 3, 3, 3, true));
storageUtil.expectOperations();
@@ -174,7 +178,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
@Test
public void testCheckQuotaExceedsDisk() {
- expectQuota(IQuota.build(new Quota(4, 4, 4)));
+ expectQuota(IResourceAggregate.build(new ResourceAggregate(4, 4, 4)));
expectTasks(createTask("foo", "id1", 3, 3, 3, true));
storageUtil.expectOperations();
@@ -198,7 +202,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
storageUtil.expectOperations();
control.replay();
- quotaManager.saveQuota(ROLE, IQuota.build(new Quota()));
+ quotaManager.saveQuota(ROLE, IResourceAggregate.build(new ResourceAggregate()));
}
@Test(expected = QuotaException.class)
@@ -206,7 +210,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
storageUtil.expectOperations();
control.replay();
- quotaManager.saveQuota(ROLE, IQuota.build(new Quota(-2.0, 4, 5)));
+ quotaManager.saveQuota(ROLE, IResourceAggregate.build(new ResourceAggregate(-2.0, 4, 5)));
}
private IExpectationSetters<?> expectTasks(IScheduledTask... tasks) {
@@ -217,7 +221,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
return expectTasks();
}
- private IExpectationSetters<Optional<IQuota>> expectQuota(IQuota quota) {
+ private IExpectationSetters<Optional<IResourceAggregate>> expectQuota(IResourceAggregate quota) {
return expect(storageUtil.quotaStore.fetchQuota(ROLE))
.andReturn(Optional.of(quota));
}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/test/java/org/apache/aurora/scheduler/stats/SlotSizeCounterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/stats/SlotSizeCounterTest.java b/src/test/java/org/apache/aurora/scheduler/stats/SlotSizeCounterTest.java
index c785b1c..415b48c 100644
--- a/src/test/java/org/apache/aurora/scheduler/stats/SlotSizeCounterTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/stats/SlotSizeCounterTest.java
@@ -23,11 +23,11 @@ import com.google.common.collect.ImmutableMap;
import com.twitter.common.stats.StatsProvider;
import com.twitter.common.testing.easymock.EasyMockTest;
-import org.apache.aurora.gen.Quota;
-import org.apache.aurora.scheduler.quota.Quotas;
+import org.apache.aurora.gen.ResourceAggregate;
+import org.apache.aurora.scheduler.quota.ResourceAggregates;
import org.apache.aurora.scheduler.stats.SlotSizeCounter.MachineResource;
import org.apache.aurora.scheduler.stats.SlotSizeCounter.MachineResourceProvider;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.junit.Before;
import org.junit.Test;
@@ -36,10 +36,11 @@ import static org.junit.Assert.assertEquals;
public class SlotSizeCounterTest extends EasyMockTest {
- private static final IQuota SMALL = IQuota.build(new Quota(1.0, 1024, 4096));
- private static final IQuota LARGE = Quotas.scale(SMALL, 4);
+ private static final IResourceAggregate SMALL =
+ IResourceAggregate.build(new ResourceAggregate(1.0, 1024, 4096));
+ private static final IResourceAggregate LARGE = ResourceAggregates.scale(SMALL, 4);
- private static final Map<String, IQuota> SLOT_SIZES = ImmutableMap.of(
+ private static final Map<String, IResourceAggregate> SLOT_SIZES = ImmutableMap.of(
"small", SMALL,
"large", LARGE);
@@ -91,7 +92,8 @@ public class SlotSizeCounterTest extends EasyMockTest {
@Test
public void testTinyOffers() {
expectStatExport();
- expectGetSlots(new MachineResource(IQuota.build(new Quota(0.1, 1, 1)), false));
+ expectGetSlots(
+ new MachineResource(IResourceAggregate.build(new ResourceAggregate(0.1, 1, 1)), false));
control.replay();
@@ -105,7 +107,9 @@ public class SlotSizeCounterTest extends EasyMockTest {
@Test
public void testStarvedResourceVector() {
expectStatExport();
- expectGetSlots(new MachineResource(IQuota.build(new Quota(1000, 16384, 1)), false));
+ expectGetSlots(
+ new MachineResource(
+ IResourceAggregate.build(new ResourceAggregate(1000, 16384, 1)), false));
control.replay();
@@ -123,11 +127,11 @@ public class SlotSizeCounterTest extends EasyMockTest {
new MachineResource(SMALL, false),
new MachineResource(SMALL, false),
new MachineResource(LARGE, false),
- new MachineResource(Quotas.scale(LARGE, 4), false),
- new MachineResource(IQuota.build(new Quota(1, 1, 1)), false),
+ new MachineResource(ResourceAggregates.scale(LARGE, 4), false),
+ new MachineResource(IResourceAggregate.build(new ResourceAggregate(1, 1, 1)), false),
new MachineResource(SMALL, true),
new MachineResource(SMALL, true),
- new MachineResource(Quotas.scale(SMALL, 2), true));
+ new MachineResource(ResourceAggregates.scale(SMALL, 2), true));
control.replay();
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/test/java/org/apache/aurora/scheduler/storage/backup/StorageBackupTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/backup/StorageBackupTest.java b/src/test/java/org/apache/aurora/scheduler/storage/backup/StorageBackupTest.java
index a07f3c9..dbca32d 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/backup/StorageBackupTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/backup/StorageBackupTest.java
@@ -34,7 +34,7 @@ import org.apache.aurora.gen.Attribute;
import org.apache.aurora.gen.HostAttributes;
import org.apache.aurora.gen.JobConfiguration;
import org.apache.aurora.gen.JobKey;
-import org.apache.aurora.gen.Quota;
+import org.apache.aurora.gen.ResourceAggregate;
import org.apache.aurora.gen.ScheduledTask;
import org.apache.aurora.gen.storage.QuotaConfiguration;
import org.apache.aurora.gen.storage.SchedulerMetadata;
@@ -175,7 +175,7 @@ public class StorageBackupTest extends EasyMockTest {
"jobManager",
new JobConfiguration().setKey(new JobKey("owner", "env", "jobA")))));
snapshot.setQuotaConfigurations(
- ImmutableSet.of(new QuotaConfiguration("roleA", new Quota(10, 1024, 1024))));
+ ImmutableSet.of(new QuotaConfiguration("roleA", new ResourceAggregate(10, 1024, 1024))));
snapshot.setSchedulerMetadata(new SchedulerMetadata().setFrameworkId("frameworkId"));
snapshot.setTasks(ImmutableSet.of(new ScheduledTask()));
return snapshot;
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java b/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java
index d6624f4..1b9bf0c 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java
@@ -43,7 +43,7 @@ import org.apache.aurora.gen.JobConfiguration;
import org.apache.aurora.gen.JobKey;
import org.apache.aurora.gen.Lock;
import org.apache.aurora.gen.LockKey;
-import org.apache.aurora.gen.Quota;
+import org.apache.aurora.gen.ResourceAggregate;
import org.apache.aurora.gen.ScheduleStatus;
import org.apache.aurora.gen.ScheduledTask;
import org.apache.aurora.gen.TaskConfig;
@@ -80,7 +80,7 @@ import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
import org.apache.aurora.scheduler.storage.entities.IJobKey;
import org.apache.aurora.scheduler.storage.entities.ILock;
import org.apache.aurora.scheduler.storage.entities.ILockKey;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
import org.apache.aurora.scheduler.storage.log.LogStorage.SchedulingService;
@@ -609,7 +609,9 @@ public class LogStorageTest extends EasyMockTest {
@Test
public void testSaveQuota() throws Exception {
final String role = "role";
- final IQuota quota = IQuota.build(new Quota(1.0, 128L, 1024L));
+ final IResourceAggregate quota =
+ IResourceAggregate.build(new ResourceAggregate(1.0, 128L, 1024L));
+
new MutationFixture() {
@Override
protected void setupExpectations() throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplTest.java b/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplTest.java
index 69dadaf..4a13dbc 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplTest.java
@@ -36,7 +36,7 @@ import org.apache.aurora.gen.storage.Snapshot;
import org.apache.aurora.gen.storage.StoredJob;
import org.apache.aurora.scheduler.base.JobKeys;
import org.apache.aurora.scheduler.base.Query;
-import org.apache.aurora.scheduler.quota.Quotas;
+import org.apache.aurora.scheduler.quota.ResourceAggregates;
import org.apache.aurora.scheduler.storage.SnapshotStore;
import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
import org.apache.aurora.scheduler.storage.entities.ILock;
@@ -69,7 +69,8 @@ public class SnapshotStoreImplTest extends EasyMockTest {
ImmutableSet<IScheduledTask> tasks = ImmutableSet.of(
IScheduledTask.build(new ScheduledTask().setStatus(ScheduleStatus.PENDING)));
Set<QuotaConfiguration> quotas =
- ImmutableSet.of(new QuotaConfiguration("steve", Quotas.noQuota().newBuilder()));
+ ImmutableSet.of(
+ new QuotaConfiguration("steve", ResourceAggregates.none().newBuilder()));
HostAttributes attribute = new HostAttributes("host",
ImmutableSet.of(new Attribute("attr", ImmutableSet.of("value"))));
StoredJob job = new StoredJob(
@@ -89,7 +90,7 @@ public class SnapshotStoreImplTest extends EasyMockTest {
storageUtil.expectOperations();
expect(storageUtil.taskStore.fetchTasks(Query.unscoped())).andReturn(tasks);
expect(storageUtil.quotaStore.fetchQuotas())
- .andReturn(ImmutableMap.of("steve", Quotas.noQuota()));
+ .andReturn(ImmutableMap.of("steve", ResourceAggregates.none()));
expect(storageUtil.attributeStore.getHostAttributes()).andReturn(ImmutableSet.of(attribute));
expect(storageUtil.jobStore.fetchManagerIds()).andReturn(ImmutableSet.of("jobManager"));
expect(storageUtil.jobStore.fetchJobs("jobManager"))
@@ -99,7 +100,7 @@ public class SnapshotStoreImplTest extends EasyMockTest {
expectDataWipe();
storageUtil.taskStore.saveTasks(tasks);
- storageUtil.quotaStore.saveQuota("steve", Quotas.noQuota());
+ storageUtil.quotaStore.saveQuota("steve", ResourceAggregates.none());
storageUtil.attributeStore.saveHostAttributes(attribute);
storageUtil.jobStore.saveAcceptedJob(
job.getJobManagerId(),
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
index 4a2d39d..dc55771 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
@@ -51,7 +51,7 @@ import org.apache.aurora.gen.JobKey;
import org.apache.aurora.gen.LimitConstraint;
import org.apache.aurora.gen.Lock;
import org.apache.aurora.gen.LockKey;
-import org.apache.aurora.gen.Quota;
+import org.apache.aurora.gen.ResourceAggregate;
import org.apache.aurora.gen.Response;
import org.apache.aurora.gen.ResponseCode;
import org.apache.aurora.gen.RewriteConfigsRequest;
@@ -84,7 +84,7 @@ import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
import org.apache.aurora.scheduler.storage.entities.IJobKey;
import org.apache.aurora.scheduler.storage.entities.ILock;
import org.apache.aurora.scheduler.storage.entities.ILockKey;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
import org.apache.aurora.scheduler.storage.testing.StorageTestUtil;
@@ -127,8 +127,12 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
private static final ILock LOCK = ILock.build(new Lock().setKey(LOCK_KEY.newBuilder()));
private static final JobConfiguration CRON_JOB = makeJob().setCronSchedule("test");
private static final Lock DEFAULT_LOCK = null;
- private static final IQuota QUOTA = IQuota.build(new Quota(10.0, 1024, 2048));
- private static final IQuota CONSUMED = IQuota.build(new Quota(0.0, 0, 0));
+
+ private static final IResourceAggregate QUOTA =
+ IResourceAggregate.build(new ResourceAggregate(10.0, 1024, 2048));
+
+ private static final IResourceAggregate CONSUMED =
+ IResourceAggregate.build(new ResourceAggregate(0.0, 0, 0));
private StorageTestUtil storageUtil;
private SchedulerCore scheduler;
@@ -413,54 +417,54 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
@Test
public void testSetQuota() throws Exception {
- Quota quota = new Quota()
+ ResourceAggregate resourceAggregate = new ResourceAggregate()
.setNumCpus(10)
.setDiskMb(100)
.setRamMb(200);
expectAuth(ROOT, true);
- quotaManager.saveQuota(ROLE, IQuota.build(quota));
+ quotaManager.saveQuota(ROLE, IResourceAggregate.build(resourceAggregate));
control.replay();
- Response response = thrift.setQuota(ROLE, quota, SESSION);
+ Response response = thrift.setQuota(ROLE, resourceAggregate, SESSION);
assertEquals(ResponseCode.OK, response.getResponseCode());
}
@Test
public void testSetQuotaFails() throws Exception {
- Quota quota = new Quota()
+ ResourceAggregate resourceAggregate = new ResourceAggregate()
.setNumCpus(10)
.setDiskMb(100)
.setRamMb(200);
expectAuth(ROOT, true);
- quotaManager.saveQuota(ROLE, IQuota.build(quota));
+ quotaManager.saveQuota(ROLE, IResourceAggregate.build(resourceAggregate));
expectLastCall().andThrow(new QuotaManager.QuotaException("fail"));
control.replay();
- Response response = thrift.setQuota(ROLE, quota, SESSION);
+ Response response = thrift.setQuota(ROLE, resourceAggregate, SESSION);
assertEquals(ResponseCode.INVALID_REQUEST, response.getResponseCode());
}
@Test
public void testProvisionerSetQuota() throws Exception {
- Quota quota = new Quota()
+ ResourceAggregate resourceAggregate = new ResourceAggregate()
.setNumCpus(10)
.setDiskMb(100)
.setRamMb(200);
expectAuth(ROOT, false);
expectAuth(Capability.PROVISIONER, true);
- quotaManager.saveQuota(ROLE, IQuota.build(quota));
+ quotaManager.saveQuota(ROLE, IResourceAggregate.build(resourceAggregate));
control.replay();
- Response response = thrift.setQuota(ROLE, quota, SESSION);
+ Response response = thrift.setQuota(ROLE, resourceAggregate, SESSION);
assertEquals(ResponseCode.OK, response.getResponseCode());
}
@Test
public void testSetQuotaAuthFailure() throws Exception {
- Quota quota = new Quota()
+ ResourceAggregate resourceAggregate = new ResourceAggregate()
.setNumCpus(10)
.setDiskMb(100)
.setRamMb(200);
@@ -469,7 +473,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
- Response response = thrift.setQuota(ROLE, quota, SESSION);
+ Response response = thrift.setQuota(ROLE, resourceAggregate, SESSION);
assertEquals(ResponseCode.AUTH_FAILED, response.getResponseCode());
}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java b/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java
index 09a288a..f5effe7 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java
@@ -31,7 +31,7 @@ import org.apache.aurora.auth.CapabilityValidator;
import org.apache.aurora.auth.CapabilityValidator.Capability;
import org.apache.aurora.auth.SessionValidator;
import org.apache.aurora.gen.AuroraAdmin;
-import org.apache.aurora.gen.Quota;
+import org.apache.aurora.gen.ResourceAggregate;
import org.apache.aurora.gen.SessionKey;
import org.apache.aurora.scheduler.cron.CronScheduler;
import org.apache.aurora.scheduler.quota.QuotaManager;
@@ -43,7 +43,7 @@ import org.apache.aurora.scheduler.storage.Storage;
import org.apache.aurora.scheduler.storage.Storage.NonVolatileStorage;
import org.apache.aurora.scheduler.storage.backup.Recovery;
import org.apache.aurora.scheduler.storage.backup.StorageBackup;
-import org.apache.aurora.scheduler.storage.entities.IQuota;
+import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.apache.aurora.scheduler.storage.testing.StorageTestUtil;
import org.apache.aurora.scheduler.thrift.auth.ThriftAuthModule;
import org.junit.Before;
@@ -60,7 +60,8 @@ public class ThriftIT extends EasyMockTest {
private static final String USER = "someuser";
private static final String ROOT_USER = "blue";
private static final String PROVISIONER_USER = "red";
- private static final IQuota QUOTA = IQuota.build(new Quota(1, 1, 1));
+ private static final IResourceAggregate QUOTA =
+ IResourceAggregate.build(new ResourceAggregate(1, 1, 1));
private static final Map<Capability, String> CAPABILITIES =
ImmutableMap.of(Capability.ROOT, ROOT_USER, Capability.PROVISIONER, PROVISIONER_USER);
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/test/java/org/apache/aurora/scheduler/thrift/aop/ForwardingThrift.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/aop/ForwardingThrift.java b/src/test/java/org/apache/aurora/scheduler/thrift/aop/ForwardingThrift.java
index 1edc0d7..a5fcbd4 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/aop/ForwardingThrift.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/aop/ForwardingThrift.java
@@ -25,7 +25,7 @@ import org.apache.aurora.gen.JobKey;
import org.apache.aurora.gen.Lock;
import org.apache.aurora.gen.LockKey;
import org.apache.aurora.gen.LockValidation;
-import org.apache.aurora.gen.Quota;
+import org.apache.aurora.gen.ResourceAggregate;
import org.apache.aurora.gen.Response;
import org.apache.aurora.gen.RewriteConfigsRequest;
import org.apache.aurora.gen.ScheduleStatus;
@@ -48,10 +48,12 @@ abstract class ForwardingThrift implements AuroraAdmin.Iface {
}
@Override
- public Response setQuota(String ownerRole, Quota quota, SessionKey session)
- throws TException {
+ public Response setQuota(
+ String ownerRole,
+ ResourceAggregate resourceAggregate,
+ SessionKey session) throws TException {
- return delegate.setQuota(ownerRole, quota, session);
+ return delegate.setQuota(ownerRole, resourceAggregate, session);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/test/python/apache/aurora/client/api/test_quota_check.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/api/test_quota_check.py b/src/test/python/apache/aurora/client/api/test_quota_check.py
index 6b1d7bd..4dff351 100644
--- a/src/test/python/apache/aurora/client/api/test_quota_check.py
+++ b/src/test/python/apache/aurora/client/api/test_quota_check.py
@@ -24,7 +24,7 @@ from gen.apache.aurora.AuroraSchedulerManager import Client as scheduler_client
from gen.apache.aurora.ttypes import (
GetQuotaResult,
JobKey,
- Quota,
+ ResourceAggregate,
Response,
ResponseCode,
Result)
@@ -64,27 +64,27 @@ class QuotaCheckTest(unittest.TestCase):
assert not self._scheduler.getQuota.called, 'Scheduler.getQuota() unexpected call.'
def test_pass(self):
- allocated = Quota(numCpus=50.0, ramMb=1000, diskMb=3000)
- consumed = Quota(numCpus=25.0, ramMb=500, diskMb=2000)
- released = CapacityRequest(Quota(numCpus=5.0, ramMb=100, diskMb=500))
- acquired = CapacityRequest(Quota(numCpus=15.0, ramMb=300, diskMb=800))
+ allocated = ResourceAggregate(numCpus=50.0, ramMb=1000, diskMb=3000)
+ consumed = ResourceAggregate(numCpus=25.0, ramMb=500, diskMb=2000)
+ released = CapacityRequest(ResourceAggregate(numCpus=5.0, ramMb=100, diskMb=500))
+ acquired = CapacityRequest(ResourceAggregate(numCpus=15.0, ramMb=300, diskMb=800))
self.mock_get_quota(allocated, consumed)
self.assert_result(True, released, acquired)
def test_pass_with_no_consumed(self):
- allocated = Quota(numCpus=50.0, ramMb=1000, diskMb=3000)
- released = CapacityRequest(Quota(numCpus=5.0, ramMb=100, diskMb=500))
- acquired = CapacityRequest(Quota(numCpus=15.0, ramMb=300, diskMb=800))
+ allocated = ResourceAggregate(numCpus=50.0, ramMb=1000, diskMb=3000)
+ released = CapacityRequest(ResourceAggregate(numCpus=5.0, ramMb=100, diskMb=500))
+ acquired = CapacityRequest(ResourceAggregate(numCpus=15.0, ramMb=300, diskMb=800))
self.mock_get_quota(allocated, None)
self.assert_result(True, released, acquired)
def test_pass_due_to_released(self):
- allocated = Quota(numCpus=50.0, ramMb=1000, diskMb=3000)
- consumed = Quota(numCpus=45.0, ramMb=900, diskMb=2900)
- released = CapacityRequest(Quota(numCpus=5.0, ramMb=100, diskMb=100))
- acquired = CapacityRequest(Quota(numCpus=10.0, ramMb=200, diskMb=200))
+ allocated = ResourceAggregate(numCpus=50.0, ramMb=1000, diskMb=3000)
+ consumed = ResourceAggregate(numCpus=45.0, ramMb=900, diskMb=2900)
+ released = CapacityRequest(ResourceAggregate(numCpus=5.0, ramMb=100, diskMb=100))
+ acquired = CapacityRequest(ResourceAggregate(numCpus=10.0, ramMb=200, diskMb=200))
self.mock_get_quota(allocated, consumed)
self.assert_result(True, released, acquired)
@@ -93,19 +93,19 @@ class QuotaCheckTest(unittest.TestCase):
self.assert_result(False, None, None)
def test_fail(self):
- allocated = Quota(numCpus=50.0, ramMb=1000, diskMb=3000)
- consumed = Quota(numCpus=25.0, ramMb=500, diskMb=2000)
- released = CapacityRequest(Quota(numCpus=5.0, ramMb=100, diskMb=500))
- acquired = CapacityRequest(Quota(numCpus=35.0, ramMb=300, diskMb=800))
+ allocated = ResourceAggregate(numCpus=50.0, ramMb=1000, diskMb=3000)
+ consumed = ResourceAggregate(numCpus=25.0, ramMb=500, diskMb=2000)
+ released = CapacityRequest(ResourceAggregate(numCpus=5.0, ramMb=100, diskMb=500))
+ acquired = CapacityRequest(ResourceAggregate(numCpus=35.0, ramMb=300, diskMb=800))
self.mock_get_quota(allocated, consumed)
self.assert_result(True, released, acquired, ResponseCode.INVALID_REQUEST)
def test_fail_scheduler_call(self):
- allocated = Quota(numCpus=50.0, ramMb=1000, diskMb=3000)
- consumed = Quota(numCpus=25.0, ramMb=500, diskMb=2000)
- released = CapacityRequest(Quota(numCpus=5.0, ramMb=100, diskMb=500))
- acquired = CapacityRequest(Quota(numCpus=1.0, ramMb=100, diskMb=100))
+ allocated = ResourceAggregate(numCpus=50.0, ramMb=1000, diskMb=3000)
+ consumed = ResourceAggregate(numCpus=25.0, ramMb=500, diskMb=2000)
+ released = CapacityRequest(ResourceAggregate(numCpus=5.0, ramMb=100, diskMb=500))
+ acquired = CapacityRequest(ResourceAggregate(numCpus=1.0, ramMb=100, diskMb=100))
self.mock_get_quota(allocated, consumed, response_code=ResponseCode.INVALID_REQUEST)
self.assert_result(True, released, acquired, ResponseCode.INVALID_REQUEST)
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/test/python/apache/aurora/client/api/test_scheduler_client.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/api/test_scheduler_client.py b/src/test/python/apache/aurora/client/api/test_scheduler_client.py
index 49cab15..10c2a90 100644
--- a/src/test/python/apache/aurora/client/api/test_scheduler_client.py
+++ b/src/test/python/apache/aurora/client/api/test_scheduler_client.py
@@ -203,11 +203,11 @@ class TestSchedulerProxyInjection(unittest.TestCase):
class TestSchedulerProxyAdminInjection(TestSchedulerProxyInjection):
def test_setQuota(self):
- self.mock_thrift_client.setQuota(IgnoreArg(), IsA(Quota), IsA(SessionKey))
+ self.mock_thrift_client.setQuota(IgnoreArg(), IsA(ResourceAggregate), IsA(SessionKey))
self.mox.ReplayAll()
- self.make_scheduler_proxy().setQuota(ROLE, Quota())
+ self.make_scheduler_proxy().setQuota(ROLE, ResourceAggregate())
def test_forceTaskState(self):
self.mock_thrift_client.forceTaskState(IgnoreArg(), IgnoreArg(), IsA(SessionKey))
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/130bc487/src/test/python/apache/aurora/client/api/test_sla.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/api/test_sla.py b/src/test/python/apache/aurora/client/api/test_sla.py
index 79ec921..c5ef100 100644
--- a/src/test/python/apache/aurora/client/api/test_sla.py
+++ b/src/test/python/apache/aurora/client/api/test_sla.py
@@ -30,7 +30,6 @@ from gen.apache.aurora.AuroraSchedulerManager import Client as scheduler_client
from gen.apache.aurora.ttypes import (
AssignedTask,
Identity,
- Quota,
Response,
ResponseCode,
Result,