use of org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry in project jackrabbit-oak by apache.
the class NodeStateEntryWriterTest method newLines.
@Test
public void newLines() {
NodeStateEntryWriter nw = new NodeStateEntryWriter(blobStore);
builder.setProperty("foo", 1);
builder.setProperty("foo2", Arrays.asList("a", "b"), Type.STRINGS);
builder.setProperty("foo3", "text with \n new line");
String line = nw.toString(new NodeStateEntry(builder.getNodeState(), "/a"));
NodeStateEntryReader nr = new NodeStateEntryReader(blobStore);
NodeStateEntry ne = nr.read(line);
assertEquals("/a", ne.getPath());
assertEquals("/a", NodeStateEntryWriter.getPath(line));
assertTrue(EqualsDiff.equals(ne.getNodeState(), builder.getNodeState()));
}
use of org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry in project jackrabbit-oak by apache.
the class FlatFileBufferLinkedListTest method memLimit.
@Test
public void memLimit() {
list = new FlatFileBufferLinkedList(10);
NodeStateEntry e10Bytes = new NodeStateEntry(EMPTY_NODE, "/", 10);
NodeStateEntry e1Byte = new NodeStateEntry(EMPTY_NODE, "/", 1);
// this should succeed
list.add(e10Bytes);
list.remove();
list.add(e1Byte);
try {
list.add(e10Bytes);
} catch (IllegalStateException ise) {
// ignore
}
assertEquals("Addition beyond mem limit shouldn't get added", 1, list.size());
assertEquals("Addition beyond mem limit shouldn't show up in usage", 1, list.estimatedMemoryUsage());
}
use of org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry in project jackrabbit-oak by apache.
the class FlatFileBufferLinkedListTest method memUsage.
@Test
public void memUsage() {
assertEquals("Empty list must be estimate 0", 0, list.estimatedMemoryUsage());
list.add(new NodeStateEntry(EMPTY_NODE, "/", 20));
assertEquals(20, list.estimatedMemoryUsage());
list.add(new NodeStateEntry(EMPTY_NODE, "/", 30));
assertEquals(50, list.estimatedMemoryUsage());
list.remove();
assertEquals(30, list.estimatedMemoryUsage());
}
use of org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry in project jackrabbit-oak by apache.
the class FlatFileStoreIteratorTest method bufferEstimatesMemory.
@Test
public void bufferEstimatesMemory() {
List<NodeStateEntry> nseList = Lists.newArrayList(new NodeStateEntry(EmptyNodeState.EMPTY_NODE, "/a", 20), new NodeStateEntry(EmptyNodeState.EMPTY_NODE, "/a/b", 30));
FlatFileStoreIterator fitr = new FlatFileStoreIterator(nseList.iterator(), ImmutableSet.of());
NodeStateEntry entry = fitr.next();
NodeState entryNS = entry.getNodeState();
assertEquals("/a", entry.getPath());
assertEquals("Fetching from iterator doesn't use buffer", 0, fitr.getBufferMemoryUsage());
entryNS.getChildNode("b");
assertEquals(1, fitr.getBufferSize());
assertEquals("Reaching child from node state should estimate 30 for /a/b", 30, fitr.getBufferMemoryUsage());
}
use of org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry in project jackrabbit-oak by apache.
the class FlatFileStoreIteratorTest method memUsageConfig.
@Test
public void memUsageConfig() {
String configuredValue = System.clearProperty(BUFFER_MEM_LIMIT_CONFIG_NAME);
try {
NodeStateEntry root = new NodeStateEntry(EmptyNodeState.EMPTY_NODE, "/");
NodeStateEntry e1Byte = new NodeStateEntry(EmptyNodeState.EMPTY_NODE, "/a/b", 1);
NodeStateEntry e1MB = new NodeStateEntry(EmptyNodeState.EMPTY_NODE, "/a", 1 * 1024 * 1024);
NodeStateEntry e100MB = new NodeStateEntry(EmptyNodeState.EMPTY_NODE, "/a", 100 * 1024 * 1024);
{
// default configured limit
List<NodeStateEntry> list = Lists.newArrayList(root, e100MB, e1Byte);
FlatFileStoreIterator fitr = new FlatFileStoreIterator(list.iterator(), ImmutableSet.of());
NodeState rootNS = fitr.next().getNodeState();
// default is 100MB, this should work
NodeState aNS = rootNS.getChildNode("a");
try {
aNS.getChildNode("b");
fail("Reading beyond default 100MB must fail");
} catch (IllegalStateException ise) {
// ignore
}
}
{
System.setProperty(BUFFER_MEM_LIMIT_CONFIG_NAME, "1");
List<NodeStateEntry> list = Lists.newArrayList(root, e1MB, e1Byte);
FlatFileStoreIterator fitr = new FlatFileStoreIterator(list.iterator(), ImmutableSet.of());
NodeState rootNS = fitr.next().getNodeState();
// configured limit is 10 bytes, this should work
NodeState aNS = rootNS.getChildNode("a");
try {
aNS.getChildNode("b");
fail("Reading beyond configured 1MB must fail");
} catch (IllegalStateException ise) {
// ignore
}
}
{
// illegal config behaves as default
System.setProperty(BUFFER_MEM_LIMIT_CONFIG_NAME, "1A");
List<NodeStateEntry> list = Lists.newArrayList(root, e100MB, e1Byte);
FlatFileStoreIterator fitr = new FlatFileStoreIterator(list.iterator(), ImmutableSet.of());
NodeState rootNS = fitr.next().getNodeState();
// default is 100MB, this should work
NodeState aNS = rootNS.getChildNode("a");
try {
aNS.getChildNode("b");
fail("Reading beyond default 100MB must fail");
} catch (IllegalStateException ise) {
// ignore
}
}
{
// negative value for unbounded buffer
System.setProperty(BUFFER_MEM_LIMIT_CONFIG_NAME, "-1");
List<NodeStateEntry> list = Lists.newArrayList(root, e100MB, e1Byte);
FlatFileStoreIterator fitr = new FlatFileStoreIterator(list.iterator(), ImmutableSet.of());
NodeState rootNS = fitr.next().getNodeState();
NodeState aNS = rootNS.getChildNode("a");
// configure negative value - mem usage limit should be unbounded (long_max)
aNS.getChildNode("b");
}
} finally {
if (configuredValue == null) {
System.clearProperty(BUFFER_MEM_LIMIT_CONFIG_NAME);
} else {
System.setProperty(BUFFER_MEM_LIMIT_CONFIG_NAME, configuredValue);
}
}
}
Aggregations