Search in sources :

Example 56 with IgniteKernal

use of org.apache.ignite.internal.IgniteKernal in project ignite by apache.

the class CacheExchangeMergeTest method checkExchanges.

/**
 * @param node Node.
 * @param vers Expected exchange versions.
 */
private void checkExchanges(Ignite node, long... vers) {
    IgniteKernal node0 = (IgniteKernal) node;
    List<AffinityTopologyVersion> expVers = new ArrayList<>();
    for (long ver : vers) expVers.add(new AffinityTopologyVersion(ver));
    List<AffinityTopologyVersion> doneVers = new ArrayList<>();
    List<GridDhtPartitionsExchangeFuture> futs = node0.context().cache().context().exchange().exchangeFutures();
    for (int i = futs.size() - 1; i >= 0; i--) {
        GridDhtPartitionsExchangeFuture fut = futs.get(i);
        if (fut.exchangeDone() && fut.firstEvent().type() != EVT_DISCOVERY_CUSTOM_EVT) {
            AffinityTopologyVersion resVer = fut.topologyVersion();
            if (resVer != null)
                doneVers.add(resVer);
        }
    }
    assertEquals(expVers, doneVers);
    for (CacheGroupContext grpCtx : node0.context().cache().cacheGroups()) {
        for (AffinityTopologyVersion ver : grpCtx.affinity().cachedVersions()) {
            if (ver.minorTopologyVersion() > 0)
                continue;
            assertTrue("Unexpected version [ver=" + ver + ", exp=" + expVers + ']', expVers.contains(ver));
        }
    }
}
Also used : IgniteKernal(org.apache.ignite.internal.IgniteKernal) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) ArrayList(java.util.ArrayList) CacheGroupContext(org.apache.ignite.internal.processors.cache.CacheGroupContext)

Example 57 with IgniteKernal

use of org.apache.ignite.internal.IgniteKernal in project ignite by apache.

the class MarshallerContextSelfTest method testClassName.

/**
 * @throws Exception If failed.
 */
public void testClassName() throws Exception {
    MarshallerContextImpl marshCtx = new MarshallerContextImpl(null, null);
    marshCtx.onMarshallerProcessorStarted(ctx, null);
    MarshallerMappingItem item = new MarshallerMappingItem(JAVA_ID, 1, String.class.getName());
    marshCtx.onMappingProposed(item);
    marshCtx.onMappingAccepted(item);
    try (Ignite g1 = startGrid(1)) {
        marshCtx = ((IgniteKernal) g1).context().marshallerContext();
        String clsName = marshCtx.getClassName(JAVA_ID, 1);
        assertEquals("java.lang.String", clsName);
    }
}
Also used : MarshallerMappingItem(org.apache.ignite.internal.processors.marshaller.MarshallerMappingItem) MarshallerContextImpl(org.apache.ignite.internal.MarshallerContextImpl) IgniteKernal(org.apache.ignite.internal.IgniteKernal) Ignite(org.apache.ignite.Ignite)

Example 58 with IgniteKernal

use of org.apache.ignite.internal.IgniteKernal in project ignite by apache.

the class GridIoManagerBenchmark method main.

/**
 * @param args Command line arguments.
 */
public static void main(String[] args) {
    int threads = args.length > 0 ? Integer.parseInt(args[0]) : DFLT_THREADS;
    int duration = args.length > 1 ? Integer.parseInt(args[1]) : 0;
    String outputFilename = args.length > 2 ? args[2] : null;
    String path = args.length > 3 ? args[3] : DFLT_CONFIG;
    testHeavyMsgs = args.length > 4 && "true".equalsIgnoreCase(args[4]);
    testLatency = args.length > 5 && "true".equalsIgnoreCase(args[5]);
    // threads = 128;
    // testLatency = true;
    // testHeavyMsgs = true;
    X.println("Config: " + path);
    X.println("Test heavy messages: " + testHeavyMsgs);
    X.println("Test latency: " + testLatency);
    X.println("Threads: " + threads);
    X.println("Duration: " + duration);
    X.println("Output file name: " + outputFilename);
    IgniteKernal g = (IgniteKernal) G.start(path);
    if (g.localNode().order() > 1) {
        try {
            sendMessages(g, threads, duration, outputFilename);
        } finally {
            G.stopAll(false);
        }
    } else
        receiveMessages(g);
}
Also used : IgniteKernal(org.apache.ignite.internal.IgniteKernal)

Example 59 with IgniteKernal

use of org.apache.ignite.internal.IgniteKernal in project ignite by apache.

the class IgniteExceptionInNioWorkerSelfTest method testBrokenMessage.

/**
 * @throws Exception If failed.
 */
