func main() { if len(os.Args) != 3 { println("Usage:", os.Args[0], "AnchorPath Service") os.Exit(1) } file, err := anchorfs.OpenFile(os.Args[1]) if err != nil { fmt.Fprintf(os.Stderr, "Problem opening (%s)", err) os.Exit(1) } x, err := circuit.TryDial(file.Owner(), "acid") if err != nil { fmt.Fprintf(os.Stderr, "Problem dialing 'acid' service (%s)", err) os.Exit(1) } defer func() { if p := recover(); p != nil { fmt.Fprintf(os.Stderr, "Worker disappeared during call (%#v)", p) os.Exit(1) } }() r := x.Call("OnBehalfCallStringer", os.Args[2], "Stat") fmt.Println(r[0].(string)) }
func tailViaCircuit(addr circuit.Addr, jailpath string) { x, err := circuit.TryDial(addr, "acid") if err != nil { fmt.Fprintf(os.Stderr, "Problem dialing 'acid' service (%s)", err) os.Exit(1) } defer func() { if p := recover(); p != nil { fmt.Fprintf(os.Stderr, "Worker disappeared during call (%#v)", p) os.Exit(1) } }() r := x.Call("JailTail", jailpath) if r[1] != nil { fmt.Fprintf(os.Stderr, "Open problem: %s\n", r[1].(error)) os.Exit(1) } io.Copy(os.Stdout, teleio.NewClient(r[0].(circuit.X))) /* tailr := teleio.NewClient(r[0].(circuit.X)) for { p := make([]byte, 1e3) n, err := tailr.Read(p) if err != nil { println(err.Error(),"+++") break } println("n=", n) }*/ }
func main() { if len(os.Args) != 2 { println("Usage:", os.Args[0], "AnchorPath") os.Exit(1) } file, err := anchorfs.OpenFile(os.Args[1]) if err != nil { log.Printf("Problem opening (%s)", err) os.Exit(1) } x, err := circuit.TryDial(file.Owner(), "acid") if err != nil { log.Printf("Problem dialing acid service (%s)", err) os.Exit(1) } defer func() { if p := recover(); p != nil { log.Printf("Worker disappeared during call (%#v)", p) os.Exit(1) } }() retrn := x.Call("RuntimeProfile", "goroutine", 1) if err, ok := retrn[1].(error); ok && err != nil { log.Printf("Problem obtaining runtime profile (%s)", err) os.Exit(1) } fmt.Println(string(retrn[0].([]byte))) }
func topFile(anchor string, id circuit.WorkerID, addr circuit.Addr) { x, err := circuit.TryDial(addr, "acid") if err != nil { fmt.Fprintf(os.Stderr, "Problem dialing acid service (%s)", err) os.Exit(1) } defer func() { if p := recover(); p != nil { fmt.Fprintf(os.Stderr, "%40s: Worker disappeared during call (%#v)\n", anchor, p) os.Exit(1) } }() r := x.Call("Stat")[0].(*acid.Stat) fmt.Printf("%40s: user=%s sys=%s #malloc=%d #free=%d\n", anchor, FormatBytes(r.MemStats.Alloc), FormatBytes(r.MemStats.Sys), r.MemStats.Mallocs, r.MemStats.Frees, ) }
func main() { if len(os.Args) != 3 { println("Usage:", os.Args[0], "AnchorPath DurationSeconds") os.Exit(1) } // Parse duration dursec, err := strconv.Atoi(os.Args[2]) if err != nil { fmt.Fprintf(os.Stderr, "Problem parsing duration (%s)\n", err) os.Exit(1) } dur := time.Duration(int64(dursec) * 1e9) // Find anchor file file, err := anchorfs.OpenFile(os.Args[1]) if err != nil { fmt.Fprintf(os.Stderr, "Problem opening (%s)\n", err) os.Exit(1) } x, err := circuit.TryDial(file.Owner(), "acid") if err != nil { fmt.Fprintf(os.Stderr, "Problem dialing acid service (%s)\n", err) os.Exit(1) } defer func() { if p := recover(); p != nil { fmt.Fprintf(os.Stderr, "Worker disappeared during call (%#v)\n", p) os.Exit(1) } }() // Connect to worker retrn := x.Call("CPUProfile", dur) if err, ok := retrn[1].(error); ok && err != nil { fmt.Fprintf(os.Stderr, "Problem obtaining CPU profile (%s)\n", err) os.Exit(1) } fmt.Println(string(retrn[0].([]byte))) }
func getReducerTop(addr circuit.Addr, lk *sync.Mutex, top *SortablePosts) { // Obtain cross-runtime pointer to reducer service on the worker owning file f x, err := circuit.TryDial(addr, "reducer-service") if err != nil { println("dial", addr.String(), "error", err.Error()) // Skip reducers that seem to be dead return } // Catch panics due to dead worker and return empty list of top ten posts in this case defer func() { if p := recover(); p != nil { fmt.Fprintf(os.Stderr, "%s.Top panic: %#v\n", x.String(), p) } }() // Fetch top ten posts rtop := x.Call("Top")[0].([]*Post) lk.Lock() defer lk.Unlock() println("Reducer", addr.String(), "contributed", len(rtop), "posts") (*top) = append(*top, rtop...) }