use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.
the class IgfsFragmentizerManager method processFragmentizerRequest.
/**
* Processes fragmentizer request. For each range assigned to this node:
* <ul>
* <li>Mark range as moving indicating that block copying started.</li>
* <li>Copy blocks to non-colocated keys.</li>
* <li>Update map to indicate that blocks were copied and old blocks should be deleted.</li>
* <li>Delete old blocks.</li>
* <li>Remove range from file map.</li>
* </ul>
*
* @param req Request.
* @throws IgniteCheckedException In case of error.
*/
@SuppressWarnings("fallthrough")
private void processFragmentizerRequest(IgfsFragmentizerRequest req) throws IgniteCheckedException {
req.finishUnmarshal(igfsCtx.kernalContext().config().getMarshaller(), null);
Collection<IgfsFileAffinityRange> ranges = req.fragmentRanges();
IgniteUuid fileId = req.fileId();
IgfsEntryInfo fileInfo = igfsCtx.meta().info(fileId);
if (fileInfo == null) {
if (log.isDebugEnabled())
log.debug("Failed to find file info for fragmentizer request: " + req);
return;
}
if (log.isDebugEnabled())
log.debug("Moving file ranges for fragmentizer request [req=" + req + ", fileInfo=" + fileInfo + ']');
for (IgfsFileAffinityRange range : ranges) {
try {
IgfsEntryInfo updated;
switch(range.status()) {
case RANGE_STATUS_INITIAL:
{
// Mark range as moving.
updated = igfsCtx.meta().updateInfo(fileId, new IgfsMetaFileRangeUpdateProcessor(range, RANGE_STATUS_MOVING));
if (updated == null) {
igfsCtx.data().cleanBlocks(fileInfo, range, true);
continue;
}
// Fall-through.
}
case RANGE_STATUS_MOVING:
{
// Move colocated blocks.
igfsCtx.data().spreadBlocks(fileInfo, range);
// Mark range as moved.
updated = igfsCtx.meta().updateInfo(fileId, new IgfsMetaFileRangeUpdateProcessor(range, RANGE_STATUS_MOVED));
if (updated == null) {
igfsCtx.data().cleanBlocks(fileInfo, range, true);
continue;
}
// Fall-through.
}
case RANGE_STATUS_MOVED:
{
// Remove old blocks.
igfsCtx.data().cleanBlocks(fileInfo, range, false);
// Remove range from map.
updated = igfsCtx.meta().updateInfo(fileId, new IgfsMetaFileRangeDeleteProcessor(range));
if (updated == null)
igfsCtx.data().cleanBlocks(fileInfo, range, true);
}
}
} catch (IgfsInvalidRangeException e) {
if (log.isDebugEnabled())
log.debug("Failed to update file range " + "[range=" + range + "fileId=" + fileId + ", err=" + e.getMessage() + ']');
}
}
}
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 IgniteUtils method writeGridUuids.
/**
* Writes Grid UUIDs to output stream. This method is meant to be used by
* implementations of {@link Externalizable} interface.
*
* @param out Output stream.
* @param col Grid UUIDs to write.
* @throws IOException If write failed.
*/
public static void writeGridUuids(DataOutput out, @Nullable Collection<IgniteUuid> col) throws IOException {
if (col != null) {
out.writeBoolean(true);
out.writeInt(col.size());
for (IgniteUuid id : col) writeGridUuid(out, id);
} else
out.writeBoolean(false);
}
use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.
the class BinaryMarshallerSelfTest method testIgniteUuid.
/**
* @throws Exception If failed.
*/
public void testIgniteUuid() throws Exception {
IgniteUuid uuid = IgniteUuid.randomUuid();
assertEquals(uuid, marshalUnmarshal(uuid));
}
use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.
the class IgfsMetaManager method pathIds.
/**
* Gets all file IDs for components of specified path. Result cannot be empty - there is at least root element.
* But each element (except the first) can be {@code null} if such files don't exist.
*
* @param path Path.
* @return Collection of file IDs for components of specified path.
* @throws IgniteCheckedException If failed.
*/
public IgfsPathIds pathIds(IgfsPath path) throws IgniteCheckedException {
// Prepare parts.
String[] components = path.componentsArray();
String[] parts = new String[components.length + 1];
System.arraycopy(components, 0, parts, 1, components.length);
// Get IDs.
if (client) {
List<IgniteUuid> ids = runClientTask(new IgfsClientMetaIdsForPathCallable(cfg.getName(), IgfsUserContext.currentUser(), path));
return new IgfsPathIds(path, parts, ids.toArray(new IgniteUuid[ids.size()]));
} else {
if (busyLock.enterBusy()) {
try {
validTxState(false);
IgniteUuid[] ids = new IgniteUuid[parts.length];
ids[0] = IgfsUtils.ROOT_ID;
for (int i = 1; i < ids.length; i++) {
IgniteUuid id = fileId(ids[i - 1], parts[i], false);
if (id != null)
ids[i] = id;
else
break;
}
// Return.
return new IgfsPathIds(path, parts, ids);
} finally {
busyLock.leaveBusy();
}
} else
throw new IllegalStateException("Failed to get file IDS because Grid is stopping: " + path);
}
}
Aggregations