Search in sources :

Example 1 with NamespacedStorage

use of com.bakdata.conquery.io.storage.NamespacedStorage in project conquery by bakdata.

the class XodusStoreFactory method loadNamespacedStores.

private <T extends NamespacedStorage> Queue<T> loadNamespacedStores(String prefix, Function<String, T> creator, Set<String> storesToTest) throws InterruptedException {
    File baseDir = getDirectory().toFile();
    if (baseDir.mkdirs()) {
        log.warn("Had to create Storage Dir at `{}`", baseDir);
    }
    Queue<T> storages = new ConcurrentLinkedQueue<>();
    ExecutorService loaders = Executors.newFixedThreadPool(getNThreads());
    for (File directory : Objects.requireNonNull(baseDir.listFiles((file, name) -> file.isDirectory() && name.startsWith(prefix)))) {
        final String name = directory.getName();
        loaders.submit(() -> {
            try {
                ConqueryMDC.setLocation(directory.toString());
                if (!environmentHasStores(directory, storesToTest)) {
                    log.warn("No valid WorkerStorage found.");
                    return;
                }
                T namespacedStorage = creator.apply(name);
                namespacedStorage.openStores(this);
                log.debug("BEGIN reading Storage");
                namespacedStorage.loadData();
                storages.add(namespacedStorage);
            } catch (Exception e) {
                log.error("Failed reading Storage", e);
            } finally {
                log.debug("DONE reading Storage");
                ConqueryMDC.clearLocation();
            }
        });
    }
    loaders.shutdown();
    while (!loaders.awaitTermination(1, TimeUnit.MINUTES)) {
        log.debug("Waiting for Worker storages to load. {} are already finished.", storages.size());
    }
    log.info("All WorkerStores loaded: {}", storages);
    return storages;
}
Also used : Role(com.bakdata.conquery.models.auth.entities.Role) Dictionary(com.bakdata.conquery.models.dictionary.Dictionary) WorkerStorage(com.bakdata.conquery.io.storage.WorkerStorage) SneakyThrows(lombok.SneakyThrows) MultimapBuilder(com.google.common.collect.MultimapBuilder) IId(com.bakdata.conquery.models.identifiable.ids.IId) EntityIdMap(com.bakdata.conquery.models.identifiable.mapping.EntityIdMap) Import(com.bakdata.conquery.models.datasets.Import) Environment(jetbrains.exodus.env.Environment) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) Valid(javax.validation.Valid) CachedStore(com.bakdata.conquery.io.storage.xodus.stores.CachedStore) ManagedExecution(com.bakdata.conquery.models.execution.ManagedExecution) ToString(lombok.ToString) WeakCachedStore(com.bakdata.conquery.io.storage.xodus.stores.WeakCachedStore) XodusStore(com.bakdata.conquery.io.storage.xodus.stores.XodusStore) Path(java.nio.file.Path) InternalOnly(com.bakdata.conquery.io.jackson.InternalOnly) BiMap(com.google.common.collect.BiMap) Bucket(com.bakdata.conquery.models.events.Bucket) BigStore(com.bakdata.conquery.io.storage.xodus.stores.BigStore) NamespacedStorage(com.bakdata.conquery.io.storage.NamespacedStorage) CPSType(com.bakdata.conquery.io.cps.CPSType) With(lombok.With) NonNull(lombok.NonNull) Collection(java.util.Collection) Table(com.bakdata.conquery.models.datasets.Table) FormConfig(com.bakdata.conquery.models.forms.configs.FormConfig) Concept(com.bakdata.conquery.models.datasets.concepts.Concept) Set(java.util.Set) Validator(javax.validation.Validator) Min(javax.validation.constraints.Min) NotNull(javax.validation.constraints.NotNull) User(com.bakdata.conquery.models.auth.entities.User) Executors(java.util.concurrent.Executors) Sets(com.google.common.collect.Sets) Dataset(com.bakdata.conquery.models.datasets.Dataset) Objects(java.util.Objects) SecondaryIdDescription(com.bakdata.conquery.models.datasets.SecondaryIdDescription) List(java.util.List) FileUtil(com.bakdata.conquery.util.io.FileUtil) Slf4j(lombok.extern.slf4j.Slf4j) CBlock(com.bakdata.conquery.models.events.CBlock) Jackson(com.bakdata.conquery.io.jackson.Jackson) Queue(java.util.Queue) MetaStorage(com.bakdata.conquery.io.storage.MetaStorage) SerializingStore(com.bakdata.conquery.io.storage.xodus.stores.SerializingStore) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) IdentifiableStore(com.bakdata.conquery.io.storage.IdentifiableStore) Setter(lombok.Setter) Getter(lombok.Getter) Environments(jetbrains.exodus.env.Environments) Multimap(com.google.common.collect.Multimap) StoreMappings(com.bakdata.conquery.io.storage.StoreMappings) Function(java.util.function.Function) StoreInfo(com.bakdata.conquery.io.storage.xodus.stores.StoreInfo) Duration(io.dropwizard.util.Duration) SingletonStore(com.bakdata.conquery.io.storage.xodus.stores.SingletonStore) Multimaps(com.google.common.collect.Multimaps) HashSet(java.util.HashSet) Injectable(com.bakdata.conquery.io.jackson.Injectable) NamespaceStorage(com.bakdata.conquery.io.storage.NamespaceStorage) MutableInjectableValues(com.bakdata.conquery.io.jackson.MutableInjectableValues) WorkerInformation(com.bakdata.conquery.models.worker.WorkerInformation) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) ManagerNode(com.bakdata.conquery.commands.ManagerNode) ExecutorService(java.util.concurrent.ExecutorService) Nullable(javax.annotation.Nullable) Group(com.bakdata.conquery.models.auth.entities.Group) ConqueryMDC(com.bakdata.conquery.util.io.ConqueryMDC) ShardNode(com.bakdata.conquery.commands.ShardNode) WorkerToBucketsMap(com.bakdata.conquery.models.worker.WorkerToBucketsMap) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) File(java.io.File) Store(com.bakdata.conquery.io.storage.Store) TimeUnit(java.util.concurrent.TimeUnit) HashBiMap(com.google.common.collect.HashBiMap) StructureNode(com.bakdata.conquery.models.datasets.concepts.StructureNode) DatasetRegistry(com.bakdata.conquery.models.worker.DatasetRegistry) AllArgsConstructor(lombok.AllArgsConstructor) NoArgsConstructor(lombok.NoArgsConstructor) ExecutorService(java.util.concurrent.ExecutorService) ToString(lombok.ToString) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) File(java.io.File) IOException(java.io.IOException)

