use of org.apache.ignite.internal.managers.discovery.GridDiscoveryManager in project ignite by apache.
the class GridCacheQueryJdbcMetadataTask method map.
/** {@inheritDoc} */
@Override
public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable String cacheName) {
Map<JdbcDriverMetadataJob, ClusterNode> map = new HashMap<>();
IgniteKernal kernal = (IgniteKernal) ignite;
GridDiscoveryManager discoMgr = kernal.context().discovery();
for (ClusterNode n : subgrid) if (discoMgr.cacheAffinityNode(n, cacheName)) {
map.put(new JdbcDriverMetadataJob(cacheName), n);
break;
}
return map;
}
use of org.apache.ignite.internal.managers.discovery.GridDiscoveryManager in project ignite by apache.
the class PlatformDataStreamer method processInLongOutLong.
/** {@inheritDoc} */
@Override
public long processInLongOutLong(int type, final long val) throws IgniteCheckedException {
switch(type) {
case OP_SET_ALLOW_OVERWRITE:
ldr.allowOverwrite(val == TRUE);
return TRUE;
case OP_SET_PER_NODE_BUFFER_SIZE:
ldr.perNodeBufferSize((int) val);
return TRUE;
case OP_SET_SKIP_STORE:
ldr.skipStore(val == TRUE);
return TRUE;
case OP_SET_PER_NODE_PARALLEL_OPS:
ldr.perNodeParallelOperations((int) val);
return TRUE;
case OP_LISTEN_TOPOLOGY:
{
lsnr = new GridLocalEventListener() {
@Override
public void onEvent(Event evt) {
DiscoveryEvent discoEvt = (DiscoveryEvent) evt;
long topVer = discoEvt.topologyVersion();
int topSize = platformCtx.kernalContext().discovery().cacheNodes(cacheName, new AffinityTopologyVersion(topVer)).size();
platformCtx.gateway().dataStreamerTopologyUpdate(val, topVer, topSize);
}
};
platformCtx.kernalContext().event().addLocalEventListener(lsnr, EVT_NODE_JOINED, EVT_NODE_FAILED, EVT_NODE_LEFT);
GridDiscoveryManager discoMgr = platformCtx.kernalContext().discovery();
AffinityTopologyVersion topVer = discoMgr.topologyVersionEx();
int topSize = discoMgr.cacheNodes(cacheName, topVer).size();
platformCtx.gateway().dataStreamerTopologyUpdate(val, topVer.topologyVersion(), topSize);
return TRUE;
}
case OP_ALLOW_OVERWRITE:
return ldr.allowOverwrite() ? TRUE : FALSE;
case OP_PER_NODE_BUFFER_SIZE:
return ldr.perNodeBufferSize();
case OP_SKIP_STORE:
return ldr.skipStore() ? TRUE : FALSE;
case OP_PER_NODE_PARALLEL_OPS:
return ldr.perNodeParallelOperations();
}
return super.processInLongOutLong(type, val);
}
use of org.apache.ignite.internal.managers.discovery.GridDiscoveryManager in project ignite by apache.
the class VisorNodeDataCollectorJob method proxyCache.
/**
* @param cacheName Cache name to check.
* @return {@code true} if cache on local node is not a data cache or near cache disabled.
*/
private boolean proxyCache(String cacheName) {
GridDiscoveryManager discovery = ignite.context().discovery();
ClusterNode locNode = ignite.localNode();
return !(discovery.cacheAffinityNode(locNode, cacheName) || discovery.cacheNearNode(locNode, cacheName));
}
use of org.apache.ignite.internal.managers.discovery.GridDiscoveryManager in project ignite by apache.
the class GridManagerMxBeanIllegalArgumentHandleTest method testIllegalStateIsCatch.
/** Creates minimal disco manager mock, checks illegal state is not propagated */
public void testIllegalStateIsCatch() {
final IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setDiscoverySpi(new TcpDiscoverySpi());
final IgniteLogger log = Mockito.mock(IgniteLogger.class);
final GridKernalContext ctx = Mockito.mock(GridKernalContext.class);
when(ctx.config()).thenReturn(cfg);
when(ctx.log(Mockito.anyString())).thenReturn(log);
when(ctx.log(Mockito.any(Class.class))).thenReturn(log);
final GridDiscoveryManager mgr = new GridDiscoveryManager(ctx);
final long nHeapMax = mgr.metrics().getNonHeapMemoryMaximum();
if (correctSetupOfTestPerformed)
assertEquals(0, nHeapMax);
final long heapMax = mgr.metrics().getHeapMemoryMaximum();
if (correctSetupOfTestPerformed)
assertEquals(0, heapMax);
}
use of org.apache.ignite.internal.managers.discovery.GridDiscoveryManager in project ignite by apache.
the class GridBinaryCacheEntryMemorySizeSelfTest method createMarshaller.
/** {@inheritDoc} */
@Override
protected Marshaller createMarshaller() throws IgniteCheckedException {
BinaryMarshaller marsh = new BinaryMarshaller();
IgniteConfiguration iCfg = new IgniteConfiguration();
iCfg.setDiscoverySpi(new TcpDiscoverySpi() {
@Override
public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException {
// No-op.
}
});
iCfg.setClientMode(false);
GridTestKernalContext kernCtx = new GridTestKernalContext(log, iCfg);
kernCtx.add(new GridDiscoveryManager(kernCtx));
MarshallerContextTestImpl marshCtx = new MarshallerContextTestImpl(null);
marshCtx.onMarshallerProcessorStarted(kernCtx, null);
marsh.setContext(marshCtx);
BinaryContext pCtx = new BinaryContext(BinaryNoopMetadataHandler.instance(), iCfg, new NullLogger());
IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", pCtx, iCfg);
return marsh;
}
Aggregations