use of org.apache.ignite.internal.managers.discovery.CustomMessageWrapper in project ignite by apache.
the class RunningQueriesTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
cfg.setDiscoverySpi(new TcpDiscoverySpi() {
@Override
public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException {
if (CustomMessageWrapper.class.isAssignableFrom(msg.getClass())) {
DiscoveryCustomMessage delegate = ((CustomMessageWrapper) msg).delegate();
if (DynamicCacheChangeBatch.class.isAssignableFrom(delegate.getClass())) {
((DynamicCacheChangeBatch) delegate).requests().stream().filter((c) -> !c.cacheName().equalsIgnoreCase("default")).findAny().ifPresent((c) -> {
try {
awaitTimeout();
} catch (Exception e) {
e.printStackTrace();
}
});
} else if (SchemaProposeDiscoveryMessage.class.isAssignableFrom(delegate.getClass())) {
try {
awaitTimeout();
} catch (Exception e) {
e.printStackTrace();
}
}
}
super.sendCustomEvent(msg);
}
});
cfg.setCommunicationSpi(new TcpCommunicationSpi() {
/**
* {@inheritDoc}
*/
@Override
public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackC) {
if (GridIoMessage.class.isAssignableFrom(msg.getClass())) {
Message gridMsg = ((GridIoMessage) msg).message();
if (GridNearAtomicSingleUpdateFilterRequest.class.isAssignableFrom(gridMsg.getClass()) || GridNearAtomicFullUpdateRequest.class.isAssignableFrom(gridMsg.getClass())) {
try {
awaitTimeout();
} catch (Exception ignore) {
}
}
}
super.sendMessage(node, msg, ackC);
}
});
return cfg;
}
Aggregations