func (s *Stats) Info() *StatsInfo { s.Refresh() sj := &StatsInfo{ Anteater: s.Anteater, Storage: s.Storage, Env: s.Env, Traffic: map[string]uint64{"in": 0, "out": 0}, TrafficH: map[string]string{"in": "0", "out": "0"}, Allocate: map[string]uint64{"append": 0, "in": 0, "replace": 0}, Counters: map[string]uint64{"add": 0, "get": 0, "delete": 0, "notFound": 0, "notModified": 0}, } sj.Allocate["append"] = s.Allocate.Append.GetValue() sj.Allocate["in"] = s.Allocate.In.GetValue() sj.Allocate["replace"] = s.Allocate.Replace.GetValue() sj.Counters["get"] = s.Counters.Get.GetValue() sj.Counters["add"] = s.Counters.Add.GetValue() sj.Counters["delete"] = s.Counters.Delete.GetValue() sj.Counters["notFound"] = s.Counters.NotFound.GetValue() sj.Counters["notModified"] = s.Counters.NotModified.GetValue() sj.Traffic["in"] = s.Traffic.Input.GetValue() sj.Traffic["out"] = s.Traffic.Output.GetValue() sj.TrafficH["in"] = utils.HumanBytes(int64(sj.Traffic["in"])) sj.TrafficH["out"] = utils.HumanBytes(int64(sj.Traffic["out"])) return sj }
func (c *Container) Print() { if c.last == nil { fmt.Println("EMPTY") return } fmt.Printf("C%d. Size: %s(%s); BI: %d\n", c.Id, utils.HumanBytes(c.Size), utils.HumanBytes(c.FileSize), c.holeIndex.biggestIndex) res := "" var s Space s = c.last i := 0 for s != nil { i++ n := "F" if s.IsFree() { n = "H" if !c.holeIndex.Exists(s.(*Hole)) { n = "E" } } res = fmt.Sprintf("-%s%d-", n, s.Index()) + res s = s.Prev() } fmt.Printf("%s\n", res) }
func (c *Container) Dump() (err error) { c.m.Lock() defer c.m.Unlock() if !c.ch { return } st := time.Now() var i int64 c.FDump = make(map[int64]*File, c.FileCount) c.HDump = make(map[int64]*Hole, c.holeIndex.Count) var last Space = c.last for last != nil && c.last != nil { if last.IsFree() { c.HDump[i] = last.(*Hole) } else { c.FDump[i] = last.(*File) } last = last.Prev() i++ } pr := time.Since(st) n, err := dump.DumpTo(c.indexName(), c) aelog.Debugf("Dump container %d, writed %s for a %v (prep: %v)", c.Id, utils.HumanBytes(n), time.Since(st), pr) c.ch = false return }
func (fs *Files) Upload(conf *config.Config, stor *storage.Storage, r *http.Request, w http.ResponseWriter) (err error) { // make temp files object tmpfs := &TmpFiles{r: r, fields: make(map[string]*temp.File), result: make(map[string]*temp.File), tmpDir: conf.TmpDir} defer tmpfs.Close() // upload for _, f := range *fs { err = f.Upload(tmpfs) if err != nil { return } } result := tmpfs.Result() // add to storage and set stae for name, tf := range result { aelog.Debugf("Uploader add file: %s (%s, %s)", name, utils.HumanBytes(tf.Size), tf.MimeType) file, _ := stor.Add(name, tf.File, tf.Size) for _, f := range *fs { if f.Name == name { f.SetState(file) } } } return }
func (c *RpcCommandStatus) Print() { fmt.Println("Anteater") fmt.Printf(" Start time: %v (uptime: %v)\n Version: %s\n\n", c.Anteater.StartTime, c.Env.Time.Sub(c.Anteater.StartTime), c.Anteater.Version) fmt.Println("Enviroment") fmt.Printf(" Go version: %s\n Server time: %v\n Num goroutines: %d\n Memory allocated: %s\n\n", c.Env.GoVersion, c.Env.Time, c.Env.NumGoroutine, utils.HumanBytes(int64(c.Env.MemAlloc))) fmt.Println("Storage") fmt.Printf(" Containers count: %d\n Files count: %d\n Files size: %s\n Allocated size: %s (profit: %.2f%%)\n Holes: %s (%d)\n Index version: %d\n\n", c.Storage.ContainersCount, c.Storage.FilesCount, utils.HumanBytes(c.Storage.FilesSize), utils.HumanBytes(c.Storage.FilesRealSize), (float64(c.Storage.FilesSize)/float64(c.Storage.FilesRealSize))*100, utils.HumanBytes(c.Storage.HoleSize), c.Storage.HoleCount, c.Storage.IndexVersion) fmt.Println("Counters") fmt.Printf(" Get: %d\n Add: %d\n Delete: %d\n Not found: %d\n Not modified: %d\n\n", c.Counters["get"], c.Counters["add"], c.Counters["delete"], c.Counters["notFound"], c.Counters["notModified"]) fmt.Println("Traffic") fmt.Printf(" In: %s\n Out: %s\n\n", utils.HumanBytes(int64(c.Traffic["in"])), utils.HumanBytes(int64(c.Traffic["out"]))) fmt.Println("Allocates") fmt.Printf(" Append: %d\n Replace: %d\n In hole: %d\n\n", c.Allocate["append"], c.Allocate["replace"], c.Allocate["in"]) }
func (u unZip) OnSave(file *storage.File, w http.ResponseWriter, r *http.Request, s *storage.Storage) (e error) { mode := u.needUnZip(r) if mode == UNZIP_NO { return } aelog.Debugf("UnZip: start unzip(%d) files to: %s (%s)", mode, file.Name, utils.HumanBytes(file.FSize)) if mode == UNZIP_FORCE { s.DeleteChilds(file.Name) } filesCount, filesSize, err := u.unZipTo(file.Name, file, s) if err != nil { aelog.Debugf("UnZip: error: %v", err) w.Header().Add("X-Ae-Unzip-Error", err.Error()) return } aelog.Debugf("UnZip: unziped: %s (%d files, %s files size)", file.Name, filesCount, utils.HumanBytes(filesSize)) w.Header().Add("X-Ae-Unzip-Count", fmt.Sprint(filesCount)) w.Header().Add("X-Ae-Unzip-Size", utils.HumanBytes(filesSize)) return }
func printStats(stat *aerpc.RpcCommandStatus) { if old != nil { get := stat.Counters["get"] - old.Counters["get"] add := stat.Counters["add"] - old.Counters["add"] del := stat.Counters["delete"] - old.Counters["delete"] notfound := stat.Counters["notFound"] - old.Counters["notFound"] op := stat.Storage.IndexVersion - old.Storage.IndexVersion hp := float64(stat.Storage.HoleCount) / float64(stat.Storage.FilesCount) * 100 hps := float64(stat.Storage.HoleSize) / float64(stat.Storage.FilesSize) * 100 in := stat.Traffic["in"] - old.Traffic["in"] out := stat.Traffic["out"] - old.Traffic["out"] fmt.Printf("%d\t%d\t%d\t%d\t%d\t%.2f%%\t%.2f%%\t%s / %s\n", get, add, del, notfound, op, hp, hps, utils.HumanBytes(int64(in)), utils.HumanBytes(int64(out))) } old = stat }