Search in sources :

Example 6 with IgniteCheckedException

use of org.apache.ignite.IgniteCheckedException in project ignite by apache.

the class IgniteH2Indexing method registerCache.

/** {@inheritDoc} */
@Override
public void registerCache(String cacheName, String schemaName, GridCacheContext<?, ?> cctx) throws IgniteCheckedException {
    if (!isDefaultSchema(schemaName)) {
        if (schemas.putIfAbsent(schemaName, new H2Schema(schemaName)) != null)
            throw new IgniteCheckedException("Schema already registered: " + U.maskName(schemaName));
        createSchema(schemaName);
    }
    cacheName2schema.put(cacheName, schemaName);
    createSqlFunctions(schemaName, cctx.config().getSqlFunctionClasses());
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException)

Example 7 with IgniteCheckedException

use of org.apache.ignite.IgniteCheckedException in project ignite by apache.

the class GridDhtPartitionsExchangeFuture method onReceive.

/**
     * @param node Sender node.
     * @param msg Full partition info.
     */
public void onReceive(final ClusterNode node, final GridDhtPartitionsFullMessage msg) {
    assert msg != null;
    final UUID nodeId = node.id();
    if (isDone()) {
        if (log.isDebugEnabled())
            log.debug("Received message for finished future [msg=" + msg + ", fut=" + this + ']');
        return;
    }
    if (log.isDebugEnabled())
        log.debug("Received full partition map from node [nodeId=" + nodeId + ", msg=" + msg + ']');
    initFut.listen(new CI1<IgniteInternalFuture<Boolean>>() {

        @Override
        public void apply(IgniteInternalFuture<Boolean> f) {
            try {
                if (!f.get())
                    return;
            } catch (IgniteCheckedException e) {
                U.error(log, "Failed to initialize exchange future: " + this, e);
                return;
            }
            processMessage(node, msg);
        }
    });
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) UUID(java.util.UUID) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

Example 8 with IgniteCheckedException

use of org.apache.ignite.IgniteCheckedException in project ignite by apache.

the class GridCacheQueryManager method scanIterator.

/**
     * @param qry Query.
     * @param locNode Local node.
     * @return Full-scan row iterator.
     * @throws IgniteCheckedException If failed to get iterator.
     */
@SuppressWarnings({ "unchecked" })
private GridCloseableIterator<IgniteBiTuple<K, V>> scanIterator(final GridCacheQueryAdapter<?> qry, boolean locNode) throws IgniteCheckedException {
    final IgniteBiPredicate<K, V> keyValFilter = qry.scanFilter();
    try {
        injectResources(keyValFilter);
        Integer part = qry.partition();
        if (cctx.isLocal())
            part = null;
        if (part != null && (part < 0 || part >= cctx.affinity().partitions()))
            return new GridEmptyCloseableIterator<>();
        final ExpiryPolicy plc = cctx.expiry();
        AffinityTopologyVersion topVer = GridQueryProcessor.getRequestAffinityTopologyVersion();
        if (topVer == null)
            topVer = cctx.affinity().affinityTopologyVersion();
        final boolean backups = qry.includeBackups() || cctx.isReplicated();
        final GridDhtLocalPartition locPart;
        final GridIterator<CacheDataRow> it;
        if (part != null) {
            final GridDhtCacheAdapter dht = cctx.isNear() ? cctx.near().dht() : cctx.dht();
            GridDhtLocalPartition locPart0 = dht.topology().localPartition(part, topVer, false);
            if (locPart0 == null || locPart0.state() != OWNING || !locPart0.reserve())
                throw new GridDhtUnreservedPartitionException(part, cctx.affinity().affinityTopologyVersion(), "Partition can not be reserved");
            if (locPart0.state() != OWNING) {
                locPart0.release();
                throw new GridDhtUnreservedPartitionException(part, cctx.affinity().affinityTopologyVersion(), "Partition can not be reserved");
            }
            locPart = locPart0;
            it = cctx.offheap().iterator(part);
        } else {
            locPart = null;
            it = cctx.offheap().iterator(true, backups, topVer);
        }
        return new PeekValueExpiryAwareIterator(it, plc, topVer, keyValFilter, qry.keepBinary(), locNode) {

            @Override
            protected void onClose() {
                super.onClose();
                if (locPart != null)
                    locPart.release();
                closeScanFilter(keyValFilter);
            }
        };
    } catch (IgniteCheckedException | RuntimeException e) {
        closeScanFilter(keyValFilter);
        throw e;
    }
}
Also used : CacheDataRow(org.apache.ignite.internal.processors.cache.database.CacheDataRow) GridDhtCacheAdapter(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter) GridDhtUnreservedPartitionException(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtUnreservedPartitionException) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteCacheExpiryPolicy(org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy) ExpiryPolicy(javax.cache.expiry.ExpiryPolicy) GridDhtLocalPartition(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition)

