forked from uschi2000/atlasdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Timestamp Store Invalidator plus basic tests.
- Loading branch information
1 parent
282a8c7
commit 7ed9c79
Showing
3 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
timestamp-api/src/main/java/com/palantir/timestamp/TimestampStoreInvalidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright 2017 Palantir Technologies | ||
* | ||
* Licensed under the BSD-3 License (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* 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 com.palantir.timestamp; | ||
|
||
public interface TimestampStoreInvalidator { | ||
/** | ||
* This method corrupts the data in an underlying timestamp bound store. This is important for the safety of | ||
* timestamp store migrations; if one migrates AtlasDB to a different timestamp bound store, then the | ||
* original timestamp bound store must not be used again if it is not updated with information about what | ||
* timestamps the new store has given out. | ||
* | ||
* As this method performs corruption, it should only be called *after* the migration of the existing timestamp | ||
* bound to the new timestamp bound store has been carried out successfully. | ||
* | ||
* Of course, this is not strictly needed if no one ever uses the original timestamp bound store again. | ||
* However, we find this to be a safety precaution worth taking, especially if AtlasDB is subsequently downgraded. | ||
*/ | ||
void invalidateTimestampStore(); | ||
|
||
/** | ||
* This method performs the inverse of invalidateTimestampStore(). | ||
* | ||
* It is not safe to use a revalidated timestamp store directly, *unless* we can guarantee that no timestamps | ||
* have been taken out for the relevant data since invalidation. | ||
*/ | ||
default void revalidateTimestampStore() { | ||
throw new UnsupportedOperationException("This timestamp store does not support revalidation!"); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
timestamp-api/src/test/java/com/palantir/timestamp/TimestampStoreInvalidatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Copyright 2017 Palantir Technologies | ||
* | ||
* Licensed under the BSD-3 License (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* 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 com.palantir.timestamp; | ||
|
||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
import org.junit.Test; | ||
|
||
public class TimestampStoreInvalidatorTest { | ||
@Test | ||
public void revalidateTimestampStoreThrowsByDefault() { | ||
TimestampStoreInvalidator nopInvalidator = () -> {}; | ||
assertThatThrownBy(nopInvalidator::revalidateTimestampStore).isInstanceOf(UnsupportedOperationException.class); | ||
} | ||
} |