public class IgfsUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
DATA_CACHE_SUFFIX
Data cache suffix.
|
static IgniteUuid |
DELETE_LOCK_ID
Lock Id used to lock files being deleted from TRASH.
|
static String |
IGFS_CACHE_PREFIX
Filesystem cache prefix.
|
static String |
META_CACHE_SUFFIX
Meta cache suffix.
|
static String |
PROP_GROUP_NAME
File property: group name.
|
static String |
PROP_PERMISSION
File property: permission.
|
static String |
PROP_PREFER_LOCAL_WRITES
File property: prefer writes to local node.
|
static String |
PROP_USER_NAME
File property: user name.
|
static IgniteUuid |
ROOT_ID
ID for the root directory.
|
static int |
TRASH_CONCURRENCY
Constant trash concurrency level.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
canContain(IgfsMode parent,
IgfsMode child)
Answers if directory of this mode can contain a subdirectory of the given mode.
|
static IgfsDirectoryInfo |
createDirectory(IgniteUuid id)
Create empty directory with the given ID.
|
static IgfsDirectoryInfo |
createDirectory(IgniteUuid id,
Map<String,IgfsListingEntry> listing,
Map<String,String> props)
Create directory.
|
static IgfsDirectoryInfo |
createDirectory(IgniteUuid id,
Map<String,IgfsListingEntry> listing,
Map<String,String> props,
long createTime,
long modificationTime)
Create directory.
|
static IgfsFileInfo |
createFile(IgniteUuid id,
int blockSize,
long len,
IgniteUuid affKey,
IgniteUuid lockId,
boolean evictExclude,
Map<String,String> props,
long accessTime,
long modificationTime)
Create file.
|
static <T> T |
doInTransactionWithRetries(IgniteInternalCache cache,
IgniteOutClosureX<T> clo)
Performs an operation with transaction with retries.
|
static IgfsPath |
extractOriginalPathFromTrash(String name)
Parses the TRASH file name to extract the original path.
|
static String |
fixUserName(String user)
Provides non-null user name.
|
static byte |
flags(boolean isDir,
boolean isFile)
Create flags value.
|
static boolean |
isDirectory(byte flags)
Check whether passed flags represent directory.
|
static boolean |
isDualMode(IgfsMode mode)
Check whether mode is dual.
|
static boolean |
isFile(byte flags)
Check whether passed flags represent file.
|
static boolean |
isIgfsCache(IgniteConfiguration cfg,
String cacheName) |
static boolean |
isIgfsNode(ClusterNode node,
String igfsName)
Check whether provided node contains IGFS with the given name.
|
static boolean |
isRootId(IgniteUuid id)
Check whether provided ID is root ID.
|
static boolean |
isRootOrTrashId(IgniteUuid id)
Check whether provided ID is either root ID or trash ID.
|
static boolean |
matchIgfsCacheName(String cacheName) |
static IgfsException |
newIgfsException(Class<? extends IgfsException> cls,
String msg,
Throwable cause)
Construct new IGFS exception passing specified message and cause.
|
static void |
prepareCacheConfigurations(IgniteConfiguration cfg)
Prepare cache configuration if this is IGFS meta or data cache.
|
static ArrayList<T2<IgfsPath,IgfsMode>> |
preparePathModes(IgfsMode dfltMode,
List<T2<IgfsPath,IgfsMode>> modes,
Set<IgfsPath> dualParentsContainingPrimaryChildren)
Checks, filters and sorts the modes.
|
static IgniteUuid |
randomTrashId()
Get random trash ID.
|
static IgfsFileAffinityRange |
readFileAffinityRange(BinaryRawReader reader)
Read IgfsFileAffinityRange.
|
static IgfsListingEntry |
readListingEntry(BinaryRawReader in)
Read listing entry.
|
static IgfsListingEntry |
readListingEntry(DataInput in)
Read listing entry.
|
static IgfsPath |
readPath(BinaryRawReader reader)
Read IGFS path.
|
static IgfsPath |
readPath(ObjectInput in)
Read non-null path from the input.
|
static Map<String,String> |
readProperties(BinaryRawReader in)
Read entry properties.
|
static Map<String,String> |
readProperties(DataInput in)
Read entry properties.
|
static Map<String,String> |
readStringMap(DataInput in)
Reads string-to-string map written by
writeStringMap(DataOutput, Map). |
static String |
readUTF(DataInput in)
Read UTF string which can be
null. |
static void |
sendEvents(GridKernalContext kernalCtx,
IgfsPath path,
IgfsPath newPath,
int type)
Sends a series of event.
|
static void |
sendEvents(GridKernalContext kernalCtx,
IgfsPath path,
int type)
Sends a series of event.
|
static IgfsException |
toIgfsException(Throwable err)
Converts any passed exception to IGFS exception.
|
static IgniteUuid |
trashId(int idx)
Get trash ID for the given index.
|
static void |
writeFileAffinityRange(BinaryRawWriter writer,
IgfsFileAffinityRange affRange)
Write IgfsFileAffinityRange.
|
static void |
writeListingEntry(BinaryRawWriter out,
IgfsListingEntry entry)
Write listing entry.
|
static void |
writeListingEntry(DataOutput out,
IgfsListingEntry entry)
Write listing entry.
|
static void |
writePath(BinaryRawWriter writer,
IgfsPath path)
Write IGFS path.
|
static void |
writeProperties(BinaryRawWriter out,
Map<String,String> props)
Write entry properties.
|
static void |
writeProperties(DataOutput out,
Map<String,String> props)
Write entry properties.
|
static void |
writeStringMap(DataOutput out,
Map<String,String> map)
Writes string-to-string map to given data output.
|
static void |
writeUTF(DataOutput out,
String val)
Write UTF string which can be
null. |
public static final IgniteUuid ROOT_ID
public static final IgniteUuid DELETE_LOCK_ID
public static final int TRASH_CONCURRENCY
public static final String PROP_USER_NAME
public static final String PROP_GROUP_NAME
public static final String PROP_PERMISSION
public static final String PROP_PREFER_LOCAL_WRITES
public static final String IGFS_CACHE_PREFIX
public static final String DATA_CACHE_SUFFIX
public static final String META_CACHE_SUFFIX
public static IgniteUuid randomTrashId()
public static IgniteUuid trashId(int idx)
idx - Index.public static boolean isRootOrTrashId(@Nullable
IgniteUuid id)
id - ID.True if this is root ID or trash ID.public static boolean isRootId(@Nullable
IgniteUuid id)
id - ID.True if this is root ID.public static IgfsException toIgfsException(Throwable err)
err - Initial exception.public static IgfsException newIgfsException(Class<? extends IgfsException> cls, String msg, Throwable cause)
cls - Class.msg - Message.cause - Cause.public static String fixUserName(@Nullable String user)
FileSystemConfiguration.DFLT_USER_NAME,
which is the current process owner user.user - a user name to be fixed.public static <T> T doInTransactionWithRetries(IgniteInternalCache cache, IgniteOutClosureX<T> clo) throws IgniteCheckedException
cache - Cache to do the transaction on.clo - Closure.IgniteCheckedException - If failed.public static void sendEvents(GridKernalContext kernalCtx, IgfsPath path, int type)
kernalCtx - Kernal context.path - The path of the created file.type - The type of event to send.public static void sendEvents(GridKernalContext kernalCtx, IgfsPath path, IgfsPath newPath, int type)
kernalCtx - Kernal context.path - The path of the created file.newPath - New path.type - The type of event to send.public static boolean matchIgfsCacheName(@Nullable
String cacheName)
cacheName - Cache name.True in this is IGFS data or meta cache.public static boolean isIgfsCache(IgniteConfiguration cfg, @Nullable String cacheName)
cfg - Grid configuration.cacheName - Cache name.True in this is IGFS data or meta cache.public static void prepareCacheConfigurations(IgniteConfiguration cfg) throws IgniteCheckedException
cfg - Configuration.IgniteCheckedException - If failed.public static IgfsDirectoryInfo createDirectory(IgniteUuid id)
id - ID.public static IgfsDirectoryInfo createDirectory(IgniteUuid id, @Nullable Map<String,IgfsListingEntry> listing, @Nullable Map<String,String> props)
id - ID.listing - Listing.props - Properties.public static IgfsDirectoryInfo createDirectory(IgniteUuid id, @Nullable Map<String,IgfsListingEntry> listing, @Nullable Map<String,String> props, long createTime, long modificationTime)
id - ID.listing - Listing.props - Properties.createTime - Create time.modificationTime - Modification time.public static IgfsFileInfo createFile(IgniteUuid id, int blockSize, long len, @Nullable IgniteUuid affKey, @Nullable IgniteUuid lockId, boolean evictExclude, @Nullable Map<String,String> props, long accessTime, long modificationTime)
id - File ID.blockSize - Block size.len - Length.affKey - Affinity key.lockId - Lock ID.evictExclude - Evict exclude flag.props - Properties.accessTime - Access time.modificationTime - Modification time.public static void writeListingEntry(BinaryRawWriter out, @Nullable IgfsListingEntry entry)
out - Writer.entry - Entry.@Nullable public static IgfsListingEntry readListingEntry(BinaryRawReader in)
in - Reader.public static void writeListingEntry(DataOutput out, @Nullable IgfsListingEntry entry) throws IOException
out - Writer.entry - Entry.IOException - If failed.@Nullable public static IgfsListingEntry readListingEntry(DataInput in) throws IOException
in - Reader.IOException - If failed.public static void writeProperties(BinaryRawWriter out, @Nullable Map<String,String> props)
out - Writer.props - Properties.@Nullable public static Map<String,String> readProperties(BinaryRawReader in)
in - Reader.public static void writeProperties(DataOutput out, @Nullable Map<String,String> props) throws IOException
out - Writer.props - Properties.IOException - If failed.@Nullable public static Map<String,String> readProperties(DataInput in) throws IOException
in - Reader.IOException - If failed.public static void writePath(BinaryRawWriter writer, @Nullable IgfsPath path)
writer - Writer.path - Path.@Nullable public static IgfsPath readPath(BinaryRawReader reader)
reader - Reader.public static IgfsPath readPath(ObjectInput in) throws IOException
in - Input.IOException - If failed.public static void writeFileAffinityRange(BinaryRawWriter writer, @Nullable IgfsFileAffinityRange affRange)
writer - WriteraffRange - affinity range.public static IgfsFileAffinityRange readFileAffinityRange(BinaryRawReader reader)
reader - Reader.public static IgfsPath extractOriginalPathFromTrash(String name)
name - The TRASH short (entry) name.public static boolean isIgfsNode(ClusterNode node, String igfsName)
node - Node.igfsName - IGFS name.True if it contains IGFS.public static boolean isDualMode(IgfsMode mode)
mode - Mode.True if dual.public static boolean canContain(IgfsMode parent, IgfsMode child)
parent - Parent mode.child - Child mode.true if directory of this mode can contain a directory of the given mode.public static ArrayList<T2<IgfsPath,IgfsMode>> preparePathModes(IgfsMode dfltMode, @Nullable List<T2<IgfsPath,IgfsMode>> modes, Set<IgfsPath> dualParentsContainingPrimaryChildren) throws IgniteCheckedException
dfltMode - The root mode. Must always be not null.modes - The subdirectory modes.dualParentsContainingPrimaryChildren - The set to store parents into.IgniteCheckedException - On error.public static byte flags(boolean isDir,
boolean isFile)
isDir - Directory flag.isFile - File flag.public static boolean isDirectory(byte flags)
flags - Flags.True if this is directory.public static boolean isFile(byte flags)
flags - Flags.True if this is file.public static Map<String,String> readStringMap(DataInput in) throws IOException
writeStringMap(DataOutput, Map).in - Data input.IOException - If write failed.public static void writeStringMap(DataOutput out, @Nullable Map<String,String> map) throws IOException
out - Data output.map - Map.IOException - If write failed.public static void writeUTF(DataOutput out, @Nullable String val) throws IOException
null.out - Output stream.val - Value.IOException - If failed.public static String readUTF(DataInput in) throws IOException
null.in - Input stream.IOException - If failed.
Follow @ApacheIgnite
Ignite Fabric : ver. 2.6.0 Release Date : July 10 2018