use of org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage in project ignite by apache.
the class CacheBlockOnReadAbstractTest method destroyCachePredicate.
/**
* Checks that given discovery event is from "Destroy cache" operation.
*
* @param discoEvt Discovery event.
*/
private static boolean destroyCachePredicate(DiscoveryEvent discoEvt) {
if (discoEvt instanceof DiscoveryCustomEvent) {
DiscoveryCustomEvent discoCustomEvt = (DiscoveryCustomEvent) discoEvt;
DiscoveryCustomMessage customMsg = discoCustomEvt.customMessage();
if (customMsg instanceof DynamicCacheChangeBatch) {
DynamicCacheChangeBatch cacheChangeBatch = (DynamicCacheChangeBatch) customMsg;
ExchangeActions exchangeActions = U.field(cacheChangeBatch, "exchangeActions");
Collection<CacheActionData> stopRequests = exchangeActions.cacheStopRequests();
return !stopRequests.isEmpty();
}
}
return false;
}
use of org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage in project ignite by apache.
the class GridServiceProxyTopologyInitializationTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
if (getTestIgniteInstanceName(NODES_CNT - 1).equals(igniteInstanceName)) {
((TestTcpDiscoverySpi) cfg.getDiscoverySpi()).discoveryHook(new DiscoveryHook() {
@Override
public void beforeDiscovery(DiscoveryCustomMessage customMsg) {
if (customMsg instanceof ServiceClusterDeploymentResultBatch) {
fullMsgReceivedLatch.countDown();
try {
fullMsgUnblockedLatch.await(getTestTimeout(), MILLISECONDS);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
@Override
public void afterDiscovery(DiscoveryCustomMessage customMsg) {
if (customMsg instanceof ServiceClusterDeploymentResultBatch)
fullMsgHandledLatch.countDown();
}
});
cfg.setUserAttributes(Collections.singletonMap(ATTR_SKIP_DEPLOYMENT, true));
}
return cfg;
}
use of org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage 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;
}
use of org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage in project ignite by apache.
the class KillQueryTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
CacheConfiguration<?, ?> cache = GridAbstractTest.defaultCacheConfiguration();
cache.setAffinity(new RendezvousAffinityFunction(false, PARTS_CNT));
cache.setCacheMode(PARTITIONED);
cache.setBackups(1);
cache.setWriteSynchronizationMode(FULL_SYNC);
cache.setSqlFunctionClasses(TestSQLFunctions.class);
cache.setIndexedTypes(Integer.class, Integer.class, Long.class, Long.class, String.class, Person.class);
cfg.setCacheConfiguration(cache);
TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
cfg.setCommunicationSpi(commSpi);
if (++cntr == NODES_COUNT)
clientBlocker = commSpi;
cfg.setDiscoverySpi(new TcpDiscoverySpi() {
@Override
public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException {
if (msg instanceof CustomMessageWrapper) {
DiscoveryCustomMessage delegate = ((CustomMessageWrapper) msg).delegate();
if (delegate instanceof DynamicCacheChangeBatch) {
try {
awaitTimeout();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
} else if (delegate instanceof SchemaProposeDiscoveryMessage) {
try {
awaitTimeout();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
super.sendCustomEvent(msg);
}
}.setIpFinder(IP_FINDER));
return cfg;
}
Aggregations