Search in sources :

Example 1 with TableTxManagerImpl

use of org.apache.ignite.internal.table.distributed.TableTxManagerImpl 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;
    });
}
Also used : ConcurrentHashMapPartitionStorage(org.apache.ignite.internal.storage.basic.ConcurrentHashMapPartitionStorage) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) BinaryRow(org.apache.ignite.internal.schema.BinaryRow) ItAbstractListenerSnapshotTest(org.apache.ignite.raft.client.service.ItAbstractListenerSnapshotTest) RaftGroupListener(org.apache.ignite.raft.client.service.RaftGroupListener) VersionedRowStore(org.apache.ignite.internal.table.distributed.storage.VersionedRowStore) ArrayList(java.util.ArrayList) BooleanSupplier(java.util.function.BooleanSupplier) HeapLockManager(org.apache.ignite.internal.tx.impl.HeapLockManager) Row(org.apache.ignite.internal.schema.row.Row) RowAssembler(org.apache.ignite.internal.schema.row.RowAssembler) RaftGroupService(org.apache.ignite.raft.client.service.RaftGroupService) Map(java.util.Map) JraftServerImpl(org.apache.ignite.internal.raft.server.impl.JraftServerImpl) Path(java.nio.file.Path) ByteBufferRow(org.apache.ignite.internal.schema.ByteBufferRow) SchemaDescriptor(org.apache.ignite.internal.schema.SchemaDescriptor) Int2ObjectMaps(it.unimi.dsi.fastutil.ints.Int2ObjectMaps) InternalTableImpl(org.apache.ignite.internal.table.distributed.storage.InternalTableImpl) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TxManagerImpl(org.apache.ignite.internal.tx.impl.TxManagerImpl) UUID(java.util.UUID) TableTxManagerImpl(org.apache.ignite.internal.table.distributed.TableTxManagerImpl) TableStorage(org.apache.ignite.internal.storage.engine.TableStorage) TxManager(org.apache.ignite.internal.tx.TxManager) NetworkAddress(org.apache.ignite.network.NetworkAddress) List(java.util.List) NativeTypes(org.apache.ignite.internal.schema.NativeTypes) AfterEach(org.junit.jupiter.api.AfterEach) Column(org.apache.ignite.internal.schema.Column) ClusterService(org.apache.ignite.network.ClusterService) PartitionListener(org.apache.ignite.internal.table.distributed.raft.PartitionListener) Mockito.mock(org.mockito.Mockito.mock) VersionedRowStore(org.apache.ignite.internal.table.distributed.storage.VersionedRowStore) HeapLockManager(org.apache.ignite.internal.tx.impl.HeapLockManager) PartitionListener(org.apache.ignite.internal.table.distributed.raft.PartitionListener) ConcurrentHashMapPartitionStorage(org.apache.ignite.internal.storage.basic.ConcurrentHashMapPartitionStorage) TableTxManagerImpl(org.apache.ignite.internal.table.distributed.TableTxManagerImpl)

Example 2 with TableTxManagerImpl

use of org.apache.ignite.internal.table.distributed.TableTxManagerImpl in project ignite-3 by apache.

the class ItTxDistributedTestSingleNode method before.

/**
 * Initialize the test state.
 */
