Search in sources :

Example 21 with StatementExecutionException

use of herddb.model.StatementExecutionException in project herddb by diennea.

the class TableSpaceManager method dropIndex.

private StatementExecutionResult dropIndex(DropIndexStatement statement, Transaction transaction) throws StatementExecutionException {
    generalLock.writeLock().lock();
    try {
        if (!indexes.containsKey(statement.getIndexName())) {
            if (statement.isIfExists()) {
                return new DDLStatementExecutionResult(transaction != null ? transaction.transactionId : 0);
            }
            throw new IndexDoesNotExistException("index " + statement.getIndexName() + " does not exist " + statement.getIndexName() + " on tableSpace " + statement.getTableSpace());
        }
        if (transaction != null && transaction.isIndexDropped(statement.getIndexName())) {
            if (statement.isIfExists()) {
                return new DDLStatementExecutionResult(transaction.transactionId);
            }
            throw new IndexDoesNotExistException("index does not exist " + statement.getIndexName() + " on tableSpace " + statement.getTableSpace());
        }
        LogEntry entry = LogEntryFactory.dropIndex(statement.getIndexName(), transaction);
        CommitLogResult pos;
        try {
            pos = log.log(entry, entry.transactionId <= 0);
        } catch (LogNotAvailableException ex) {
            throw new StatementExecutionException(ex);
        }
        apply(pos, entry, false);
        return new DDLStatementExecutionResult(entry.transactionId);
    } catch (DataStorageManagerException err) {
        throw new StatementExecutionException(err);
    } finally {
        generalLock.writeLock().unlock();
    }
}
Also used : DataStorageManagerException(herddb.storage.DataStorageManagerException) IndexDoesNotExistException(herddb.model.IndexDoesNotExistException) DDLStatementExecutionResult(herddb.model.DDLStatementExecutionResult) CommitLogResult(herddb.log.CommitLogResult) LogEntry(herddb.log.LogEntry) DumpedLogEntry(herddb.backup.DumpedLogEntry) StatementExecutionException(herddb.model.StatementExecutionException) LogNotAvailableException(herddb.log.LogNotAvailableException)

Example 22 with StatementExecutionException

use of herddb.model.StatementExecutionException in project herddb by diennea.

the class TableSpaceManager method beginTransaction.

private StatementExecutionResult beginTransaction() throws StatementExecutionException {
    long id = newTransactionId.incrementAndGet();
    LogEntry entry = LogEntryFactory.beginTransaction(id);
    CommitLogResult pos;
    generalLock.readLock().lock();
    try {
        pos = log.log(entry, false);
        apply(pos, entry, false);
        return new TransactionResult(id, TransactionResult.OutcomeType.BEGIN);
    } catch (Exception err) {
        throw new StatementExecutionException(err);
    } finally {
        generalLock.readLock().unlock();
    }
}
Also used : TransactionResult(herddb.model.TransactionResult) CommitLogResult(herddb.log.CommitLogResult) LogEntry(herddb.log.LogEntry) DumpedLogEntry(herddb.backup.DumpedLogEntry) HDBException(herddb.client.HDBException) IndexAlreadyExistsException(herddb.model.IndexAlreadyExistsException) LogNotAvailableException(herddb.log.LogNotAvailableException) ClientSideMetadataProviderException(herddb.client.ClientSideMetadataProviderException) IndexDoesNotExistException(herddb.model.IndexDoesNotExistException) FullRecoveryNeededException(herddb.log.FullRecoveryNeededException) TableAlreadyExistsException(herddb.model.TableAlreadyExistsException) TimeoutException(java.util.concurrent.TimeoutException) DataStorageManagerException(herddb.storage.DataStorageManagerException) TableDoesNotExistException(herddb.model.TableDoesNotExistException) DDLException(herddb.model.DDLException) StatementExecutionException(herddb.model.StatementExecutionException) EOFException(java.io.EOFException) MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) StatementExecutionException(herddb.model.StatementExecutionException)

Example 23 with StatementExecutionException

use of herddb.model.StatementExecutionException in project herddb by diennea.

the class TableSpaceManager method commitTransaction.

private StatementExecutionResult commitTransaction(CommitTransactionStatement commitTransactionStatement) throws StatementExecutionException {
    long txId = commitTransactionStatement.getTransactionId();
    LogEntry entry = LogEntryFactory.commitTransaction(txId);
    generalLock.readLock().lock();
    try {
        Transaction tx = transactions.get(txId);
        if (tx == null) {
            throw new StatementExecutionException("no such transaction " + commitTransactionStatement.getTransactionId());
        }
        CommitLogResult pos = log.log(entry, true);
        apply(pos, entry, false);
    } catch (Exception err) {
        throw new StatementExecutionException(err);
    } finally {
        generalLock.readLock().unlock();
    }
    return new TransactionResult(txId, TransactionResult.OutcomeType.COMMIT);
}
Also used : TransactionResult(herddb.model.TransactionResult) Transaction(herddb.model.Transaction) CommitLogResult(herddb.log.CommitLogResult) LogEntry(herddb.log.LogEntry) DumpedLogEntry(herddb.backup.DumpedLogEntry) StatementExecutionException(herddb.model.StatementExecutionException) HDBException(herddb.client.HDBException) IndexAlreadyExistsException(herddb.model.IndexAlreadyExistsException) LogNotAvailableException(herddb.log.LogNotAvailableException) ClientSideMetadataProviderException(herddb.client.ClientSideMetadataProviderException) IndexDoesNotExistException(herddb.model.IndexDoesNotExistException) FullRecoveryNeededException(herddb.log.FullRecoveryNeededException) TableAlreadyExistsException(herddb.model.TableAlreadyExistsException) TimeoutException(java.util.concurrent.TimeoutException) DataStorageManagerException(herddb.storage.DataStorageManagerException) TableDoesNotExistException(herddb.model.TableDoesNotExistException) DDLException(herddb.model.DDLException) StatementExecutionException(herddb.model.StatementExecutionException) EOFException(java.io.EOFException) MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException)

