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;
}
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;
}
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);
}
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);
}
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);
}
}
}
}
Aggregations