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 2014/07/23 04:20:00 UTC
git commit: Fix constraint violation caused by slave ID change.
Repository: incubator-aurora
Updated Branches:
refs/heads/master 813794b0e -> 2b78affb3
Fix constraint violation caused by slave ID change.
Bugs closed: AURORA-596
Reviewed at https://reviews.apache.org/r/23832/
Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/2b78affb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/2b78affb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/2b78affb
Branch: refs/heads/master
Commit: 2b78affb3129ffb42ef07217e2362f904ca35177
Parents: 813794b
Author: Bill Farner <wf...@apache.org>
Authored: Tue Jul 22 19:04:42 2014 -0700
Committer: Bill Farner <wf...@apache.org>
Committed: Tue Jul 22 19:04:42 2014 -0700
----------------------------------------------------------------------
.../apache/aurora/scheduler/storage/db/DbAttributeStore.java | 2 +-
.../apache/aurora/scheduler/storage/db/AttributeMapper.xml | 2 +-
.../aurora/scheduler/storage/db/DbAttributeStoreTest.java | 8 ++++++++
3 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/2b78affb/src/main/java/org/apache/aurora/scheduler/storage/db/DbAttributeStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/DbAttributeStore.java b/src/main/java/org/apache/aurora/scheduler/storage/db/DbAttributeStore.java
index c5bfa1b..34f12a9 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/DbAttributeStore.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/db/DbAttributeStore.java
@@ -82,7 +82,7 @@ class DbAttributeStore implements AttributeStore.Mutable {
"Host attributes contains empty values: " + hostAttributes);
}
- mapper.deleteAttributesAndValues(hostAttributes.getSlaveId());
+ mapper.deleteAttributesAndValues(hostAttributes.getHost());
mapper.insert(hostAttributes);
if (!hostAttributes.getAttributes().isEmpty()) {
mapper.insertAttributeValues(hostAttributes);
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/2b78affb/src/main/resources/org/apache/aurora/scheduler/storage/db/AttributeMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/AttributeMapper.xml b/src/main/resources/org/apache/aurora/scheduler/storage/db/AttributeMapper.xml
index f9b689d..deb25bd 100644
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/AttributeMapper.xml
+++ b/src/main/resources/org/apache/aurora/scheduler/storage/db/AttributeMapper.xml
@@ -33,7 +33,7 @@
<delete id="deleteAttributesAndValues">
<!-- This assumes the schema enables cascading deletes in the values table. -->
DELETE FROM host_attributes
- WHERE slave_id = #{id}
+ WHERE host = #{id}
</delete>
<resultMap id="hostAttributeResultMap" type="org.apache.aurora.gen.HostAttributes">
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/2b78affb/src/test/java/org/apache/aurora/scheduler/storage/db/DbAttributeStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/DbAttributeStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/DbAttributeStoreTest.java
index 3962fb0..4c82389 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/DbAttributeStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/db/DbAttributeStoreTest.java
@@ -137,6 +137,14 @@ public class DbAttributeStoreTest {
read(HOST_A));
}
+ @Test
+ public void testSlaveIdChanges() {
+ insert(HOST_A_ATTRS);
+ IHostAttributes updated = IHostAttributes.build(HOST_A_ATTRS.newBuilder().setSlaveId(SLAVE_B));
+ insert(updated);
+ assertEquals(Optional.of(updated), read(HOST_A));
+ }
+
private void insert(final IHostAttributes attributes) {
storage.write(new MutateWork.NoResult.Quiet() {
@Override