@Test public void shouldLoadAndConfigureCustomBinaryStore() throws Exception { CustomBinaryStoreImpl store = (CustomBinaryStoreImpl)config.getBinaryStorage().getBinaryStore(); assertThat(store, is(notNullValue())); assertEquals("value", store.getKey()); }
@Test public void shouldAllowUpdatingRepositoryConfigurationWhileNotRunning() throws Exception { engine.start(); JcrRepository repository = engine.deploy(config); String name = repository.getName(); assertThat(engine.getRepositoryState(name), is(State.NOT_RUNNING)); assertThat(config.getBinaryStorage().getMinimumBinarySizeInBytes(), is(Default.MINIMUM_BINARY_SIZE_IN_BYTES)); // Change the configuration ... long newLargeValueSizeInBytes = Default.MINIMUM_BINARY_SIZE_IN_BYTES * 2; Editor editor = repository.getConfiguration().edit(); EditableDocument binaryStorage = editor.getOrCreateDocument(FieldName.STORAGE) .getOrCreateDocument(FieldName.BINARY_STORAGE); binaryStorage.setNumber(FieldName.MINIMUM_BINARY_SIZE_IN_BYTES, newLargeValueSizeInBytes); Changes changes = editor.getChanges(); // Apply the changes to the deployed repository ... engine.update(name, changes).get(); // blocks assertThat(engine.getRepositoryState(name), is(State.NOT_RUNNING)); RepositoryConfiguration newConfig = engine.getRepository(name).getConfiguration(); assertThat(newConfig.getBinaryStorage().getMinimumBinarySizeInBytes(), is(newLargeValueSizeInBytes)); }
@Test public void shouldAllowUpdatingRepositoryConfigurationWhileRunning() throws Exception { engine.start(); JcrRepository repository = engine.deploy(config); String name = repository.getName(); assertThat(engine.getRepositoryState(name), is(State.NOT_RUNNING)); engine.startRepository(name).get(); // blocks assertThat(engine.getRepositoryState(name), is(State.RUNNING)); long defaultLargeValueSize = Default.MINIMUM_BINARY_SIZE_IN_BYTES; assertThat(config.getBinaryStorage().getMinimumBinarySizeInBytes(), is(defaultLargeValueSize)); assertThat(repository.repositoryCache().largeValueSizeInBytes(), is(defaultLargeValueSize)); // Change the configuration. We'll do something simple, like changing the large value size ... long newLargeValueSizeInBytes = defaultLargeValueSize * 2L; Editor editor = repository.getConfiguration().edit(); EditableDocument binaryStorage = editor.getOrCreateDocument(FieldName.STORAGE) .getOrCreateDocument(FieldName.BINARY_STORAGE); binaryStorage.setNumber(FieldName.MINIMUM_BINARY_SIZE_IN_BYTES, newLargeValueSizeInBytes); Changes changes = editor.getChanges(); // Apply the changes to the deployed repository ... engine.update(name, changes).get(); // blocks assertThat(engine.getRepositoryState(name), is(State.RUNNING)); // Verify the running repository and its configuraiton are using the new value ... RepositoryConfiguration newConfig = engine.getRepository(name).getConfiguration(); assertThat(newConfig.getBinaryStorage().getMinimumBinarySizeInBytes(), is(newLargeValueSizeInBytes)); assertThat(repository.repositoryCache().largeValueSizeInBytes(), is(newLargeValueSizeInBytes)); }
private void storeStringsAndAssert( String stringNode ) throws Exception { Node testRoot = jcrSession().getRootNode().addNode(stringNode); long minStringSize = repository.getConfiguration().getBinaryStorage().getMinimumStringSize(); //the small string should be stored as a string String smallString = randomString(minStringSize - 1); testRoot.setProperty("smallString", smallString); //the large string should be stored as a binary String largeString = randomString(minStringSize + 1); testRoot.setProperty("largeString", largeString); jcrSession().save(); //use a separate session to validate because the original one still caches the properties as string... JcrSession readerSession = repository.login(); try { Property smallStringProperty = readerSession.getProperty("/" + stringNode + "/smallString"); assertEquals("Small string should've been stored as a string", PropertyType.STRING, smallStringProperty.getType()); assertEquals("Incorrect stored string value", smallString, smallStringProperty.getString()); Property largeStringProperty = readerSession.getProperty("/" + stringNode + "/largeString"); assertEquals("Large string should've been stored as a binary", PropertyType.BINARY, largeStringProperty.getType()); String binaryStringValue = IoUtil.read(largeStringProperty.getBinary().getStream()); assertEquals("Incorrect stored string value", largeString, binaryStringValue); } finally { readerSession.logout(); } }
@Test @FixFor( {"MODE-2575", "MODE-2635"} ) public void shouldSuccessfullyValidateMongoBinaryStorageConfiguration() throws Exception { RepositoryConfiguration config = assertValid("config/mongo-binary-storage-full-config.json"); Document storageDoc = config.getDocument().getDocument(FieldName.STORAGE).getDocument(FieldName.BINARY_STORAGE); assertEquals(Arrays.asList("192.1.68.1.1:90", "143.22.33.123:120"), storageDoc.get(FieldName.HOST_ADDRESSES)); RepositoryConfiguration.BinaryStorage storage = config.getBinaryStorage(); assertEquals(RepositoryConfiguration.FieldValue.BINARY_STORAGE_TYPE_MONGO, storage.getType()); assertTrue(storage.getBinaryStore() instanceof MongodbBinaryStore); // remove host and port, check that the config is still valid Editor editor = config.edit(); EditableDocument storageDocEditable = editor.getDocument(FieldName.STORAGE).getDocument(FieldName.BINARY_STORAGE); storageDocEditable.remove(FieldName.HOST); storageDocEditable.remove(FieldName.PORT); RepositoryConfiguration configWithoutHostPort = new RepositoryConfiguration(editor.unwrap(), "mongo-config-1"); assertValid(configWithoutHostPort); // remove host addresses as well and check that what remains is not valid storageDocEditable.remove(FieldName.HOST_ADDRESSES); RepositoryConfiguration invalidConfig = new RepositoryConfiguration(editor.unwrap(), "mongo-config-2"); try { invalidConfig.getBinaryStorage().getBinaryStore(); fail("Should not allow a Mongo binary storage without host, port and host addresses"); } catch (IllegalArgumentException e) { //expected } }
this.configuration = configuration; this.documentStore = documentStore; this.minimumStringLengthForBinaryStorage.set(configuration.getBinaryStorage().getMinimumStringSize()); this.translator = new DocumentTranslator(this.context, this.documentStore, this.minimumStringLengthForBinaryStorage.get()); this.repositoryEnvironment = repositoryEnvironment;
this.configuration = configuration; this.documentStore = documentStore; this.minimumStringLengthForBinaryStorage.set(configuration.getBinaryStorage().getMinimumStringSize()); this.translator = new DocumentTranslator(this.context, this.documentStore, this.minimumStringLengthForBinaryStorage.get()); this.repositoryEnvironment = repositoryEnvironment;
BinaryStorage binaryStorage = config.getBinaryStorage(); this.cache.setLargeStringLength(binaryStorage.getMinimumBinarySizeInBytes()); this.context.getBinaryStore().setMinimumBinarySizeInBytes(binaryStorage.getMinimumBinarySizeInBytes()); BinaryStorage binaryStorageConfig = config.getBinaryStorage(); binaryStore = binaryStorageConfig.getBinaryStore(); binaryStore.start();
BinaryStorage binaryStorage = config.getBinaryStorage(); this.cache.setLargeStringLength(binaryStorage.getMinimumBinarySizeInBytes()); this.context.getBinaryStore().setMinimumBinarySizeInBytes(binaryStorage.getMinimumBinarySizeInBytes()); BinaryStorage binaryStorageConfig = config.getBinaryStorage(); binaryStore = binaryStorageConfig.getBinaryStore(); binaryStore.start();