object Base { val context_uuid = SQL.Column.string("context_uuid").make_primary_key val context = SQL.Column.long("context").make_primary_key val stopped = SQL.Column.bool("stopped")
val table = make_table(List(context_uuid, context, stopped))
}
object Agents { val agent_uuid = SQL.Column.string("agent_uuid").make_primary_key val context_uuid = SQL.Column.string("context_uuid").make_primary_key val kind = SQL.Column.string("kind") val hostname = SQL.Column.string("hostname") val java_pid = SQL.Column.long("java_pid") val java_start = SQL.Column.date("java_start") val start = SQL.Column.date("start") val stamp = SQL.Column.date("stamp") val stop = SQL.Column.date("stop") val seen = SQL.Column.long("seen")
val table =
make_table(
List(agent_uuid, context_uuid, kind, hostname, java_pid, java_start,
start, stamp, stop, seen),
name = "agents")
}
object Messages { type T = SortedMap[Long, Progress.Message] val empty: T = SortedMap.empty
val context = SQL.Column.long("context").make_primary_key val serial = SQL.Column.long("serial").make_primary_key val kind = SQL.Column.int("kind") val text = SQL.Column.string("text") val verbose = SQL.Column.bool("verbose")
val table = make_table(List(context, serial, kind, text, verbose), name = "messages")
}
val channel: String = Base.table.name val channel_ping: SQL.Notification = SQL.Notification(channel, payload = "ping") val channel_output: SQL.Notification = SQL.Notification(channel, payload = "output")
privatedef sync_context[A](body: => A): A = synchronized { if (_context < 0) thrownew IllegalStateException("Database_Progress before init") if (_context == 0) thrownew IllegalStateException("Database_Progress after exit")
body
}
privatedef sync_database[A](body: => A): A = synchronized {
Database_Progress.private_data.transaction_lock(db, label = "Database_Progress.sync_database") { val stopped_db = Database_Progress.private_data.read_progress_stopped(db, _context)
if (stopped_db && !base_progress.stopped) base_progress.stop() if (!stopped_db && base_progress.stopped) {
Database_Progress.private_data.write_progress_stopped(db, _context, true)
db.send(Database_Progress.private_data.channel_ping)
}
val serial0 = _serial if (input_messages) { val messages = Database_Progress.private_data.read_messages(db, _context, seen = _serial) for ((message_serial, message) <- messages) {
base_progress.output(List(message))
_serial = _serial max message_serial
}
} else {
_serial = _serial max Database_Progress.private_data.read_messages_serial(db, _context)
}
val res = body
if (_serial != serial0) Database_Progress.private_data.update_agent(db, _agent_uuid, _serial)
res
}
}
privatedef sync(): Unit = sync_database {}
overridedef status_output(msgs: Progress.Output): Unit = sync_context { _consumer.send(msgs) }
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.