From 1d96e6de9b7287e8c2e9a46e70153e35d0030364 Mon Sep 17 00:00:00 2001 From: Leonid Stryuk Date: Wed, 27 Nov 2024 11:42:51 +0100 Subject: [PATCH] XD-1086 some more code removed from interfaces --- .../PersistentEntityStoreImpl.java | 47 ++++++++++++--- .../iterate/EntityIterableBase.java | 2 +- .../orientdb/OPersistentEntityStore.kt | 23 -------- .../entitystore/PersistentEntityStore.java | 59 ------------------- 4 files changed, 41 insertions(+), 90 deletions(-) diff --git a/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java b/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java index 32152cb7a..a80f56e67 100644 --- a/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java +++ b/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java @@ -23,6 +23,8 @@ import jetbrains.exodus.core.dataStructures.hash.HashSet; import jetbrains.exodus.core.dataStructures.hash.IntHashMap; import jetbrains.exodus.core.dataStructures.hash.IntHashSet; +import jetbrains.exodus.core.execution.JobProcessor; +import jetbrains.exodus.core.execution.MultiThreadDelegatingJobProcessor; import jetbrains.exodus.crypto.EncryptedBlobVault; import jetbrains.exodus.crypto.StreamCipherProvider; import jetbrains.exodus.entitystore.PersistentStoreTransaction.TransactionType; @@ -721,7 +723,13 @@ public ArrayList ensureBlobsConsistency(final PersistentStoreTransaction return result; } - @Override + /** + * Clears all the data in the {@code PersistentEntityStore}. It is safe to clear {@code PersistentEntityStore} + * with lots of parallel transactions. Make sure all {@linkplain java.io.InputStream} instances got from + * the {@linkplain #getBlobVault() blob vault} are closed. + * + * Don't use this method if the underlying {@linkplain Environment} is shared among different entity stores. + */ public void clear() { environment.clear(); allSequences.clear(); @@ -743,10 +751,16 @@ public String getName() { } @NotNull - @Override public PersistentEntityStoreConfig getConfig() { return config; } + /** + * Returns {@linkplain PersistentEntityStoreConfig} instance used during creation of the + * {@code PersistentEntityStore}. If no config was specified and no setting was mutated, then returned config has + * the same settings as {@linkplain PersistentEntityStoreConfig#DEFAULT}. + * + * @return {@linkplain PersistentEntityStoreConfig} instance + */ @Override @NotNull @@ -794,12 +808,14 @@ public List getAllSequences() { } } - @Override + + /** + * @return The number of available bytes on the partition where the database is located + */ public long getUsableSpace() { return new File(location).getUsableSpace(); } - @Override @NotNull public BlobVault getBlobVault() { return blobVault; @@ -2365,20 +2381,37 @@ public Iterable> getBlobFileLengths(@NotNull final PersistentSt return new BlobFileLengthsIterable(txn, fromHandle); } - @Override + /** + * {@linkplain MultiThreadDelegatingJobProcessor Job processor} used by the {@code PersistentEntityStore} for + * background caching activities. Allows to indirectly estimate load of the {@code PersistentEntityStore}. E.g., + * if it has numerous {@linkplain JobProcessor#pendingJobs() pending caching jobs} (say, thousands) then most + * likely caching doesn't work well and the {@code PersistentEntityStore} looks overloaded. + * + * @return job processor used for background caching activities + */ @NotNull public EntityStoreSharedAsyncProcessor getAsyncProcessor() { return iterableCache.getProcessor(); } - @Override + /** + * {@linkplain MultiThreadDelegatingJobProcessor Job processor} used by the {@code PersistentEntityStore} for + * background counts (inconsistent) caching activities. Allows to indirectly estimate load of the {@code PersistentEntityStore}. E.g., + * if it has numerous {@linkplain JobProcessor#pendingJobs() pending caching jobs} (say, thousands) then most + * likely caching doesn't work well and the {@code PersistentEntityStore} looks overloaded. + * + * @return job processor used for background caching activities + */ @NotNull public EntityStoreSharedAsyncProcessor getCountsAsyncProcessor() { return iterableCache.getCountsProcessor(); } + /** + * @return statistics of this {@code PersistentEntityStore} instance + * @see PersistentEntityStoreConfig#GATHER_STATISTICS + */ @NotNull - @Override public Statistics getStatistics() { return statistics; } diff --git a/entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/EntityIterableBase.java b/entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/EntityIterableBase.java index 6942a34df..0c3cd6b03 100644 --- a/entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/EntityIterableBase.java +++ b/entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/EntityIterableBase.java @@ -546,7 +546,7 @@ public final CachedInstanceIterable getOrCreateCachedInstance(@NotNull StoreTran } if (cached == null || cached.getHandle().isExpired()) { cached = createCachedInstance(txn); - if (canBeReordered() && !store.getConfig().isReorderingDisabled() && !cached.isSortedById()) { + if (canBeReordered() && !((PersistentEntityStoreImpl) store).getConfig().isReorderingDisabled() && !cached.isSortedById()) { cached = cached.orderById(); } if (canBeCached) { diff --git a/entity-store/src/main/kotlin/jetbrains/exodus/entitystore/orientdb/OPersistentEntityStore.kt b/entity-store/src/main/kotlin/jetbrains/exodus/entitystore/orientdb/OPersistentEntityStore.kt index a7f8e7c01..cde645d89 100644 --- a/entity-store/src/main/kotlin/jetbrains/exodus/entitystore/orientdb/OPersistentEntityStore.kt +++ b/entity-store/src/main/kotlin/jetbrains/exodus/entitystore/orientdb/OPersistentEntityStore.kt @@ -19,10 +19,7 @@ import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal import com.orientechnologies.orient.core.db.ODatabaseSession import jetbrains.exodus.backup.BackupStrategy import jetbrains.exodus.bindings.ComparableBinding -import jetbrains.exodus.core.execution.MultiThreadDelegatingJobProcessor import jetbrains.exodus.entitystore.* -import jetbrains.exodus.management.Statistics -import java.io.File class OPersistentEntityStore( private val databaseProvider: ODatabaseProvider, @@ -30,9 +27,6 @@ class OPersistentEntityStore( private val schemaBuddy: OSchemaBuddy = OSchemaBuddyImpl(databaseProvider) ) : PersistentEntityStore, OEntityStore { - private val config = PersistentEntityStoreConfig() - private val dummyJobProcessor = object : MultiThreadDelegatingJobProcessor("dummy", 1) {} - private val dummyStatistics = object : Statistics>(arrayOf()) {} private val currentTransaction = ThreadLocal() override fun close() { @@ -112,10 +106,6 @@ class OPersistentEntityStore( return object : BackupStrategy() {} } - override fun clear() { - throw IllegalStateException("Should not ever be called") - } - override fun executeInTransaction(executable: StoreTransactionalExecutable) { computeInTransaction { tx -> executable.execute(tx) @@ -147,8 +137,6 @@ class OPersistentEntityStore( override fun computeInReadonlyTransaction(computable: StoreTransactionalComputable) = computeInTransaction(computable) - override fun getBlobVault() = DummyBlobVault(config) - override fun registerCustomPropertyType( txn: StoreTransaction, clazz: Class>, @@ -177,22 +165,11 @@ class OPersistentEntityStore( currentTx.renameOClass(oldEntityTypeName, newEntityTypeName) } - override fun getUsableSpace(): Long { - return File(location).usableSpace - } - - override fun getConfig(): PersistentEntityStoreConfig = config - - override fun getAsyncProcessor() = dummyJobProcessor - - override fun getStatistics() = dummyStatistics override fun getAndCheckCurrentTransaction(): StoreTransaction { return requireActiveTransaction() } - override fun getCountsAsyncProcessor() = dummyJobProcessor - override fun requireActiveTransaction(): OStoreTransaction { val tx = currentTransaction.get() check(tx != null) { "No active transactions on the current thread" } diff --git a/openAPI/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStore.java b/openAPI/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStore.java index 71f4c44f4..05260b5c9 100644 --- a/openAPI/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStore.java +++ b/openAPI/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStore.java @@ -39,15 +39,6 @@ */ public interface PersistentEntityStore extends EntityStore, Backupable { - /** - * Clears all the data in the {@code PersistentEntityStore}. It is safe to clear {@code PersistentEntityStore} - * with lots of parallel transactions. Make sure all {@linkplain java.io.InputStream} instances got from - * the {@linkplain #getBlobVault() blob vault} are closed. - * - * Don't use this method if the underlying {@linkplain Environment} is shared among different entity stores. - */ - void clear(); - /** * Executes specified executable in a new {@linkplain StoreTransaction transaction}. If transaction cannot be * flushed after {@linkplain StoreTransactionalExecutable#execute(StoreTransaction)} is called, the executable @@ -110,12 +101,6 @@ public interface PersistentEntityStore extends EntityStore, Backupable { */ T computeInReadonlyTransaction(@NotNull StoreTransactionalComputable computable); - /** - * @return {@linkplain BlobVault} which is used for managing blobs - */ - @NotNull - BlobVault getBlobVault(); - /** * Registers custom property type extending {@linkplain Comparable}. Values of specified {@code clazz} can be * passed then to {@linkplain Entity#setProperty(String, Comparable)}. {@code ComparableBinding} describes the @@ -170,50 +155,6 @@ void registerCustomPropertyType(@NotNull final StoreTransaction txn, */ void renameEntityType(@NotNull String oldEntityTypeName, @NotNull String newEntityTypeName); - /** - * @return The number of available bytes on the partition where the database is located - */ - long getUsableSpace(); - - /** - * Returns {@linkplain PersistentEntityStoreConfig} instance used during creation of the - * {@code PersistentEntityStore}. If no config was specified and no setting was mutated, then returned config has - * the same settings as {@linkplain PersistentEntityStoreConfig#DEFAULT}. - * - * @return {@linkplain PersistentEntityStoreConfig} instance - */ - @NotNull - PersistentEntityStoreConfig getConfig(); - - /** - * {@linkplain MultiThreadDelegatingJobProcessor Job processor} used by the {@code PersistentEntityStore} for - * background caching activities. Allows to indirectly estimate load of the {@code PersistentEntityStore}. E.g., - * if it has numerous {@linkplain JobProcessor#pendingJobs() pending caching jobs} (say, thousands) then most - * likely caching doesn't work well and the {@code PersistentEntityStore} looks overloaded. - * - * @return job processor used for background caching activities - */ - @NotNull - MultiThreadDelegatingJobProcessor getAsyncProcessor(); - - /** - * {@linkplain MultiThreadDelegatingJobProcessor Job processor} used by the {@code PersistentEntityStore} for - * background counts (inconsistent) caching activities. Allows to indirectly estimate load of the {@code PersistentEntityStore}. E.g., - * if it has numerous {@linkplain JobProcessor#pendingJobs() pending caching jobs} (say, thousands) then most - * likely caching doesn't work well and the {@code PersistentEntityStore} looks overloaded. - * - * @return job processor used for background caching activities - */ - @NotNull - MultiThreadDelegatingJobProcessor getCountsAsyncProcessor(); - - /** - * @return statistics of this {@code PersistentEntityStore} instance - * @see PersistentEntityStoreConfig#GATHER_STATISTICS - */ - @NotNull - Statistics getStatistics(); - @NotNull StoreTransaction getAndCheckCurrentTransaction(); }