Search in sources :

Example 1 with LegacyIndexNotFoundKernelException

use of org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException in project neo4j by neo4j.

the class LegacyIndexTransactionStateImpl method nodeChanges.

@Override
public LegacyIndex nodeChanges(String indexName) throws LegacyIndexNotFoundKernelException {
    Map<String, String> configuration = indexConfigStore.get(Node.class, indexName);
    if (configuration == null) {
        throw new LegacyIndexNotFoundKernelException("Node index '" + indexName + " not found");
    }
    String providerName = configuration.get(IndexManager.PROVIDER);
    IndexImplementation provider = providerLookup.apply(providerName);
    LegacyIndexProviderTransaction transaction = transactions.get(providerName);
    if (transaction == null) {
        transactions.put(providerName, transaction = provider.newTransaction(this));
    }
    return transaction.nodeIndex(indexName, configuration);
}
Also used : LegacyIndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException) IndexImplementation(org.neo4j.kernel.spi.legacyindex.IndexImplementation) LegacyIndexProviderTransaction(org.neo4j.kernel.spi.legacyindex.LegacyIndexProviderTransaction)

Example 2 with LegacyIndexNotFoundKernelException

use of org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException in project neo4j by neo4j.

the class LegacyIndexProxy method putIfAbsent.

@Override
public T putIfAbsent(T entity, String key, Object value) {
    try (Statement statement = statementContextBridge.get()) {
        // Does it already exist?
        long existing = single(internalGet(key, value, statement), -1L);
        if (existing != -1) {
            return entityOf(existing);
        }
        // No, OK so Grab lock
        statement.readOperations().acquireExclusive(LEGACY_INDEX, legacyIndexResourceId(name, key));
        // and check again -- now holding an exclusive lock
        existing = single(internalGet(key, value, statement), -1L);
        if (existing != -1) {
            // Someone else created this entry before us just before we got the lock,
            // release the lock as we won't be needing it
            statement.readOperations().releaseExclusive(LEGACY_INDEX, legacyIndexResourceId(name, key));
            return entityOf(existing);
        }
        internalAdd(entity, key, value, statement);
        return null;
    } catch (EntityNotFoundException e) {
        throw new NotFoundException(format("%s %d not found", type, type.id(entity)), e);
    } catch (InvalidTransactionTypeKernelException e) {
        throw new ConstraintViolationException(e.getMessage(), e);
    } catch (LegacyIndexNotFoundKernelException e) {
        throw new RuntimeException(e);
    }
}
Also used : Statement(org.neo4j.kernel.api.Statement) InvalidTransactionTypeKernelException(org.neo4j.kernel.api.exceptions.InvalidTransactionTypeKernelException) LegacyIndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException) NotFoundException(org.neo4j.graphdb.NotFoundException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) ConstraintViolationException(org.neo4j.graphdb.ConstraintViolationException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException)

Example 3 with LegacyIndexNotFoundKernelException

use of org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException in project neo4j by neo4j.

the class InternalAutoIndexOperations method propertyAdded.

@Override
public void propertyAdded(DataWriteOperations ops, long entityId, Property property) throws AutoIndexingKernelException {
    if (enabled) {
        try {
            String name = propertyKeyLookup.getTokenById(property.propertyKeyId()).name();
            if (propertyKeysToInclude.get().contains(name)) {
                ensureIndexExists(ops);
                type.add(ops, entityId, name, property.value());
            }
        } catch (LegacyIndexNotFoundKernelException | EntityNotFoundException | PropertyNotFoundException e) {
            throw new AutoIndexingKernelException(e);
        } catch (TokenNotFoundException e) {
            // KernelException now
            throw new AutoIndexingKernelException(new PropertyKeyIdNotFoundKernelException(property.propertyKeyId(), e));
        }
    }
}
Also used : PropertyNotFoundException(org.neo4j.kernel.api.exceptions.PropertyNotFoundException) LegacyIndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) TokenNotFoundException(org.neo4j.kernel.impl.core.TokenNotFoundException) AutoIndexingKernelException(org.neo4j.kernel.api.exceptions.legacyindex.AutoIndexingKernelException) PropertyKeyIdNotFoundKernelException(org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Example 4 with LegacyIndexNotFoundKernelException

use of org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException in project neo4j by neo4j.

the class InternalAutoIndexOperations method propertyRemoved.

@Override
public void propertyRemoved(DataWriteOperations ops, long entityId, int propertyKey) throws AutoIndexingKernelException {
    if (enabled) {
        try {
            String name = propertyKeyLookup.getTokenById(propertyKey).name();
            if (propertyKeysToInclude.get().contains(name)) {
                ensureIndexExists(ops);
                type.remove(ops, entityId, name);
            }
        } catch (LegacyIndexNotFoundKernelException | EntityNotFoundException e) {
            throw new AutoIndexingKernelException(e);
        } catch (TokenNotFoundException e) {
            // KernelException now
            throw new AutoIndexingKernelException(new PropertyKeyIdNotFoundKernelException(propertyKey, e));
        }
    }
}
Also used : LegacyIndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) TokenNotFoundException(org.neo4j.kernel.impl.core.TokenNotFoundException) AutoIndexingKernelException(org.neo4j.kernel.api.exceptions.legacyindex.AutoIndexingKernelException) PropertyKeyIdNotFoundKernelException(org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Example 5 with LegacyIndexNotFoundKernelException

use of org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException in project neo4j by neo4j.

the class InternalAutoIndexOperations method entityRemoved.

@Override
public void entityRemoved(DataWriteOperations ops, long entityId) throws AutoIndexingKernelException {
    if (enabled) {
        try {
            ensureIndexExists(ops);
            type.remove(ops, entityId);
        } catch (LegacyIndexNotFoundKernelException | EntityNotFoundException e) {
            throw new AutoIndexingKernelException(e);
        }
    }
}
Also used : LegacyIndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) AutoIndexingKernelException(org.neo4j.kernel.api.exceptions.legacyindex.AutoIndexingKernelException)

Aggregations

LegacyIndexNotFoundKernelException (org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException)7 EntityNotFoundException (org.neo4j.kernel.api.exceptions.EntityNotFoundException)5 AutoIndexingKernelException (org.neo4j.kernel.api.exceptions.legacyindex.AutoIndexingKernelException)4 PropertyKeyIdNotFoundKernelException (org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)3 TokenNotFoundException (org.neo4j.kernel.impl.core.TokenNotFoundException)3 PropertyNotFoundException (org.neo4j.kernel.api.exceptions.PropertyNotFoundException)2 IndexImplementation (org.neo4j.kernel.spi.legacyindex.IndexImplementation)2 LegacyIndexProviderTransaction (org.neo4j.kernel.spi.legacyindex.LegacyIndexProviderTransaction)2 ConstraintViolationException (org.neo4j.graphdb.ConstraintViolationException)1 NotFoundException (org.neo4j.graphdb.NotFoundException)1 Statement (org.neo4j.kernel.api.Statement)1 InvalidTransactionTypeKernelException (org.neo4j.kernel.api.exceptions.InvalidTransactionTypeKernelException)1