DatastoreContextIntrospector { public synchronized boolean update(final Map<String, Object> properties) { currentProperties = null; if (properties == null || properties.isEmpty()) { return false; } LOG.debug("In update: properties: {}", properties); final ImmutableMap.Builder<String, Object> mapBuilder = ImmutableMap.<String, Object>builder(); final Builder builder = DatastoreContext.newBuilderFrom(context); final String dataStoreTypePrefix = context.getDataStoreName() + '.'; final List<String> keys = getSortedKeysByDatastoreType(properties.keySet(), dataStoreTypePrefix); boolean updated = false; for (String key: keys) { final Object value = properties.get(key); mapBuilder.put(key, value); if (key.startsWith(dataStoreTypePrefix)) { key = key.replaceFirst(dataStoreTypePrefix, ""); } if (convertValueAndInvokeSetter(key, value.toString(), builder)) { updated = true; } } currentProperties = mapBuilder.build(); if (updated) { context = builder.build(); } return updated; } DatastoreContextIntrospector(final DatastoreContext context,
            final DataStorePropertiesContainer defaultPropsContainer); synchronized DatastoreContext getContext(); DatastoreContextFactory newContextFactory(); synchronized DatastoreContext getShardDatastoreContext(final String forShardName); synchronized boolean update(final Map<String, Object> properties);  }
@Test public void testUpdate() { final DatastoreContextIntrospector introspector = INTROSPECTOR_FACTORY.newInstance(OPERATIONAL); final Map<String, Object> properties = new HashMap<>(); properties.put("shard-transaction-idle-timeout-in-minutes", "31"); properties.put("operation-timeout-in-seconds", "26"); properties.put("shard-transaction-commit-timeout-in-seconds", "100"); properties.put("shard-journal-recovery-log-batch-size", "199"); properties.put("shard-snapshot-batch-count", "212"); properties.put("shard-heartbeat-interval-in-millis", "101"); properties.put("shard-transaction-commit-queue-capacity", "567"); properties.put("shard-initialization-timeout-in-seconds", "82"); properties.put("shard-leader-election-timeout-in-seconds", "66"); properties.put("initial-settle-timeout-multiplier", "5"); properties.put("recovery-snapshot-interval-seconds", "360"); properties.put("shard-isolated-leader-check-interval-in-millis", "123"); properties.put("shard-snapshot-data-threshold-percentage", "100"); properties.put("shard-snapshot-data-threshold", "800"); properties.put("shard-election-timeout-factor", "21"); properties.put("shard-batched-modification-count", "901"); properties.put("transactionCreationInitialRateLimit", "200"); properties.put("MaxShardDataChangeExecutorPoolSize", "41"); properties.put("Max-Shard-Data-Change Executor-Queue Size", "1111"); properties.put(" max shard data change listener queue size", "2222"); properties.put("mAx-shaRd-data-STORE-executor-quEUe-size", "3333"); properties.put("persistent", "false"); properties.put("initial-payload-serialized-buffer-capacity", "600"); boolean updated = introspector.update(properties); assertTrue("updated", updated); DatastoreContext context = introspector.getContext(); assertEquals(31, context.getShardTransactionIdleTimeout().toMinutes()); assertEquals(26000, context.getOperationTimeoutInMillis()); assertEquals(100, context.getShardTransactionCommitTimeoutInSeconds()); assertEquals(199, context.getShardRaftConfig().getJournalRecoveryLogBatchSize()); assertEquals(212, context.getShardRaftConfig().getSnapshotBatchCount()); assertEquals(101, context.getShardRaftConfig().getHeartBeatInterval().length()); assertEquals(567, context.getShardTransactionCommitQueueCapacity()); assertEquals(82, context.getShardInitializationTimeout().duration().toSeconds()); assertEquals(66, context.getShardLeaderElectionTimeout().duration().toSeconds()); assertEquals(5, context.getInitialSettleTimeoutMultiplier()); assertEquals(360, context.getShardRaftConfig().getRecoverySnapshotIntervalSeconds()); assertEquals(123, context.getShardRaftConfig().getIsolatedCheckIntervalInMillis()); assertEquals(100, context.getShardRaftConfig().getSnapshotDataThresholdPercentage()); assertEquals(800, context.getShardRaftConfig().getSnapshotDataThreshold()); assertEquals(21, context.getShardRaftConfig().getElectionTimeoutFactor()); assertEquals(901, context.getShardBatchedModificationCount()); assertEquals(200, context.getTransactionCreationInitialRateLimit()); assertEquals(600, context.getInitialPayloadSerializedBufferCapacity()); assertFalse(context.isPersistent()); properties.put("shard-transaction-idle-timeout-in-minutes", "32"); properties.put("operation-timeout-in-seconds", "27"); properties.put("shard-heartbeat-interval-in-millis", "102"); properties.put("shard-election-timeout-factor", "22"); properties.put("initial-settle-timeout-multiplier", "6"); properties.put("max-shard-data-change-executor-pool-size", "42"); properties.put("max-shard-data-store-executor-queue-size", "4444"); properties.put("persistent", "true"); updated = introspector.update(properties); assertTrue("updated", updated); context = introspector.getContext(); assertEquals(32, context.getShardTransactionIdleTimeout().toMinutes()); assertEquals(27000, context.getOperationTimeoutInMillis()); assertEquals(100, context.getShardTransactionCommitTimeoutInSeconds()); assertEquals(199, context.getShardRaftConfig().getJournalRecoveryLogBatchSize()); assertEquals(212, context.getShardRaftConfig().getSnapshotBatchCount()); assertEquals(102, context.getShardRaftConfig().getHeartBeatInterval().length()); assertEquals(567, context.getShardTransactionCommitQueueCapacity()); assertEquals(82, context.getShardInitializationTimeout().duration().toSeconds()); assertEquals(66, context.getShardLeaderElectionTimeout().duration().toSeconds()); assertEquals(6, context.getInitialSettleTimeoutMultiplier()); assertEquals(123, context.getShardRaftConfig().getIsolatedCheckIntervalInMillis()); assertEquals(100, context.getShardRaftConfig().getSnapshotDataThresholdPercentage()); assertEquals(800, context.getShardRaftConfig().getSnapshotDataThreshold()); assertEquals(22, context.getShardRaftConfig().getElectionTimeoutFactor()); assertEquals(200, context.getTransactionCreationInitialRateLimit()); assertTrue(context.isPersistent()); updated = introspector.update(null); assertFalse("updated", updated); updated = introspector.update(new HashMap<>()); assertFalse("updated", updated); }