Search in sources :

Example 1 with GridDiscoveryManager

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;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteKernal(org.apache.ignite.internal.IgniteKernal) GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) HashMap(java.util.HashMap)

Example 2 with GridDiscoveryManager

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);
}
Also used : GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) GridLocalEventListener(org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) Event(org.apache.ignite.events.Event) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent)

Example 3 with GridDiscoveryManager

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));
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager)

Example 4 with GridDiscoveryManager

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);
}
Also used : GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridKernalContext(org.apache.ignite.internal.GridKernalContext) IgniteLogger(org.apache.ignite.IgniteLogger) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 5 with GridDiscoveryManager

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;
}
Also used : DiscoverySpiCustomMessage(org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage) GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) NullLogger(org.apache.ignite.logger.NullLogger) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) IgniteException(org.apache.ignite.IgniteException) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) BinaryContext(org.apache.ignite.internal.binary.BinaryContext) MarshallerContextTestImpl(org.apache.ignite.marshaller.MarshallerContextTestImpl) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

GridDiscoveryManager (org.apache.ignite.internal.managers.discovery.GridDiscoveryManager)18 ClusterNode (org.apache.ignite.cluster.ClusterNode)10 IgniteKernal (org.apache.ignite.internal.IgniteKernal)5 Ignite (org.apache.ignite.Ignite)4 IgniteException (org.apache.ignite.IgniteException)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)3 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)3 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)3 UUID (java.util.UUID)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)2 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)2 Event (org.apache.ignite.events.Event)2 GridIoManager (org.apache.ignite.internal.managers.communication.GridIoManager)2 GridLocalEventListener (org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener)2 NullLogger (org.apache.ignite.logger.NullLogger)2 MarshallerContextTestImpl (org.apache.ignite.marshaller.MarshallerContextTestImpl)2 IgniteSpiVersionCheckException (org.apache.ignite.spi.IgniteSpiVersionCheckException)2