Skip to content

Commit 222b005

Browse files
authored
Make metadata getAll fetch limit configurable (#209)
1 parent ec7de3b commit 222b005

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

engine/src/main/kotlin/com/kakao/actionbase/v2/engine/Graph.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ class Graph(
174174

175175
val encoderPoolSize = config.encoderPoolSize
176176

177+
val metadataFetchLimit = config.metadataFetchLimit
178+
177179
init {
178180
if (config.metastoreReloadInitialDelay != null && config.metastoreReloadInterval != null) {
179181
startMetastoreReload(config.metastoreReloadInitialDelay, config.metastoreReloadInterval, log)
@@ -834,10 +836,7 @@ class Graph(
834836
return onlineMetadataLabel.mutate(edges, EdgeOperation.INSERT, bulk = true).then()
835837
}
836838

837-
@Suppress("ForbiddenComment")
838839
private fun getOnlineMetadata(type: MetadataType): Mono<List<RowWithSchema>> {
839-
// TODO: use configuration or pagination
840-
val sufficientFetchSize = 1000
841840
val bound = Duration.ofMinutes(2)
842841
val lastTs = System.currentTimeMillis() - bound.toMillis()
843842

@@ -846,7 +845,7 @@ class Graph(
846845
name = Metadata.onlineMetadataLabelV2Entity.name,
847846
srcSet = setOf(MetadataSyncEntity.Src(phase, type).toCompositeKey()),
848847
indexName = Metadata.onlineMetadataLabelV2Entity.indices[0].name,
849-
limit = sufficientFetchSize,
848+
limit = metadataFetchLimit,
850849
)
851850

852851
return singleStepQuery(scanFilter, emptySet())

engine/src/main/kotlin/com/kakao/actionbase/v2/engine/GraphConfig.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.kakao.actionbase.v2.engine
22

33
import com.kakao.actionbase.v2.engine.entity.DefaultStorageEntity
4+
import com.kakao.actionbase.v2.engine.service.ddl.DdlService
45
import com.kakao.actionbase.v2.engine.warmup.WarmUpConfig
56

67
import java.net.InetAddress
@@ -31,6 +32,7 @@ data class GraphConfig(
3132
// Aligned with nginx.conf proxy_read_timeout 300
3233
val mutationRequestTimeout: Long = 300_000,
3334
val hbase: Map<String, String> = emptyMap(),
35+
val metadataFetchLimit: Int = DdlService.DEFAULT_METADATA_LIMIT,
3436
) {
3537
companion object {
3638
val builder: Builder
@@ -58,6 +60,7 @@ data class GraphConfig(
5860
private var warmUp: WarmUpConfig = WarmUpConfig()
5961
private var artifactInfo: String? = null
6062
private var hbase: Map<String, String> = emptyMap()
63+
private var metadataFetchLimit: Int = DdlService.DEFAULT_METADATA_LIMIT
6164

6265
// Aligned with nginx.conf proxy_read_timeout 300
6366
private var mutationRequestTimeout: Long = 300_000
@@ -110,6 +113,12 @@ data class GraphConfig(
110113

111114
fun withHBase(hbase: Map<String, String>) = apply { this.hbase = hbase }
112115

116+
fun withMetadataFetchLimit(limit: Int) =
117+
apply {
118+
require(limit > 0) { "ddlFetchLimit must be positive, got $limit" }
119+
this.metadataFetchLimit = limit
120+
}
121+
113122
fun build(): GraphConfig =
114123
GraphConfig(
115124
phase = phase,
@@ -133,6 +142,7 @@ data class GraphConfig(
133142
artifactInfo = artifactInfo,
134143
mutationRequestTimeout = mutationRequestTimeout,
135144
hbase = hbase,
145+
metadataFetchLimit = metadataFetchLimit,
136146
)
137147
}
138148
}

engine/src/main/kotlin/com/kakao/actionbase/v2/engine/service/ddl/DdlService.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ abstract class DdlService<Entity : EdgeEntity, Create : DdlRequest, Update : Ddl
2525
protected val graph: Graph,
2626
private val label: Label,
2727
private val factory: EntityFactory<Entity>,
28-
private val limit: Int = DEFAULT_METADATA_LIMIT,
2928
) {
3029
fun createMetadataOnlyForTest(
3130
name: EntityName,
@@ -171,7 +170,7 @@ abstract class DdlService<Entity : EdgeEntity, Create : DdlRequest, Update : Ddl
171170
ScanFilter(
172171
name = label.name,
173172
srcSet = setOf(name.phaseServiceName),
174-
limit = limit,
173+
limit = graph.metadataFetchLimit,
175174
)
176175
return label
177176
.scan(scanFilter, emptySet(), EmptyEdgeIdEncoder.INSTANCE)

server/src/main/kotlin/com/kakao/actionbase/server/configuration/GraphConfiguration.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class GraphConfiguration {
8181
.of(infoEndpoint)
8282
withArtifactInfo(artifactInfo.toString())
8383
withHBase(properties.hbase)
84+
properties.metadataFetchLimit?.let { withMetadataFetchLimit(it) }
8485
}
8586
return builder.build()
8687
}

server/src/main/kotlin/com/kakao/actionbase/server/configuration/GraphProperties.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ data class GraphProperties(
3030
val allowMirror: Boolean = false,
3131
val mutationRequestTimeout: Long?,
3232
val hbase: Map<String, String> = emptyMap(),
33+
val metadataFetchLimit: Int?,
3334
)

0 commit comments

Comments
 (0)