@Override
@BeforeEach
public void before() throws Exception {
    int nodes = nodes();
    int replicas = replicas();
    assertTrue(nodes > 0);
    assertTrue(replicas > 0);
    List<NetworkAddress> localAddresses = findLocalAddresses(NODE_PORT_BASE, NODE_PORT_BASE + nodes);
    var nodeFinder = new StaticNodeFinder(localAddresses);
    nodeFinder.findNodes().parallelStream().map(addr -> startNode(testInfo, addr.toString(), addr.port(), nodeFinder)).forEach(cluster::add);
    for (ClusterService node : cluster) {
        assertTrue(waitForTopology(node, nodes, 1000));
    }
    log.info("The cluster has been started");
    if (startClient()) {
        client = startNode(testInfo, "client", NODE_PORT_BASE - 1, nodeFinder);
        assertTrue(waitForTopology(client, nodes + 1, 1000));
        log.info("The client has been started");
    }
    // Start raft servers. Each raft server can hold multiple groups.
    raftServers = new HashMap<>(nodes);
    txManagers = new HashMap<>(nodes);
    executor = new ScheduledThreadPoolExecutor(20, new NamedThreadFactory(Loza.CLIENT_POOL_NAME));
    for (int i = 0; i < nodes; i++) {
        var raftSrv = new Loza(cluster.get(i), workDir);
        raftSrv.start();
        ClusterNode node = cluster.get(i).topologyService().localMember();
        raftServers.put(node, raftSrv);
        TableTxManagerImpl txMgr = new TableTxManagerImpl(cluster.get(i), new HeapLockManager());
        txMgr.start();
        txManagers.put(node, txMgr);
    }
    log.info("Raft servers have been started");
    final String accountsName = "accounts";
    final String customersName = "customers";
    UUID accTblId = UUID.randomUUID();
    UUID custTblId = UUID.randomUUID();
    accRaftClients = startTable(accountsName, accTblId);
    custRaftClients = startTable(customersName, custTblId);
    log.info("Partition groups have been started");
    TxManager txMgr;
    if (startClient()) {
        txMgr = new TxManagerImpl(client, new HeapLockManager());
    } else {
        // Collocated mode.
        txMgr = txManagers.get(accRaftClients.get(0).clusterService().topologyService().localMember());
    }
    assertNotNull(txMgr);
    igniteTransactions = new IgniteTransactionsImpl(txMgr);
    this.accounts = new TableImpl(new InternalTableImpl(accountsName, accTblId, accRaftClients, 1, NetworkAddress::toString, txMgr, Mockito.mock(TableStorage.class)), new DummySchemaManagerImpl(ACCOUNTS_SCHEMA));
    this.customers = new TableImpl(new InternalTableImpl(customersName, custTblId, custRaftClients, 1, NetworkAddress::toString, txMgr, Mockito.mock(TableStorage.class)), new DummySchemaManagerImpl(CUSTOMERS_SCHEMA));
    log.info("Tables have been started");
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) TxAbstractTest(org.apache.ignite.internal.table.TxAbstractTest) RaftMessagesFactory(org.apache.ignite.raft.jraft.RaftMessagesFactory) RaftGroupService(org.apache.ignite.raft.client.service.RaftGroupService) Map(java.util.Map) JraftServerImpl(org.apache.ignite.internal.raft.server.impl.JraftServerImpl) NodeFinder(org.apache.ignite.network.NodeFinder) Int2ObjectOpenHashMap(it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap) InternalTableImpl(org.apache.ignite.internal.table.distributed.storage.InternalTableImpl) Set(java.util.Set) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) TxManager(org.apache.ignite.internal.tx.TxManager) TestInfo(org.junit.jupiter.api.TestInfo) ClusterNode(org.apache.ignite.network.ClusterNode) List(java.util.List) StaticNodeFinder(org.apache.ignite.network.StaticNodeFinder) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) RaftGroupServiceImpl(org.apache.ignite.raft.jraft.rpc.impl.RaftGroupServiceImpl) ClusterServiceTestUtils.findLocalAddresses(org.apache.ignite.utils.ClusterServiceTestUtils.findLocalAddresses) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Assertions.fail(org.junit.jupiter.api.Assertions.fail) ConcurrentHashMapPartitionStorage(org.apache.ignite.internal.storage.basic.ConcurrentHashMapPartitionStorage) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) RendezvousAffinityFunction(org.apache.ignite.internal.affinity.RendezvousAffinityFunction) ClusterServiceTestUtils(org.apache.ignite.utils.ClusterServiceTestUtils) Loza(org.apache.ignite.internal.raft.Loza) HashMap(java.util.HashMap) VersionedRowStore(org.apache.ignite.internal.table.distributed.storage.VersionedRowStore) HeapLockManager(org.apache.ignite.internal.tx.impl.HeapLockManager) TestScaleCubeClusterServiceFactory(org.apache.ignite.network.scalecube.TestScaleCubeClusterServiceFactory) TestUtils.waitForTopology(org.apache.ignite.raft.jraft.test.TestUtils.waitForTopology) TableImpl(org.apache.ignite.internal.table.TableImpl) IgniteUtils(org.apache.ignite.internal.util.IgniteUtils) DummySchemaManagerImpl(org.apache.ignite.internal.table.impl.DummySchemaManagerImpl) TxManagerImpl(org.apache.ignite.internal.tx.impl.TxManagerImpl) TableTxManagerImpl(org.apache.ignite.internal.table.distributed.TableTxManagerImpl) TableStorage(org.apache.ignite.internal.storage.engine.TableStorage) NetworkAddress(org.apache.ignite.network.NetworkAddress) TimeUnit(java.util.concurrent.TimeUnit) Mockito(org.mockito.Mockito) Peer(org.apache.ignite.raft.client.Peer) AfterEach(org.junit.jupiter.api.AfterEach) ClusterService(org.apache.ignite.network.ClusterService) PartitionListener(org.apache.ignite.internal.table.distributed.raft.PartitionListener) IgniteTransactionsImpl(org.apache.ignite.internal.tx.impl.IgniteTransactionsImpl) NamedThreadFactory(org.apache.ignite.internal.thread.NamedThreadFactory) Table(org.apache.ignite.table.Table) ClusterNode(org.apache.ignite.network.ClusterNode) TableStorage(org.apache.ignite.internal.storage.engine.TableStorage) StaticNodeFinder(org.apache.ignite.network.StaticNodeFinder) IgniteTransactionsImpl(org.apache.ignite.internal.tx.impl.IgniteTransactionsImpl) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) NamedThreadFactory(org.apache.ignite.internal.thread.NamedThreadFactory) InternalTableImpl(org.apache.ignite.internal.table.distributed.storage.InternalTableImpl) TableImpl(org.apache.ignite.internal.table.TableImpl) TxManager(org.apache.ignite.internal.tx.TxManager) Loza(org.apache.ignite.internal.raft.Loza) DummySchemaManagerImpl(org.apache.ignite.internal.table.impl.DummySchemaManagerImpl) HeapLockManager(org.apache.ignite.internal.tx.impl.HeapLockManager) ClusterService(org.apache.ignite.network.ClusterService) InternalTableImpl(org.apache.ignite.internal.table.distributed.storage.InternalTableImpl) NetworkAddress(org.apache.ignite.network.NetworkAddress) TxManagerImpl(org.apache.ignite.internal.tx.impl.TxManagerImpl) TableTxManagerImpl(org.apache.ignite.internal.table.distributed.TableTxManagerImpl) TableTxManagerImpl(org.apache.ignite.internal.table.distributed.TableTxManagerImpl) UUID(java.util.UUID) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

