Search in sources :

Example 1 with PartitionStorage

use of org.apache.ignite.internal.storage.PartitionStorage in project ignite-3 by apache.

the class RocksDbTableStorage method dropPartition.

/**
 * {@inheritDoc}
 */
@Override
public void dropPartition(int partId) throws StorageException {
    PartitionStorage partition = getPartition(partId);
    if (partition != null) {
        partitions.set(partId, null);
        partition.destroy();
        meta.removePartitionId(partId);
    }
}
Also used : PartitionStorage(org.apache.ignite.internal.storage.PartitionStorage)

Example 2 with PartitionStorage

use of org.apache.ignite.internal.storage.PartitionStorage in project ignite-3 by apache.

the class RocksDbTableStorage method getOrCreatePartition.

/**
 * {@inheritDoc}
 */
@Override
public PartitionStorage getOrCreatePartition(int partId) throws StorageException {
    PartitionStorage storage = getPartition(partId);
    if (storage != null) {
        return storage;
    }
    // Possible races when creating the partitions with the same ID are safe, since both the storage creation and the meta update
    // are cheap and idempotent.
    storage = new RocksDbPartitionStorage(threadPool, partId, db, partitionCf);
    partitions.set(partId, storage);
    meta.putPartitionId(partId);
    return storage;
}
Also used : PartitionStorage(org.apache.ignite.internal.storage.PartitionStorage)

Example 3 with PartitionStorage

use of org.apache.ignite.internal.storage.PartitionStorage in project ignite-3 by apache.

the class RocksDbTableStorage method stop.

/**
 * {@inheritDoc}
 */
@Override
public void stop() throws StorageException {
    stopped = true;
    List<AutoCloseable> resources = new ArrayList<>();
    resources.addAll(autoCloseables);
    resources.addAll(sortedIndices.values());
    for (int i = 0; i < partitions.length(); i++) {
        PartitionStorage partition = partitions.get(i);
        if (partition != null) {
            resources.add(partition);
        }
    }
    Collections.reverse(resources);
    try {
        IgniteUtils.closeAll(resources);
    } catch (Exception e) {
        throw new StorageException("Failed to stop RocksDB table storage.", e);
    }
}
Also used : ArrayList(java.util.ArrayList) StorageException(org.apache.ignite.internal.storage.StorageException) StorageException(org.apache.ignite.internal.storage.StorageException) RocksDBException(org.rocksdb.RocksDBException) IOException(java.io.IOException) PartitionStorage(org.apache.ignite.internal.storage.PartitionStorage)

Aggregations

PartitionStorage (org.apache.ignite.internal.storage.PartitionStorage)3 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 StorageException (org.apache.ignite.internal.storage.StorageException)1 RocksDBException (org.rocksdb.RocksDBException)1