Search in sources :

Example 31 with OStorageException

use of com.orientechnologies.orient.core.exception.OStorageException in project orientdb by orientechnologies.

the class OLocalHashTable method setKeySerializer.

@Override
public void setKeySerializer(OBinarySerializer<K> keySerializer) {
    startOperation();
    try {
        final OAtomicOperation atomicOperation;
        try {
            atomicOperation = startAtomicOperation(true);
        } catch (IOException e) {
            throw OException.wrapException(new OIndexException("Error during hash set serializer for index keys"), e);
        }
        acquireExclusiveLock();
        try {
            this.keySerializer = keySerializer;
            OCacheEntry hashStateEntry = loadPage(atomicOperation, fileStateId, hashStateEntryIndex, true);
            hashStateEntry.acquireExclusiveLock();
            try {
                OHashIndexFileLevelMetadataPage metadataPage = new OHashIndexFileLevelMetadataPage(hashStateEntry, getChanges(atomicOperation, hashStateEntry), false);
                metadataPage.setKeySerializerId(keySerializer.getId());
            } finally {
                hashStateEntry.releaseExclusiveLock();
                releasePage(atomicOperation, hashStateEntry);
            }
            endAtomicOperation(false, null);
        } catch (IOException e) {
            rollback(e);
            throw OException.wrapException(new OIndexException("Cannot set serializer for index keys"), e);
        } catch (Exception e) {
            rollback(e);
            throw OException.wrapException(new OStorageException("Cannot set serializer for index keys"), e);
        } finally {
            releaseExclusiveLock();
        }
    } finally {
        completeOperation();
    }
}
Also used : OAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation) OCacheEntry(com.orientechnologies.orient.core.storage.cache.OCacheEntry) OIndexException(com.orientechnologies.orient.core.index.OIndexException) OStorageException(com.orientechnologies.orient.core.exception.OStorageException) IOException(java.io.IOException) OIndexException(com.orientechnologies.orient.core.index.OIndexException) OException(com.orientechnologies.common.exception.OException) IOException(java.io.IOException) OLocalHashTableException(com.orientechnologies.orient.core.exception.OLocalHashTableException) OTooBigIndexKeyException(com.orientechnologies.orient.core.exception.OTooBigIndexKeyException) OStorageException(com.orientechnologies.orient.core.exception.OStorageException)

Example 32 with OStorageException

use of com.orientechnologies.orient.core.exception.OStorageException in project orientdb by orientechnologies.

the class OLocalHashTable method put.

private boolean put(K key, V value, OIndexEngine.Validator<K, V> validator) {
    final OSessionStoragePerformanceStatistic statistic = performanceStatisticManager.getSessionPerformanceStatistic();
    startOperation();
    if (statistic != null)
        statistic.startIndexEntryUpdateTimer();
    try {
        final OAtomicOperation atomicOperation;
        try {
            atomicOperation = startAtomicOperation(true);
        } catch (IOException e) {
            throw OException.wrapException(new OIndexException("Error during hash table entry put"), e);
        }
        acquireExclusiveLock();
        try {
            checkNullSupport(key);
            if (key != null) {
                final int keySize = keySerializer.getObjectSize(key, (Object[]) keyTypes);
                if (keySize > MAX_KEY_SIZE)
                    throw new OTooBigIndexKeyException("Key size is more than allowed, operation was canceled. Current key size " + keySize + ", allowed  " + MAX_KEY_SIZE, getName());
            }
            key = keySerializer.preprocess(key, (Object[]) keyTypes);
            final boolean putResult = doPut(key, value, validator, atomicOperation);
            endAtomicOperation(false, null);
            return putResult;
        } catch (IOException e) {
            rollback(e);
            throw OException.wrapException(new OIndexException("Error during index update"), e);
        } catch (Exception e) {
            rollback(e);
            throw OException.wrapException(new OStorageException("Error during index update"), e);
        } finally {
            releaseExclusiveLock();
        }
    } finally {
        if (statistic != null)
            statistic.stopIndexEntryUpdateTimer();
        completeOperation();
    }
}
Also used : OAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation) OIndexException(com.orientechnologies.orient.core.index.OIndexException) OStorageException(com.orientechnologies.orient.core.exception.OStorageException) IOException(java.io.IOException) OSessionStoragePerformanceStatistic(com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic) OTooBigIndexKeyException(com.orientechnologies.orient.core.exception.OTooBigIndexKeyException) OIndexException(com.orientechnologies.orient.core.index.OIndexException) OException(com.orientechnologies.common.exception.OException) IOException(java.io.IOException) OLocalHashTableException(com.orientechnologies.orient.core.exception.OLocalHashTableException) OTooBigIndexKeyException(com.orientechnologies.orient.core.exception.OTooBigIndexKeyException) OStorageException(com.orientechnologies.orient.core.exception.OStorageException)

