use of org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileRangeDeleteProcessor 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() + ']');
}
}
}
Aggregations