Commit eda9bd52 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

merge

parents 931cd8fb 99a4becd
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -22,8 +22,12 @@ class FnordMetric::Reactor
private

  def execute_unsafe(socket, event, messages = [])
    return false unless event["namespace"]
    return false unless ns = @namespaces[event["namespace"].to_sym]
    return [] unless event["namespace"]

    unless ns = @namespaces[event["namespace"].to_sym]
      return([{ "error" => "invalid namespace: #{event["namespace"]}" }])
    end

    messages << discover(ns) if event["type"] == "discover_request"
    messages << widget(ns, event) if event["type"] == "widget_request"
    messages << gauge(ns, event) if event["type"] == "render_request"
+3 −0
Original line number Diff line number Diff line
@@ -29,6 +29,9 @@ class FnordMetric::WebSocket < Rack::WebSocket::Application
        send_data m.to_json
      end
    end
  rescue Exception => e
    FnordMetric.error("[WebSocket] #{e.to_s}")
    puts e.backtrace.join("\n")
  end

  def get_uuid
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ name := "FnordMetric Enterprise"

organization := "com.paulasmuth"

version := "0.0.4"
version := "0.0.5"

mainClass in (Compile, run) := Some("com.fnordmetric.enterprise.FnordMetric")

+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ import scala.collection.mutable.HashMap

object FnordMetric {

  val VERSION = "v0.0.4"
  val VERSION = "v0.0.5"

  val CONFIG  = HashMap[Symbol,String]()

+14 −4
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ class SwapFile(metric_key: MetricKey) {

  // adds a new (time, value) tuple to be written to the swap file
  // but does not write it yet. this method is not thread safe!
  def put(time: Long, value: Double) : Unit = {
  def put(time: Long, value: Double) : Unit = this.synchronized {
    val bvalue = java.lang.Double.doubleToLongBits(value)

    if (buffer.remaining < BLOCK_SIZE)
@@ -46,9 +46,12 @@ class SwapFile(metric_key: MetricKey) {

  // fluhes the queued writes from the buffer to disk. this method
  // is not thread safe!
  def flush : Unit = {
  def flush : Unit = this.synchronized {
    last_flush = FnordMetric.now

    if (buffer.position < BLOCK_SIZE)
      return

    file.synchronized {
      file.seek(write_pos)
      file.write(buffer.array, 0, buffer.position)
@@ -75,12 +78,19 @@ class SwapFile(metric_key: MetricKey) {

      // we need to seek before every read as calls to load_chunk don't
      // have to be synchronized with writes
      file.synchronized {
      val nxt_read = file.synchronized {
        file.seek(position - chunk_size)

        read_pos += file.read(chunk.array, read_pos,
        file.read(chunk.array, read_pos,
          chunk_size - read_pos - 1)
      }

      if (nxt_read >= 0)
        read_pos += nxt_read
      else
        // this should never happen
        FnordMetric.error("end of file reached while reading " + file_name, false)

    }

    read_pos = chunk_size - BLOCK_SIZE
Loading