Search in sources :

Example 1 with RaftServerImpl

use of org.apache.ignite.internal.raft.server.impl.RaftServerImpl in project ignite-3 by apache.

the class ItMetaStorageServiceTest method prepareMetaStorage.

/**
 * Prepares meta storage by instantiating corresponding raft server with {@link MetaStorageListener} and {@link
 * MetaStorageServiceImpl}.
 *
 * @return {@link MetaStorageService} instance.
 */
private MetaStorageService prepareMetaStorage() throws Exception {
    List<Peer> peers = List.of(new Peer(cluster.get(0).topologyService().localMember().address()));
    metaStorageRaftSrv = new RaftServerImpl(cluster.get(0), FACTORY);
    metaStorageRaftSrv.start();
    metaStorageRaftSrv.startRaftGroup(METASTORAGE_RAFT_GROUP_NAME, new MetaStorageListener(mockStorage), peers);
    metaStorageRaftGrpSvc = RaftGroupServiceImpl.start(METASTORAGE_RAFT_GROUP_NAME, cluster.get(1), FACTORY, 10_000, peers, true, 200, executor).get(3, TimeUnit.SECONDS);
    return new MetaStorageServiceImpl(metaStorageRaftGrpSvc, NODE_ID_0);
}
Also used : RaftServerImpl(org.apache.ignite.internal.raft.server.impl.RaftServerImpl) Peer(org.apache.ignite.raft.client.Peer) MetaStorageListener(org.apache.ignite.internal.metastorage.server.raft.MetaStorageListener)

Example 2 with RaftServerImpl

use of org.apache.ignite.internal.raft.server.impl.RaftServerImpl in project ignite-3 by apache.

the class ItInternalTableScanTest method setUp.

/**
 * Prepare test environment.
 * <ol>
 * <li>Start network node.</li>
 * <li>Start raft server.</li>
 * <li>Prepare partitioned raft group.</li>
 * <li>Prepare partitioned raft group service.</li>
 * <li>Prepare internal table as a test object.</li>
 * </ol>
 *
 * @throws Exception If any.
 */
@BeforeEach
public void setUp(TestInfo testInfo) throws Exception {
    NetworkAddress nodeNetworkAddress = new NetworkAddress("localhost", 20_000);
    network = ClusterServiceTestUtils.clusterService(testInfo, 20_000, new StaticNodeFinder(List.of(nodeNetworkAddress)), NETWORK_FACTORY);
    network.start();
    raftSrv = new RaftServerImpl(network, FACTORY);
    raftSrv.start();
    String grpName = "test_part_grp";
    List<Peer> conf = List.of(new Peer(nodeNetworkAddress));
    mockStorage = mock(PartitionStorage.class);
    txManager = new TxManagerImpl(network, new HeapLockManager());
    txManager.start();
    UUID tblId = UUID.randomUUID();
    raftSrv.startRaftGroup(grpName, new PartitionListener(tblId, new VersionedRowStore(mockStorage, txManager) {

        @Override
        protected Pair<BinaryRow, BinaryRow> versionedRow(@Nullable DataRow row, Timestamp timestamp) {
            // Return as is.
            return new Pair<>(new ByteBufferRow(row.valueBytes()), null);
        }
    }), conf);
    executor = new ScheduledThreadPoolExecutor(20, new NamedThreadFactory(Loza.CLIENT_POOL_NAME));
    RaftGroupService raftGrpSvc = RaftGroupServiceImpl.start(RAFT_GRP_ID, network, FACTORY, 10_000, conf, true, 200, executor).get(3, TimeUnit.SECONDS);
    internalTbl = new InternalTableImpl(TEST_TABLE_NAME, tblId, Int2ObjectMaps.singleton(0, raftGrpSvc), 1, NetworkAddress::toString, txManager, mock(TableStorage.class));
}
Also used : VersionedRowStore(org.apache.ignite.internal.table.distributed.storage.VersionedRowStore) StaticNodeFinder(org.apache.ignite.network.StaticNodeFinder) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) NamedThreadFactory(org.apache.ignite.internal.thread.NamedThreadFactory) Peer(org.apache.ignite.raft.client.Peer) ByteBufferRow(org.apache.ignite.internal.schema.ByteBufferRow) RaftGroupService(org.apache.ignite.raft.client.service.RaftGroupService) BinaryRow(org.apache.ignite.internal.schema.BinaryRow) SimpleDataRow(org.apache.ignite.internal.storage.basic.SimpleDataRow) DataRow(org.apache.ignite.internal.storage.DataRow) Timestamp(org.apache.ignite.internal.tx.Timestamp) RaftServerImpl(org.apache.ignite.internal.raft.server.impl.RaftServerImpl) HeapLockManager(org.apache.ignite.internal.tx.impl.HeapLockManager) PartitionListener(org.apache.ignite.internal.table.distributed.raft.PartitionListener) InternalTableImpl(org.apache.ignite.internal.table.distributed.storage.InternalTableImpl) NetworkAddress(org.apache.ignite.network.NetworkAddress) TxManagerImpl(org.apache.ignite.internal.tx.impl.TxManagerImpl) UUID(java.util.UUID) Nullable(org.jetbrains.annotations.Nullable) PartitionStorage(org.apache.ignite.internal.storage.PartitionStorage) Pair(org.apache.ignite.internal.util.Pair) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

RaftServerImpl (org.apache.ignite.internal.raft.server.impl.RaftServerImpl)2 Peer (org.apache.ignite.raft.client.Peer)2 UUID (java.util.UUID)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 MetaStorageListener (org.apache.ignite.internal.metastorage.server.raft.MetaStorageListener)1 BinaryRow (org.apache.ignite.internal.schema.BinaryRow)1 ByteBufferRow (org.apache.ignite.internal.schema.ByteBufferRow)1 DataRow (org.apache.ignite.internal.storage.DataRow)1 PartitionStorage (org.apache.ignite.internal.storage.PartitionStorage)1 SimpleDataRow (org.apache.ignite.internal.storage.basic.SimpleDataRow)1 PartitionListener (org.apache.ignite.internal.table.distributed.raft.PartitionListener)1 InternalTableImpl (org.apache.ignite.internal.table.distributed.storage.InternalTableImpl)1 VersionedRowStore (org.apache.ignite.internal.table.distributed.storage.VersionedRowStore)1 NamedThreadFactory (org.apache.ignite.internal.thread.NamedThreadFactory)1 Timestamp (org.apache.ignite.internal.tx.Timestamp)1 HeapLockManager (org.apache.ignite.internal.tx.impl.HeapLockManager)1 TxManagerImpl (org.apache.ignite.internal.tx.impl.TxManagerImpl)1 Pair (org.apache.ignite.internal.util.Pair)1 NetworkAddress (org.apache.ignite.network.NetworkAddress)1 StaticNodeFinder (org.apache.ignite.network.StaticNodeFinder)1