Search in sources :

Example 1 with IgfsListingEntry

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

the class IgfsMetaDirectoryListingReplaceProcessor 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 oldEntry = listing.get(name);
    if (oldEntry == null)
        throw new IgniteException("Directory listing doesn't contain expected entry: " + name);
    listing.put(name, new IgfsListingEntry(id, oldEntry.isDirectory()));
    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 2 with IgfsListingEntry

use of org.apache.ignite.internal.processors.igfs.IgfsListingEntry 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 3 with IgfsListingEntry

use of org.apache.ignite.internal.processors.igfs.IgfsListingEntry 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 4 with IgfsListingEntry

use of org.apache.ignite.internal.processors.igfs.IgfsListingEntry 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

HashMap (java.util.HashMap)4 IgniteException (org.apache.ignite.IgniteException)4 IgfsEntryInfo (org.apache.ignite.internal.processors.igfs.IgfsEntryInfo)4 IgfsListingEntry (org.apache.ignite.internal.processors.igfs.IgfsListingEntry)4