Search in sources :

Example 1 with LockReleaser

use of org.neo4j.kernel.impl.core.LockReleaser in project graphdb by neo4j-attic.

the class MasterImpl method acquireLock.

private <T extends PropertyContainer> Response<LockResult> acquireLock(SlaveContext context, LockGrabber lockGrabber, T... entities) {
    Transaction otherTx = suspendOtherAndResumeThis(context);
    try {
        LockManager lockManager = graphDbConfig.getLockManager();
        LockReleaser lockReleaser = graphDbConfig.getLockReleaser();
        for (T entity : entities) {
            lockGrabber.grab(lockManager, lockReleaser, entity);
        }
        return packResponse(context, new LockResult(LockStatus.OK_LOCKED));
    } catch (DeadlockDetectedException e) {
        return packResponse(context, new LockResult(e.getMessage()));
    } catch (IllegalResourceException e) {
        return packResponse(context, new LockResult(LockStatus.NOT_LOCKED));
    } finally {
        suspendThisAndResumeOther(otherTx, context);
    }
}
Also used : LockManager(org.neo4j.kernel.impl.transaction.LockManager) LockReleaser(org.neo4j.kernel.impl.core.LockReleaser) Transaction(javax.transaction.Transaction) DeadlockDetectedException(org.neo4j.kernel.DeadlockDetectedException) IllegalResourceException(org.neo4j.kernel.impl.transaction.IllegalResourceException)

Example 2 with LockReleaser

use of org.neo4j.kernel.impl.core.LockReleaser in project graphdb by neo4j-attic.

the class TestNeoStore method initializeStores.

private void initializeStores() throws IOException {
    try {
        LockManager lockManager = getEmbeddedGraphDb().getConfig().getLockManager();
        LockReleaser lockReleaser = getEmbeddedGraphDb().getConfig().getLockReleaser();
        ds = new NeoStoreXaDataSource(MapUtil.genericMap(LockManager.class, lockManager, LockReleaser.class, lockReleaser, IdGeneratorFactory.class, ID_GENERATOR_FACTORY, FileSystemAbstraction.class, CommonFactories.defaultFileSystemAbstraction(), LogBufferFactory.class, CommonFactories.defaultLogBufferFactory(MapUtil.stringMap()), TxIdGenerator.class, TxIdGenerator.DEFAULT, "store_dir", path(), "neo_store", file("neo"), "logical_log", file("nioneo_logical.log")));
    // ds = new NeoStoreXaDataSource( file( "neo" ), file( "nioneo_logical.log" ),
    // lockManager, lockReleaser );
    } catch (InstantiationException e) {
        throw new IOException("" + e);
    }
    xaCon = (NeoStoreXaConnection) ds.getXaConnection();
    nStore = xaCon.getNodeConsumer();
    pStore = xaCon.getPropertyStore();
    relTypeStore = xaCon.getRelationshipTypeConsumer();
    rStore = xaCon.getRelationshipConsumer();
}
Also used : LockManager(org.neo4j.kernel.impl.transaction.LockManager) LockReleaser(org.neo4j.kernel.impl.core.LockReleaser) NeoStoreXaDataSource(org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource) IOException(java.io.IOException)

Aggregations

LockReleaser (org.neo4j.kernel.impl.core.LockReleaser)2 LockManager (org.neo4j.kernel.impl.transaction.LockManager)2 IOException (java.io.IOException)1 Transaction (javax.transaction.Transaction)1 DeadlockDetectedException (org.neo4j.kernel.DeadlockDetectedException)1 NeoStoreXaDataSource (org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource)1 IllegalResourceException (org.neo4j.kernel.impl.transaction.IllegalResourceException)1