use of org.apache.ignite.internal.managers.communication.GridIoMessage in project ignite by apache.
the class IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setCommunicationSpi(new TcpCommunicationSpi() {
@Override
public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackClosure) throws IgniteSpiException {
if (getSpiContext().localNode().id().equals(failingNodeId)) {
if (ignoredMessage((GridIoMessage) msg) && ignoreMsgNodeIds != null) {
for (UUID ignored : ignoreMsgNodeIds) {
if (node.id().equals(ignored))
return;
}
}
}
super.sendMessage(node, msg, ackClosure);
}
});
cfg.getTransactionConfiguration().setDefaultTxConcurrency(PESSIMISTIC);
return cfg;
}
use of org.apache.ignite.internal.managers.communication.GridIoMessage in project ignite by apache.
the class IgniteCachePartitionedQuerySelfTest method testScanQueryPagination.
/**
* @throws Exception If failed.
*/
public void testScanQueryPagination() throws Exception {
final int pageSize = 5;
final AtomicInteger pages = new AtomicInteger(0);
IgniteCache<Integer, Integer> cache = jcache(Integer.class, Integer.class);
for (int i = 0; i < 50; i++) cache.put(i, i);
CommunicationSpi spi = ignite().configuration().getCommunicationSpi();
assert spi instanceof TestTcpCommunicationSpi;
TestTcpCommunicationSpi commSpi = (TestTcpCommunicationSpi) spi;
commSpi.filter = new IgniteInClosure<Message>() {
@Override
public void apply(Message msg) {
if (!(msg instanceof GridIoMessage))
return;
Message msg0 = ((GridIoMessage) msg).message();
if (msg0 instanceof GridCacheQueryRequest) {
assertEquals(pageSize, ((GridCacheQueryRequest) msg0).pageSize());
pages.incrementAndGet();
} else if (msg0 instanceof GridCacheQueryResponse)
assertTrue(((GridCacheQueryResponse) msg0).data().size() <= pageSize);
}
};
try {
ScanQuery<Integer, Integer> qry = new ScanQuery<Integer, Integer>();
qry.setPageSize(pageSize);
List<Cache.Entry<Integer, Integer>> all = cache.query(qry).getAll();
assertTrue(pages.get() > ignite().cluster().forDataNodes(DEFAULT_CACHE_NAME).nodes().size());
assertEquals(50, all.size());
} finally {
commSpi.filter = null;
}
}
use of org.apache.ignite.internal.managers.communication.GridIoMessage in project ignite by apache.
the class TestRecordingCommunicationSpi method sendMessage.
/** {@inheritDoc} */
@Override
public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackC) throws IgniteSpiException {
if (msg instanceof GridIoMessage) {
GridIoMessage ioMsg = (GridIoMessage) msg;
Message msg0 = ioMsg.message();
synchronized (this) {
boolean record = (recordClasses != null && recordClasses.contains(msg0.getClass())) || (recordP != null && recordP.apply(node, msg0));
if (record)
recordedMsgs.add(msg0);
boolean block = false;
if (blockP != null && blockP.apply(node, msg0))
block = true;
else {
Set<String> blockNodes = blockCls.get(msg0.getClass());
if (blockNodes != null) {
String nodeName = (String) node.attributes().get(ATTR_IGNITE_INSTANCE_NAME);
block = blockNodes.contains(nodeName);
}
}
if (block) {
ignite.log().info("Block message [node=" + node.id() + ", msg=" + ioMsg.message() + ']');
blockedMsgs.add(new T2<>(node, ioMsg));
notifyAll();
return;
} else if (record)
notifyAll();
}
}
super.sendMessage(node, msg, ackC);
}
use of org.apache.ignite.internal.managers.communication.GridIoMessage in project ignite by apache.
the class IgniteTxOriginatingNodeFailureAbstractSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setCommunicationSpi(new TcpCommunicationSpi() {
@Override
public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackClosure) throws IgniteSpiException {
if (!F.eq(ignoreMsgNodeId, node.id()) || !ignoredMessage((GridIoMessage) msg))
super.sendMessage(node, msg, ackClosure);
}
});
cfg.getTransactionConfiguration().setDefaultTxConcurrency(OPTIMISTIC);
return cfg;
}
Aggregations