Skip to content

Commit

Permalink
Merge pull request #792 from modelix/MODELIX-932
Browse files Browse the repository at this point in the history
fix(model-server): fix `IgniteStoreClient.getAll` not returning values for existing entries
  • Loading branch information
odzhychko authored Jun 6, 2024
2 parents 180ca4f + 4ac2181 commit cef7ec7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
13 changes: 13 additions & 0 deletions model-server-test/src/test/kotlin/IgnitePostgresTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue

class IgnitePostgresTest {
lateinit var store: IgniteStoreClient
Expand All @@ -35,6 +36,18 @@ class IgnitePostgresTest {
store.dispose()
}

@Test
fun `can get values for multiple keys when Ignite has not cached the keys yet`() {
// The actual keys are irrelevant for this test.
// A fresh client will have no keys cached.
val keys = listOf("zK4Y2*xIEWlYlQGJL2Va4Z0ESgpWgnSQcOmnPeqt34PA", "zxgZN*oLuudxsu42ppSEGnCib8LkrSvauQk2B6T7AW6o")
.map { ObjectInRepository.global(it) }

val values = store.getAll(keys)

assertTrue(values.filterNotNull().isNotEmpty())
}

@Test
fun `store immutable object in repository`() {
val value = "immutable value " + System.nanoTime()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@

package org.modelix.model.server.store

/**
* A composed key used in the key-value stores to persist model data.
* The key is composed of a [key] and an optional [repositoryId].
* The [repositoryId] is set when an entry is scoped to the repository.
*
* This class is directly used with the Ignite cache (see [IgniteStoreClient]).
* Therefore, the order of fields must be consistent with the configuration of `JdbcType` in ignite.xml.
*/
data class ObjectInRepository(private val repositoryId: String, val key: String) : Comparable<ObjectInRepository> {
fun isGlobal() = repositoryId == ""
fun getRepositoryId() = repositoryId.takeIf { it != "" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,23 @@
<property name="keyType" value="org.modelix.model.server.store.ObjectInRepository"/>
<property name="valueType" value="java.lang.String"/>
<property name="keyFields">
<!-- Order of fields must be consistent with ObjectInRepository -->
<list>
<bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
<property name="databaseFieldType">
<util:constant static-field="java.sql.Types.VARCHAR"/>
</property>
<property name="databaseFieldName" value="key"/>
<property name="databaseFieldName" value="repository"/>
<property name="javaFieldType" value="java.lang.String"/>
<property name="javaFieldName" value="key"/>
<property name="javaFieldName" value="repositoryId"/>
</bean>
<bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
<property name="databaseFieldType">
<util:constant static-field="java.sql.Types.VARCHAR"/>
</property>
<property name="databaseFieldName" value="repository"/>
<property name="databaseFieldName" value="key"/>
<property name="javaFieldType" value="java.lang.String"/>
<property name="javaFieldName" value="repositoryId"/>
<property name="javaFieldName" value="key"/>
</bean>
</list>
</property>
Expand Down

0 comments on commit cef7ec7

Please sign in to comment.