use of org.opendaylight.controller.cluster.io.FileBackedOutputStreamFactory in project controller by opendaylight.
the class SnapshotTrackerTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
data = new HashMap<>();
data.put("key1", "value1");
data.put("key2", "value2");
data.put("key3", "value3");
byteString = ByteString.copyFrom(SerializationUtils.serialize((Serializable) data));
chunk1 = getNextChunk(byteString, 0, 10);
chunk2 = getNextChunk(byteString, 10, 10);
chunk3 = getNextChunk(byteString, 20, byteString.size());
fbos = spy(new FileBackedOutputStream(100000000, "target"));
FileBackedOutputStreamFactory mockFactory = mock(FileBackedOutputStreamFactory.class);
doReturn(fbos).when(mockFactory).newInstance();
doReturn(mockFactory).when(mockContext).getFileBackedOutputStreamFactory();
}
use of org.opendaylight.controller.cluster.io.FileBackedOutputStreamFactory in project controller by opendaylight.
the class SnapshotManagerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
doReturn(false).when(mockRaftActorContext).hasFollowers();
doReturn(mockConfigParams).when(mockRaftActorContext).getConfigParams();
doReturn(10L).when(mockConfigParams).getSnapshotBatchCount();
doReturn(70).when(mockConfigParams).getSnapshotDataThresholdPercentage();
doReturn(mockReplicatedLog).when(mockRaftActorContext).getReplicatedLog();
doReturn("123").when(mockRaftActorContext).getId();
doReturn(mockDataPersistenceProvider).when(mockRaftActorContext).getPersistenceProvider();
doReturn(mockRaftActorBehavior).when(mockRaftActorContext).getCurrentBehavior();
doReturn("123").when(mockRaftActorBehavior).getLeaderId();
doReturn(mockElectionTerm).when(mockRaftActorContext).getTermInformation();
doReturn(5L).when(mockElectionTerm).getCurrentTerm();
doReturn("member5").when(mockElectionTerm).getVotedFor();
doReturn(new FileBackedOutputStreamFactory(10000000, "target")).when(mockRaftActorContext).getFileBackedOutputStreamFactory();
snapshotManager = new SnapshotManager(mockRaftActorContext, LoggerFactory.getLogger(this.getClass()));
factory = new TestActorFactory(getSystem());
actorRef = factory.createActor(MessageCollectorActor.props(), factory.generateActorId("test-"));
doReturn(actorRef).when(mockRaftActorContext).getActor();
snapshotManager.setCreateSnapshotConsumer(mockProcedure);
}
Aggregations