mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
parent
2b3d494bbe
commit
68aa662491
2 changed files with 15 additions and 1 deletions
|
@ -140,7 +140,14 @@ public class Queue implements Closeable {
|
|||
}
|
||||
|
||||
public long getPersistedByteSize() {
|
||||
return headPage.getPageIO().getHead() + tailPages.stream().mapToLong((p) -> p.getPageIO().getHead()).sum();
|
||||
final long size;
|
||||
if (headPage == null) {
|
||||
size = 0L;
|
||||
} else {
|
||||
size = headPage.getPageIO().getHead()
|
||||
+ tailPages.stream().mapToLong(p -> p.getPageIO().getHead()).sum();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
public int getPageCapacity() {
|
||||
|
|
|
@ -725,4 +725,11 @@ public class QueueTest {
|
|||
q.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getsPersistedByteSizeCorrectlyForUnopened() throws Exception {
|
||||
Settings settings = TestSettings.persistedQueueSettings(100, dataPath);
|
||||
try (Queue q = new Queue(settings)) {
|
||||
assertThat(q.getPersistedByteSize(), is(equalTo(0L)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue