Search in sources :

Example 16 with NoSuchItemStateException

use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.

the class GarbageCollector method scanPersistenceManagersByNodeInfos.

private void scanPersistenceManagersByNodeInfos() throws RepositoryException, ItemStateException {
    int pmCount = 0;
    for (IterablePersistenceManager pm : pmList) {
        pmCount++;
        int count = 0;
        Map<NodeId, NodeInfo> batch = pm.getAllNodeInfos(null, NODESATONCE);
        while (!batch.isEmpty()) {
            NodeId lastId = null;
            for (NodeInfo info : batch.values()) {
                count++;
                if (count % 1000 == 0) {
                    LOG.debug(pm.toString() + " (" + pmCount + "/" + pmList.length + "): analyzed " + count + " nodes...");
                }
                lastId = info.getId();
                if (callback != null) {
                    callback.beforeScanning(null);
                }
                if (info.hasBlobsInDataStore()) {
                    try {
                        NodeState state = pm.load(info.getId());
                        Set<Name> propertyNames = state.getPropertyNames();
                        for (Name name : propertyNames) {
                            PropertyId pid = new PropertyId(info.getId(), name);
                            PropertyState ps = pm.load(pid);
                            if (ps.getType() == PropertyType.BINARY) {
                                for (InternalValue v : ps.getValues()) {
                                    // getLength will update the last modified date
                                    // if the persistence manager scan is running
                                    v.getLength();
                                }
                            }
                        }
                    } catch (NoSuchItemStateException ignored) {
                    // the node may have been deleted in the meantime
                    }
                }
            }
            batch = pm.getAllNodeInfos(lastId, NODESATONCE);
        }
    }
    NodeInfo.clearPool();
}
Also used : IterablePersistenceManager(org.apache.jackrabbit.core.persistence.IterablePersistenceManager) NodeState(org.apache.jackrabbit.core.state.NodeState) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) NodeInfo(org.apache.jackrabbit.core.persistence.util.NodeInfo) NodeId(org.apache.jackrabbit.core.id.NodeId) InternalValue(org.apache.jackrabbit.core.value.InternalValue) Name(org.apache.jackrabbit.spi.Name) PropertyId(org.apache.jackrabbit.core.id.PropertyId) PropertyState(org.apache.jackrabbit.core.state.PropertyState)

Example 17 with NoSuchItemStateException

use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.

the class GarbageCollector method scanNodeIdList.

private void scanNodeIdList(int split, List<NodeId> nodeList, PersistenceManager pm, int pmCount) throws RepositoryException, ItemStateException {
    int count = 0;
    for (NodeId id : nodeList) {
        count++;
        if (count % 1000 == 0) {
            if (split > 0) {
                LOG.debug("[Split " + split + "] " + pm.toString() + " (" + pmCount + "/" + pmList.length + "): analyzed " + count + " nodes [" + nodeList.size() + "]...");
            } else {
                LOG.debug(pm.toString() + " (" + pmCount + "/" + pmList.length + "): analyzed " + count + " nodes [" + nodeList.size() + "]...");
            }
        }
        if (callback != null) {
            callback.beforeScanning(null);
        }
        try {
            NodeState state = pm.load(id);
            Set<Name> propertyNames = state.getPropertyNames();
            for (Name name : propertyNames) {
                PropertyId pid = new PropertyId(id, name);
                PropertyState ps = pm.load(pid);
                if (ps.getType() == PropertyType.BINARY) {
                    for (InternalValue v : ps.getValues()) {
                        // getLength will update the last modified date
                        // if the persistence manager scan is running
                        v.getLength();
                    }
                }
            }
        } catch (NoSuchItemStateException e) {
        // the node may have been deleted or moved in the meantime
        // ignore it
        }
    }
}
Also used : NodeState(org.apache.jackrabbit.core.state.NodeState) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) NodeId(org.apache.jackrabbit.core.id.NodeId) InternalValue(org.apache.jackrabbit.core.value.InternalValue) Name(org.apache.jackrabbit.spi.Name) PropertyId(org.apache.jackrabbit.core.id.PropertyId) PropertyState(org.apache.jackrabbit.core.state.PropertyState)

Example 18 with NoSuchItemStateException

use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.

the class ObjectPersistenceManager method load.

/**
     * {@inheritDoc}
     */
