/** * Save SnapshotDiff list for an INodeDirectoryWithSnapshot. * @param sNode The directory that the SnapshotDiff list belongs to. * @param out The {@link DataOutput} to write. */ private static <N extends INode, A extends INodeAttributes, D extends AbstractINodeDiff<N, A, D>> void saveINodeDiffs(final AbstractINodeDiffList<N, A, D> diffs, final DataOutput out, ReferenceMap referenceMap) throws IOException { // Record the diffs in reversed order, so that we can find the correct // reference for INodes in the created list when loading the FSImage if (diffs == null) { out.writeInt(-1); // no diffs } else { final List<D> list = diffs.asList(); final int size = list.size(); out.writeInt(size); for (int i = size - 1; i >= 0; i--) { list.get(i).write(out, referenceMap); } } }
private Collection<INodeAttributes> findByPrimaryKeys( INodeAttributes.Finder qfinder, Object[] params) throws StorageCallPreventedException, StorageException { final List<INodeCandidatePrimaryKey> inodePks = (List<INodeCandidatePrimaryKey>) params[0]; Collection<INodeAttributes> result = null; if (contains(inodePks)) { result = get(inodePks); hit(qfinder, result, "inodeids", inodePks); } else { aboutToAccessStorage(qfinder, inodePks); result = dataAccess.findAttributesByPkList(inodePks); gotFromDB(result); miss(qfinder, result, "inodeids", inodePks); if(result!=null){ for(INodeAttributes iNodeAttributes:result){ log("read-attributes", "id", iNodeAttributes.getInodeId(), "DSQ", iNodeAttributes.getDsQuota(),"DS", iNodeAttributes.getDiskspace(), "NSQ", iNodeAttributes.getNsQuota(), "NS", iNodeAttributes.getNsCount()); } } } return result; }
private void updateAttributes(INodeCandidatePrimaryKey trg_param, List<INodeCandidatePrimaryKey> toBeDeletedSrcs) throws TransactionContextException { toBeDeletedSrcs.remove(trg_param); for (INodeCandidatePrimaryKey src : toBeDeletedSrcs) { if (contains(src.getInodeId())) { INodeAttributes toBeDeleted = get(src.getInodeId()); INodeAttributes toBeAdded = clone(toBeDeleted, trg_param.getInodeId()); remove(toBeDeleted); if(isLogDebugEnabled()) { log("snapshot-maintenance-removed-inode-attribute", "inodeId", toBeDeleted.getInodeId()); } add(toBeAdded); if(isLogDebugEnabled()) { log("snapshot-maintenance-added-inode-attribute", "inodeId", toBeAdded.getInodeId()); } } } }
@Override public void update(INodeAttributes iNodeAttributes) throws TransactionContextException { if (iNodeAttributes.getInodeId() != INode.NON_EXISTING_ID) { super.update(iNodeAttributes); if(isLogDebugEnabled()){ log("updated-attributes", "id", iNodeAttributes.getInodeId(), "DSQ", iNodeAttributes.getDsQuota(),"DS", iNodeAttributes.getDiskspace(), "NSQ", iNodeAttributes.getNsQuota(), "NS", iNodeAttributes.getNsCount()); } } else { if(isLogDebugEnabled()) { log("updated-attributes -- IGNORED as id is not set"); } } }
@Override public void remove(INodeAttributes iNodeAttributes) throws TransactionContextException { super.remove(iNodeAttributes); if(isLogDebugEnabled()) { log("removed-attributes", "id", iNodeAttributes.getInodeId()); for(int i = 0; i < Thread.currentThread().getStackTrace().length;i++){ System.out.println(Thread.currentThread().getStackTrace()[i]) ; } } }
@Override public INodeAttributes find(FinderType<INodeAttributes> finder, Object... params) throws TransactionContextException, StorageException { INodeAttributes.Finder qfinder = (INodeAttributes.Finder) finder; switch (qfinder) { case ByINodeId: return findByPrimaryKey(qfinder, params); } throw new UnsupportedOperationException(UNSUPPORTED_FINDER); }
@Override public Collection<INodeAttributes> findList( FinderType<INodeAttributes> finder, Object... params) throws TransactionContextException, StorageException { INodeAttributes.Finder qfinder = (INodeAttributes.Finder) finder; switch (qfinder) { case ByINodeIds: return findByPrimaryKeys(qfinder, params); } throw new UnsupportedOperationException(UNSUPPORTED_FINDER); }
@Override public void prepare(TransactionLocks tlm) throws TransactionContextException, StorageException { Collection<INodeAttributes> modified = new ArrayList<>(getModified()); modified.addAll(getAdded()); dataAccess.prepare(modified, getRemoved()); }
private INodeAttributes findByPrimaryKey(INodeAttributes.Finder qfinder, Object[] params) throws StorageCallPreventedException, StorageException { final int inodeId = (Integer) params[0]; INodeAttributes result = null; if (contains(inodeId)) { result = get(inodeId); hit(qfinder, result, "inodeid", inodeId); } else { aboutToAccessStorage(qfinder, params); result = dataAccess.findAttributesByPk(inodeId); gotFromDB(inodeId, result); miss(qfinder, result, "inodeid", inodeId, "size", size()); } return result; }
private Collection<INodeAttributes> get( List<INodeCandidatePrimaryKey> iNodeCandidatePKs) { Collection<INodeAttributes> iNodeAttributeses = new ArrayList<>(iNodeCandidatePKs.size()); for (INodeCandidatePrimaryKey pk : iNodeCandidatePKs) { iNodeAttributeses.add(get(pk.getInodeId())); } return iNodeAttributeses; }
protected void acquireINodeAttributes() throws StorageException, TransactionContextException { List<INodeCandidatePrimaryKey> pks = new ArrayList<>(); for (INode inode : getAllResolvedINodes()) { if (inode instanceof INodeDirectoryWithQuota) { INodeCandidatePrimaryKey pk = new INodeCandidatePrimaryKey(inode.getId()); pks.add(pk); } } acquireLockList(DEFAULT_LOCK_TYPE, INodeAttributes.Finder.ByINodeIds, pks); }
public INodeAttributesContext( INodeAttributesDataAccess<INodeAttributes> dataAccess) { this.dataAccess = dataAccess; }
@Override Integer getKey(INodeAttributes iNodeAttributes) { return iNodeAttributes.getInodeId(); }
private INodeAttributes clone(INodeAttributes src, int inodeId) { return new INodeAttributes(inodeId, src.getNsQuota(), src.getNsCount(), src.getDsQuota(), src.getDiskspace()); }