use of org.apache.ignite.raft.client.service.RaftGroupListener in project ignite-3 by apache.
the class ItTablePersistenceTest method createListener.
/**
* {@inheritDoc}
*/
@Override
public RaftGroupListener createListener(ClusterService service, Path workDir) {
return paths.entrySet().stream().filter(entry -> entry.getValue().equals(workDir)).map(Map.Entry::getKey).findAny().orElseGet(() -> {
TableTxManagerImpl txManager = new TableTxManagerImpl(service, new HeapLockManager());
// Init listener.
txManager.start();
PartitionListener listener = new PartitionListener(UUID.randomUUID(), new VersionedRowStore(new ConcurrentHashMapPartitionStorage(), txManager));
paths.put(listener, workDir);
return listener;
});
}
use of org.apache.ignite.raft.client.service.RaftGroupListener in project ignite-3 by apache.
the class RaftServerImpl method processQueue.
/**
* Process the queue.
*
* @param queue The queue.
* @param clo The closure.
* @param <T> Command type.
*/
private <T extends Command> void processQueue(BlockingQueue<CommandClosureEx<T>> queue, BiConsumer<RaftGroupListener, Iterator<CommandClosure<T>>> clo) {
while (!Thread.interrupted()) {
try {
CommandClosureEx<T> cmdClo = queue.take();
RaftGroupListener lsnr = cmdClo.listener();
clo.accept(lsnr, List.<CommandClosure<T>>of(cmdClo).iterator());
} catch (InterruptedException e0) {
return;
} catch (Exception e) {
LOG.error("Failed to process the command", e);
}
}
}
use of org.apache.ignite.raft.client.service.RaftGroupListener in project ignite-3 by apache.
the class LozaTest method testLozaStop.
/**
* Checks that the all API methods throw the exception ({@link org.apache.ignite.lang.NodeStoppingException})
* when Loza is closed.
*
* @throws Exception If fail.
*/
@Test
public void testLozaStop() throws Exception {
Mockito.doReturn(new ClusterLocalConfiguration("test_node", null)).when(clusterNetSvc).localConfiguration();
Mockito.doReturn(Mockito.mock(MessagingService.class)).when(clusterNetSvc).messagingService();
Mockito.doReturn(Mockito.mock(TopologyService.class)).when(clusterNetSvc).topologyService();
Loza loza = new Loza(clusterNetSvc, workDir);
loza.start();
loza.beforeNodeStop();
loza.stop();
String raftGroupId = "test_raft_group";
List<ClusterNode> nodes = List.of(new ClusterNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), NetworkAddress.from("127.0.0.1:123")));
List<ClusterNode> newNodes = List.of(new ClusterNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), NetworkAddress.from("127.0.0.1:124")), new ClusterNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), NetworkAddress.from("127.0.0.1:125")));
Supplier<RaftGroupListener> lsnrSupplier = () -> null;
assertThrows(NodeStoppingException.class, () -> loza.updateRaftGroup(raftGroupId, nodes, newNodes, lsnrSupplier));
assertThrows(NodeStoppingException.class, () -> loza.stopRaftGroup(raftGroupId));
assertThrows(NodeStoppingException.class, () -> loza.prepareRaftGroup(raftGroupId, nodes, lsnrSupplier));
assertThrows(NodeStoppingException.class, () -> loza.changePeers(raftGroupId, nodes, newNodes));
}
Aggregations