Search in sources :

Example 21 with IgniteUuid

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

the class IgfsGroupDataBlockKeyMapperHashSelfTest method checkDistribution.

/**
 * Check hash code generation for the given group size and partitions count.
 *
 * @throws Exception If failed.
 */
public void checkDistribution(int grpSize, int partCnt) throws Exception {
    IgniteUuid fileId = IgniteUuid.randomUuid();
    IgfsGroupDataBlocksKeyMapper mapper = new IgfsGroupDataBlocksKeyMapper(grpSize);
    int lastPart = 0;
    boolean first = true;
    for (int i = 0; i < 10; i++) {
        // Ensure that all blocks within the group has the same hash codes.
        boolean firstInGroup = true;
        for (int j = 0; j < grpSize; j++) {
            int part = partition(mapper, fileId, i * grpSize + j, partCnt);
            if (firstInGroup) {
                if (first)
                    first = false;
                else
                    assert checkPartition(lastPart, part, partCnt) : "[fileId = " + fileId + ", i=" + i + ", j=" + j + ", grpSize= " + grpSize + ", partCnt=" + partCnt + ", lastPart=" + lastPart + ", part=" + part + ']';
                firstInGroup = false;
            } else
                assert part == lastPart;
            lastPart = part;
        }
    }
}
Also used : IgfsGroupDataBlocksKeyMapper(org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper) IgniteUuid(org.apache.ignite.lang.IgniteUuid)

Example 22 with IgniteUuid

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

the class DirectByteBufferStreamImplV2 method readIgniteUuid.

/**
 * {@inheritDoc}
 */
@Override
public IgniteUuid readIgniteUuid() {
    switch(uuidState) {
        case 0:
            boolean isNull = readBoolean();
            if (!lastFinished || isNull)
                return null;
            uuidState++;
        case 1:
            uuidMost = readLong();
            if (!lastFinished)
                return null;
            uuidState++;
        case 2:
            uuidLeast = readLong();
            if (!lastFinished)
                return null;
            uuidState++;
        case 3:
            uuidLocId = readLong();
            if (!lastFinished)
                return null;
            uuidState = 0;
    }
    IgniteUuid val = new IgniteUuid(new UUID(uuidMost, uuidLeast), uuidLocId);
    uuidMost = 0;
    uuidLeast = 0;
    uuidLocId = 0;
    return val;
}
Also used : IgniteUuid(org.apache.ignite.lang.IgniteUuid) UUID(java.util.UUID)

Example 23 with IgniteUuid

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

the class IgfsUtils method readListingEntry.

/**
 * Read listing entry.
 *
 * @param in Reader.
 * @return Entry.
 * @throws IOException If failed.
 */
@Nullable
public static IgfsListingEntry readListingEntry(DataInput in) throws IOException {
    if (in.readBoolean()) {
        IgniteUuid id = IgniteUtils.readGridUuid(in);
        boolean dir = in.readBoolean();
        return new IgfsListingEntry(id, dir);
    } else
        return null;
}
Also used : IgniteUuid(org.apache.ignite.lang.IgniteUuid) Nullable(org.jetbrains.annotations.Nullable)

Example 24 with IgniteUuid

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

the class GridRuntimeExceptionSelfTest method testResultFailed.

/**
 * @throws Exception If failed.
 */
public void testResultFailed() throws Exception {
    Ignite ignite = G.ignite(getTestIgniteInstanceName());
    ignite.compute().localDeployTask(GridTaskFailedTestTask.class, GridTaskFailedTestTask.class.getClassLoader());
    ComputeTaskFuture<?> fut = executeAsync(ignite.compute(), GridTaskFailedTestTask.class.getName(), FailType.RESULT);
    try {
        fut.get();
        assert false;
    } catch (IgniteException e) {
        info("Got expected grid exception: " + e);
    }
    IgniteUuid sesId = fut.getTaskSession().getId();
    // Query for correct events.
    List<Event> evts = ignite.events().remoteQuery(new TaskFailedEventFilter(sesId), 0);
    assert evts.size() == 1;
    info("Task failed event: " + evts.get(0));
}
Also used : IgniteException(org.apache.ignite.IgniteException) IgniteUuid(org.apache.ignite.lang.IgniteUuid) Event(org.apache.ignite.events.Event) TaskEvent(org.apache.ignite.events.TaskEvent) Ignite(org.apache.ignite.Ignite)

Example 25 with IgniteUuid

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

the class ComputeTaskInternalFuture method finishedFuture.

