Search in sources :

Example 11 with MessagingService

use of org.apache.ignite.network.MessagingService 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 12 with MessagingService

use of org.apache.ignite.network.MessagingService 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));
}
Also used : ClusterNode(org.apache.ignite.network.ClusterNode) RaftGroupListener(org.apache.ignite.raft.client.service.RaftGroupListener) ClusterLocalConfiguration(org.apache.ignite.network.ClusterLocalConfiguration) MessagingService(org.apache.ignite.network.MessagingService) TopologyService(org.apache.ignite.network.TopologyService) Test(org.junit.jupiter.api.Test) IgniteAbstractTest(org.apache.ignite.internal.testframework.IgniteAbstractTest)

Aggregations

MessagingService (org.apache.ignite.network.MessagingService)12 ClusterService (org.apache.ignite.network.ClusterService)9 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 DummySchemaManagerImpl (org.apache.ignite.internal.table.impl.DummySchemaManagerImpl)6 TxManager (org.apache.ignite.internal.tx.TxManager)5 List (java.util.List)4 Test (org.junit.jupiter.api.Test)4 Collections (java.util.Collections)3 SchemaDescriptor (org.apache.ignite.internal.schema.SchemaDescriptor)3 LockManager (org.apache.ignite.internal.tx.LockManager)3 NetworkAddress (org.apache.ignite.network.NetworkAddress)3 NotNull (org.jetbrains.annotations.NotNull)3 Arrays (java.util.Arrays)2 Map (java.util.Map)2 Random (java.util.Random)2 Set (java.util.Set)2