Search in sources :

Example 1 with IgfsClientMetaIdsForPathCallable

use of org.apache.ignite.internal.processors.igfs.client.meta.IgfsClientMetaIdsForPathCallable 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);
    }
}
Also used : IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgfsClientMetaIdsForPathCallable(org.apache.ignite.internal.processors.igfs.client.meta.IgfsClientMetaIdsForPathCallable)

Aggregations

IgfsClientMetaIdsForPathCallable (org.apache.ignite.internal.processors.igfs.client.meta.IgfsClientMetaIdsForPathCallable)1 IgniteUuid (org.apache.ignite.lang.IgniteUuid)1