Skip to content

Commit 5a18d4e

Browse files
committed
Add isConsistentReadGuaranteed() to StorageInfo
1 parent 5c9de75 commit 5a18d4e

File tree

38 files changed

+322
-181
lines changed

38 files changed

+322
-181
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.scalar.db.storage.cassandra;
22

3-
import com.scalar.db.api.DistributedStorageMutationAtomicityUnitIntegrationTestBase;
3+
import com.scalar.db.api.DistributedStorageAtomicityUnitIntegrationTestBase;
44
import java.util.Collections;
55
import java.util.Map;
66
import java.util.Properties;
77

8-
public class CassandraMutationAtomicityUnitIntegrationTest
9-
extends DistributedStorageMutationAtomicityUnitIntegrationTestBase {
8+
public class CassandraAtomicityUnitIntegrationTest
9+
extends DistributedStorageAtomicityUnitIntegrationTestBase {
1010

1111
@Override
1212
protected Properties getProperties(String testName) {
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.scalar.db.storage.cosmos;
22

3-
import com.scalar.db.api.DistributedStorageMutationAtomicityUnitIntegrationTestBase;
3+
import com.scalar.db.api.DistributedStorageAtomicityUnitIntegrationTestBase;
44
import java.util.Map;
55
import java.util.Properties;
66
import org.junit.jupiter.api.Disabled;
77

8-
public class CosmosMutationAtomicityUnitIntegrationTest
9-
extends DistributedStorageMutationAtomicityUnitIntegrationTestBase {
8+
public class CosmosAtomicityUnitIntegrationTest
9+
extends DistributedStorageAtomicityUnitIntegrationTestBase {
1010

1111
@Override
1212
protected Properties getProperties(String testName) {
@@ -20,6 +20,5 @@ protected Map<String, String> getCreationOptions() {
2020

2121
@Disabled("This test fails. It might be a bug")
2222
@Override
23-
public void
24-
mutate_MutationsWithinRecordGiven_ShouldBehaveCorrectlyBaseOnMutationAtomicityUnit() {}
23+
public void mutate_MutationsWithinRecordGiven_ShouldBehaveCorrectlyBaseOnAtomicityUnit() {}
2524
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.scalar.db.storage.dynamo;
22

3-
import com.scalar.db.api.DistributedStorageMutationAtomicityUnitIntegrationTestBase;
3+
import com.scalar.db.api.DistributedStorageAtomicityUnitIntegrationTestBase;
44
import java.util.Map;
55
import java.util.Properties;
66
import org.junit.jupiter.api.Disabled;
77

8-
public class DynamoMutationAtomicityUnitIntegrationTest
9-
extends DistributedStorageMutationAtomicityUnitIntegrationTestBase {
8+
public class DynamoAtomicityUnitIntegrationTest
9+
extends DistributedStorageAtomicityUnitIntegrationTestBase {
1010

1111
@Override
1212
protected Properties getProperties(String testName) {
@@ -20,6 +20,5 @@ protected Map<String, String> getCreationOptions() {
2020

2121
@Disabled("Transaction request cannot include multiple operations on one item in DynamoDB")
2222
@Override
23-
public void
24-
mutate_MutationsWithinRecordGiven_ShouldBehaveCorrectlyBaseOnMutationAtomicityUnit() {}
23+
public void mutate_MutationsWithinRecordGiven_ShouldBehaveCorrectlyBaseOnAtomicityUnit() {}
2524
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.scalar.db.storage.jdbc;
2+
3+
import com.scalar.db.api.DistributedStorageAtomicityUnitIntegrationTestBase;
4+
import java.util.Properties;
5+
6+
public class JdbcDatabaseAtomicityUnitIntegrationTest
7+
extends DistributedStorageAtomicityUnitIntegrationTestBase {
8+
9+
@Override
10+
protected Properties getProperties(String testName) {
11+
return JdbcEnv.getProperties(testName);
12+
}
13+
}

core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcDatabaseMutationAtomicityUnitIntegrationTest.java

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import static org.assertj.core.api.Assertions.assertThat;
44

5-
import com.scalar.db.api.DistributedStorageMutationAtomicityUnitIntegrationTestBase;
5+
import com.scalar.db.api.DistributedStorageAtomicityUnitIntegrationTestBase;
66
import com.scalar.db.api.Put;
77
import com.scalar.db.config.DatabaseConfig;
88
import com.scalar.db.exception.storage.ExecutionException;
@@ -12,8 +12,8 @@
1212
import org.assertj.core.api.Assertions;
1313
import org.junit.jupiter.api.Test;
1414

15-
public class MultiStorageMutationAtomicityUnitIntegrationTest
16-
extends DistributedStorageMutationAtomicityUnitIntegrationTestBase {
15+
public class MultiStorageAtomicityUnitIntegrationTest
16+
extends DistributedStorageAtomicityUnitIntegrationTestBase {
1717

1818
@Override
1919
public Properties getProperties(String testName) {
@@ -61,7 +61,7 @@ public Properties getProperties(String testName) {
6161
}
6262

6363
@Test
64-
public void mutate_MutationsAcrossStorageGiven_ShouldBehaveCorrectlyBaseOnMutationAtomicityUnit()
64+
public void mutate_MutationsAcrossStorageGiven_ShouldBehaveCorrectlyBaseOnAtomicityUnit()
6565
throws ExecutionException {
6666
// Arrange
6767
Put put1 =

core/src/integration-test/java/com/scalar/db/storage/objectstorage/ObjectStorageMutationAtomicityUnitIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.scalar.db.storage.objectstorage;
22

3-
import com.scalar.db.api.DistributedStorageMutationAtomicityUnitIntegrationTestBase;
3+
import com.scalar.db.api.DistributedStorageAtomicityUnitIntegrationTestBase;
44
import java.util.Map;
55
import java.util.Properties;
66

77
public class ObjectStorageMutationAtomicityUnitIntegrationTest
8-
extends DistributedStorageMutationAtomicityUnitIntegrationTestBase {
8+
extends DistributedStorageAtomicityUnitIntegrationTestBase {
99

1010
@Override
1111
protected Properties getProperties(String testName) {

core/src/main/java/com/scalar/db/api/DistributedStorage.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ public interface DistributedStorage extends AutoCloseable {
182182
* Mutates entries of the underlying storage with the specified list of {@link Mutation} commands.
183183
*
184184
* <p>Note that this method only supports mutations within the atomicity unit specified by {@link
185-
* StorageInfo#getMutationAtomicityUnit()}. For example, if the atomicity unit of the storage is
186-
* {@link StorageInfo.MutationAtomicityUnit#PARTITION}, the mutations must occur within the same
187-
* partition. Also note that the maximum number of mutations that can be performed atomically is
188-
* defined by {@link StorageInfo#getMaxAtomicMutationsCount()}.
185+
* StorageInfo#getAtomicityUnit()}. For example, if the atomicity unit of the storage is {@link
186+
* StorageInfo.AtomicityUnit#PARTITION}, the mutations must occur within the same partition. Also
187+
* note that the maximum number of mutations that can be performed atomically is defined by {@link
188+
* StorageInfo#getMaxAtomicMutationsCount()}.
189189
*
190190
* <p>To retrieve storage information, use {@link DistributedStorageAdmin#getStorageInfo(String)}.
191191
*

core/src/main/java/com/scalar/db/api/DistributedStorageAdmin.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public interface DistributedStorageAdmin extends Admin, AutoCloseable {
4747
/**
4848
* Returns the storage information.
4949
*
50+
* <p>Note: This feature is primarily for internal use. Breaking changes can and will be
51+
* introduced to it. Users should not depend on it.
52+
*
5053
* @param namespace the namespace to get the storage information for
5154
* @return the storage information
5255
* @throws ExecutionException if the operation fails

core/src/main/java/com/scalar/db/api/StorageInfo.java

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.scalar.db.api;
22

3+
/** Represents storage information. */
34
public interface StorageInfo {
45
/**
56
* Returns the storage name.
@@ -9,11 +10,11 @@ public interface StorageInfo {
910
String getStorageName();
1011

1112
/**
12-
* Returns the mutation atomicity unit of the storage.
13+
* Returns the atomicity unit of the storage.
1314
*
14-
* @return the mutation atomicity unit of the storage
15+
* @return the atomicity unit of the storage
1516
*/
16-
MutationAtomicityUnit getMutationAtomicityUnit();
17+
AtomicityUnit getAtomicityUnit();
1718

1819
/**
1920
* Returns the maximum number of mutations that can be performed atomically in the storage.
@@ -23,38 +24,45 @@ public interface StorageInfo {
2324
int getMaxAtomicMutationsCount();
2425

2526
/**
26-
* The mutation atomicity unit of the storage.
27+
* Returns whether the storage guarantees consistent reads within its atomicity unit.
2728
*
28-
* <p>This enum defines the atomicity unit for mutations in the storage. It determines the scope
29-
* of atomicity for mutations such as put and delete.
29+
* @return true if the storage guarantees consistent reads within its atomicity unit, false
30+
* otherwise
3031
*/
31-
enum MutationAtomicityUnit {
32+
boolean isConsistentReadGuaranteed();
33+
34+
/**
35+
* The atomicity unit of the storage.
36+
*
37+
* <p>This enum defines the atomicity unit for operations in the storage.
38+
*/
39+
enum AtomicityUnit {
3240
/**
33-
* The atomicity unit is at the record level, meaning that mutations are performed atomically
41+
* The atomicity unit is at the record level, meaning that operations are performed atomically
3442
* for each record.
3543
*/
3644
RECORD,
3745

3846
/**
39-
* The atomicity unit is at the partition level, meaning that mutations are performed atomically
40-
* for each partition.
47+
* The atomicity unit is at the partition level, meaning that operations are performed
48+
* atomically for each partition.
4149
*/
4250
PARTITION,
4351

4452
/**
45-
* The atomicity unit is at the table level, meaning that mutations are performed atomically for
46-
* each table.
53+
* The atomicity unit is at the table level, meaning that operations are performed atomically
54+
* for each table.
4755
*/
4856
TABLE,
4957

5058
/**
51-
* The atomicity unit is at the namespace level, meaning that mutations are performed atomically
52-
* for each namespace.
59+
* The atomicity unit is at the namespace level, meaning that operations are performed
60+
* atomically for each namespace.
5361
*/
5462
NAMESPACE,
5563

5664
/**
57-
* The atomicity unit is at the storage level, meaning that mutations are performed atomically
65+
* The atomicity unit is at the storage level, meaning that operations are performed atomically
5866
* for the entire storage.
5967
*/
6068
STORAGE

0 commit comments

Comments
 (0)