use of com.alipay.sofa.jraft.option.SnapshotCopierOptions in project sofa-jraft by sofastack.
the class LocalSnapshotCopierTest method setup.
@Override
@Before
public void setup() throws Exception {
super.setup();
this.timerManager = new TimerManager(5);
this.raftOptions = new RaftOptions();
this.writer = new LocalSnapshotWriter(this.path, this.snapshotStorage, this.raftOptions);
this.reader = new LocalSnapshotReader(this.snapshotStorage, null, new Endpoint("localhost", 8081), this.raftOptions, this.path);
Mockito.when(this.snapshotStorage.open()).thenReturn(this.reader);
Mockito.when(this.snapshotStorage.create(true)).thenReturn(this.writer);
this.table = new LocalSnapshotMetaTable(this.raftOptions);
this.table.addFile("testFile", LocalFileMetaOutter.LocalFileMeta.newBuilder().setChecksum("test").build());
this.table.setMeta(RaftOutter.SnapshotMeta.newBuilder().setLastIncludedIndex(1).setLastIncludedTerm(1).build());
this.uri = "remote://" + this.hostPort + "/" + this.readerId;
this.copier = new LocalSnapshotCopier();
this.copyOpts = new CopyOptions();
Mockito.when(this.raftClientService.connect(new Endpoint("localhost", 8081))).thenReturn(true);
assertTrue(this.copier.init(this.uri, new SnapshotCopierOptions(this.raftClientService, this.timerManager, this.raftOptions, new NodeOptions())));
this.copier.setStorage(this.snapshotStorage);
}
use of com.alipay.sofa.jraft.option.SnapshotCopierOptions in project sofa-jraft by sofastack.
the class RemoteFileCopierTest method testInit.
@Test
public void testInit() {
Mockito.when(rpcService.connect(new Endpoint("localhost", 8081))).thenReturn(true);
assertTrue(copier.init("remote://localhost:8081/999", null, new SnapshotCopierOptions(rpcService, timerManager, new RaftOptions(), new NodeOptions())));
assertEquals(999, copier.getReaderId());
Assert.assertEquals("localhost", copier.getEndpoint().getIp());
Assert.assertEquals(8081, copier.getEndpoint().getPort());
}
use of com.alipay.sofa.jraft.option.SnapshotCopierOptions in project sofa-jraft by sofastack.
the class SnapshotExecutorImpl method newCopierOpts.
private SnapshotCopierOptions newCopierOpts() {
final SnapshotCopierOptions copierOpts = new SnapshotCopierOptions();
copierOpts.setNodeOptions(this.node.getOptions());
copierOpts.setRaftClientService(this.node.getRpcService());
copierOpts.setTimerManager(this.node.getTimerManager());
copierOpts.setRaftOptions(this.node.getRaftOptions());
return copierOpts;
}
use of com.alipay.sofa.jraft.option.SnapshotCopierOptions in project sofa-jraft by sofastack.
the class RemoteFileCopierTest method testInitFail.
@Test
public void testInitFail() {
Mockito.when(rpcService.connect(new Endpoint("localhost", 8081))).thenReturn(false);
assertFalse(copier.init("remote://localhost:8081/999", null, new SnapshotCopierOptions(rpcService, timerManager, new RaftOptions(), new NodeOptions())));
}
Aggregations