Search in sources :

Example 6 with SnapshotMeta

use of com.alipay.sofa.jraft.entity.RaftOutter.SnapshotMeta in project sofa-jraft by sofastack.

the class ProtobufMsgFactoryTest method testNewMessage.

@Test
public void testNewMessage() {
    SnapshotMeta meta = SnapshotMeta.newBuilder().setLastIncludedIndex(99).setLastIncludedTerm(1).build();
    SnapshotMeta pMeta = ProtobufMsgFactory.newMessageByProtoClassName("jraft.SnapshotMeta", meta.toByteArray());
    assertNotNull(pMeta);
    assertNotSame(pMeta, meta);
    assertEquals(pMeta, meta);
}
Also used : SnapshotMeta(com.alipay.sofa.jraft.entity.RaftOutter.SnapshotMeta) Test(org.junit.Test)

Example 7 with SnapshotMeta

use of com.alipay.sofa.jraft.entity.RaftOutter.SnapshotMeta in project sofa-jraft by sofastack.

the class ProtobufMsgFactoryTest method testNewMessageByJavaClassName.

@Test
public void testNewMessageByJavaClassName() {
    SnapshotMeta meta = SnapshotMeta.newBuilder().setLastIncludedIndex(99).setLastIncludedTerm(1).build();
    SnapshotMeta pMeta = ProtobufMsgFactory.newMessageByJavaClassName(meta.getClass().getName(), meta.toByteArray());
    assertNotNull(pMeta);
    assertNotSame(pMeta, meta);
    assertEquals(pMeta, meta);
}
Also used : SnapshotMeta(com.alipay.sofa.jraft.entity.RaftOutter.SnapshotMeta) Test(org.junit.Test)

Example 8 with SnapshotMeta

use of com.alipay.sofa.jraft.entity.RaftOutter.SnapshotMeta in project sofa-jraft by sofastack.

the class SnapshotExecutorImpl method installSnapshot.

@Override
public void installSnapshot(final InstallSnapshotRequest request, final InstallSnapshotResponse.Builder response, final RpcRequestClosure done) {
    final SnapshotMeta meta = request.getMeta();
    final DownloadingSnapshot ds = new DownloadingSnapshot(request, response, done);
    // as the retry snapshot will replace this one.
    if (!registerDownloadingSnapshot(ds)) {
        LOG.warn("Fail to register downloading snapshot.");
        // This RPC will be responded by the previous session
        return;
    }
    Requires.requireNonNull(this.curCopier, "curCopier");
    try {
        this.curCopier.join();
    } catch (final InterruptedException e) {
        Thread.currentThread().interrupt();
        LOG.warn("Install snapshot copy job was canceled.");
        return;
    }
    loadDownloadingSnapshot(ds, meta);
}
Also used : SnapshotMeta(com.alipay.sofa.jraft.entity.RaftOutter.SnapshotMeta)

Aggregations

SnapshotMeta (com.alipay.sofa.jraft.entity.RaftOutter.SnapshotMeta)8 Test (org.junit.Test)7 Status (com.alipay.sofa.jraft.Status)5 CountDownLatch (java.util.concurrent.CountDownLatch)4 LoadSnapshotClosure (com.alipay.sofa.jraft.closure.LoadSnapshotClosure)3 SnapshotReader (com.alipay.sofa.jraft.storage.snapshot.SnapshotReader)3 SaveSnapshotClosure (com.alipay.sofa.jraft.closure.SaveSnapshotClosure)2 SnapshotWriter (com.alipay.sofa.jraft.storage.snapshot.SnapshotWriter)2