/**
 * @param ctx Context.
 * @param taskCls Task class.
 * @param e Error.
 * @return Finished task future.
 */
public static <R> ComputeTaskInternalFuture<R> finishedFuture(final GridKernalContext ctx, final Class<?> taskCls, IgniteCheckedException e) {
    assert ctx != null;
    assert taskCls != null;
    assert e != null;
    final long time = U.currentTimeMillis();
    final IgniteUuid id = IgniteUuid.fromUuid(ctx.localNodeId());
    ComputeTaskSession ses = new ComputeTaskSession() {

        @Override
        public String getTaskName() {
            return taskCls.getName();
        }

        @Override
        public UUID getTaskNodeId() {
            return ctx.localNodeId();
        }

        @Override
        public long getStartTime() {
            return time;
        }

        @Override
        public long getEndTime() {
            return time;
        }

        @Override
        public IgniteUuid getId() {
            return id;
        }

        @Override
        public ClassLoader getClassLoader() {
            return null;
        }

        @Override
        public Collection<ComputeJobSibling> getJobSiblings() throws IgniteException {
            return Collections.emptyList();
        }

        @Override
        public Collection<ComputeJobSibling> refreshJobSiblings() throws IgniteException {
            return Collections.emptyList();
        }

        @Nullable
        @Override
        public ComputeJobSibling getJobSibling(IgniteUuid jobId) throws IgniteException {
            return null;
        }

        @Override
        public void setAttribute(Object key, @Nullable Object val) throws IgniteException {
        }

        @Nullable
        @Override
        public <K, V> V getAttribute(K key) {
            return null;
        }

        @Override
        public void setAttributes(Map<?, ?> attrs) throws IgniteException {
        // No-op.
        }

        @Override
        public Map<?, ?> getAttributes() {
            return Collections.emptyMap();
        }

        @Override
        public void addAttributeListener(ComputeTaskSessionAttributeListener lsnr, boolean rewind) {
        // No-op.
        }

        @Override
        public boolean removeAttributeListener(ComputeTaskSessionAttributeListener lsnr) {
            return false;
        }

        @Override
        public <K, V> V waitForAttribute(K key, long timeout) throws InterruptedException {
            throw new InterruptedException("Session was closed.");
        }

        @Override
        public <K, V> boolean waitForAttribute(K key, @Nullable V val, long timeout) throws InterruptedException {
            throw new InterruptedException("Session was closed.");
        }

        @Override
        public Map<?, ?> waitForAttributes(Collection<?> keys, long timeout) throws InterruptedException {
            throw new InterruptedException("Session was closed.");
        }

        @Override
        public boolean waitForAttributes(Map<?, ?> attrs, long timeout) throws InterruptedException {
            throw new InterruptedException("Session was closed.");
        }

        @Override
        public void saveCheckpoint(String key, Object state) {
            throw new IgniteException("Session was closed.");
        }

        @Override
        public void saveCheckpoint(String key, Object state, ComputeTaskSessionScope scope, long timeout) {
            throw new IgniteException("Session was closed.");
        }

        @Override
        public void saveCheckpoint(String key, Object state, ComputeTaskSessionScope scope, long timeout, boolean overwrite) {
            throw new IgniteException("Session was closed.");
        }

        @Nullable
        @Override
        public <T> T loadCheckpoint(String key) throws IgniteException {
            throw new IgniteException("Session was closed.");
        }

        @Override
        public boolean removeCheckpoint(String key) throws IgniteException {
            throw new IgniteException("Session was closed.");
        }

        @Override
        public Collection<UUID> getTopology() {
            return Collections.emptyList();
        }

        @Override
        public IgniteFuture<?> mapFuture() {
            return new IgniteFinishedFutureImpl<Object>();
        }
    };
    ComputeTaskInternalFuture<R> fut = new ComputeTaskInternalFuture<>(ses, ctx);
    fut.onDone(e);
    return fut;
}
Also used : ComputeTaskSessionScope(org.apache.ignite.compute.ComputeTaskSessionScope) ComputeTaskSessionAttributeListener(org.apache.ignite.compute.ComputeTaskSessionAttributeListener) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgniteException(org.apache.ignite.IgniteException) Collection(java.util.Collection) ComputeJobSibling(org.apache.ignite.compute.ComputeJobSibling) UUID(java.util.UUID) Map(java.util.Map) IgniteFinishedFutureImpl(org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl) ComputeTaskSession(org.apache.ignite.compute.ComputeTaskSession) Nullable(org.jetbrains.annotations.Nullable)

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