Example 33 with OStorageException

use of com.orientechnologies.orient.core.exception.OStorageException in project orientdb by orientechnologies.

the class OLocalHashTable20 method setValueSerializer.

@Override
public void setValueSerializer(OBinarySerializer<V> valueSerializer) {
    final OAtomicOperation atomicOperation;
    try {
        atomicOperation = startAtomicOperation(true);
    } catch (IOException e) {
        throw OException.wrapException(new OIndexException("Error during hash table set serializer for index values"), e);
    }
    acquireExclusiveLock();
    try {
        this.valueSerializer = valueSerializer;
        final OCacheEntry hashStateEntry = loadPage(atomicOperation, fileStateId, hashStateEntryIndex, true);
        hashStateEntry.acquireExclusiveLock();
        try {
            OHashIndexFileLevelMetadataPage metadataPage = new OHashIndexFileLevelMetadataPage(hashStateEntry, getChanges(atomicOperation, hashStateEntry), false);
            metadataPage.setValueSerializerId(valueSerializer.getId());
        } finally {
            hashStateEntry.releaseExclusiveLock();
            releasePage(atomicOperation, hashStateEntry);
        }
        endAtomicOperation(false, null);
    } catch (IOException e) {
        rollback();
        throw OException.wrapException(new OIndexException("Cannot set serializer for index values"), e);
    } catch (Exception e) {
        rollback();
        throw OException.wrapException(new OStorageException("Cannot set serializer for index values"), e);
    } finally {
        releaseExclusiveLock();
    }
}
Also used : OAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation) OCacheEntry(com.orientechnologies.orient.core.storage.cache.OCacheEntry) OIndexException(com.orientechnologies.orient.core.index.OIndexException) OStorageException(com.orientechnologies.orient.core.exception.OStorageException) IOException(java.io.IOException) OIndexException(com.orientechnologies.orient.core.index.OIndexException) OException(com.orientechnologies.common.exception.OException) IOException(java.io.IOException) OIndexEngineException(com.orientechnologies.orient.core.index.OIndexEngineException) OStorageException(com.orientechnologies.orient.core.exception.OStorageException)

Example 34 with OStorageException

use of com.orientechnologies.orient.core.exception.OStorageException in project orientdb by orientechnologies.

the class ORecordSerializerNetworkV0 method deserialize.

