Search in sources :

Example 6 with RelationshipTypeData

use of org.neo4j.kernel.impl.nioneo.store.RelationshipTypeData in project graphdb by neo4j-attic.

the class DefaultRelationshipTypeCreator method getOrCreate.

public int getOrCreate(TransactionManager txManager, EntityIdGenerator idGenerator, PersistenceManager persistence, RelationshipTypeHolder relTypeHolder, String name) {
    RelTypeCreater createrThread = new RelTypeCreater(name, txManager, idGenerator, persistence);
    synchronized (createrThread) {
        createrThread.start();
        while (createrThread.isAlive()) {
            try {
                createrThread.wait(50);
            } catch (InterruptedException e) {
                Thread.interrupted();
            }
        }
    }
    if (createrThread.succeded()) {
        int id = createrThread.getRelTypeId();
        relTypeHolder.addRawRelationshipType(new RelationshipTypeData(id, name));
        return id;
    }
    throw new TransactionFailureException("Unable to create relationship type " + name);
}
Also used : TransactionFailureException(org.neo4j.graphdb.TransactionFailureException) RelationshipTypeData(org.neo4j.kernel.impl.nioneo.store.RelationshipTypeData)

Example 7 with RelationshipTypeData

use of org.neo4j.kernel.impl.nioneo.store.RelationshipTypeData in project graphdb by neo4j-attic.

the class GraphDbModule method start.

public void start(LockReleaser lockReleaser, PersistenceManager persistenceManager, RelationshipTypeCreator relTypeCreator, Map<Object, Object> params) {
    if (!startIsOk) {
        return;
    }
    String cacheTypeName = (String) params.get(Config.CACHE_TYPE);
    CacheType cacheType = null;
    try {
        cacheType = cacheTypeName != null ? CacheType.valueOf(cacheTypeName) : DEFAULT_CACHE_TYPE;
    } catch (IllegalArgumentException e) {
        throw new IllegalArgumentException("Invalid cache type, please use one of: " + Arrays.asList(CacheType.values()) + " or keep empty for default (" + DEFAULT_CACHE_TYPE + ")", e.getCause());
    }
    if (!readOnly) {
        nodeManager = new NodeManager(graphDbService, cacheManager, lockManager, lockReleaser, transactionManager, persistenceManager, idGenerator, relTypeCreator, cacheType);
    } else {
        nodeManager = new ReadOnlyNodeManager(graphDbService, cacheManager, lockManager, lockReleaser, transactionManager, persistenceManager, idGenerator, cacheType);
    }
    // load and verify from PS
    RelationshipTypeData[] relTypes = null;
    PropertyIndexData[] propertyIndexes = null;
    // beginTx();
    relTypes = persistenceManager.loadAllRelationshipTypes();
    propertyIndexes = persistenceManager.loadPropertyIndexes(INDEX_COUNT);
    // commitTx();
    nodeManager.addRawRelationshipTypes(relTypes);
    nodeManager.addPropertyIndexes(propertyIndexes);
    if (propertyIndexes.length < INDEX_COUNT) {
        nodeManager.setHasAllpropertyIndexes(true);
    }
    nodeManager.start(params);
    startIsOk = false;
}
Also used : RelationshipTypeData(org.neo4j.kernel.impl.nioneo.store.RelationshipTypeData) PropertyIndexData(org.neo4j.kernel.impl.nioneo.store.PropertyIndexData) CacheType(org.neo4j.kernel.impl.core.NodeManager.CacheType)

Example 8 with RelationshipTypeData

use of org.neo4j.kernel.impl.nioneo.store.RelationshipTypeData in project neo4j-mobile-android by neo4j-contrib.

the class WriteTransaction method addRelationshipType.

private void addRelationshipType(int id) {
    setRecovered();
    RelationshipTypeData type;
    if (isRecovered()) {
        type = neoStore.getRelationshipTypeStore().getRelationshipType(id, true);
    } else {
        type = neoStore.getRelationshipTypeStore().getRelationshipType(id);
    }
    lockReleaser.addRelationshipType(type);
}
Also used : RelationshipTypeData(org.neo4j.kernel.impl.nioneo.store.RelationshipTypeData)

Aggregations

RelationshipTypeData (org.neo4j.kernel.impl.nioneo.store.RelationshipTypeData)8 TransactionFailureException (org.neo4j.graphdb.TransactionFailureException)2 CacheType (org.neo4j.kernel.impl.core.NodeManager.CacheType)2 PropertyIndexData (org.neo4j.kernel.impl.nioneo.store.PropertyIndexData)2