Made HostPort() an explicit method to print the HostPort, so that String() can change...
[arvados.git] / services / datamanager / datamanager.go
index cd141eeb16448d2c56eb1812e266899a32010155..d3efe621731c0e1a93cb4dc333fdd9537bad65c2 100644 (file)
@@ -66,7 +66,7 @@ func singlerun() {
        var arvLogger *logger.Logger
        if logEventTypePrefix != "" {
                arvLogger = logger.NewLogger(logger.LoggerParams{
-                       Client: arv,
+                       Client:          arv,
                        EventTypePrefix: logEventTypePrefix,
                        WriteInterval:   time.Second * time.Duration(logFrequencySeconds)})
        }
@@ -78,7 +78,7 @@ func singlerun() {
 
        var (
                readCollections collection.ReadCollections
-               keepServerInfo keep.ReadServers
+               keepServerInfo  keep.ReadServers
        )
 
        if !summary.MaybeReadData(arvLogger, &readCollections, &keepServerInfo) {
@@ -87,8 +87,8 @@ func singlerun() {
                go func() {
                        collectionChannel <- collection.GetCollectionsAndSummarize(
                                collection.GetCollectionsParams{
-                                       Client: arv,
-                                       Logger: arvLogger,
+                                       Client:    arv,
+                                       Logger:    arvLogger,
                                        BatchSize: 50})
                }()
 
@@ -96,26 +96,41 @@ func singlerun() {
                        keep.GetKeepServersParams{
                                Client: arv,
                                Logger: arvLogger,
-                               Limit: 1000})
+                               Limit:  1000})
 
                readCollections = <-collectionChannel
        }
 
        summary.MaybeWriteData(arvLogger, readCollections, keepServerInfo)
 
-       replicationSummary :=
-               summary.SummarizeReplication(readCollections, keepServerInfo)
+       buckets := summary.BucketReplication(readCollections, keepServerInfo)
+       bucketCounts := buckets.Counts()
 
-       log.Printf("Blocks In Collections: %d, " +
+       replicationSummary := buckets.SummarizeBuckets(readCollections)
+       replicationCounts := replicationSummary.ComputeCounts()
+
+       log.Printf("Blocks In Collections: %d, "+
                "\nBlocks In Keep: %d.",
                len(readCollections.BlockToReplication),
                len(keepServerInfo.BlockToServers))
-       log.Println(replicationSummary.ComputeCounts().PrettyPrint())
+       log.Println(replicationCounts.PrettyPrint())
+
+       log.Printf("Blocks Histogram:")
+       for _, rlbss := range bucketCounts {
+               log.Printf("%+v: %10d",
+                       rlbss.Levels,
+                       rlbss.Count)
+       }
 
        // Log that we're finished. We force the recording, since go will
-       // not wait for the timer before exiting.
+       // not wait for the write timer before exiting.
        if arvLogger != nil {
                arvLogger.FinalUpdate(func(p map[string]interface{}, e map[string]interface{}) {
+                       summaryInfo := logger.GetOrCreateMap(p, "summary_info")
+                       summaryInfo["block_replication_counts"] = bucketCounts
+                       summaryInfo["replication_summary"] = replicationCounts
+                       p["summary_info"] = summaryInfo
+
                        p["run_info"].(map[string]interface{})["finished_at"] = time.Now()
                })
        }