use of org.apache.ignite.network.NetworkAddress in project ignite-3 by apache.
the class TxManagerTest method testEnlist.
@Test
public void testEnlist() throws TransactionException {
NetworkAddress addr = clusterService.topologyService().localMember().address();
assertEquals(ADDR, addr);
InternalTransaction tx = txManager.begin();
RaftGroupService svc = Mockito.mock(RaftGroupService.class);
tx.enlist(svc);
assertEquals(1, tx.enlisted().size());
assertTrue(tx.enlisted().contains(svc));
}
use of org.apache.ignite.network.NetworkAddress in project ignite-3 by apache.
the class ItMetaStorageServiceTest method beforeTest.
/**
* Run {@code NODES} cluster nodes.
*/
@BeforeEach
public void beforeTest(TestInfo testInfo) throws Exception {
List<NetworkAddress> localAddresses = findLocalAddresses(NODE_PORT_BASE, NODE_PORT_BASE + NODES);
var nodeFinder = new StaticNodeFinder(localAddresses);
localAddresses.stream().map(addr -> ClusterServiceTestUtils.clusterService(testInfo, addr.port(), nodeFinder, NETWORK_FACTORY)).forEach(clusterService -> {
clusterService.start();
cluster.add(clusterService);
});
for (ClusterService node : cluster) {
assertTrue(waitForTopology(node, NODES, 1000));
}
LOG.info("Cluster started.");
executor = new ScheduledThreadPoolExecutor(20, new NamedThreadFactory(Loza.CLIENT_POOL_NAME));
metaStorageSvc = prepareMetaStorage();
}
use of org.apache.ignite.network.NetworkAddress in project ignite-3 by apache.
the class ItTablePersistenceTest method afterFollowerStop.
/**
* {@inheritDoc}
*/
@Override
public void afterFollowerStop(RaftGroupService service) throws Exception {
TxManagerImpl txManager = new TxManagerImpl(clientService(), new HeapLockManager());
managers.add(txManager);
txManager.start();
var table = new InternalTableImpl("table", UUID.randomUUID(), Int2ObjectMaps.singleton(0, service), 1, NetworkAddress::toString, txManager, mock(TableStorage.class));
// Remove the first key
table.delete(FIRST_KEY, null).get();
// Put deleted data again
table.upsert(FIRST_VALUE, null).get();
txManager.stop();
}
use of org.apache.ignite.network.NetworkAddress in project ignite-3 by apache.
the class ItTablePersistenceTest method beforeFollowerStop.
/**
* {@inheritDoc}
*/
@Override
public void beforeFollowerStop(RaftGroupService service) throws Exception {
TxManagerImpl txManager = new TxManagerImpl(clientService(), new HeapLockManager());
managers.add(txManager);
txManager.start();
var table = new InternalTableImpl("table", UUID.randomUUID(), Int2ObjectMaps.singleton(0, service), 1, NetworkAddress::toString, txManager, mock(TableStorage.class));
table.upsert(FIRST_VALUE, null).get();
}
use of org.apache.ignite.network.NetworkAddress 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");
}
Aggregations