Search in sources :

Example 1 with InternalVersionManagerImpl

use of org.apache.jackrabbit.core.version.InternalVersionManagerImpl in project jackrabbit by apache.

the class RepositoryImpl method createVersionManager.

/**
 * Creates the version manager.
 *
 * @param vConfig the versioning config
 * @return the newly created version manager
 * @throws RepositoryException if an error occurs
 */
protected InternalVersionManagerImpl createVersionManager(VersioningConfig vConfig, DelegatingObservationDispatcher delegatingDispatcher) throws RepositoryException {
    FileSystem fs = vConfig.getFileSystem();
    PersistenceManager pm = createPersistenceManager(vConfig.getHomeDir(), fs, vConfig.getPersistenceManagerConfig());
    ISMLocking ismLocking = vConfig.getISMLocking();
    return new InternalVersionManagerImpl(pm, fs, context.getNodeTypeRegistry(), delegatingDispatcher, SYSTEM_ROOT_NODE_ID, VERSION_STORAGE_NODE_ID, ACTIVITIES_NODE_ID, context.getItemStateCacheFactory(), ismLocking, context.getNodeIdFactory());
}
Also used : ISMLocking(org.apache.jackrabbit.core.state.ISMLocking) PersistenceManager(org.apache.jackrabbit.core.persistence.PersistenceManager) IterablePersistenceManager(org.apache.jackrabbit.core.persistence.IterablePersistenceManager) FileSystem(org.apache.jackrabbit.core.fs.FileSystem) InternalVersionManagerImpl(org.apache.jackrabbit.core.version.InternalVersionManagerImpl)

Example 2 with InternalVersionManagerImpl

use of org.apache.jackrabbit.core.version.InternalVersionManagerImpl in project jackrabbit by apache.

the class RepositoryImpl method createDataStoreGarbageCollector.

/**
 * Creates a data store garbage collector for this repository.
 * <p>
 * Note that you should use the {@link RepositoryManager} interface
 * to access this functionality. This RepositoryImpl method may be
 * removed in future Jackrabbit versions.
 */
public GarbageCollector createDataStoreGarbageCollector() throws RepositoryException {
    ArrayList<PersistenceManager> pmList = new ArrayList<PersistenceManager>();
    InternalVersionManagerImpl vm = context.getInternalVersionManager();
    PersistenceManager pm = vm.getPersistenceManager();
    pmList.add(pm);
    String[] wspNames = getWorkspaceNames();
    SessionImpl[] sessions = new SessionImpl[wspNames.length];
    for (int i = 0; i < wspNames.length; i++) {
        String wspName = wspNames[i];
        WorkspaceInfo wspInfo = getWorkspaceInfo(wspName);
        // this will initialize the workspace if required
        SessionImpl systemSession = SystemSession.create(context, wspInfo.getConfig());
        // mark the workspace as 'active' so it does not get disposed by
        // the workspace-janitor until the garbage collector is done
        wspInfo.setActive(true);
        // the workspace could be disposed, so re-initialize if required
        // afterwards it will not be disposed because it was marked active
        wspInfo.initialize();
        sessions[i] = systemSession;
        pm = wspInfo.getPersistenceManager();
        pmList.add(pm);
    }
    IterablePersistenceManager[] ipmList = new IterablePersistenceManager[pmList.size()];
    for (int i = 0; i < pmList.size(); i++) {
        pm = pmList.get(i);
        if (!(pm instanceof IterablePersistenceManager)) {
            ipmList = null;
            break;
        }
        ipmList[i] = (IterablePersistenceManager) pm;
    }
    GarbageCollector gc = new GarbageCollector(context, context.getDataStore(), ipmList, sessions);
    synchronized (this) {
        if (context.isGcRunning()) {
            throw new RepositoryException("Cannot create GC. GC already running");
        }
        context.setGcRunning(true);
    }
    return gc;
}
Also used : PersistenceManager(org.apache.jackrabbit.core.persistence.PersistenceManager) IterablePersistenceManager(org.apache.jackrabbit.core.persistence.IterablePersistenceManager) ArrayList(java.util.ArrayList) RepositoryException(javax.jcr.RepositoryException) InternalVersionManagerImpl(org.apache.jackrabbit.core.version.InternalVersionManagerImpl) IterablePersistenceManager(org.apache.jackrabbit.core.persistence.IterablePersistenceManager) GarbageCollector(org.apache.jackrabbit.core.gc.GarbageCollector)

Aggregations

IterablePersistenceManager (org.apache.jackrabbit.core.persistence.IterablePersistenceManager)2 PersistenceManager (org.apache.jackrabbit.core.persistence.PersistenceManager)2 InternalVersionManagerImpl (org.apache.jackrabbit.core.version.InternalVersionManagerImpl)2 ArrayList (java.util.ArrayList)1 RepositoryException (javax.jcr.RepositoryException)1 FileSystem (org.apache.jackrabbit.core.fs.FileSystem)1 GarbageCollector (org.apache.jackrabbit.core.gc.GarbageCollector)1 ISMLocking (org.apache.jackrabbit.core.state.ISMLocking)1