Search in sources :

Example 51 with IgniteUuid

use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.

the class IgniteUtils method readGridUuid.

/**
     * @param ptr Offheap address.
     * @return UUID.
     */
@Nullable
public static IgniteUuid readGridUuid(long ptr) {
    if (GridUnsafe.getBoolean(null, ptr++)) {
        long most = GridUnsafe.getLong(ptr);
        ptr += 8;
        long least = GridUnsafe.getLong(ptr);
        ptr += 8;
        UUID globalId = new UUID(most, least);
        long locId = GridUnsafe.getLong(ptr);
        return new IgniteUuid(globalId, locId);
    }
    return null;
}
Also used : IgniteUuid(org.apache.ignite.lang.IgniteUuid) UUID(java.util.UUID) Nullable(org.jetbrains.annotations.Nullable)

Example 52 with IgniteUuid

use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.

the class IgniteUtils method readGridUuid.

/**
     * @param arr Array.
     * @param off Offset.
     * @return UUID.
     */
@Nullable
public static IgniteUuid readGridUuid(byte[] arr, long off) {
    if (GridUnsafe.getBoolean(arr, off++)) {
        long most = GridUnsafe.getLong(arr, off);
        off += 8;
        long least = GridUnsafe.getLong(arr, off);
        off += 8;
        UUID globalId = new UUID(most, least);
        long locId = GridUnsafe.getLong(arr, off);
        return new IgniteUuid(globalId, locId);
    }
    return null;
}
Also used : IgniteUuid(org.apache.ignite.lang.IgniteUuid) UUID(java.util.UUID) Nullable(org.jetbrains.annotations.Nullable)

Example 53 with IgniteUuid

use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.

the class GridCacheDeploymentManager method p2pContext.

/**
     * @param sndId Sender node ID.
     * @param ldrId Loader ID.
     * @param userVer User version.
     * @param mode Deployment mode.
     * @param participants Node participants.
     * @param locDepOwner {@code True} if local deployment owner.
     */
