/** {@inheritDoc} */ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args) throws EntryProcessorException { IgfsEntryInfo oldInfo = entry.getValue(); Map<String, String> tmp = oldInfo.properties(); tmp = tmp == null ? new GridLeanMap<String, String>(props.size()) : new GridLeanMap<>(tmp); for (Map.Entry<String, String> e : props.entrySet()) { if (e.getValue() == null) // Remove properties with 'null' values. tmp.remove(e.getKey()); else // Add/overwrite property. tmp.put(e.getKey(), e.getValue()); } IgfsEntryInfo newInfo = oldInfo.properties(tmp); entry.setValue(newInfo); return newInfo; }
/** * Gets initial affinity range. This range will have 0 length and will start from first * non-occupied file block. * * @param fileInfo File info to build initial range for. * @return Affinity range. */ private IgfsFileAffinityRange initialStreamRange(IgfsEntryInfo fileInfo) { if (!igfsCtx.configuration().isFragmentizerEnabled()) return null; if (!Boolean.parseBoolean(fileInfo.properties().get(IgfsUtils.PROP_PREFER_LOCAL_WRITES))) return null; int blockSize = fileInfo.blockSize(); // Find first non-occupied block offset. long off = ((fileInfo.length() + blockSize - 1) / blockSize) * blockSize; // Need to get last affinity key and reuse it if we are on the same node. long lastBlockOff = off - fileInfo.blockSize(); if (lastBlockOff < 0) lastBlockOff = 0; IgfsFileMap map = fileInfo.fileMap(); IgniteUuid prevAffKey = map == null ? null : map.affinityKey(lastBlockOff, false); IgniteUuid affKey = igfsCtx.data().nextAffinityKey(prevAffKey); return affKey == null ? null : new IgfsFileAffinityRange(off, off, affKey); }
/** * Constructs directory info. * * @param path Path. * @param info Entry info. * @param globalGrpBlockSize Global group block size. */ public IgfsFileImpl(IgfsPath path, IgfsEntryInfo info, long globalGrpBlockSize) { A.notNull(path, "path"); A.notNull(info, "info"); this.path = path; fileId = info.id(); flags = IgfsUtils.flags(info.isDirectory(), info.isFile()); if (info.isFile()) { blockSize = info.blockSize(); len = info.length(); grpBlockSize = info.affinityKey() == null ? globalGrpBlockSize : info.length() == 0 ? globalGrpBlockSize : info.length(); } props = info.properties(); if (props == null) props = Collections.emptyMap(); accessTime = info.accessTime(); modificationTime = info.modificationTime(); }
assertNull("Unexpected stored properties: " + info, info.properties().get(key1)); assertNull("Unexpected stored properties: " + info, info.properties().get(key2)); assertEquals("Unexpected stored properties: " + info, "1", info.properties().get(key1)); assertEquals("Unexpected stored properties: " + info, "1", info.properties().get(key1)); assertEquals("Unexpected stored properties: " + info, "2", info.properties().get(key2)); assertEquals("Unexpected stored properties: " + info, "2", info.properties().get(key2)); assertNull("Unexpected stored properties: " + info, info.properties().get(key1)); assertNull("Unexpected stored properties: " + info, info.properties().get(key2));
/** {@inheritDoc} */ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args) throws EntryProcessorException { IgfsEntryInfo oldInfo = entry.getValue(); Map<String, String> tmp = oldInfo.properties(); tmp = tmp == null ? new GridLeanMap<String, String>(props.size()) : new GridLeanMap<>(tmp); for (Map.Entry<String, String> e : props.entrySet()) { if (e.getValue() == null) // Remove properties with 'null' values. tmp.remove(e.getKey()); else // Add/overwrite property. tmp.put(e.getKey(), e.getValue()); } IgfsEntryInfo newInfo = oldInfo.properties(tmp); entry.setValue(newInfo); return newInfo; }
/** * Gets initial affinity range. This range will have 0 length and will start from first * non-occupied file block. * * @param fileInfo File info to build initial range for. * @return Affinity range. */ private IgfsFileAffinityRange initialStreamRange(IgfsEntryInfo fileInfo) { if (!igfsCtx.configuration().isFragmentizerEnabled()) return null; if (!Boolean.parseBoolean(fileInfo.properties().get(IgfsUtils.PROP_PREFER_LOCAL_WRITES))) return null; int blockSize = fileInfo.blockSize(); // Find first non-occupied block offset. long off = ((fileInfo.length() + blockSize - 1) / blockSize) * blockSize; // Need to get last affinity key and reuse it if we are on the same node. long lastBlockOff = off - fileInfo.blockSize(); if (lastBlockOff < 0) lastBlockOff = 0; IgfsFileMap map = fileInfo.fileMap(); IgniteUuid prevAffKey = map == null ? null : map.affinityKey(lastBlockOff, false); IgniteUuid affKey = igfsCtx.data().nextAffinityKey(prevAffKey); return affKey == null ? null : new IgfsFileAffinityRange(off, off, affKey); }
/** * Constructs directory info. * * @param path Path. * @param info Entry info. * @param globalGrpBlockSize Global group block size. */ public IgfsFileImpl(IgfsPath path, IgfsEntryInfo info, long globalGrpBlockSize) { A.notNull(path, "path"); A.notNull(info, "info"); this.path = path; fileId = info.id(); flags = IgfsUtils.flags(info.isDirectory(), info.isFile()); if (info.isFile()) { blockSize = info.blockSize(); len = info.length(); grpBlockSize = info.affinityKey() == null ? globalGrpBlockSize : info.length() == 0 ? globalGrpBlockSize : info.length(); } props = info.properties(); if (props == null) props = Collections.emptyMap(); accessTime = info.accessTime(); modificationTime = info.modificationTime(); }