@Override
public void deserialize(final ODocument document, final BytesContainer bytes) {
    final String className = readString(bytes);
    if (className.length() != 0)
        ODocumentInternal.fillClassNameIfNeeded(document, className);
    int last = 0;
    String fieldName;
    int valuePos;
    OType type;
    while (true) {
        final int len = OVarIntSerializer.readAsInteger(bytes);
        if (len == 0) {
            // SCAN COMPLETED
            break;
        } else if (len > 0) {
            // PARSE FIELD NAME
            fieldName = stringFromBytes(bytes.bytes, bytes.offset, len).intern();
            bytes.skip(len);
            valuePos = readInteger(bytes);
            type = readOType(bytes);
        } else {
            throw new OStorageException("property id not supported in network serialization");
        }
        if (ODocumentInternal.rawContainsField(document, fieldName)) {
            continue;
        }
        if (valuePos != 0) {
            int headerCursor = bytes.offset;
            bytes.offset = valuePos;
            final Object value = deserializeValue(bytes, type, document);
            if (bytes.offset > last)
                last = bytes.offset;
            bytes.offset = headerCursor;
            document.field(fieldName, value, type);
        } else
            document.field(fieldName, null, null);
    }
    ORecordInternal.clearSource(document);
    if (last > bytes.offset)
        bytes.offset = last;
}
Also used : OStorageException(com.orientechnologies.orient.core.exception.OStorageException) OType(com.orientechnologies.orient.core.metadata.schema.OType)

Example 35 with OStorageException

use of com.orientechnologies.orient.core.exception.OStorageException in project orientdb by orientechnologies.

the class OWOWCache method delete.

public long[] delete() throws IOException {
    final List<Long> result = new ArrayList<Long>();
    filesLock.acquireWriteLock();
    try {
        for (int intId : nameIdMap.values()) {
            if (intId < 0)
                continue;
            final long externalId = composeFileId(id, intId);
            doDeleteFile(externalId);
            result.add(externalId);
        }
        if (nameIdMapHolderFile != null) {
            if (nameIdMapHolderFile.exists()) {
                nameIdMapHolder.close();
                if (!nameIdMapHolderFile.delete())
                    throw new OStorageException("Cannot delete disk cache file which contains name-id mapping.");
            }
            nameIdMapHolder = null;
            nameIdMapHolderFile = null;
        }
    } finally {
        filesLock.releaseWriteLock();
    }
    if (!commitExecutor.isShutdown()) {
        commitExecutor.shutdown();
        try {
            if (!commitExecutor.awaitTermination(5, TimeUnit.MINUTES))
                throw new OWriteCacheException("Background data flush task cannot be stopped.");
        } catch (InterruptedException e) {
            OLogManager.instance().error(this, "Data flush thread was interrupted");
            Thread.interrupted();
            throw new OInterruptedException("Data flush thread was interrupted");
        }
    }
    final long[] ids = new long[result.size()];
    int counter = 0;
    for (long id : result) {
        ids[counter] = id;
        counter++;
    }
    return ids;
}
Also used : OWriteCacheException(com.orientechnologies.orient.core.exception.OWriteCacheException) OStorageException(com.orientechnologies.orient.core.exception.OStorageException) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Aggregations

OStorageException (com.orientechnologies.orient.core.exception.OStorageException)46 OException (com.orientechnologies.common.exception.OException)13 IOException (java.io.IOException)13 OIndexException (com.orientechnologies.orient.core.index.OIndexException)10 OCacheEntry (com.orientechnologies.orient.core.storage.cache.OCacheEntry)10 OAtomicOperation (com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation)10 OLocalHashTableException (com.orientechnologies.orient.core.exception.OLocalHashTableException)5 OTooBigIndexKeyException (com.orientechnologies.orient.core.exception.OTooBigIndexKeyException)5 OIndexEngineException (com.orientechnologies.orient.core.index.OIndexEngineException)5 OFileClassic (com.orientechnologies.orient.core.storage.fs.OFileClassic)5 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)4 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)3 OCachePointer (com.orientechnologies.orient.core.storage.cache.OCachePointer)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 SubScheduledExecutorService (com.orientechnologies.common.concur.executors.SubScheduledExecutorService)2 OType (com.orientechnologies.orient.core.metadata.schema.OType)2 OSessionStoragePerformanceStatistic (com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic)2 File (java.io.File)2 RandomAccessFile (java.io.RandomAccessFile)2 OInterruptedException (com.orientechnologies.common.concur.lock.OInterruptedException)1