Skip to content

Commit df628e5

Browse files
committed
Apply suggestions
1 parent fb4ab41 commit df628e5

File tree

9 files changed

+28
-86
lines changed

9 files changed

+28
-86
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,9 @@ public void renameTable_ForExistingTableWithIndexes_ShouldRenameTableAndIndexesC
130130
@Override
131131
@Disabled("Object Storage does not support renaming tables")
132132
public void renameTable_IfOnlyOneTableExists_ShouldRenameTableCorrectly() {}
133+
134+
@Override
135+
@Disabled("There is nothing that needs to be upgraded with Object Storage")
136+
public void
137+
upgrade_WhenMetadataTableExistsButNotNamespacesTable_ShouldCreateNamespacesTableAndImportExistingNamespaces() {}
133138
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,9 @@ public void renameTable_ForExistingTableWithIndexes_ShouldRenameTableAndIndexesC
145145
@Override
146146
@Disabled("Object Storage does not support renaming tables")
147147
public void renameTable_IfOnlyOneTableExists_ShouldRenameTableCorrectly() {}
148+
149+
@Override
150+
@Disabled("There is nothing that needs to be upgraded with Object Storage")
151+
public void
152+
upgrade_WhenMetadataTableExistsButNotNamespacesTable_ShouldCreateNamespacesTableAndImportExistingNamespaces() {}
148153
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,9 @@ public void renameTable_ForExistingTableWithIndexes_ShouldRenameTableAndIndexesC
143143
@Override
144144
@Disabled("Object Storage does not support renaming tables")
145145
public void renameTable_IfOnlyOneTableExists_ShouldRenameTableCorrectly() {}
146+
147+
@Override
148+
@Disabled("There is nothing that needs to be upgraded with Object Storage")
149+
public void
150+
upgrade_WhenMetadataTableExistsButNotNamespacesTable_ShouldCreateNamespacesTableAndImportExistingNamespaces() {}
146151
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
import org.slf4j.LoggerFactory;
1616

