/** * Appends the given number of entries in the given term on the server. Must be run on server's * ThreadContext. */ protected void append(int entries, long term) throws Throwable { for (int i = 0; i < entries; i++) { try (TestEntry entry = serverState.getLog().create(TestEntry.class)) { entry.setTerm(term).setTombstone(false); serverState.getLog().append(entry); } } }
/** Creates and returns the given number of entries in the given term. */ protected List<TestEntry> entries(int entries, long term) { List<TestEntry> result = new ArrayList<>(); for (int i = 0; i < entries; i++) { try (TestEntry entry = serverState.getLog().create(TestEntry.class)) { result.add(entry.setTerm(term).setTombstone(false)); } } return result; }
/** Gets the entry at the given index. */ protected <T extends Entry> T get(long index) throws Throwable { return serverState.getLog().get(index); }