/** * Creates new pseudo-random ID. * * @return Newly created pseudo-random ID. */ public static GridUuid randomUuid() { return new GridUuid(VM_ID, cntGen.incrementAndGet()); }
/** {@inheritDoc} */ @Override public int compareTo(@NotNull GridGgfsBlockKey o) { int res = fileId.compareTo(o.fileId); if (res != 0) return res; long v1 = blockId; long v2 = o.blockId; if (v1 != v2) return v1 > v2 ? 1 : -1; if (affKey == null && o.affKey == null) return 0; if (affKey != null && o.affKey != null) return affKey.compareTo(o.affKey); return affKey != null ? -1 : 1; }
/** {@inheritDoc} */ @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof GridGgfsListingEntry)) return false; GridGgfsListingEntry that = (GridGgfsListingEntry)o; return fileId.equals(that.fileId); }
/** * Writes {@link GridUuid} to output stream. This method is meant to be used by * implementations of {@link Externalizable} interface. * * @param out Output stream. * @param uid UUID to write. * @throws IOException If write failed. */ public static void writeGridUuid(DataOutput out, GridUuid uid) throws IOException { // Write null flag. out.writeBoolean(uid == null); if (uid != null) { out.writeLong(uid.globalId().getMostSignificantBits()); out.writeLong(uid.globalId().getLeastSignificantBits()); out.writeLong(uid.localId()); } }
/** {@inheritDoc} */ @Override public int hashCode() { assert id != null; return id.hashCode(); }
/** * @return Pre-generated UUID. */ private GridUuid uuid() { return GridUuid.randomUuid(); }
/** * Constructor. * * @param creatorNodeId Creator node ID. */ protected GridTcpDiscoveryAbstractMessage(UUID creatorNodeId) { id = GridUuid.fromUuid(creatorNodeId); }
/** * Gets creator node. * * @return Creator node ID. */ public UUID creatorNodeId() { return id.globalId(); }
taskRestRes.setId(tid.toString() + '~' + ctx.localNodeId().toString()); GridUuid tid = !F.isEmpty(tidParam) ? GridUuid.fromString(tidParam) : null;
if (d.getValue().classLoaderId().equals(req.getClassLoaderId())) { assert d.getValue().local(); "task execution [taskName=" + req.getTaskName() + ", taskClsName=" + req.getTaskClassName() + ", codeVer=" + req.getUserVersion() + ", clsLdrId=" + req.getClassLoaderId() + ", seqNum=" + req.getClassLoaderId().localId() + ", depMode=" + req.getDeploymentMode() + ", dep=" + dep + ']');
/** * Gets 8-character substring of {@link GridUuid} (for terse logging). * The ID8 will be constructed as follows: * <ul> * <li>Take first 4 digits for global ID, i.e. {@code GridUuid.globalId()}.</li> * <li>Take last 4 digits for local ID, i.e. {@code GridUuid.localId()}.</li> * </ul> * * @param id Input ID. * @return 8-character representation of {@code GridUuid}. */ public static String id8(GridUuid id) { String s = id.toString(); return s.substring(0, 4) + s.substring(s.length() - 4); }
/** * Gets property seqNum. * * @return Property seqNum. */ long sequenceNumber() { return clsLdrId.localId(); }
/** {@inheritDoc} */ @Override public void connect() throws IOException { URL url = getURL(); // Gets class loader UUID. GridUuid ldrId = GridUuid.fromString(url.getHost()); // Gets resource name. String name = url.getPath(); GridDeployment dep = mgr.getDeployment(ldrId); if (dep != null) { in = dep.classLoader().getParent().getResourceAsStream(name); // If resource exists connected = true; } }
/** {@inheritDoc} */ @Override public int hashCode() { int result = queueId.hashCode(); result = 31 * result + (int)(idx ^ (idx >>> 32)); return result; }
/** * @param timeout Timeout for this object. */ protected GridTimeoutObjectAdapter(long timeout) { this(GridUuid.randomUuid(), timeout); }
/** * @param uuid {@link GridUuid}. * @return Whether value was fully written. */ public final boolean putGridUuid(@Nullable GridUuid uuid) { byte[] arr = null; if (uuid != null) { arr = new byte[24]; UNSAFE.putLong(arr, BYTE_ARR_OFF, uuid.globalId().getMostSignificantBits()); UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, uuid.globalId().getLeastSignificantBits()); UNSAFE.putLong(arr, BYTE_ARR_OFF + 16, uuid.localId()); } return putByteArray(arr); }
/** * @param task Actual task. * @param arg Optional task argument. * @param sys If {@code true}, then system pool will be used. * @return Task future. * @param <T> Task argument type. * @param <R> Task return value type. */ public <T, R> GridComputeTaskFuture<R> execute(GridComputeTask<T, R> task, @Nullable T arg, boolean sys) { lock.readLock(); try { if (stopping) throw new IllegalStateException("Failed to execute task due to grid shutdown: " + task); return startTask(null, null, task, GridUuid.fromUuid(ctx.localNodeId()), arg, sys); } finally { lock.readUnlock(); } }