Search in sources :

Example 11 with GridKernalContext

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

the class GridH2IndexBase method toSearchRow.

/**
     * @param msg Row message.
     * @return Search row.
     */
private SearchRow toSearchRow(GridH2RowMessage msg) {
    if (msg == null)
        return null;
    GridKernalContext ctx = kernalContext();
    Value[] vals = new Value[getTable().getColumns().length];
    assert vals.length > 0;
    List<GridH2ValueMessage> msgVals = msg.values();
    for (int i = 0; i < indexColumns.length; i++) {
        if (i >= msgVals.size())
            continue;
        try {
            vals[indexColumns[i].column.getColumnId()] = msgVals.get(i).value(ctx);
        } catch (IgniteCheckedException e) {
            throw new CacheException(e);
        }
    }
    return database.createRow(vals, MEMORY_CALCULATE);
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) CacheException(javax.cache.CacheException) GridKernalContext(org.apache.ignite.internal.GridKernalContext) Value(org.h2.value.Value) GridH2ValueMessage(org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2ValueMessage)

Example 12 with GridKernalContext

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

the class GridCommonAbstractTest method dumpCacheDebugInfo.

/**
     * @param ignite Node.
     */
public void dumpCacheDebugInfo(Ignite ignite) {
    GridKernalContext ctx = ((IgniteKernal) ignite).context();
    log.error("Cache information update [node=" + ignite.name() + ", client=" + ignite.configuration().isClientMode() + ']');
    GridCacheSharedContext cctx = ctx.cache().context();
    log.error("Pending transactions:");
    for (IgniteInternalTx tx : cctx.tm().activeTransactions()) log.error(">>> " + tx);
    log.error("Pending explicit locks:");
    for (GridCacheExplicitLockSpan lockSpan : cctx.mvcc().activeExplicitLocks()) log.error(">>> " + lockSpan);
    log.error("Pending cache futures:");
    for (GridCacheFuture<?> fut : cctx.mvcc().activeFutures()) log.error(">>> " + fut);
    log.error("Pending atomic cache futures:");
    for (GridCacheFuture<?> fut : cctx.mvcc().atomicFutures()) log.error(">>> " + fut);
}
Also used : IgniteKernal(org.apache.ignite.internal.IgniteKernal) IgniteInternalTx(org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx) GridKernalContext(org.apache.ignite.internal.GridKernalContext) GridCacheExplicitLockSpan(org.apache.ignite.internal.processors.cache.GridCacheExplicitLockSpan) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext)

Example 13 with GridKernalContext

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

the class GridAbstractTest method awaitTopologyChange.

/**
     * @throws IgniteInterruptedCheckedException If interrupted.
     */
private void awaitTopologyChange() throws IgniteInterruptedCheckedException {
    for (Ignite g : G.allGrids()) {
        final GridKernalContext ctx = ((IgniteKernal) g).context();
        if (ctx.isStopping())
            continue;
        AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx();
        AffinityTopologyVersion exchVer = ctx.cache().context().exchange().readyAffinityVersion();
        if (!topVer.equals(exchVer)) {
            info("Topology version mismatch [node=" + g.name() + ", exchVer=" + exchVer + ", topVer=" + topVer + ']');
            GridTestUtils.waitForCondition(new GridAbsPredicate() {

                @Override
                public boolean apply() {
                    AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx();
                    AffinityTopologyVersion exchVer = ctx.cache().context().exchange().readyAffinityVersion();
                    return exchVer.equals(topVer);
                }
            }, DFLT_TOP_WAIT_TIMEOUT);
        }
    }
}
Also used : IgniteKernal(org.apache.ignite.internal.IgniteKernal) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) GridKernalContext(org.apache.ignite.internal.GridKernalContext) Ignite(org.apache.ignite.Ignite)

Example 14 with GridKernalContext

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

the class GridH2IndexBase method initDistributedJoinMessaging.

/**
     * @param tbl Table.
     */
protected final void initDistributedJoinMessaging(GridH2Table tbl) {
    final GridH2RowDescriptor desc = tbl.rowDescriptor();
    if (desc != null && desc.context() != null) {
        ctx = desc.context();
        GridKernalContext ctx = desc.context().kernalContext();
        log = ctx.log(getClass());
        msgTopic = new IgniteBiTuple<>(GridTopic.TOPIC_QUERY, tbl.identifierString() + '.' + getName());
        msgLsnr = new GridMessageListener() {

            @Override
            public void onMessage(UUID nodeId, Object msg) {
                GridSpinBusyLock l = desc.indexing().busyLock();
                if (!l.enterBusy())
                    return;
                try {
                    onMessage0(nodeId, msg);
                } finally {
                    l.leaveBusy();
                }
            }
        };
        ctx.io().addMessageListener(msgTopic, msgLsnr);
    } else {
        msgTopic = null;
        msgLsnr = null;
        log = new NullLogger();
    }
}
Also used : NullLogger(org.apache.ignite.logger.NullLogger) GridKernalContext(org.apache.ignite.internal.GridKernalContext) GridMessageListener(org.apache.ignite.internal.managers.communication.GridMessageListener) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject)

Example 15 with GridKernalContext

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

the class GridCacheNestedTxAbstractTest method testTwoTx.

/**
     * JUnit.
     *
     * @throws Exception If failed.
     */
public void testTwoTx() throws Exception {
    final IgniteCache<String, Integer> c = grid(0).cache(DEFAULT_CACHE_NAME);
    GridKernalContext ctx = ((IgniteKernal) grid(0)).context();
    c.put(CNTR_KEY, 0);
    for (int i = 0; i < 10; i++) {
        try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
            c.get(CNTR_KEY);
            ctx.closure().callLocalSafe((new Callable<Boolean>() {

                @Override
                public Boolean call() throws Exception {
                    assertFalse(((GridCacheAdapter) c).context().tm().inUserTx());
                    assertNull(((GridCacheAdapter) c).context().tm().userTx());
                    return true;
                }
            }), true);
            tx.commit();
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteKernal(org.apache.ignite.internal.IgniteKernal) Transaction(org.apache.ignite.transactions.Transaction) GridKernalContext(org.apache.ignite.internal.GridKernalContext) Callable(java.util.concurrent.Callable)

Aggregations

GridKernalContext (org.apache.ignite.internal.GridKernalContext)19 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)7 IgniteKernal (org.apache.ignite.internal.IgniteKernal)6 Ignite (org.apache.ignite.Ignite)3 ClusterNode (org.apache.ignite.cluster.ClusterNode)3 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)3 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)3 Map (java.util.Map)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 CacheException (javax.cache.CacheException)2 IgniteLogger (org.apache.ignite.IgniteLogger)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 CacheObjectContext (org.apache.ignite.internal.processors.cache.CacheObjectContext)2 GridCacheSharedContext (org.apache.ignite.internal.processors.cache.GridCacheSharedContext)2 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)2 GridH2ValueMessage (org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2ValueMessage)2 Value (org.h2.value.Value)2 Nullable (org.jetbrains.annotations.Nullable)2 InvalidObjectException (java.io.InvalidObjectException)1 ArrayList (java.util.ArrayList)1