Aggregations

ManagerNode (com.bakdata.conquery.commands.ManagerNode)1 ShardNode (com.bakdata.conquery.commands.ShardNode)1 CPSType (com.bakdata.conquery.io.cps.CPSType)1 Injectable (com.bakdata.conquery.io.jackson.Injectable)1 InternalOnly (com.bakdata.conquery.io.jackson.InternalOnly)1 Jackson (com.bakdata.conquery.io.jackson.Jackson)1 MutableInjectableValues (com.bakdata.conquery.io.jackson.MutableInjectableValues)1 IdentifiableStore (com.bakdata.conquery.io.storage.IdentifiableStore)1 MetaStorage (com.bakdata.conquery.io.storage.MetaStorage)1 NamespaceStorage (com.bakdata.conquery.io.storage.NamespaceStorage)1 NamespacedStorage (com.bakdata.conquery.io.storage.NamespacedStorage)1 Store (com.bakdata.conquery.io.storage.Store)1 StoreMappings (com.bakdata.conquery.io.storage.StoreMappings)1 WorkerStorage (com.bakdata.conquery.io.storage.WorkerStorage)1 BigStore (com.bakdata.conquery.io.storage.xodus.stores.BigStore)1 CachedStore (com.bakdata.conquery.io.storage.xodus.stores.CachedStore)1 SerializingStore (com.bakdata.conquery.io.storage.xodus.stores.SerializingStore)1 SingletonStore (com.bakdata.conquery.io.storage.xodus.stores.SingletonStore)1 StoreInfo (com.bakdata.conquery.io.storage.xodus.stores.StoreInfo)1 WeakCachedStore (com.bakdata.conquery.io.storage.xodus.stores.WeakCachedStore)1