public synchronized NodeState load(NodeId id) throws NoSuchItemStateException, ItemStateException {
    if (!initialized) {
        throw new IllegalStateException("not initialized");
    }
    String nodeFilePath = buildNodeFilePath(id);
    try {
        if (!itemStateFS.isFile(nodeFilePath)) {
            throw new NoSuchItemStateException(nodeFilePath);
        }
    } catch (FileSystemException fse) {
        String msg = "failed to read node state: " + nodeFilePath;
        log.debug(msg);
        throw new ItemStateException(msg, fse);
    }
    try {
        BufferedInputStream in = new BufferedInputStream(itemStateFS.getInputStream(nodeFilePath));
        try {
            NodeState state = createNew(id);
            Serializer.deserialize(state, in);
            return state;
        } catch (Exception e) {
            String msg = "failed to read node state: " + id;
            log.debug(msg);
            throw new ItemStateException(msg, e);
        } finally {
            in.close();
        }
    } catch (Exception e) {
        String msg = "failed to read node state: " + nodeFilePath;
        log.debug(msg);
        throw new ItemStateException(msg, e);
    }
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) NodeState(org.apache.jackrabbit.core.state.NodeState) BufferedInputStream(java.io.BufferedInputStream) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException) FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException)

Example 19 with NoSuchItemStateException

use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.

the class BundleDbPersistenceManager method loadReferencesTo.

/**
     * {@inheritDoc}
     */
public synchronized NodeReferences loadReferencesTo(NodeId targetId) throws NoSuchItemStateException, ItemStateException {
    if (!initialized) {
        throw new IllegalStateException("not initialized");
    }
    ResultSet rs = null;
    InputStream in = null;
    try {
        rs = conHelper.exec(nodeReferenceSelectSQL, getKey(targetId), false, 0);
        if (!rs.next()) {
            throw new NoSuchItemStateException(targetId.toString());
        }
        in = rs.getBinaryStream(1);
        NodeReferences refs = new NodeReferences(targetId);
        Serializer.deserialize(refs, in);
        return refs;
    } catch (Exception e) {
        if (e instanceof NoSuchItemStateException) {
            throw (NoSuchItemStateException) e;
        }
        String msg = "failed to read references: " + targetId;
        log.error(msg, e);
        throw new ItemStateException(msg, e);
    } finally {
        IOUtils.closeQuietly(in);
        DbUtility.close(rs);
    }
}
Also used : NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) FilterInputStream(java.io.FilterInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ResultSet(java.sql.ResultSet) NodeReferences(org.apache.jackrabbit.core.state.NodeReferences) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) SQLException(java.sql.SQLException) RepositoryException(javax.jcr.RepositoryException) IOException(java.io.IOException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException)

Example 20 with NoSuchItemStateException

use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.

the class InMemPersistenceManager method load.

/**
     * {@inheritDoc}
     */
public synchronized PropertyState load(PropertyId id) throws NoSuchItemStateException, ItemStateException {
    if (!initialized) {
        throw new IllegalStateException("not initialized");
    }
    byte[] data = stateStore.get(id);
    if (data == null) {
        throw new NoSuchItemStateException(id.toString());
    }
    ByteArrayInputStream in = new ByteArrayInputStream(data);
    try {
        PropertyState state = createNew(id);
        Serializer.deserialize(state, in, blobStore);
        return state;
    } catch (Exception e) {
        String msg = "failed to read property state: " + id;
        log.debug(msg);
        throw new ItemStateException(msg, e);
    }
}
Also used : NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ByteArrayInputStream(java.io.ByteArrayInputStream) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException) PropertyState(org.apache.jackrabbit.core.state.PropertyState) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException)

Aggregations

NoSuchItemStateException (org.apache.jackrabbit.core.state.NoSuchItemStateException)37 ItemStateException (org.apache.jackrabbit.core.state.ItemStateException)31 RepositoryException (javax.jcr.RepositoryException)17 NodeId (org.apache.jackrabbit.core.id.NodeId)14 NodeState (org.apache.jackrabbit.core.state.NodeState)13 FileSystemException (org.apache.jackrabbit.core.fs.FileSystemException)11 PropertyState (org.apache.jackrabbit.core.state.PropertyState)11 IOException (java.io.IOException)10 ByteArrayInputStream (java.io.ByteArrayInputStream)8 InputStream (java.io.InputStream)8 InvalidItemStateException (javax.jcr.InvalidItemStateException)8 ItemNotFoundException (javax.jcr.ItemNotFoundException)8 ItemState (org.apache.jackrabbit.core.state.ItemState)8 NodeReferences (org.apache.jackrabbit.core.state.NodeReferences)8 SQLException (java.sql.SQLException)7 PropertyId (org.apache.jackrabbit.core.id.PropertyId)7 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)6 Name (org.apache.jackrabbit.spi.Name)6 InternalValue (org.apache.jackrabbit.core.value.InternalValue)5 FilterInputStream (java.io.FilterInputStream)4