Search in sources :

Example 61 with StoreException

use of org.apache.qpid.server.store.StoreException in project qpid-broker-j by apache.

the class JDBCLinkStore method doDeleteLink.

@Override
protected void doDeleteLink(final LinkDefinition<Source, Target> link) throws StoreException {
    try (Connection connection = getConnection();
        PreparedStatement preparedStatement = connection.prepareStatement(String.format("DELETE FROM %s WHERE link_key = ?", getLinksTableName()))) {
        preparedStatement.setString(1, generateLinkKey(link));
        preparedStatement.execute();
    } catch (SQLException e) {
        throw new StoreException(String.format("Cannot delete link %s", new LinkKey(link)), e);
    }
}
Also used : LinkKey(org.apache.qpid.server.protocol.v1_0.LinkKey) SQLException(java.sql.SQLException) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) StoreException(org.apache.qpid.server.store.StoreException)

Example 62 with StoreException

use of org.apache.qpid.server.store.StoreException in project qpid-broker-j by apache.

the class BDBConfigurationStore method closeEnvironment.

private void closeEnvironment() {
    if (_environmentFacade != null) {
        try {
            _environmentFacade.close();
            _environmentFacade = null;
        } catch (RuntimeException e) {
            throw new StoreException("Exception occurred on message store close", e);
        }
    }
}
Also used : StoreException(org.apache.qpid.server.store.StoreException)

Example 63 with StoreException

use of org.apache.qpid.server.store.StoreException in project qpid-broker-j by apache.

the class BDBConfigurationStore method update.

private void update(boolean createIfNecessary, ConfiguredObjectRecord record, com.sleepycat.je.Transaction txn) throws StoreException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Updating, creating " + createIfNecessary + " : " + record);
    }
    DatabaseEntry key = new DatabaseEntry();
    UUIDTupleBinding keyBinding = UUIDTupleBinding.getInstance();
    keyBinding.objectToEntry(record.getId(), key);
    DatabaseEntry value = new DatabaseEntry();
    DatabaseEntry newValue = new DatabaseEntry();
    ConfiguredObjectBinding configuredObjectBinding = ConfiguredObjectBinding.getInstance();
    OperationStatus status = getConfiguredObjectsDb().get(txn, key, value, LockMode.DEFAULT);
    final boolean isNewRecord = status == OperationStatus.NOTFOUND;
    if (status == OperationStatus.SUCCESS || (createIfNecessary && isNewRecord)) {
        // write the updated entry to the store
        configuredObjectBinding.objectToEntry(record, newValue);
        status = getConfiguredObjectsDb().put(txn, key, newValue);
        if (status != OperationStatus.SUCCESS) {
            throw new StoreException("Error updating configuration details within the store: " + status);
        }
        if (isNewRecord) {
            writeHierarchyRecords(txn, record);
        }
    } else if (status != OperationStatus.NOTFOUND) {
        throw new StoreException("Error finding configuration details within the store: " + status);
    }
}
Also used : ConfiguredObjectBinding(org.apache.qpid.server.store.berkeleydb.tuple.ConfiguredObjectBinding) OperationStatus(com.sleepycat.je.OperationStatus) UUIDTupleBinding(org.apache.qpid.server.store.berkeleydb.tuple.UUIDTupleBinding) DatabaseEntry(com.sleepycat.je.DatabaseEntry) StoreException(org.apache.qpid.server.store.StoreException)

Example 64 with StoreException

use of org.apache.qpid.server.store.StoreException in project qpid-broker-j by apache.

the class BDBMessageStore method doClose.

@Override
protected void doClose() {
    if (_environmentFacade != null) {
        try {
            _environmentFacade.close();
            _environmentFacade = null;
        } catch (RuntimeException e) {
            throw new StoreException("Exception occurred on message store close", e);
        }
    }
}
Also used : StoreException(org.apache.qpid.server.store.StoreException)

Example 65 with StoreException

use of org.apache.qpid.server.store.StoreException in project qpid-broker-j by apache.

the class ConfiguredObjectBinding method entryToObject.

@Override
public BDBConfiguredObjectRecord entryToObject(TupleInput tupleInput) {
    String type = tupleInput.readString();
    String json = tupleInput.readString();
    ObjectMapper mapper = new ObjectMapper();
    try {
        Map<String, Object> value = mapper.readValue(json, Map.class);
        BDBConfiguredObjectRecord configuredObject = new BDBConfiguredObjectRecord(_uuid, type, value);
        return configuredObject;
    } catch (IOException e) {
        // should never happen
        throw new StoreException(e);
    }
}
Also used : BDBConfiguredObjectRecord(org.apache.qpid.server.store.berkeleydb.BDBConfiguredObjectRecord) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) StoreException(org.apache.qpid.server.store.StoreException)

Aggregations

StoreException (org.apache.qpid.server.store.StoreException)70 SQLException (java.sql.SQLException)28 Connection (java.sql.Connection)23 PreparedStatement (java.sql.PreparedStatement)21 DatabaseEntry (com.sleepycat.je.DatabaseEntry)20 IOException (java.io.IOException)18 OperationStatus (com.sleepycat.je.OperationStatus)13 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)10 ResultSet (java.sql.ResultSet)10 UUID (java.util.UUID)8 Database (com.sleepycat.je.Database)7 ByteArrayInputStream (java.io.ByteArrayInputStream)7 HashMap (java.util.HashMap)7 Map (java.util.Map)7 ModelVersion (org.apache.qpid.server.model.ModelVersion)7 LinkKey (org.apache.qpid.server.protocol.v1_0.LinkKey)7 HashSet (java.util.HashSet)5 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)5 Cursor (com.sleepycat.je.Cursor)4 DatabaseConfig (com.sleepycat.je.DatabaseConfig)4