1717
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
18-
public class ObjectStorageWrapperIntegrationTestBase {
18+
public class ObjectStorageWrapperIntegrationTest {
1919
private static final Logger logger =
20-
LoggerFactory.getLogger(ObjectStorageWrapperIntegrationTestBase.class);
20+
LoggerFactory.getLogger(ObjectStorageWrapperIntegrationTest.class);
2121

2222
private static final String TEST_NAME = "object_storage_wrapper_integration_test";
2323
private static final String TEST_KEY1 = "test-key1";

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,9 @@ public void renameTable_ForExistingTableWithIndexes_ShouldRenameTableAndIndexesC
124124
@Override
125125
@Disabled("Object Storage does not support renaming tables")
126126
public void renameTable_IfOnlyOneTableExists_ShouldRenameTableCorrectly() {}
127+
128+
@Override
129+
@Disabled("There is nothing that needs to be upgraded with Object Storage")
130+
public void
131+
upgrade_WhenMetadataTableExistsButNotNamespacesTable_ShouldCreateNamespacesTableAndImportExistingNamespaces() {}
127132
}

core/src/main/java/com/scalar/db/storage/objectstorage/ObjectStorageAdmin.java

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -370,33 +370,7 @@ public Set<String> getNamespaceNames() throws ExecutionException {
370370

371371
@Override
372372
public void upgrade(Map<String, String> options) throws ExecutionException {
373-
try {
374-
// Get all namespace names from the table metadata table
375-
Map<String, ObjectStorageTableMetadata> tableMetadataTable = getTableMetadataTable();
376-
List<String> namespaceNames =
377-
tableMetadataTable.keySet().stream()
378-
.map(ObjectStorageAdmin::getNamespaceNameFromTableMetadataKey)
379-
.distinct()
380-
.collect(Collectors.toList());
381-
// Upsert the namespace metadata table
382-
Map<String, String> readVersionMap = new HashMap<>();
383-
Map<String, ObjectStorageNamespaceMetadata> namespaceMetadataTable =
384-
getNamespaceMetadataTable(readVersionMap);
385-
Map<String, ObjectStorageNamespaceMetadata> newNamespaceMetadataTable =
386-
namespaceNames.stream()
387-
.collect(
388-
Collectors.toMap(namespace -> namespace, ObjectStorageNamespaceMetadata::new));
389-
if (namespaceMetadataTable.isEmpty()) {
390-
insertMetadataTable(NAMESPACE_METADATA_TABLE, newNamespaceMetadataTable);
391-
} else {
392-
updateMetadataTable(
393-
NAMESPACE_METADATA_TABLE,
394-
newNamespaceMetadataTable,
395-
readVersionMap.get(NAMESPACE_METADATA_TABLE));
396-
}
397-
} catch (Exception e) {
398-
throw new ExecutionException("Failed to upgrade", e);
399-
}
373+
// Currently, nothing needs to be upgraded. Do nothing.
400374
}
401375

402376
private Map<String, ObjectStorageNamespaceMetadata> getNamespaceMetadataTable()

core/src/main/java/com/scalar/db/storage/objectstorage/blobstorage/BlobStorageConfig.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import static com.scalar.db.config.ConfigUtils.getInt;
44
import static com.scalar.db.config.ConfigUtils.getLong;
5-
import static com.scalar.db.config.ConfigUtils.getString;
65

76
import com.scalar.db.common.CoreError;
87
import com.scalar.db.config.DatabaseConfig;
@@ -22,10 +21,6 @@ public class BlobStorageConfig implements ObjectStorageConfig {
2221
PREFIX + "parallel_upload_threshold_in_bytes";
2322
public static final String REQUEST_TIMEOUT_IN_SECONDS = PREFIX + "request_timeout_in_seconds";
2423

25-
/** @deprecated As of 5.0, will be removed. */
26-
@Deprecated
27-
public static final String TABLE_METADATA_NAMESPACE = PREFIX + "table_metadata.namespace";
28-
2924
public static final long DEFAULT_PARALLEL_UPLOAD_BLOCK_SIZE_IN_BYTES = 4 * 1024 * 1024; // 4MB
3025
public static final int DEFAULT_PARALLEL_UPLOAD_MAX_PARALLELISM = 4;
3126
public static final long DEFAULT_PARALLEL_UPLOAD_THRESHOLD_IN_BYTES = 4 * 1024 * 1024; // 4MB
@@ -63,20 +58,7 @@ public BlobStorageConfig(DatabaseConfig databaseConfig) {
6358
}
6459
username = databaseConfig.getUsername().orElse(null);
6560
password = databaseConfig.getPassword().orElse(null);
66-
67-
if (databaseConfig.getProperties().containsKey(TABLE_METADATA_NAMESPACE)) {
68-
logger.warn(
69-
"The configuration property \""
70-
+ TABLE_METADATA_NAMESPACE
71-
+ "\" is deprecated and will be removed in 5.0.0.");
72-
metadataNamespace =
73-
getString(
74-
databaseConfig.getProperties(),
75-
TABLE_METADATA_NAMESPACE,
76-
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME);
77-
} else {
78-
metadataNamespace = databaseConfig.getSystemNamespaceName();
79-
}
61+
metadataNamespace = databaseConfig.getSystemNamespaceName();
8062

8163
if (databaseConfig.getScanFetchSize() != DatabaseConfig.DEFAULT_SCAN_FETCH_SIZE) {
8264
logger.warn(

core/src/test/java/com/scalar/db/storage/objectstorage/ObjectStorageAdminTest.java

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -608,43 +608,10 @@ public void repairTable_ShouldUpsertTableMetadata() throws Exception {
608608
}
609609

610610
@Test
611-
public void upgrade_WithExistingTables_ShouldUpsertNamespaces() throws Exception {
611+
public void upgrade_ShouldDoNothing() {
612612
// Arrange
613-
String tableMetadataKey1 = "ns1" + ObjectStorageUtils.CONCATENATED_KEY_DELIMITER + "tbl1";
614-
String tableMetadataKey2 = "ns1" + ObjectStorageUtils.CONCATENATED_KEY_DELIMITER + "tbl2";
615-
String tableMetadataKey3 = "ns2" + ObjectStorageUtils.CONCATENATED_KEY_DELIMITER + "tbl3";
616613

617-
String tableMetadataObjectKey =
618-
ObjectStorageUtils.getObjectKey(
619-
METADATA_NAMESPACE, ObjectStorageAdmin.TABLE_METADATA_TABLE);
620-
String namespaceMetadataObjectKey =
621-
ObjectStorageUtils.getObjectKey(
622-
METADATA_NAMESPACE, ObjectStorageAdmin.NAMESPACE_METADATA_TABLE);
623-
624-
// Mock table metadata to return existing tables
625-
Map<String, ObjectStorageTableMetadata> tableMetadataMap = new HashMap<>();
626-
tableMetadataMap.put(tableMetadataKey1, ObjectStorageTableMetadata.newBuilder().build());
627-
tableMetadataMap.put(tableMetadataKey2, ObjectStorageTableMetadata.newBuilder().build());
628-
tableMetadataMap.put(tableMetadataKey3, ObjectStorageTableMetadata.newBuilder().build());
629-
String serializedTableMetadata = Serializer.serialize(tableMetadataMap);
630-
ObjectStorageWrapperResponse tableMetadataResponse =
631-
new ObjectStorageWrapperResponse(serializedTableMetadata, "version1");
632-
when(wrapper.get(tableMetadataObjectKey)).thenReturn(Optional.of(tableMetadataResponse));
633-
634-
// Mock non-existing namespace metadata
635-
when(wrapper.get(namespaceMetadataObjectKey)).thenReturn(Optional.empty());
636-
637-
// Act
638-
admin.upgrade(Collections.emptyMap());
639-
640-
// Assert
641-
verify(wrapper).get(tableMetadataObjectKey);
642-
verify(wrapper).insert(objectKeyCaptor.capture(), payloadCaptor.capture());
643-
644-
Map<String, ObjectStorageNamespaceMetadata> insertedMetadata =
645-
Serializer.deserialize(
646-
payloadCaptor.getValue(),
647-
new TypeReference<Map<String, ObjectStorageNamespaceMetadata>>() {});
648-
assertThat(insertedMetadata).containsKeys("ns1", "ns2");
614+
// Act Assert
615+
assertThatCode(() -> admin.upgrade(Collections.emptyMap())).doesNotThrowAnyException();
649616
}
650617
}

core/src/test/java/com/scalar/db/storage/objectstorage/BlobStorageConfigTest.java renamed to core/src/test/java/com/scalar/db/storage/objectstorage/blobstorage/BlobStorageConfigTest.java

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

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

66
import com.scalar.db.config.DatabaseConfig;
7-
import com.scalar.db.storage.objectstorage.blobstorage.BlobStorageConfig;
87
import java.util.Properties;
98
import org.junit.jupiter.api.Test;
109

0 commit comments

Comments
 (0)