Repository: incubator-htrace
Updated Branches:
  refs/heads/master 4ca86d941 -> db4394d83


HTRACE-123. Fix graphviz functionality in the htrace command (cmccabe)


Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/db4394d8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/db4394d8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/db4394d8

Branch: refs/heads/master
Commit: db4394d835c24f4079a4eed318a729a12bb92a05
Parents: 4ca86d9
Author: Colin P. Mccabe <[email protected]>
Authored: Fri Feb 27 14:09:20 2015 -0800
Committer: Colin P. Mccabe <[email protected]>
Committed: Fri Feb 27 14:15:46 2015 -0800

----------------------------------------------------------------------
 htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go       | 8 ++++----
 htrace-core/src/go/src/org/apache/htrace/htrace/graph.go     | 6 +++++-
 .../src/go/src/org/apache/htrace/htrace/graph_test.go        | 3 ++-
 3 files changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/db4394d8/htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go
----------------------------------------------------------------------
diff --git a/htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go 
b/htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go
index 290984e..ef7b43f 100644
--- a/htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go
+++ b/htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go
@@ -70,14 +70,14 @@ func main() {
        loadFile := app.Command("loadFile", "Write whitespace-separated JSON 
spans from a file to the server.")
        loadFilePath := loadFile.Arg("path",
                "A file containing whitespace-separated span 
JSON.").Required().String()
+       loadJson := app.Command("load", "Write JSON spans from the command-line 
to the server.")
+       loadJsonArg := loadJson.Arg("json", "A JSON span to write to the 
server.").Required().String()
        dumpAll := app.Command("dumpAll", "Dump all spans from the htraced 
daemon.")
-       dumpAllOutPath := dumpAll.Flag("path", "The path to dump the trace 
spans to.").Default("-").String()
+       dumpAllOutPath := dumpAll.Arg("path", "The path to dump the trace spans 
to.").Default("-").String()
        dumpAllLim := dumpAll.Flag("lim", "The number of spans to transfer from 
the server at once.").
                Default("100").Int()
-       loadJson := app.Command("load", "Write JSON spans from the command-line 
to the server.")
-       loadJsonArg := loadJson.Arg("json", "A JSON span to write to the 
server.").Required().String()
        graph := app.Command("graph", "Visualize span JSON as a graph.")
-       graphJsonFile := graph.Flag("input", "The JSON file to 
load").Required().String()
+       graphJsonFile := graph.Arg("input", "The JSON file to 
load").Required().String()
        graphDotFile := graph.Flag("output",
                "The path to write a GraphViz dotfile to.  This file can be 
used as input to "+
                        "GraphViz, in order to generate a pretty picture.  See 
graphviz.org for more "+

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/db4394d8/htrace-core/src/go/src/org/apache/htrace/htrace/graph.go
----------------------------------------------------------------------
diff --git a/htrace-core/src/go/src/org/apache/htrace/htrace/graph.go 
b/htrace-core/src/go/src/org/apache/htrace/htrace/graph.go
index 36951de..dabf2df 100644
--- a/htrace-core/src/go/src/org/apache/htrace/htrace/graph.go
+++ b/htrace-core/src/go/src/org/apache/htrace/htrace/graph.go
@@ -52,6 +52,10 @@ func jsonSpanFileToDotFile(jsonFile string, dotFile string) 
error {
        if err != nil {
                return err
        }
+       err = writer.Flush()
+       if err != nil {
+               return err
+       }
        err = file.Close()
        file = nil
        return err
@@ -107,6 +111,6 @@ func spansToDot(spans common.SpanSlice, writer io.Writer) 
error {
                        }
                }
        }
-       w.Printf("}")
+       w.Printf("}\n")
        return w.Error()
 }

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/db4394d8/htrace-core/src/go/src/org/apache/htrace/htrace/graph_test.go
----------------------------------------------------------------------
diff --git a/htrace-core/src/go/src/org/apache/htrace/htrace/graph_test.go 
b/htrace-core/src/go/src/org/apache/htrace/htrace/graph_test.go
index 3003b3f..8698a98 100644
--- a/htrace-core/src/go/src/org/apache/htrace/htrace/graph_test.go
+++ b/htrace-core/src/go/src/org/apache/htrace/htrace/graph_test.go
@@ -76,7 +76,8 @@ func TestSpansToDot(t *testing.T) {
   "e2c7273efb280a8c" [label="ClientNamenodeProtocol#getBlockLocations"];
   "6af3cc058e5d829d" -> "75d16cc5b2c07d8a";
   "75d16cc5b2c07d8a" -> "e2c7273efb280a8c";
-}`
+}
+`
        if w.String() != EXPECTED_STR {
                t.Fatalf("Expected to get:\n%s\nGot:\n%s\n", EXPECTED_STR, 
w.String())
        }

Reply via email to