Search in sources :

Example 21 with DummySchemaManagerImpl

use of org.apache.ignite.internal.table.impl.DummySchemaManagerImpl in project ignite-3 by apache.

the class TxLocalTest method before.

/**
 * Initialize the test state.
 */
@Override
@BeforeEach
public void before() {
    ClusterService clusterService = Mockito.mock(ClusterService.class, RETURNS_DEEP_STUBS);
    Mockito.when(clusterService.topologyService().localMember().address()).thenReturn(DummyInternalTableImpl.ADDR);
    lockManager = new HeapLockManager();
    txManager = new TxManagerImpl(clusterService, lockManager);
    MessagingService messagingService = MessagingServiceTestUtils.mockMessagingService(txManager);
    Mockito.when(clusterService.messagingService()).thenReturn(messagingService);
    igniteTransactions = new IgniteTransactionsImpl(txManager);
    InternalTable table = new DummyInternalTableImpl(new VersionedRowStore(new ConcurrentHashMapPartitionStorage(), txManager), txManager);
    accounts = new TableImpl(table, new DummySchemaManagerImpl(ACCOUNTS_SCHEMA));
    InternalTable table2 = new DummyInternalTableImpl(new VersionedRowStore(new ConcurrentHashMapPartitionStorage(), txManager), txManager);
    customers = new TableImpl(table2, new DummySchemaManagerImpl(CUSTOMERS_SCHEMA));
}
Also used : VersionedRowStore(org.apache.ignite.internal.table.distributed.storage.VersionedRowStore) HeapLockManager(org.apache.ignite.internal.tx.impl.HeapLockManager) ClusterService(org.apache.ignite.network.ClusterService) IgniteTransactionsImpl(org.apache.ignite.internal.tx.impl.IgniteTransactionsImpl) TxManagerImpl(org.apache.ignite.internal.tx.impl.TxManagerImpl) ConcurrentHashMapPartitionStorage(org.apache.ignite.internal.storage.basic.ConcurrentHashMapPartitionStorage) DummyInternalTableImpl(org.apache.ignite.internal.table.impl.DummyInternalTableImpl) DummyInternalTableImpl(org.apache.ignite.internal.table.impl.DummyInternalTableImpl) DummySchemaManagerImpl(org.apache.ignite.internal.table.impl.DummySchemaManagerImpl) MessagingService(org.apache.ignite.network.MessagingService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 22 with DummySchemaManagerImpl

use of org.apache.ignite.internal.table.impl.DummySchemaManagerImpl in project ignite-3 by apache.

the class NumericTypesSerializerTest method testDecimalMaxScale.

@Test
public void testDecimalMaxScale() throws TupleMarshallerException {
    schema = new SchemaDescriptor(42, new Column[] { new Column("key", NativeTypes.INT64, false) }, new Column[] { new Column("decimalCol", NativeTypes.decimalOf(Integer.MAX_VALUE, Integer.MAX_VALUE), false) });
    final Tuple tup = createTuple().set("key", rnd.nextLong()).set("decimalCol", BigDecimal.valueOf(123, Integer.MAX_VALUE));
    TupleMarshaller marshaller = new TupleMarshallerImpl(new DummySchemaManagerImpl(schema));
    final Row row = marshaller.marshal(tup);
    assertEquals(row.decimalValue(1), BigDecimal.valueOf(123, Integer.MAX_VALUE));
}
Also used : SchemaDescriptor(org.apache.ignite.internal.schema.SchemaDescriptor) Column(org.apache.ignite.internal.schema.Column) TupleMarshaller(org.apache.ignite.internal.schema.marshaller.TupleMarshaller) TupleMarshallerImpl(org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl) Row(org.apache.ignite.internal.schema.row.Row) Tuple(org.apache.ignite.table.Tuple) DummySchemaManagerImpl(org.apache.ignite.internal.table.impl.DummySchemaManagerImpl) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 23 with DummySchemaManagerImpl

use of org.apache.ignite.internal.table.impl.DummySchemaManagerImpl in project ignite-3 by apache.

the class NumericTypesSerializerTest method testUpscaleForDecimal.

/**
 * Test.
 */
@ParameterizedTest
@MethodSource("stringDecimalRepresentation")
public void testUpscaleForDecimal(String decimalStr) throws TupleMarshallerException {
    schema = new SchemaDescriptor(42, new Column[] { new Column("key", NativeTypes.INT64, false) }, new Column[] { new Column("decimalCol1", NativeTypes.decimalOf(9, 0), false) });
    final Tuple tup = createTuple().set("key", rnd.nextLong()).set("decimalCol1", new BigDecimal(decimalStr));
    TupleMarshaller marshaller = new TupleMarshallerImpl(new DummySchemaManagerImpl(schema));
    final Row row = marshaller.marshal(tup);
    assertEquals(row.decimalValue(1), new BigDecimal(decimalStr).setScale(0, RoundingMode.HALF_UP));
}
Also used : SchemaDescriptor(org.apache.ignite.internal.schema.SchemaDescriptor) Column(org.apache.ignite.internal.schema.Column) TupleMarshaller(org.apache.ignite.internal.schema.marshaller.TupleMarshaller) TupleMarshallerImpl(org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl) Row(org.apache.ignite.internal.schema.row.Row) Tuple(org.apache.ignite.table.Tuple) BigDecimal(java.math.BigDecimal) DummySchemaManagerImpl(org.apache.ignite.internal.table.impl.DummySchemaManagerImpl) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 24 with DummySchemaManagerImpl

use of org.apache.ignite.internal.table.impl.DummySchemaManagerImpl in project ignite-3 by apache.

the class NumericTypesSerializerTest method testNumber.

/**
 * Test.
 */
@ParameterizedTest
@MethodSource("numbers")
public void testNumber(Pair<BigInteger, BigInteger> pair) throws TupleMarshallerException {
    schema = new SchemaDescriptor(42, new Column[] { new Column("key", NativeTypes.INT64, false) }, new Column[] { new Column("number1", NativeTypes.numberOf(19), false), new Column("number2", NativeTypes.numberOf(10), false) });
    TupleMarshaller marshaller = new TupleMarshallerImpl(new DummySchemaManagerImpl(schema));
    final Tuple tup = createTuple().set("key", rnd.nextLong()).set("number1", pair.getFirst()).set("number2", pair.getSecond());
    final Row row = marshaller.marshal(tup);
    assertEquals(row.numberValue(1), row.numberValue(2));
}
Also used : SchemaDescriptor(org.apache.ignite.internal.schema.SchemaDescriptor) Column(org.apache.ignite.internal.schema.Column) TupleMarshaller(org.apache.ignite.internal.schema.marshaller.TupleMarshaller) TupleMarshallerImpl(org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl) Row(org.apache.ignite.internal.schema.row.Row) DummySchemaManagerImpl(org.apache.ignite.internal.table.impl.DummySchemaManagerImpl) Tuple(org.apache.ignite.table.Tuple) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 25 with DummySchemaManagerImpl

use of org.apache.ignite.internal.table.impl.DummySchemaManagerImpl 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

DummySchemaManagerImpl (org.apache.ignite.internal.table.impl.DummySchemaManagerImpl)25 TupleMarshaller (org.apache.ignite.internal.schema.marshaller.TupleMarshaller)17 TupleMarshallerImpl (org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl)17 Tuple (org.apache.ignite.table.Tuple)17 Row (org.apache.ignite.internal.schema.row.Row)15 Test (org.junit.jupiter.api.Test)15 Column (org.apache.ignite.internal.schema.Column)11 SchemaDescriptor (org.apache.ignite.internal.schema.SchemaDescriptor)11 ByteBufferRow (org.apache.ignite.internal.schema.ByteBufferRow)10 ConcurrentHashMapPartitionStorage (org.apache.ignite.internal.storage.basic.ConcurrentHashMapPartitionStorage)7 VersionedRowStore (org.apache.ignite.internal.table.distributed.storage.VersionedRowStore)7 DummyInternalTableImpl (org.apache.ignite.internal.table.impl.DummyInternalTableImpl)7 HeapLockManager (org.apache.ignite.internal.tx.impl.HeapLockManager)7 TxManagerImpl (org.apache.ignite.internal.tx.impl.TxManagerImpl)7 ClusterService (org.apache.ignite.network.ClusterService)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 Random (java.util.Random)6 TxManager (org.apache.ignite.internal.tx.TxManager)6 MessagingService (org.apache.ignite.network.MessagingService)6 BigDecimal (java.math.BigDecimal)3