public void p2pContext(UUID sndId, IgniteUuid ldrId, String userVer, DeploymentMode mode, Map<UUID, IgniteUuid> participants, boolean locDepOwner) {
    assert depEnabled;
    if (mode == PRIVATE || mode == ISOLATED) {
        ClusterNode node = cctx.discovery().node(sndId);
        if (node == null) {
            if (log.isDebugEnabled())
                log.debug("Ignoring p2p context (sender has left) [sndId=" + sndId + ", ldrId=" + ldrId + ", userVer=" + userVer + ", mode=" + mode + ", participants=" + participants + ']');
            return;
        }
        boolean daemon = node.isDaemon();
        // Always output in debug.
        if (log.isDebugEnabled())
            log.debug("Ignoring deployment in PRIVATE or ISOLATED mode [sndId=" + sndId + ", ldrId=" + ldrId + ", userVer=" + userVer + ", mode=" + mode + ", participants=" + participants + ", daemon=" + daemon + ']');
        if (!daemon) {
            LT.warn(log, "Ignoring deployment in PRIVATE or ISOLATED mode " + "[sndId=" + sndId + ", ldrId=" + ldrId + ", userVer=" + userVer + ", mode=" + mode + ", participants=" + participants + ", daemon=" + daemon + ']');
        }
        return;
    }
    if (mode != cctx.gridConfig().getDeploymentMode()) {
        LT.warn(log, "Local and remote deployment mode mismatch (please fix configuration and restart) " + "[locDepMode=" + cctx.gridConfig().getDeploymentMode() + ", rmtDepMode=" + mode + ", rmtNodeId=" + sndId + ']');
        return;
    }
    if (log.isDebugEnabled())
        log.debug("Setting p2p context [sndId=" + sndId + ", ldrId=" + ldrId + ", userVer=" + userVer + ", seqNum=" + ldrId.localId() + ", mode=" + mode + ", participants=" + participants + ", locDepOwner=" + locDepOwner + ']');
    CachedDeploymentInfo<K, V> depInfo;
    while (true) {
        depInfo = deps.get(ldrId);
        if (depInfo == null) {
            depInfo = new CachedDeploymentInfo<>(sndId, ldrId, userVer, mode, participants);
            CachedDeploymentInfo<K, V> old = deps.putIfAbsent(ldrId, depInfo);
            if (old != null)
                depInfo = old;
            else
                break;
        }
        if (participants != null) {
            if (!depInfo.addParticipants(participants, cctx)) {
                deps.remove(ldrId, depInfo);
                continue;
            }
        }
        break;
    }
    Map<UUID, IgniteUuid> added = null;
    if (locDepOwner)
        added = addGlobalParticipants(sndId, ldrId, participants, locDepOwner);
    if (cctx.discovery().node(sndId) == null) {
        // Sender has left.
        deps.remove(ldrId, depInfo);
        if (added != null)
            added.remove(sndId);
        allParticipants.remove(sndId);
    }
    if (participants != null) {
        for (UUID id : participants.keySet()) {
            if (cctx.discovery().node(id) == null) {
                if (depInfo.removeParticipant(id))
                    deps.remove(ldrId, depInfo);
                if (added != null)
                    added.remove(id);
                allParticipants.remove(id);
            }
        }
    }
    if (added != null && !added.isEmpty())
        cctx.gridDeploy().addCacheParticipants(allParticipants, added);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteUuid(org.apache.ignite.lang.IgniteUuid) UUID(java.util.UUID)

Example 54 with IgniteUuid

use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.

the class IgfsFragmentizerAbstractSelfTest method awaitFileFragmenting.

/**
 * @param gridIdx Grid index.
 * @param path Path to await.
 * @throws Exception If failed.
 */
protected void awaitFileFragmenting(int gridIdx, IgfsPath path) throws Exception {
    IgfsEx igfs = (IgfsEx) grid(gridIdx).fileSystem("igfs");
    IgfsMetaManager meta = igfs.context().meta();
    IgniteUuid fileId = meta.fileId(path);
    if (fileId == null)
        throw new IgfsPathNotFoundException("File not found: " + path);
    IgfsEntryInfo fileInfo = meta.info(fileId);
    do {
        if (fileInfo == null)
            throw new IgfsPathNotFoundException("File not found: " + path);
        if (fileInfo.fileMap().ranges().isEmpty())
            return;
        U.sleep(100);
        fileInfo = meta.info(fileId);
    } while (true);
}
Also used : IgfsEx(org.apache.ignite.internal.processors.igfs.IgfsEx) IgfsMetaManager(org.apache.ignite.internal.processors.igfs.IgfsMetaManager) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgfsEntryInfo(org.apache.ignite.internal.processors.igfs.IgfsEntryInfo)

Example 55 with IgniteUuid

use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.

the class GridContinuousProcessor method addNotification.

/**
 * @param nodeId ID of the node that started routine.
 * @param routineId Routine ID.
 * @param obj Notification object.
 * @param orderedTopic Topic for ordered notifications. If {@code null}, non-ordered message will be sent.
 * @param sync If {@code true} then waits for event acknowledgment.
 * @param msg If {@code true} then sent data is message.
 * @throws IgniteCheckedException In case of error.
 */
public void addNotification(UUID nodeId, final UUID routineId, @Nullable Object obj, @Nullable Object orderedTopic, boolean sync, boolean msg) throws IgniteCheckedException {
    assert nodeId != null;
    assert routineId != null;
    assert !msg || (obj instanceof Message || obj instanceof Collection) : obj;
    assert !nodeId.equals(ctx.localNodeId());
    if (processorStopped)
        return;
    final RemoteRoutineInfo info = rmtInfos.get(routineId);
    if (info != null) {
        assert info.interval == 0 || !sync;
        if (sync) {
            SyncMessageAckFuture fut = new SyncMessageAckFuture(nodeId);
            IgniteUuid futId = IgniteUuid.randomUuid();
            syncMsgFuts.put(futId, fut);
            try {
                sendNotification(nodeId, routineId, futId, obj instanceof Collection ? (Collection) obj : F.asList(obj), null, msg, null);
                info.hnd.onBatchAcknowledged(routineId, info.add(obj), ctx);
            } catch (IgniteCheckedException e) {
                syncMsgFuts.remove(futId);
                throw e;
            }
            fut.get();
        } else {
            final GridContinuousBatch batch = info.add(obj);
            if (batch != null) {
                CI1<IgniteException> ackC = new CI1<IgniteException>() {

                    @Override
                    public void apply(IgniteException e) {
                        if (e == null)
                            info.hnd.onBatchAcknowledged(routineId, batch, ctx);
                    }
                };
                sendNotification(nodeId, routineId, null, batch.collect(), orderedTopic, msg, ackC);
            }
        }
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Message(org.apache.ignite.plugin.extensions.communication.Message) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgniteException(org.apache.ignite.IgniteException) Collection(java.util.Collection) CI1(org.apache.ignite.internal.util.typedef.CI1)

Aggregations

IgniteUuid (org.apache.ignite.lang.IgniteUuid)107 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)25 UUID (java.util.UUID)23 IgniteException (org.apache.ignite.IgniteException)17 HashMap (java.util.HashMap)15 Map (java.util.Map)13 IgfsPath (org.apache.ignite.igfs.IgfsPath)11 ArrayList (java.util.ArrayList)10 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)10 GridNearTxLocal (org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal)10 ClusterNode (org.apache.ignite.cluster.ClusterNode)9 Nullable (org.jetbrains.annotations.Nullable)9 IgfsOutputStream (org.apache.ignite.igfs.IgfsOutputStream)7 HashSet (java.util.HashSet)6 TreeSet (java.util.TreeSet)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 Ignite (org.apache.ignite.Ignite)6 IgfsException (org.apache.ignite.igfs.IgfsException)6 IgfsPathNotFoundException (org.apache.ignite.igfs.IgfsPathNotFoundException)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5