public Property removeProperty( EditableDocument document, Name propertyName, Set<BinaryKey> unusedBinaryKeys, Set<BinaryKey> usedBinaryKeys) { // Get the properties container if it exists ... EditableDocument properties = document.getDocument(PROPERTIES); if (properties == null) { // Doesn't contain the property ... return null; } // Get the namespace container for the property name's namespace ... String namespaceUri = propertyName.getNamespaceUri(); EditableDocument urlProps = properties.getDocument(namespaceUri); if (urlProps == null) { // Doesn't contain the property ... return null; } // Now remove the property ... String localName = propertyName.getLocalName(); Object fieldValue = urlProps.remove(localName); // We're removing a reference to a binary value, and we need to decrement the reference count ... decrementBinaryReferenceCount(fieldValue, unusedBinaryKeys, usedBinaryKeys); // Now remove the namespace if empty ... if (urlProps.isEmpty()) { properties.remove(namespaceUri); } return fieldValue == null ? null : propertyFor(propertyName, fieldValue); }
public Property removeProperty( EditableDocument document, Name propertyName, Set<BinaryKey> unusedBinaryKeys, Set<BinaryKey> usedBinaryKeys) { // Get the properties container if it exists ... EditableDocument properties = document.getDocument(PROPERTIES); if (properties == null) { // Doesn't contain the property ... return null; } // Get the namespace container for the property name's namespace ... String namespaceUri = propertyName.getNamespaceUri(); EditableDocument urlProps = properties.getDocument(namespaceUri); if (urlProps == null) { // Doesn't contain the property ... return null; } // Now remove the property ... String localName = propertyName.getLocalName(); Object fieldValue = urlProps.remove(localName); // We're removing a reference to a binary value, and we need to decrement the reference count ... decrementBinaryReferenceCount(fieldValue, unusedBinaryKeys, usedBinaryKeys); // Now remove the namespace if empty ... if (urlProps.isEmpty()) { properties.remove(namespaceUri); } return fieldValue == null ? null : propertyFor(propertyName, fieldValue); }
EditableDocument properties = document.getDocument(PROPERTIES); if (properties == null) { EditableDocument urlProps = properties.getDocument(namespaceUri); if (urlProps == null) {
EditableDocument properties = document.getDocument(PROPERTIES); if (properties == null) { EditableDocument urlProps = properties.getDocument(namespaceUri); if (urlProps == null) {
EditableDocument referrers = document.getDocument(REFERRERS); List<NodeKey> strongAdded = changes.getAddedReferrers(ReferenceType.STRONG); List<NodeKey> weakAdded = changes.getAddedReferrers(ReferenceType.WEAK);
EditableDocument properties = document.getDocument(PROPERTIES); if (properties == null) { properties = document.setDocument(PROPERTIES); EditableDocument urlProps = properties.getDocument(namespaceUri); if (urlProps == null) { urlProps = properties.setDocument(namespaceUri);
EditableDocument properties = document.getDocument(PROPERTIES); if (properties == null) { properties = document.setDocument(PROPERTIES); EditableDocument urlProps = properties.getDocument(namespaceUri); if (urlProps == null) { urlProps = properties.setDocument(namespaceUri);
EditableDocument referrers = document.getDocument(REFERRERS); List<NodeKey> strongAdded = changes.getAddedReferrers(ReferenceType.STRONG); List<NodeKey> weakAdded = changes.getAddedReferrers(ReferenceType.WEAK);
EditableDocument info = document.getDocument(CHILDREN_INFO); if (info == null) { info = document.setDocument(CHILDREN_INFO);
EditableDocument sequencers = sequencing.getDocument(FieldName.SEQUENCERS); EditableDocument sequencerA = sequencers.getDocument("CND sequencer");
EditableDocument externalSource = externalSources.getDocument(sourceName); assert externalSource != null;
Set<BinaryKey> usedBinaryKeys) { EditableDocument properties = document.getDocument(PROPERTIES); if (properties == null) { properties = document.setDocument(PROPERTIES); EditableDocument urlProps = properties.getDocument(namespaceUri); if (urlProps == null) { urlProps = properties.setDocument(namespaceUri);
Set<BinaryKey> usedBinaryKeys) { EditableDocument properties = document.getDocument(PROPERTIES); if (properties == null) { properties = document.setDocument(PROPERTIES); EditableDocument urlProps = properties.getDocument(namespaceUri); if (urlProps == null) { urlProps = properties.setDocument(namespaceUri);
@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)); }
EditableDocument childrenInfo = writer.document().getDocument(DocumentTranslator.CHILDREN_INFO); if (childrenInfo != null) { String nextBlockKey = childrenInfo.getString(DocumentTranslator.NEXT_BLOCK);
EditableDocument childrenInfo = writer.document().getDocument(DocumentTranslator.CHILDREN_INFO); if (childrenInfo != null) { String nextBlockKey = childrenInfo.getString(DocumentTranslator.NEXT_BLOCK);
config.getDocument(FieldName.JOURNALING).setString(FieldName.JOURNAL_LOCATION, finalJournalLocation);
externalSources.getDocument("mock-source").getArray("projections").add("default:/projection4=> /doc1");
@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 } }
@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); }