private void enableMonitoring( boolean enableMonitoring, EditableDocument configDoc ) { EditableDocument monitoring = configDoc.getOrCreateDocument(FieldName.MONITORING); monitoring.set(FieldName.MONITORING_ENABLED, enableMonitoring); } }
private void parseTextExtraction( ModelNode model, EditableDocument configDoc ) { if (model.hasDefined(ModelKeys.TEXT_EXTRACTORS_THREAD_POOL_NAME)) { EditableDocument extractors = configDoc.getOrCreateDocument(FieldName.TEXT_EXTRACTION); String poolName = model.get(ModelKeys.TEXT_EXTRACTORS_THREAD_POOL_NAME).asString(); extractors.set(FieldName.THREAD_POOL, poolName); } if (model.hasDefined(ModelKeys.TEXT_EXTRACTORS_MAX_POOL_SIZE)) { EditableDocument sequencing = configDoc.getOrCreateDocument(FieldName.TEXT_EXTRACTION); int maxPoolSize = model.get(ModelKeys.TEXT_EXTRACTORS_MAX_POOL_SIZE).asInt(); sequencing.set(FieldName.MAX_POOL_SIZE, maxPoolSize); } }
private void parseReindexing( ModelNode model, EditableDocument configDoc ) { if (model.hasDefined(ModelKeys.REINDEXING_ASYNC)) { EditableDocument reindexing = configDoc.getOrCreateDocument(FieldName.REINDEXING); boolean async = model.get(ModelKeys.REINDEXING_ASYNC).asBoolean(); reindexing.set(FieldName.REINDEXING_ASYNC, async); } if (model.hasDefined(ModelKeys.REINDEXING_MODE)) { EditableDocument reindexing = configDoc.getOrCreateDocument(FieldName.REINDEXING); String mode = model.get(ModelKeys.REINDEXING_MODE).asString(); reindexing.set(FieldName.REINDEXING_MODE, mode); } }
private void parseSequencing( ModelNode model, EditableDocument configDoc ) { if (model.hasDefined(ModelKeys.SEQUENCERS_THREAD_POOL_NAME)) { EditableDocument sequencing = configDoc.getOrCreateDocument(FieldName.SEQUENCING); String sequencingThreadPool = model.get(ModelKeys.SEQUENCERS_THREAD_POOL_NAME).asString(); sequencing.set(FieldName.THREAD_POOL, sequencingThreadPool); } if (model.hasDefined(ModelKeys.SEQUENCERS_MAX_POOL_SIZE)) { EditableDocument sequencing = configDoc.getOrCreateDocument(FieldName.SEQUENCING); int maxPoolSize = model.get(ModelKeys.SEQUENCERS_MAX_POOL_SIZE).asInt(); sequencing.set(FieldName.MAX_POOL_SIZE, maxPoolSize); } }
private void parseClustering(String clusterName, String clusterConfig, String clusterLocking, EditableDocument configDoc) { EditableDocument clustering = configDoc.getOrCreateDocument(FieldName.CLUSTERING); clustering.setString(FieldName.CLUSTER_NAME, clusterName); if (!StringUtil.isBlank(clusterConfig)) { clustering.setString(FieldName.CLUSTER_CONFIGURATION, clusterConfig); } if (!StringUtil.isBlank(clusterLocking)) { clustering.setString(FieldName.CLUSTER_LOCKING, clusterLocking); } }
private EditableDocument parseWorkspaces(OperationContext context, ModelNode model, EditableDocument configDoc, List<String> additionalClasspathEntries) throws OperationFailedException { EditableDocument workspacesDoc = configDoc.getOrCreateDocument(FieldName.WORKSPACES); boolean allowWorkspaceCreation = attribute(context, model, ModelAttributes.ALLOW_WORKSPACE_CREATION).asBoolean(); String defaultWorkspaceName = attribute(context, model, ModelAttributes.DEFAULT_WORKSPACE).asString(); workspacesDoc.set(FieldName.ALLOW_CREATION, allowWorkspaceCreation); workspacesDoc.set(FieldName.DEFAULT, defaultWorkspaceName); if (model.hasDefined(ModelKeys.WORKSPACES_CACHE_SIZE)) { workspacesDoc.set(FieldName.WORKSPACE_CACHE_SIZE, model.get(ModelKeys.WORKSPACES_CACHE_SIZE).asInt()); } if (model.hasDefined(ModelKeys.PREDEFINED_WORKSPACE_NAMES)) { for (ModelNode name : model.get(ModelKeys.PREDEFINED_WORKSPACE_NAMES).asList()) { workspacesDoc.getOrCreateArray(FieldName.PREDEFINED).add(name.asString()); } if (model.hasDefined(ModelKeys.WORKSPACES_INITIAL_CONTENT)) { EditableDocument initialContentDocument = workspacesDoc.getOrCreateDocument(FieldName.INITIAL_CONTENT); List<ModelNode> workspacesInitialContent = model.get(ModelKeys.WORKSPACES_INITIAL_CONTENT).asList(); for (ModelNode initialContent : workspacesInitialContent) { Property initialContentProperty = initialContent.asProperty(); initialContentDocument.set(initialContentProperty.getName(), initialContentProperty.getValue().asString()); } } } if (model.hasDefined(ModelKeys.DEFAULT_INITIAL_CONTENT)) { EditableDocument initialContentDocument = workspacesDoc.getOrCreateDocument(FieldName.INITIAL_CONTENT); initialContentDocument.set(FieldName.DEFAULT_INITIAL_CONTENT, model.get(ModelKeys.DEFAULT_INITIAL_CONTENT).asString()); } return workspacesDoc; }
@Override public DocumentWriter addPage( String parentId, String nextPageOffset, long blockSize, long totalChildCount ) { EditableDocument childrenInfo = document().getOrCreateDocument(DocumentTranslator.CHILDREN_INFO); childrenInfo.setNumber(DocumentTranslator.COUNT, totalChildCount); childrenInfo.setNumber(DocumentTranslator.BLOCK_SIZE, blockSize); PageKey pageKey = new PageKey(parentId, nextPageOffset, blockSize); childrenInfo.setString(DocumentTranslator.NEXT_BLOCK, pageKey.toString()); return this; }
@Override public DocumentWriter addPage( String parentId, String nextPageOffset, long blockSize, long totalChildCount ) { EditableDocument childrenInfo = document().getOrCreateDocument(DocumentTranslator.CHILDREN_INFO); childrenInfo.setNumber(DocumentTranslator.COUNT, totalChildCount); childrenInfo.setNumber(DocumentTranslator.BLOCK_SIZE, blockSize); PageKey pageKey = new PageKey(parentId, nextPageOffset, blockSize); childrenInfo.setString(DocumentTranslator.NEXT_BLOCK, pageKey.toString()); return this; }
protected void addSequencer( EditableDocument doc, String desc, String type, String... pathExpressions ) { EditableDocument sequencing = doc.getOrCreateDocument(FieldName.SEQUENCING); EditableDocument sequencers = sequencing.getOrCreateDocument(FieldName.SEQUENCERS); // Create the sequencer doc ... String name = desc; EditableDocument sequencer = Schematic.newDocument(); sequencer.set(FieldName.NAME, name); sequencer.set(FieldName.CLASSNAME, type); sequencer.setArray(FieldName.PATH_EXPRESSIONS, (Object[])pathExpressions); // Set it on the 'sequencers' doc ... sequencers.set(name, sequencer); }
Map<NodeKey, Integer> strongCount = computeReferrersCountDelta(strongAdded, strongRemoved); if (!strongCount.isEmpty()) { EditableDocument strong = referrers.getOrCreateDocument(STRONG); updateReferrers(strong, strongCount); Map<NodeKey, Integer> weakCount = computeReferrersCountDelta(weakAdded, weakRemoved); if (!weakCount.isEmpty()) { EditableDocument weak = referrers.getOrCreateDocument(WEAK); updateReferrers(weak, weakCount);
Map<NodeKey, Integer> strongCount = computeReferrersCountDelta(strongAdded, strongRemoved); if (!strongCount.isEmpty()) { EditableDocument strong = referrers.getOrCreateDocument(STRONG); updateReferrers(strong, strongCount); Map<NodeKey, Integer> weakCount = computeReferrersCountDelta(weakAdded, weakRemoved); if (!weakCount.isEmpty()) { EditableDocument weak = referrers.getOrCreateDocument(WEAK); updateReferrers(weak, weakCount);
private void parseSecurity( OperationContext context, ModelNode model, EditableDocument configDoc ) throws OperationFailedException { EditableDocument security = configDoc.getOrCreateDocument(FieldName.SECURITY); EditableDocument anon = security.getOrCreateDocument(FieldName.ANONYMOUS); String anonUsername = attribute(context, model, ModelAttributes.ANONYMOUS_USERNAME).asString(); boolean useAnonIfFailed = attribute(context, model, ModelAttributes.USE_ANONYMOUS_IF_AUTH_FAILED).asBoolean();
EditableDocument extractors = textExtracting.getOrCreateDocument(pathToContainer.get(2));
EditableDocument sequencers = sequencing.getOrCreateDocument(FieldName.SEQUENCERS);
EditableDocument configDoc ) throws OperationFailedException { if (model.hasDefined(ModelKeys.JOURNALING)) { EditableDocument journaling = configDoc.getOrCreateDocument(FieldName.JOURNALING);
/** * Immediately change and apply the specified persistence field to the repository configuration * * @param defn the attribute definition for the value; may not be null * @param newValue the new string value * @throws RepositoryException if there is a problem obtaining the repository configuration or applying the change * @throws OperationFailedException if there is a problem obtaining the raw value from the supplied model node */ public void changePersistenceField(MappedAttributeDefinition defn, ModelNode newValue) throws RepositoryException, OperationFailedException { ModeShapeEngine engine = getEngine(); String repositoryName = repositoryName(); // Get a snapshot of the current configuration ... RepositoryConfiguration config = engine.getRepositoryConfiguration(repositoryName); // Now start to make changes ... Editor editor = config.edit(); EditableDocument persistence = editor.getOrCreateDocument(FieldName.STORAGE).getOrCreateDocument(FieldName.PERSISTENCE); // Change the field ... String fieldName = defn.getFieldName(); // Get the raw value from the model node ... Object rawValue = defn.getTypedValue(newValue); // And update the field ... persistence.set(fieldName, rawValue); // Get and apply the changes to the current configuration. Note that the 'update' call asynchronously // updates the configuration, and returns a Future<JcrRepository> that we could use if we wanted to // wait for the changes to take place. But we don't want/need to wait, so we'll not use the Future ... Changes changes = editor.getChanges(); engine.update(repositoryName, changes); }
@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)); }
config.getOrCreateDocument(FieldName.STORAGE).setDocument(FieldName.BINARY_STORAGE, binaryConfig);
EditableDocument childInfo = rootDoc.getOrCreateDocument(DocumentTranslator.CHILDREN_INFO); childInfo.setNumber(DocumentTranslator.COUNT, 1);