Skip to content

Commit 001f0b9

Browse files
committed
CASL-1784 - documentation update, use a common mapId in NakshaHub
Signed-off-by: Piotr-Here <ext-piotr.sobotowski@here.com>
1 parent 05b3fa4 commit 001f0b9

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,16 @@ Before running Gradle, set the environment variables for the mode you want.
256256
export NAKSHA_APP_SERVICE_TEST_CONTEXT=LOCAL_STANDALONE
257257
export NAKSHA_TEST_STORAGE_ID=local_psql_test_storage
258258
export HUB_ADMIN_STORAGE_ID=local_psql_test_storage
259-
export NAKSHA_TEST_ADMIN_DB_URL="jdbc:postgresql://localhost:5432/postgres?user=postgres&password=password"
259+
260+
# For `here-naksha-lib-psql` tests.
260261
export NAKSHA_TEST_PSQL_DB_URL="jdbc:postgresql://localhost:5432/postgres?user=postgres&password=password"
262+
263+
# For `here-naksha-app-service` admin storage tests.
264+
export NAKSHA_TEST_ADMIN_DB_URL="jdbc:postgresql://localhost:5432/postgres?user=postgres&password=password"
265+
266+
# For `here-naksha-app-service` data storage tests.
267+
# Kept separate from the admin DB URL to allow deployment-like test setups,
268+
# where administrative entities are stored in a different database/storage than data entities.
261269
export NAKSHA_TEST_DATA_DB_URL="jdbc:postgresql://localhost:5432/postgres?user=postgres&password=password"
262270
263271
./gradlew cleanAndTest

here-naksha-lib-hub/src/jvmMain/java/com/here/naksha/lib/hub/NakshaHub.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public NakshaHub(
172172
this.spaceStorageInstance = new NHSpaceStorage(this, new NakshaEventPipelineFactory(this));
173173
// setup backend storage DB and Hub config
174174
NakshaContext nakshaContext = setupMapAndContext(adminMapId);
175-
final NakshaHubConfig finalCfg = this.storageSetup(customCfg, configId, nakshaContext);
175+
final NakshaHubConfig finalCfg = this.storageSetup(customCfg, configId, nakshaContext, adminMapId);
176176
if (finalCfg == null) {
177177
throw new RuntimeException("Server configuration not found! Neither in Admin storage nor a default file.");
178178
}
@@ -218,19 +218,19 @@ private NakshaContext setupMapAndContext(String mapId) {
218218
private @Nullable NakshaHubConfig storageSetup(
219219
final @Nullable NakshaHubConfig customCfg,
220220
final @Nullable String configId,
221-
final @NotNull NakshaContext nakshaContext
222-
) {
221+
final @NotNull NakshaContext nakshaContext,
222+
final @NotNull String adminMapId) {
223223
// 1. Create all Admin collections in Admin DB
224-
createAdminCollections(nakshaContext);
224+
createAdminCollections(nakshaContext, adminMapId);
225225

226226
// 2. fetch / add latest config
227-
return configSetup(nakshaContext, customCfg, configId);
227+
return configSetup(nakshaContext, customCfg, configId, adminMapId);
228228
}
229229

230-
private void createAdminCollections(NakshaContext nakshaContext) {
230+
private void createAdminCollections(NakshaContext nakshaContext, String adminMapId) {
231231
getAdminStorage().runInWriteSession(SessionOptions.from(nakshaContext, true), admin -> {
232232
logger.info("WriteCollections Request for {}, against Admin storage.", ALL_HUB_INTERNAL_COLLECTIONS);
233-
final Response createAdminCollectionsResponse = admin.execute(upsertAdminCollectionsRequest());
233+
final Response createAdminCollectionsResponse = admin.execute(upsertAdminCollectionsRequest(adminMapId));
234234
if (createAdminCollectionsResponse instanceof SuccessResponse successResponse) {
235235
NakshaFeatureList createdCollections = successResponse.getFeatures();
236236
for (NakshaFeature createdCollection : createdCollections) {
@@ -253,18 +253,19 @@ private void createAdminCollections(NakshaContext nakshaContext) {
253253
});
254254
}
255255

256-
private static WriteRequest upsertAdminCollectionsRequest() {
256+
private static WriteRequest upsertAdminCollectionsRequest(@NotNull String adminMapId) {
257257
final WriteRequest writeRequest = new WriteRequest();
258258
for (String adminCollectionId : ALL_HUB_INTERNAL_COLLECTIONS) {
259-
writeRequest.add(new Write().upsertCollection(new NakshaCollection(adminCollectionId, NakshaHubAdminStorageIdentifiers.getHubAdminMapId())));
259+
writeRequest.add(new Write().upsertCollection(new NakshaCollection(adminCollectionId, adminMapId)));
260260
}
261261
return writeRequest;
262262
}
263263

264264
private @Nullable NakshaHubConfig configSetup(
265265
final @NotNull NakshaContext nakshaContext,
266266
final @Nullable NakshaHubConfig customCfg,
267-
final @Nullable String configId) {
267+
final @Nullable String configId,
268+
final @NotNull String adminMapId) {
268269
/*
269270
* Config preference, for a given configId (e.g. "custom-config"):
270271
* 1. Custom config - If provided, persist the same in DB, and use the same for NakshaHub
@@ -276,7 +277,7 @@ private static WriteRequest upsertAdminCollectionsRequest() {
276277
return getAdminStorage().useWriteSession(SessionOptions.from(nakshaContext, true), admin -> {
277278
if (customCfg != null) {
278279
WriteRequest writeCustomCfg = new WriteRequest()
279-
.add(new Write().upsertFeature(NakshaHubAdminStorageIdentifiers.getHubAdminMapId(), CONFIGS, customCfg));
280+
.add(new Write().upsertFeature(adminMapId, CONFIGS, customCfg));
280281
Response writeCustomCfgResponse = admin.execute(writeCustomCfg);
281282
if (writeCustomCfgResponse instanceof SuccessResponse) {
282283
admin.commit();

0 commit comments

Comments
 (0)