Example 9 with IgniteCheckedException

use of org.apache.ignite.IgniteCheckedException in project ignite by apache.

the class GridCacheStoreManagerAdapter method sessionInit0.

/**
     * @param tx Current transaction.
     * @throws IgniteCheckedException If failed.
     */
private void sessionInit0(@Nullable IgniteInternalTx tx) throws IgniteCheckedException {
    assert sesHolder != null;
    SessionData ses;
    if (tx != null) {
        ses = tx.meta(SES_ATTR);
        if (ses == null) {
            ses = new SessionData(tx, cctx.name());
            tx.addMeta(SES_ATTR, ses);
        } else
            // Session cache name may change in cross-cache transaction.
            ses.cacheName(cctx.name());
    } else
        ses = new SessionData(null, cctx.name());
    sesHolder.set(ses);
    try {
        if (sesLsnrs != null && !ses.started(this)) {
            for (CacheStoreSessionListener lsnr : sesLsnrs) lsnr.onSessionStart(locSes);
        }
    } catch (Exception e) {
        throw new IgniteCheckedException("Failed to start store session: " + e, e);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) CacheStoreSessionListener(org.apache.ignite.cache.store.CacheStoreSessionListener) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) CacheWriterException(javax.cache.integration.CacheWriterException) CacheLoaderException(javax.cache.integration.CacheLoaderException) NoSuchElementException(java.util.NoSuchElementException) CacheStorePartialUpdateException(org.apache.ignite.internal.processors.cache.CacheStorePartialUpdateException)

Example 10 with IgniteCheckedException

use of org.apache.ignite.IgniteCheckedException in project ignite by apache.

the class DataStreamProcessor method start.

/** {@inheritDoc} */
@Override
public void start(boolean activeOnStart) throws IgniteCheckedException {
    if (ctx.config().isDaemon())
        return;
    marshErrBytes = U.marshal(marsh, new IgniteCheckedException("Failed to marshal response error, " + "see node log for details."));
    flusher = new IgniteThread(new GridWorker(ctx.igniteInstanceName(), "grid-data-loader-flusher", log) {

        @Override
        protected void body() throws InterruptedException {
            while (!isCancelled()) {
                DataStreamerImpl<K, V> ldr = flushQ.take();
                if (!busyLock.enterBusy())
                    return;
                try {
                    if (ldr.isClosed())
                        continue;
                    ldr.tryFlush();
                    flushQ.offer(ldr);
                } finally {
                    busyLock.leaveBusy();
                }
            }
        }
    });
    flusher.start();
    if (log.isDebugEnabled())
        log.debug("Started data streamer processor.");
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteThread(org.apache.ignite.thread.IgniteThread) GridWorker(org.apache.ignite.internal.util.worker.GridWorker)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1568 IgniteException (org.apache.ignite.IgniteException)388 ArrayList (java.util.ArrayList)237 IOException (java.io.IOException)226 ClusterNode (org.apache.ignite.cluster.ClusterNode)215 Map (java.util.Map)181 UUID (java.util.UUID)163 HashMap (java.util.HashMap)160 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)150 Test (org.junit.Test)143 List (java.util.List)139 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)138 Nullable (org.jetbrains.annotations.Nullable)134 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)118 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)109 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)105 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)104 Collection (java.util.Collection)97 HashSet (java.util.HashSet)97 Ignite (org.apache.ignite.Ignite)96