org.modeshape.jcr.RepositoryConfiguration.getBinaryStorage()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中org.modeshape.jcr.RepositoryConfiguration.getBinaryStorage方法的一些代码示例,展示了RepositoryConfiguration.getBinaryStorage的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RepositoryConfiguration.getBinaryStorage方法的具体详情如下:
包路径:org.modeshape.jcr.RepositoryConfiguration
类名称:RepositoryConfiguration
方法名:getBinaryStorage

RepositoryConfiguration.getBinaryStorage介绍

暂无

代码示例

代码示例来源:origin: ModeShape/modeshape

@Test
public void shouldLoadAndConfigureCustomBinaryStore() throws Exception {
  CustomBinaryStoreImpl store = (CustomBinaryStoreImpl)config.getBinaryStorage().getBinaryStore();
  assertThat(store, is(notNullValue()));
  assertEquals("value", store.getKey());
}

代码示例来源:origin: ModeShape/modeshape

@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));
}

代码示例来源:origin: ModeShape/modeshape

@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));
}

代码示例来源:origin: ModeShape/modeshape

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();
  }
}

代码示例来源:origin: ModeShape/modeshape

@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
  }
}

代码示例来源:origin: ModeShape/modeshape

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;

代码示例来源:origin: org.fcrepo/modeshape-jcr

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;

代码示例来源:origin: ModeShape/modeshape

BinaryStorage binaryStorage = config.getBinaryStorage();
  this.cache.setLargeStringLength(binaryStorage.getMinimumBinarySizeInBytes());
  this.context.getBinaryStore().setMinimumBinarySizeInBytes(binaryStorage.getMinimumBinarySizeInBytes());
BinaryStorage binaryStorageConfig = config.getBinaryStorage();
binaryStore = binaryStorageConfig.getBinaryStore();
binaryStore.start();

代码示例来源:origin: org.fcrepo/modeshape-jcr

BinaryStorage binaryStorage = config.getBinaryStorage();
  this.cache.setLargeStringLength(binaryStorage.getMinimumBinarySizeInBytes());
  this.context.getBinaryStore().setMinimumBinarySizeInBytes(binaryStorage.getMinimumBinarySizeInBytes());
BinaryStorage binaryStorageConfig = config.getBinaryStorage();
binaryStore = binaryStorageConfig.getBinaryStore();
binaryStore.start();

相关文章

微信公众号

最新文章

更多