Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ case class CleanupPathMsg(path: String)
case class RenamePathMsg(dbName: String)
case class CleanupDbMsg(dbName: String, activeSigs: List[String])
case class DiskSizeMsg(path: String)
case class CloseLRUByPathMsg(path: String)

case class Group1Msg(query: String, field: String, refresh: Boolean, groupSort: Any, groupOffset: Int,
groupLimit: Int)
Expand Down Expand Up @@ -92,6 +93,8 @@ object ClouseauTypeFactory extends TypeFactory {
Some(DeleteDocMsg(reader.readAs[String]))
case ('disk_size, 2) =>
Some(DiskSizeMsg(reader.readAs[String]))
case ('close_lru_by_path, 2) =>
Some(CloseLRUByPathMsg(reader.readAs[String]))
case ('commit, 2) =>
Some(CommitMsg(toLong(reader.readTerm)))
case ('set_update_seq, 2) =>
Expand Down
12 changes: 12 additions & 0 deletions src/main/scala/com/cloudant/clouseau/IndexManagerService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ class IndexManagerService(ctx: ServiceContext[ConfigurationArgs]) extends Servic
}
}

def closeByPath(path: String) {
pidToPath foreach {
kv =>
if (kv._2.startsWith(path)) {
logger.info("closing lru for " + path)
kv._1 ! ('close, 'closing)
}
}
}
}

val logger = Logger.getLogger("clouseau.main")
Expand Down Expand Up @@ -124,6 +133,9 @@ class IndexManagerService(ctx: ServiceContext[ConfigurationArgs]) extends Servic
case 'close_lru =>
lru.close()
'ok
case CloseLRUByPathMsg(path: String) =>
lru.closeByPath(path)
'ok
case 'version =>
('ok, getClass.getPackage.getImplementationVersion)
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/scala/com/cloudant/clouseau/IndexService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ class IndexService(ctx: ServiceContext[IndexServiceArgs]) extends Service(ctx) w
ctx.args.writer.rollback()
} catch {
case e: AlreadyClosedException => 'ignored
case e: IOException => warn("Error while closing writer", e)
case e: IOException =>
warn("Error while closing writer", e)
ctx.args.writer.close()
} finally {
super.exit(msg)
}
Expand Down