List (java.util.List)2 Map (java.util.Map)2 UUID (java.util.UUID)2 JraftServerImpl (org.apache.ignite.internal.raft.server.impl.JraftServerImpl)2 ConcurrentHashMapPartitionStorage (org.apache.ignite.internal.storage.basic.ConcurrentHashMapPartitionStorage)2 TableStorage (org.apache.ignite.internal.storage.engine.TableStorage)2 TableTxManagerImpl (org.apache.ignite.internal.table.distributed.TableTxManagerImpl)2 PartitionListener (org.apache.ignite.internal.table.distributed.raft.PartitionListener)2 InternalTableImpl (org.apache.ignite.internal.table.distributed.storage.InternalTableImpl)2 VersionedRowStore (org.apache.ignite.internal.table.distributed.storage.VersionedRowStore)2 TxManager (org.apache.ignite.internal.tx.TxManager)2 HeapLockManager (org.apache.ignite.internal.tx.impl.HeapLockManager)2 TxManagerImpl (org.apache.ignite.internal.tx.impl.TxManagerImpl)2 ClusterService (org.apache.ignite.network.ClusterService)2 NetworkAddress (org.apache.ignite.network.NetworkAddress)2 RaftGroupService (org.apache.ignite.raft.client.service.RaftGroupService)2 Int2ObjectMaps (it.unimi.dsi.fastutil.ints.Int2ObjectMaps)1 Int2ObjectOpenHashMap (it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1