public void testBrokenMessage() throws Exception {
    startGrids(GRID_CNT);
    try {
        IgniteKernal kernal = (IgniteKernal) ignite(0);
        UUID nodeId = ignite(1).cluster().localNode().id();
        // This should trigger a failure in a NIO thread.
        kernal.context().io().sendToCustomTopic(nodeId, GridTopic.TOPIC_CACHE.topic("cache"), new BrokenMessage(), (byte) 0);
        for (int i = 0; i < 100; i++) ignite(0).cache("cache").put(i, i);
    } finally {
        stopAllGrids();
    }
}
Also used : IgniteKernal(org.apache.ignite.internal.IgniteKernal) UUID(java.util.UUID)

Example 60 with IgniteKernal

use of org.apache.ignite.internal.IgniteKernal in project ignite by apache.

the class GridIoManagerBenchmark0 method testLatency.

/**
 * @throws Exception If failed.
 */
@SuppressWarnings("deprecation")
public void testLatency() throws Exception {
    final IgniteKernal sndKernal = (IgniteKernal) grid(0);
    final IgniteKernal rcvKernal = (IgniteKernal) grid(1);
    final ClusterNode sndNode = sndKernal.localNode();
    final ClusterNode rcvNode = rcvKernal.localNode();
    final GridIoManager snd = sndKernal.context().io();
    final GridIoManager rcv = rcvKernal.context().io();
    final LongAdder msgCntr = new LongAdder();
    final Integer topic = 1;
    final Map<IgniteUuid, CountDownLatch> map = new ConcurrentHashMap<>();
    rcv.addMessageListener(topic, new GridMessageListener() {

        @Override
        public void onMessage(UUID nodeId, Object msg, byte plc) {
            try {
                rcv.sendToCustomTopic(sndNode, topic, (Message) msg, PUBLIC_POOL);
            } catch (IgniteCheckedException e) {
                error("Failed to send message.", e);
            }
        }
    });
    snd.addMessageListener(topic, new GridMessageListener() {

        @Override
        public void onMessage(UUID nodeId, Object msg, byte plc) {
            map.get(((GridTestMessage) msg).id()).countDown();
        }
    });
    Timer t = new Timer("results-reporter");
    t.schedule(new TimerTask() {

        private long ts = System.currentTimeMillis();

        @Override
        public void run() {
            long newTs = System.currentTimeMillis();
            long qrys = msgCntr.sumThenReset();
            long time = newTs - ts;
            X.println("Communication benchmark [qps=" + qrys * 1000 / time + ", executed=" + qrys + ", time=" + time + ']');
            ts = newTs;
        }
    }, 10000, 10000);
    final AtomicBoolean finish = new AtomicBoolean();
    IgniteInternalFuture<?> f = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            try {
                IgniteUuid msgId = IgniteUuid.randomUuid();
                while (!finish.get()) {
                    CountDownLatch latch = new CountDownLatch(1);
                    map.put(msgId, latch);
                    snd.sendToCustomTopic(rcvNode, topic, new GridTestMessage(msgId, (String) null), PUBLIC_POOL);
                    latch.await();
                    msgCntr.increment();
                }
            } catch (IgniteCheckedException e) {
                X.println("Message send failed", e);
            } catch (InterruptedException ignored) {
            // No-op.
            }
            return null;
        }
    }, 1, "send-thread");
    Thread.sleep(TEST_TIMEOUT);
    finish.set(true);
    t.cancel();
    f.get();
}
Also used : Message(org.apache.ignite.plugin.extensions.communication.Message) GridMessageListener(org.apache.ignite.internal.managers.communication.GridMessageListener) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) TimerTask(java.util.TimerTask) IgniteUuid(org.apache.ignite.lang.IgniteUuid) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) UUID(java.util.UUID) ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteKernal(org.apache.ignite.internal.IgniteKernal) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LongAdder(java.util.concurrent.atomic.LongAdder) Timer(java.util.Timer) GridIoManager(org.apache.ignite.internal.managers.communication.GridIoManager)

Aggregations

IgniteKernal (org.apache.ignite.internal.IgniteKernal)181 Ignite (org.apache.ignite.Ignite)78 ClusterNode (org.apache.ignite.cluster.ClusterNode)35 ArrayList (java.util.ArrayList)34 Map (java.util.Map)30 Transaction (org.apache.ignite.transactions.Transaction)30 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)27 IgniteCache (org.apache.ignite.IgniteCache)26 UUID (java.util.UUID)22 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)22 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)22 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)22 IgniteException (org.apache.ignite.IgniteException)21 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)20 GridAbsPredicate (org.apache.ignite.internal.util.lang.GridAbsPredicate)19 IgniteEx (org.apache.ignite.internal.IgniteEx)15 HashMap (java.util.HashMap)14 List (java.util.List)14 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)13 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)13