public void setKey( EditableDocument document, NodeKey key ) { assert document.getString(KEY) == null; document.setString(KEY, key.toString()); }
public void setKey( EditableDocument document, NodeKey key ) { assert document.getString(KEY) == null; document.setString(KEY, key.toString()); }
@Override public void start( StartContext arg0 ) { // Not much to do, since we've already captured the properties for the index storage. // When this is injected into the RepositoryService, the RepositoryService will use the // properties to update the configuration. // All we need to do is update the relative paths and make them absolute, given the absolute paths that are injected ... String binaryStorageBasePath = getBinaryStorageBasePath(); if (binaryStorageBasePath != null) { EditableDocument binaryConfig = binaryStorage.getBinaryConfiguration(); // Set the binary storage directory ... String relativePath = binaryConfig.getString(FieldName.DIRECTORY); if (relativePath != null) { binaryConfig.set(FieldName.DIRECTORY, binaryStorageBasePath + relativePath); } String trashPath = binaryConfig.getString(FieldName.TRASH_DIRECTORY); if (trashPath != null) { binaryConfig.set(FieldName.TRASH_DIRECTORY, binaryStorageBasePath + trashPath); } } }
protected void createBinaryStorageService(OperationContext context, ModelNode model, ServiceTarget target, String repositoryName, EditableDocument binaries, ServiceName serviceName) throws OperationFailedException { // Now create the new service ... BinaryStorageService service = BinaryStorageService.createWithConfiguration(binaries); ServiceBuilder<BinaryStorage> builder = target.addService(serviceName, service); // Add dependencies to the various data directories ... String binariesStoreName = binaries.containsField(FieldName.BINARY_STORE_NAME) ? binaries.getString(FieldName.BINARY_STORE_NAME) : null; addControllersAndDependencies(repositoryName, service, builder, target, binariesStoreName); builder.setInitialMode(ServiceController.Mode.ACTIVE).install(); }
String nextBlockKey = childrenInfo.getString(DocumentTranslator.NEXT_BLOCK); if (!StringUtil.isBlank(nextBlockKey)) { childrenInfo.setString(DocumentTranslator.NEXT_BLOCK, documentIdToNodeKeyString(sourceName, nextBlockKey)); String lastBlockKey = childrenInfo.getString(DocumentTranslator.LAST_BLOCK); if (!StringUtil.isBlank(lastBlockKey)) { childrenInfo.setString(DocumentTranslator.LAST_BLOCK, documentIdToNodeKeyString(sourceName, lastBlockKey));
@Override protected void performRuntime( final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { ServiceTarget target = context.getServiceTarget(); final AddressContext addressContext = AddressContext.forOperation(operation); final String repositoryName = addressContext.repositoryName(); // Build the 'binaryStorage' document ... EditableDocument binaries = Schematic.newDocument(); writeCommonBinaryStorageConfiguration(context, model, binaries); writeBinaryStorageConfiguration(repositoryName, context, model, binaries); //the store-name attribute is specific only to nested stores, as per schema final boolean isNestedStore = model.hasDefined(ModelKeys.STORE_NAME); ServiceName serviceName = ModeShapeServiceNames.binaryStorageDefaultServiceName(repositoryName); if (isNestedStore) { //if it's part of a composite binary container, we don't want to overwrite the default binary service because //the composite binary storage container will do that String binaryStorageName = binaries.getString(FieldName.BINARY_STORE_NAME); assert binaryStorageName != null; serviceName = ModeShapeServiceNames.binaryStorageNestedServiceName(repositoryName, binaryStorageName); } else { // Remove the default service, added by "AddRepository" context.removeService(serviceName); } createBinaryStorageService(context, model, target, repositoryName, binaries, serviceName); }
String nextBlockKey = childrenInfo.getString(DocumentTranslator.NEXT_BLOCK); if (!StringUtil.isBlank(nextBlockKey)) { childrenInfo.setString(DocumentTranslator.NEXT_BLOCK, documentIdToNodeKeyString(sourceName, nextBlockKey)); String lastBlockKey = childrenInfo.getString(DocumentTranslator.LAST_BLOCK); if (!StringUtil.isBlank(lastBlockKey)) { childrenInfo.setString(DocumentTranslator.LAST_BLOCK, documentIdToNodeKeyString(sourceName, lastBlockKey));
if (nested instanceof EditableDocument) { EditableDocument doc = (EditableDocument)nested; if (doc.getString(FieldName.NAME).equals(configuredAuthenticatorName)) {
@Test public void shouldNotSplitDocumentWithChildReferenceBlocksThatAreAlreadyTooSmall() throws Exception { NodeKey key = new NodeKey("source1works1-childB"); transactions().begin(); EditableDocument doc = workspaceCache.documentStore().edit(key.toString(), true); EditableArray children = doc.getArray(DocumentTranslator.CHILDREN); String nextBlock = doc.getDocument(DocumentTranslator.CHILDREN_INFO).getString(DocumentTranslator.NEXT_BLOCK); boolean changed = optimizer.splitChildren(key, doc, children, 100, 50, true, nextBlock); transactions().commit(); assertThat(changed, is(false)); }
while (doc != null) { EditableDocument docInfo = doc.getDocument(CHILDREN_INFO); String nextKey = docInfo != null ? docInfo.getString(NEXT_BLOCK) : null; children = doc.getArray(CHILDREN); int count = children.size();
while (doc != null) { EditableDocument docInfo = doc.getDocument(CHILDREN_INFO); String nextKey = docInfo != null ? docInfo.getString(NEXT_BLOCK) : null; children = doc.getArray(CHILDREN); int count = children.size();
String parent = systemDoc.getString(DocumentTranslator.PARENT); EditableArray parents = systemDoc.getOrCreateArray(DocumentTranslator.PARENT); if (parent != null) {
String parent = systemDoc.getString(DocumentTranslator.PARENT); EditableArray parents = systemDoc.getOrCreateArray(DocumentTranslator.PARENT); if (parent != null) {
@Test public void shouldMergeDocumentWithTooSmallChildReferencesSegmentInFirstBlock() throws Exception { NodeKey key = new NodeKey("source1works1-childB"); transactions().begin(); EditableDocument doc = workspaceCache.documentStore().edit(key.toString(), true); EditableArray children = doc.getArray(DocumentTranslator.CHILDREN); String nextBlock = doc.getDocument(DocumentTranslator.CHILDREN_INFO).getString(DocumentTranslator.NEXT_BLOCK); optimizer.mergeChildren(key, doc, children, true, nextBlock); transactions().commit(); // Refetch the document, which should no longer be segmented ... transactions().begin(); doc = workspaceCache.documentStore().edit(key.toString(), true); assertInfo(key.toString(), 2, null, null, true, 0); children = doc.getArray(DocumentTranslator.CHILDREN); transactions().commit(); assertThat(children.size(), is(2)); assertChildren(doc, name("childC"), name("childD")); print(false); print(doc); }