Search in sources :

Example 1 with PaxosProposalId

use of com.palantir.paxos.PaxosProposalId in project atlasdb by palantir.

the class LeaderRemotingTest method testAccept.

@Test
public void testAccept() throws IOException {
    PaxosProposalId id = new PaxosProposalId(123123, UUID.randomUUID().toString());
    PaxosProposal paxosProposal = new PaxosProposal(id, new PaxosValue(id.getProposerUUID(), 0, new byte[] { 0, 1, 2, 4, 1 }));
    PaxosAcceptor accept = AtlasDbFeignTargetFactory.createProxy(Optional.empty(), acceptor.baseUri().toString(), PaxosAcceptor.class, UserAgents.DEFAULT_USER_AGENT);
    accept.accept(0, paxosProposal);
    accept.getLatestSequencePreparedOrAccepted();
    accept.prepare(0, id);
    accept.prepare(1, id);
}
Also used : PaxosAcceptor(com.palantir.paxos.PaxosAcceptor) PaxosProposal(com.palantir.paxos.PaxosProposal) PaxosProposalId(com.palantir.paxos.PaxosProposalId) PaxosValue(com.palantir.paxos.PaxosValue) Test(org.junit.Test)

Example 2 with PaxosProposalId

use of com.palantir.paxos.PaxosProposalId in project atlasdb by palantir.

the class ProtobufTest method testPaxosProposalIdPersistence.

@Test
public void testPaxosProposalIdPersistence() throws Exception {
    PaxosProposalId expected;
    PaxosPersistence.PaxosProposalId persisted;
    PaxosProposalId actual;
    expected = new PaxosProposalId(10, "string");
    persisted = expected.persistToProto();
    actual = PaxosProposalId.hydrateFromProto(persisted);
    assertEquals(expected, actual);
    expected = new PaxosProposalId(10, "");
    persisted = expected.persistToProto();
    actual = PaxosProposalId.hydrateFromProto(persisted);
    assertEquals(expected, actual);
}
Also used : PaxosProposalId(com.palantir.paxos.PaxosProposalId) PaxosPersistence(com.palantir.paxos.persistence.generated.PaxosPersistence) Test(org.junit.Test)

Example 3 with PaxosProposalId

use of com.palantir.paxos.PaxosProposalId in project atlasdb by palantir.

the class ProtobufTest method testPaxosProposalPersistence.

@Test
public void testPaxosProposalPersistence() throws Exception {
    PaxosProposal expected;
    PaxosAcceptorPersistence.PaxosProposal persisted;
    PaxosProposal actual;
    expected = new PaxosProposal(new PaxosProposalId(55, "nonce"), new PaxosValue("red leader", 93, null));
    persisted = expected.persistToProto();
    actual = PaxosProposal.hydrateFromProto(persisted);
    assertEquals(expected, actual);
    expected = new PaxosProposal(new PaxosProposalId(0, "noice"), new PaxosValue("", 93, new byte[] {}));
    persisted = expected.persistToProto();
    actual = PaxosProposal.hydrateFromProto(persisted);
    assertEquals(expected, actual);
}
Also used : PaxosProposal(com.palantir.paxos.PaxosProposal) PaxosProposalId(com.palantir.paxos.PaxosProposalId) PaxosAcceptorPersistence(com.palantir.paxos.persistence.generated.remoting.PaxosAcceptorPersistence) PaxosValue(com.palantir.paxos.PaxosValue) Test(org.junit.Test)

Example 4 with PaxosProposalId

use of com.palantir.paxos.PaxosProposalId in project atlasdb by palantir.

the class ProtobufTest method testPaxosPromisePersistence.

@Test
public void testPaxosPromisePersistence() throws Exception {
    PaxosPromise expected;
    PaxosPromiseProto persisted;
    PaxosPromise actual;
    expected = PaxosPromise.reject(new PaxosProposalId(3, "unique"));
    persisted = PaxosPromises.toProto(expected);
    actual = PaxosPromises.fromProto(persisted);
    assertEquals(expected, actual);
    expected = PaxosPromise.accept(new PaxosProposalId(20, "id"), new PaxosProposalId(6, "fire"), new PaxosValue("me", 5, new byte[] { 8, 8, 100 }));
    persisted = PaxosPromises.toProto(expected);
    actual = PaxosPromises.fromProto(persisted);
    assertEquals(expected, actual);
    expected = PaxosPromise.accept(new PaxosProposalId(20, "id"), null, new PaxosValue("me", 5, new byte[] { 8, 8, 100 }));
    persisted = PaxosPromises.toProto(expected);
    actual = PaxosPromises.fromProto(persisted);
    assertEquals(expected, actual);
    expected = PaxosPromise.accept(new PaxosProposalId(20, "id"), null, null);
    persisted = PaxosPromises.toProto(expected);
    actual = PaxosPromises.fromProto(persisted);
    assertEquals(expected, actual);
}
Also used : PaxosPromise(com.palantir.paxos.PaxosPromise) PaxosProposalId(com.palantir.paxos.PaxosProposalId) PaxosPromiseProto(com.palantir.paxos.persistence.generated.remoting.PaxosAcceptorPersistence.PaxosPromiseProto) PaxosValue(com.palantir.paxos.PaxosValue) Test(org.junit.Test)

Aggregations

PaxosProposalId (com.palantir.paxos.PaxosProposalId)4 Test (org.junit.Test)4 PaxosValue (com.palantir.paxos.PaxosValue)3 PaxosProposal (com.palantir.paxos.PaxosProposal)2 PaxosAcceptor (com.palantir.paxos.PaxosAcceptor)1 PaxosPromise (com.palantir.paxos.PaxosPromise)1 PaxosPersistence (com.palantir.paxos.persistence.generated.PaxosPersistence)1 PaxosAcceptorPersistence (com.palantir.paxos.persistence.generated.remoting.PaxosAcceptorPersistence)1 PaxosPromiseProto (com.palantir.paxos.persistence.generated.remoting.PaxosAcceptorPersistence.PaxosPromiseProto)1