Package net.kuujo.copycat.internal.log

Examples of net.kuujo.copycat.internal.log.OperationEntry


    }
    log.delete();
  }

  public void testAppendEntries() throws Exception {
    Entry entry = new OperationEntry(1, "foo", "bar");
    assertEquals(log.appendEntries(entry, entry, entry), Arrays.asList(1L, 2L, 3L));
  }
View Full Code Here


    Entry entry = new OperationEntry(1, "foo", "bar");
    assertEquals(log.appendEntries(entry, entry, entry), Arrays.asList(1L, 2L, 3L));
  }

  public void testAppendEntry() throws Exception {
    assertEquals(log.appendEntry(new OperationEntry(1, "foo", "bar")), 1);
    assertEquals(log.appendEntry(new OperationEntry(1, "foo", "bar")), 2);
    assertEquals(log.appendEntry(new OperationEntry(1, "foo", "bar")), 3);
  }
View Full Code Here

  }

  @Test(expectedExceptions = IllegalStateException.class)
  public void testThrowsIllegalStateExceptionWhenClosed() throws Exception {
    log.close();
    log.appendEntry(new OperationEntry(1, "foo", "bar"));
  }
View Full Code Here

    assertEquals(log.firstIndex(), 3);
    assertEquals(log.lastIndex(), 5);
    SnapshotEntry entry = log.getEntry(3);
    assertEquals(entry.term(), 1);
    assertEquals("Hello world!", new String(entry.data()));
    OperationEntry entry2 = log.getEntry(4);
    assertEquals(entry2.term(), 1);
    assertEquals("bar", entry2.operation());
    OperationEntry entry3 = log.getEntry(5);
    assertEquals(entry3.term(), 1);
    assertEquals("baz", entry3.operation());
  }
View Full Code Here

    assertTrue(log.getEntry(3) instanceof OperationEntry);
  }

  public void testIsEmpty() {
    assertTrue(log.isEmpty());
    assertEquals(log.appendEntry(new OperationEntry(1, "foo", "bar")), 1);
    assertFalse(log.isEmpty());
  }
View Full Code Here

    assertTrue(log.lastEntry() instanceof ConfigurationEntry);
  }

  public void testSize() {
    long size = log.size();
    log.appendEntry(new OperationEntry(1, "foo", "bar"));
    assertNotEquals(size, size = log.size());
    log.appendEntry(new OperationEntry(1, "foo", "bar"));
    assertNotEquals(size, size = log.size());
    log.appendEntry(new OperationEntry(1, "foo", "bar"));
    assertNotEquals(size, size = log.size());
  }
View Full Code Here

      .withLocalMember(new Member("foo"))
      .withRemoteMembers(new Member("bar"), new Member("baz")), new byte[10]));
    log.appendEntry(new ConfigurationEntry(1, new ClusterConfig()
      .withLocalMember(new Member("foo"))
      .withRemoteMembers(new Member("bar"), new Member("baz"))));
    log.appendEntry(new OperationEntry(1, "foo", Arrays.asList("bar", "baz")));
    log.appendEntry(new OperationEntry(1, "bar", Arrays.asList("bar", "baz")));
    log.appendEntry(new OperationEntry(1, "baz", Arrays.asList("bar", "baz")));
  }
View Full Code Here

   * Returns a set of entry types/impls to test.
   */
  @DataProvider
  private Object[][] entryProvider() {
    return new Object[][] {
      {OperationEntry.class, new OperationEntry(1, "foo", Arrays.asList("bar", "baz"))},
      {
        ConfigurationEntry.class,
        new ConfigurationEntry(1, new ClusterConfig().withLocalMember(new Member("foo"))
          .withRemoteMembers(new Member("bar"), new Member("baz")))},
      {
View Full Code Here

   * @param term The term in which to add the entries.
   * @return The test log.
   */
  public TestLog withCommandEntries(int numEntries, long term) {
    for (int i = 0; i < numEntries; i++) {
      appendEntry(new OperationEntry(term, "foo", Arrays.asList("bar", "baz")));
    }
    return this;
  }
View Full Code Here

    ClusterConfig<Member> clusterConfig = new ClusterConfig<>()
      .withLocalMember(new Member(new MemberConfig("foo")))
      .withRemoteMembers(new Member(new MemberConfig("bar")), new Member(new MemberConfig("baz")));
    SnapshotEntry snapshotEntry = new SnapshotEntry(1, clusterConfig, new byte[50]);
    ConfigurationEntry configurationEntry = new ConfigurationEntry(1, clusterConfig);
    OperationEntry operationEntry = new OperationEntry(1, "foo", Arrays.asList("bar", "baz"));
    List<Entry> entries = Arrays.asList(snapshotEntry, configurationEntry, operationEntry);
    SyncRequest request = new SyncRequest(UUID.randomUUID().toString(), 1, "foo", 4, 1, entries, 3);
    SyncRequest result = reader.readRequest(writer.writeRequest(request));
    Assert.assertEquals(result.id(), request.id());
    Assert.assertEquals(result.term(), request.term());
View Full Code Here

TOP

Related Classes of net.kuujo.copycat.internal.log.OperationEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.