Rename master_index_id to last_master_index_id

This is consistent with last_container_id and last_key_id in
brute_force_iterator.

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 4 years ago
parent e565b0cb4f
commit 4ca9bcb6d2
  1. 2
      archive/src/main/kotlin/org/openrs2/archive/cache/CacheDownloader.kt
  2. 12
      archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt
  3. 12
      archive/src/main/kotlin/org/openrs2/archive/cache/Js5ChannelHandler.kt
  4. 2
      archive/src/main/kotlin/org/openrs2/archive/game/Game.kt
  5. 8
      archive/src/main/kotlin/org/openrs2/archive/game/GameDatabase.kt
  6. 2
      archive/src/main/resources/org/openrs2/archive/V1__init.sql

@ -30,7 +30,7 @@ public class CacheDownloader @Inject constructor(
hostname, hostname,
port, port,
build, build,
game.previousMasterIndexId, game.lastMasterIndexId,
continuation, continuation,
importer importer
) )

@ -169,7 +169,7 @@ public class CacheImporter @Inject constructor(
uncompressed: ByteBuf, uncompressed: ByteBuf,
gameId: Int, gameId: Int,
build: Int, build: Int,
previousId: Int?, lastId: Int?,
timestamp: Instant, timestamp: Instant,
name: String, name: String,
): Pair<Int, List<ByteBuf?>> { ): Pair<Int, List<ByteBuf?>> {
@ -222,7 +222,7 @@ public class CacheImporter @Inject constructor(
ORDER BY a.archive_id ASC ORDER BY a.archive_id ASC
""".trimIndent() """.trimIndent()
).use { stmt -> ).use { stmt ->
stmt.setObject(1, previousId, Types.INTEGER) stmt.setObject(1, lastId, Types.INTEGER)
stmt.setInt(2, id) stmt.setInt(2, id)
stmt.executeQuery().use { rows -> stmt.executeQuery().use { rows ->
@ -252,7 +252,7 @@ public class CacheImporter @Inject constructor(
index: Js5Index, index: Js5Index,
buf: ByteBuf, buf: ByteBuf,
uncompressed: ByteBuf, uncompressed: ByteBuf,
previousMasterIndexId: Int? lastMasterIndexId: Int?
): List<Int> { ): List<Int> {
return database.execute { connection -> return database.execute { connection ->
prepare(connection) prepare(connection)
@ -284,7 +284,7 @@ public class CacheImporter @Inject constructor(
ORDER BY ig.group_id ASC ORDER BY ig.group_id ASC
""".trimIndent() """.trimIndent()
).use { stmt -> ).use { stmt ->
stmt.setObject(1, previousMasterIndexId, Types.INTEGER) stmt.setObject(1, lastMasterIndexId, Types.INTEGER)
stmt.setInt(2, archive) stmt.setInt(2, archive)
stmt.setLong(3, id) stmt.setLong(3, id)
@ -770,11 +770,11 @@ public class CacheImporter @Inject constructor(
} }
} }
public suspend fun setMasterIndexId(gameId: Int, masterIndexId: Int) { public suspend fun setLastMasterIndexId(gameId: Int, masterIndexId: Int) {
database.execute { connection -> database.execute { connection ->
connection.prepareStatement( connection.prepareStatement(
""" """
UPDATE games SET master_index_id = ? WHERE id = ? UPDATE games SET last_master_index_id = ? WHERE id = ?
""".trimIndent() """.trimIndent()
).use { stmt -> ).use { stmt ->
stmt.setInt(1, masterIndexId) stmt.setInt(1, masterIndexId)

@ -35,7 +35,7 @@ public class Js5ChannelHandler(
private val hostname: String, private val hostname: String,
private val port: Int, private val port: Int,
private var build: Int, private var build: Int,
private val previousMasterIndexId: Int?, private val lastMasterIndexId: Int?,
private val continuation: Continuation<Unit>, private val continuation: Continuation<Unit>,
private val importer: CacheImporter, private val importer: CacheImporter,
private val masterIndexFormat: MasterIndexFormat = MasterIndexFormat.VERSIONED, private val masterIndexFormat: MasterIndexFormat = MasterIndexFormat.VERSIONED,
@ -45,7 +45,7 @@ public class Js5ChannelHandler(
private val maxBuild = build + maxBuildAttempts private val maxBuild = build + maxBuildAttempts
private val inFlightRequests = mutableSetOf<Js5Request.Group>() private val inFlightRequests = mutableSetOf<Js5Request.Group>()
private val pendingRequests = ArrayDeque<Js5Request.Group>() private val pendingRequests = ArrayDeque<Js5Request.Group>()
private var currentMasterIndexId: Int = 0 private var masterIndexId: Int = 0
private var masterIndex: Js5MasterIndex? = null private var masterIndex: Js5MasterIndex? = null
private lateinit var indexes: Array<Js5Index?> private lateinit var indexes: Array<Js5Index?>
private val groups = mutableListOf<CacheImporter.Group>() private val groups = mutableListOf<CacheImporter.Group>()
@ -144,7 +144,7 @@ public class Js5ChannelHandler(
if (complete) { if (complete) {
runBlocking { runBlocking {
importer.setMasterIndexId(gameId, currentMasterIndexId) importer.setLastMasterIndexId(gameId, masterIndexId)
} }
ctx.close() ctx.close()
@ -164,7 +164,7 @@ public class Js5ChannelHandler(
uncompressed, uncompressed,
gameId, gameId,
build, build,
previousMasterIndexId, lastMasterIndexId,
timestamp = Instant.now(), timestamp = Instant.now(),
name name
) )
@ -183,7 +183,7 @@ public class Js5ChannelHandler(
rawIndexes.filterNotNull().forEach(ByteBuf::release) rawIndexes.filterNotNull().forEach(ByteBuf::release)
} }
currentMasterIndexId = id masterIndexId = id
} }
} }
@ -202,7 +202,7 @@ public class Js5ChannelHandler(
} }
val groups = runBlocking { val groups = runBlocking {
importer.importIndexAndGetMissingGroups(archive, index, buf, uncompressed, previousMasterIndexId) importer.importIndexAndGetMissingGroups(archive, index, buf, uncompressed, lastMasterIndexId)
} }
for (group in groups) { for (group in groups) {
request(archive, group) request(archive, group)

@ -5,5 +5,5 @@ public data class Game(
public val hostname: String?, public val hostname: String?,
public val port: Int?, public val port: Int?,
public val build: Int?, public val build: Int?,
public val previousMasterIndexId: Int? public val lastMasterIndexId: Int?
) )

@ -12,7 +12,7 @@ public class GameDatabase @Inject constructor(
return database.execute { connection -> return database.execute { connection ->
connection.prepareStatement( connection.prepareStatement(
""" """
SELECT id, hostname, port, build, master_index_id SELECT id, hostname, port, build, last_master_index_id
FROM games FROM games
WHERE name = ? WHERE name = ?
""".trimIndent() """.trimIndent()
@ -37,12 +37,12 @@ public class GameDatabase @Inject constructor(
build = null build = null
} }
var masterIndexId: Int? = rows.getInt(5) var lastMasterIndexId: Int? = rows.getInt(5)
if (rows.wasNull()) { if (rows.wasNull()) {
masterIndexId = null lastMasterIndexId = null
} }
return@execute Game(id, hostname, port, build, masterIndexId) return@execute Game(id, hostname, port, build, lastMasterIndexId)
} }
} }
} }

@ -108,7 +108,7 @@ CREATE TABLE master_indexes (
UNIQUE (container_id, format) UNIQUE (container_id, format)
); );
ALTER TABLE games ADD COLUMN master_index_id INT NULL REFERENCES master_indexes (id); ALTER TABLE games ADD COLUMN last_master_index_id INT NULL REFERENCES master_indexes (id);
CREATE TABLE master_index_archives ( CREATE TABLE master_index_archives (
master_index_id INTEGER NOT NULL REFERENCES master_indexes (id), master_index_id INTEGER NOT NULL REFERENCES master_indexes (id),

Loading…
Cancel
Save