Search in sources :

Example 6 with IgfsEntryInfo

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

Example 7 with IgfsEntryInfo

use of org.apache.ignite.internal.processors.igfs.IgfsEntryInfo in project ignite by apache.

the class IgfsMetaDirectoryCreateProcessor method process.

/** {@inheritDoc} */
@Override
public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args) throws EntryProcessorException {
    IgfsEntryInfo info = IgfsUtils.createDirectory(entry.getKey(), null, props, accessTime, modificationTime);
    if (childName != null)
        info = info.listing(Collections.singletonMap(childName, childEntry));
    entry.setValue(info);
    return info;
}
Also used : IgfsEntryInfo(org.apache.ignite.internal.processors.igfs.IgfsEntryInfo)

Example 8 with IgfsEntryInfo

use of org.apache.ignite.internal.processors.igfs.IgfsEntryInfo in project ignite by apache.

the class IgfsMetaDirectoryListingAddProcessor method process.

/** {@inheritDoc} */
@Override
public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) {
    IgfsEntryInfo fileInfo = e.getValue();
    assert fileInfo != null && fileInfo.isDirectory() : fileInfo;
    Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing());
    // Modify listing in-place.
    IgfsListingEntry oldEntry = listing.put(fileName, entry);
    if (oldEntry != null && !oldEntry.fileId().equals(entry.fileId())) {
        throw new IgniteException("Directory listing contains unexpected file" + " [listing=" + listing + ", fileName=" + fileName + ", entry=" + entry + ", oldEntry=" + oldEntry + ']');
    }
    e.setValue(fileInfo.listing(listing));
    return null;
}
Also used : HashMap(java.util.HashMap) IgniteException(org.apache.ignite.IgniteException) IgfsEntryInfo(org.apache.ignite.internal.processors.igfs.IgfsEntryInfo) IgfsListingEntry(org.apache.ignite.internal.processors.igfs.IgfsListingEntry)

Example 9 with IgfsEntryInfo

use of org.apache.ignite.internal.processors.igfs.IgfsEntryInfo in project ignite by apache.

the class IgfsMetaDirectoryListingRemoveProcessor method process.

/** {@inheritDoc} */
@Override
public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) throws EntryProcessorException {
    IgfsEntryInfo fileInfo = e.getValue();
    assert fileInfo != null;
    assert fileInfo.isDirectory();
    Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing());
    IgfsListingEntry oldEntry = listing.get(fileName);
    if (oldEntry == null || !oldEntry.fileId().equals(fileId))
        throw new IgniteException("Directory listing doesn't contain expected file" + " [listing=" + listing + ", fileName=" + fileName + "]");
    // Modify listing in-place.
    listing.remove(fileName);
    e.setValue(fileInfo.listing(listing));
    return null;
}
Also used : HashMap(java.util.HashMap) IgniteException(org.apache.ignite.IgniteException) IgfsEntryInfo(org.apache.ignite.internal.processors.igfs.IgfsEntryInfo) IgfsListingEntry(org.apache.ignite.internal.processors.igfs.IgfsListingEntry)

Example 10 with IgfsEntryInfo

use of org.apache.ignite.internal.processors.igfs.IgfsEntryInfo in project ignite by apache.

the class IgfsMetaDirectoryListingRenameProcessor method process.

/** {@inheritDoc} */
@Override
public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) throws EntryProcessorException {
    IgfsEntryInfo fileInfo = e.getValue();
    assert fileInfo.isDirectory();
    Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing());
    // Modify listing in-place.
    IgfsListingEntry entry = listing.remove(oldName);
    if (entry == null)
        throw new IgniteException("Directory listing doesn't contain expected entry: " + oldName);
    IgfsListingEntry replacedEntry = listing.put(newName, entry);
    if (replacedEntry != null)
        throw new IgniteException("Entry with new name already exists [name=" + newName + ", entry=" + replacedEntry + ']');
    e.setValue(fileInfo.listing(listing));
    return null;
}
Also used : HashMap(java.util.HashMap) IgniteException(org.apache.ignite.IgniteException) IgfsEntryInfo(org.apache.ignite.internal.processors.igfs.IgfsEntryInfo) IgfsListingEntry(org.apache.ignite.internal.processors.igfs.IgfsListingEntry)

Aggregations

IgfsEntryInfo (org.apache.ignite.internal.processors.igfs.IgfsEntryInfo)16 HashMap (java.util.HashMap)4 IgniteException (org.apache.ignite.IgniteException)4 IgfsFileMap (org.apache.ignite.internal.processors.igfs.IgfsFileMap)4 IgfsListingEntry (org.apache.ignite.internal.processors.igfs.IgfsListingEntry)4 IOException (java.io.IOException)2 IgfsPath (org.apache.ignite.igfs.IgfsPath)2 IgfsMetaManager (org.apache.ignite.internal.processors.igfs.IgfsMetaManager)2 FileNotFoundException (java.io.FileNotFoundException)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Configuration (org.apache.hadoop.conf.Configuration)1 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)1 FileStatus (org.apache.hadoop.fs.FileStatus)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 FileSystemConfiguration (org.apache.ignite.configuration.FileSystemConfiguration)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1