Example 24 with StatementExecutionException

use of herddb.model.StatementExecutionException in project herddb by diennea.

the class TableSpaceManager method createIndex.

private StatementExecutionResult createIndex(CreateIndexStatement statement, Transaction transaction) throws StatementExecutionException {
    generalLock.writeLock().lock();
    try {
        if (indexes.containsKey(statement.getIndexefinition().name)) {
            throw new IndexAlreadyExistsException(statement.getIndexefinition().name);
        }
        LogEntry entry = LogEntryFactory.createIndex(statement.getIndexefinition(), transaction);
        CommitLogResult pos;
        try {
            pos = log.log(entry, entry.transactionId <= 0);
        } catch (LogNotAvailableException ex) {
            throw new StatementExecutionException(ex);
        }
        apply(pos, entry, false);
        return new DDLStatementExecutionResult(entry.transactionId);
    } catch (DataStorageManagerException err) {
        throw new StatementExecutionException(err);
    } finally {
        generalLock.writeLock().unlock();
    }
}
Also used : DataStorageManagerException(herddb.storage.DataStorageManagerException) IndexAlreadyExistsException(herddb.model.IndexAlreadyExistsException) CommitLogResult(herddb.log.CommitLogResult) DDLStatementExecutionResult(herddb.model.DDLStatementExecutionResult) LogEntry(herddb.log.LogEntry) DumpedLogEntry(herddb.backup.DumpedLogEntry) StatementExecutionException(herddb.model.StatementExecutionException) LogNotAvailableException(herddb.log.LogNotAvailableException)

Example 25 with StatementExecutionException

use of herddb.model.StatementExecutionException in project herddb by diennea.

the class TableSpaceManager method rollbackTransaction.

private StatementExecutionResult rollbackTransaction(RollbackTransactionStatement rollbackTransactionStatement) throws StatementExecutionException {
    long txId = rollbackTransactionStatement.getTransactionId();
    LogEntry entry = LogEntryFactory.rollbackTransaction(txId);
    generalLock.readLock().lock();
    try {
        Transaction tx = transactions.get(txId);
        if (tx == null) {
            throw new StatementExecutionException("no such transaction " + rollbackTransactionStatement.getTransactionId());
        }
        CommitLogResult pos = log.log(entry, true);
        apply(pos, entry, false);
    } catch (Exception err) {
        throw new StatementExecutionException(err);
    } finally {
        generalLock.readLock().unlock();
    }
    return new TransactionResult(txId, TransactionResult.OutcomeType.ROLLBACK);
}
Also used : TransactionResult(herddb.model.TransactionResult) Transaction(herddb.model.Transaction) CommitLogResult(herddb.log.CommitLogResult) LogEntry(herddb.log.LogEntry) DumpedLogEntry(herddb.backup.DumpedLogEntry) StatementExecutionException(herddb.model.StatementExecutionException) HDBException(herddb.client.HDBException) IndexAlreadyExistsException(herddb.model.IndexAlreadyExistsException) LogNotAvailableException(herddb.log.LogNotAvailableException) ClientSideMetadataProviderException(herddb.client.ClientSideMetadataProviderException) IndexDoesNotExistException(herddb.model.IndexDoesNotExistException) FullRecoveryNeededException(herddb.log.FullRecoveryNeededException) TableAlreadyExistsException(herddb.model.TableAlreadyExistsException) TimeoutException(java.util.concurrent.TimeoutException) DataStorageManagerException(herddb.storage.DataStorageManagerException) TableDoesNotExistException(herddb.model.TableDoesNotExistException) DDLException(herddb.model.DDLException) StatementExecutionException(herddb.model.StatementExecutionException) EOFException(java.io.EOFException) MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException)

Aggregations

StatementExecutionException (herddb.model.StatementExecutionException)163 Table (herddb.model.Table)69 ArrayList (java.util.ArrayList)57 DataScanner (herddb.model.DataScanner)49 TransactionContext (herddb.model.TransactionContext)47 DataStorageManagerException (herddb.storage.DataStorageManagerException)40 List (java.util.List)40 DataScannerException (herddb.model.DataScannerException)39 StatementExecutionResult (herddb.model.StatementExecutionResult)39 Column (herddb.model.Column)37 DataAccessor (herddb.utils.DataAccessor)36 LogNotAvailableException (herddb.log.LogNotAvailableException)35 LogEntry (herddb.log.LogEntry)34 Test (org.junit.Test)34 InsertStatement (herddb.model.commands.InsertStatement)32 Bytes (herddb.utils.Bytes)32 CommitLogResult (herddb.log.CommitLogResult)31 Record (herddb.model.Record)31 DMLStatementExecutionResult (herddb.model.DMLStatementExecutionResult)30 Map (java.util.Map)30