use of com.bakdata.conquery.io.storage.xodus.stores.XodusStore in project conquery by bakdata.
the class XodusStoreFactory method createStore.
public <KEY, VALUE> Store<KEY, VALUE> createStore(Environment environment, Validator validator, StoreMappings storeId, ObjectMapper objectMapper) {
final StoreInfo<KEY, VALUE> storeInfo = storeId.storeInfo();
synchronized (openStoresInEnv) {
if (openStoresInEnv.get(environment).stream().map(XodusStore::getName).anyMatch(name -> storeInfo.getName().equals(name))) {
throw new IllegalStateException("Attempted to open an already opened store:" + storeInfo.getName());
}
final XodusStore store = new XodusStore(environment, storeInfo.getName(), this::closeStore, this::removeStore);
openStoresInEnv.put(environment, store);
return new CachedStore<>(new SerializingStore<>(store, validator, objectMapper, storeInfo.getKeyType(), storeInfo.getValueType(), this.isValidateOnWrite(), this.isRemoveUnreadableFromStore(), this.getUnreadableDataDumpDirectory()));
}
}
use of com.bakdata.conquery.io.storage.xodus.stores.XodusStore in project conquery by bakdata.
the class XodusStoreFactory method removeStore.
private void removeStore(XodusStore store) {
Environment env = store.getEnvironment();
synchronized (openStoresInEnv) {
Collection<XodusStore> stores = openStoresInEnv.get(env);
stores.remove(store);
if (!stores.isEmpty()) {
return;
}
}
removeEnvironment(env);
}
use of com.bakdata.conquery.io.storage.xodus.stores.XodusStore in project conquery by bakdata.
the class TokenStorage method start.
@Override
public void start() {
String storeName = "api-token";
File tokenStore = new File(storageDir.toFile(), storeName);
environment = Environments.newInstance(tokenStore, storeConfig.createConfig());
final XodusStore data = new XodusStore(environment, "DATA", this::closeStoreHook, this::removeStoreHook);
dataStore = StoreMappings.cached(new SerializingStore<>(data, validator, objectMapper, ApiTokenHash.class, ApiTokenData.class, true, false, null));
openStoresInEnv.add(data);
final XodusStore meta = new XodusStore(environment, "META", this::closeStoreHook, this::removeStoreHook);
metaDataStore = StoreMappings.cached(new SerializingStore<>(meta, validator, objectMapper, UUID.class, ApiTokenData.MetaData.class, true, false, null));
openStoresInEnv.add(meta);
}
use of com.bakdata.conquery.io.storage.xodus.stores.XodusStore in project conquery by bakdata.
the class LocalAuthenticationRealm method onInit.
@Override
protected void onInit() {
super.onInit();
// Open/create the database/store
File passwordStoreFile = new File(storageDir, storeName);
passwordEnvironment = Environments.newInstance(passwordStoreFile, passwordStoreConfig.createConfig());
passwordStore = StoreMappings.cached(new SerializingStore<>(new XodusStore(passwordEnvironment, "passwords", store -> store.getEnvironment().close(), store -> {
}), validator, mapper, UserId.class, PasswordHasher.HashedEntry.class, false, true, null));
}
use of com.bakdata.conquery.io.storage.xodus.stores.XodusStore in project conquery by bakdata.
the class XodusStoreFactory method closeStore.
private void closeStore(XodusStore store) {
Environment env = store.getEnvironment();
synchronized (openStoresInEnv) {
Collection<XodusStore> stores = openStoresInEnv.get(env);
stores.remove(store);
log.info("Closed XodusStore: {}", store);
if (!stores.isEmpty()) {
return;
}
}
log.info("Closed last XodusStore in Environment. Closing Environment as well: {}", env.getLocation());
closeEnvironment(env);
}
Aggregations