Put back existing code
This commit is contained in:
parent
27383e950e
commit
993b648eff
21
src/corso.go
21
src/corso.go
@ -10,19 +10,23 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/pkg/profile"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/cli"
|
"github.com/alcionai/corso/src/cli"
|
||||||
"github.com/alcionai/corso/src/pkg/logger"
|
"github.com/alcionai/corso/src/pkg/logger"
|
||||||
"github.com/pkg/profile"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var profileTicker = time.NewTicker(1 * time.Second)
|
var (
|
||||||
var perMinuteMap = make(map[time.Time]int)
|
profileTicker = time.NewTicker(1 * time.Second)
|
||||||
var timeSinceRefresh = time.Now()
|
perMinuteMap = make(map[time.Time]int)
|
||||||
|
timeSinceRefresh = time.Now()
|
||||||
|
)
|
||||||
|
|
||||||
// var profileTicker = time.NewTicker(120 * time.Second)
|
// var profileTicker = time.NewTicker(120 * time.Second)
|
||||||
|
var (
|
||||||
var printTicker = time.NewTicker(1 * time.Second)
|
printTicker = time.NewTicker(1 * time.Second)
|
||||||
var profileCounter = 0
|
profileCounter = 0
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
defer profile.Start(profile.MemProfile).Stop()
|
defer profile.Start(profile.MemProfile).Stop()
|
||||||
@ -39,7 +43,7 @@ func main() {
|
|||||||
// or if its been 2 mins since last profile, capture it
|
// or if its been 2 mins since last profile, capture it
|
||||||
t := time.Now().Truncate(time.Minute)
|
t := time.Now().Truncate(time.Minute)
|
||||||
// if (m.HeapAlloc > uint64(3*1024*1024*1024) && perMinuteMap[t] == 0) || time.Since(timeSinceRefresh) > 2*time.Minute {
|
// if (m.HeapAlloc > uint64(3*1024*1024*1024) && perMinuteMap[t] == 0) || time.Since(timeSinceRefresh) > 2*time.Minute {
|
||||||
if time.Since(timeSinceRefresh) > 2*time.Minute {
|
if time.Since(timeSinceRefresh) > 3*time.Minute {
|
||||||
filename := "mem." + strconv.Itoa(profileCounter) + ".pprof"
|
filename := "mem." + strconv.Itoa(profileCounter) + ".pprof"
|
||||||
|
|
||||||
f, _ := os.Create(filename)
|
f, _ := os.Create(filename)
|
||||||
@ -53,7 +57,6 @@ func main() {
|
|||||||
perMinuteMap[t] = 1
|
perMinuteMap[t] = 1
|
||||||
timeSinceRefresh = time.Now()
|
timeSinceRefresh = time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|||||||
@ -577,7 +577,7 @@ func (oc *Collection) streamDriveItem(
|
|||||||
"item_name", clues.Hide(itemName),
|
"item_name", clues.Hide(itemName),
|
||||||
"item_size", itemSize)
|
"item_size", itemSize)
|
||||||
|
|
||||||
// item.SetParentReference(setName(item.GetParentReference(), oc.driveName))
|
item.SetParentReference(setName(item.GetParentReference(), oc.driveName))
|
||||||
|
|
||||||
isFile := item.GetFile() != nil
|
isFile := item.GetFile() != nil
|
||||||
|
|
||||||
|
|||||||
@ -273,7 +273,7 @@ func ToCorsoDriveItemable(item models.DriveItemable) CorsoDriveItemable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if item.GetCreatedBy() != nil {
|
if item.GetCreatedBy() != nil && item.GetCreatedBy().GetUser() != nil {
|
||||||
cdi.CreatedBy = &itemIdentitySet{
|
cdi.CreatedBy = &itemIdentitySet{
|
||||||
user: &itemUser{
|
user: &itemUser{
|
||||||
additionalData: item.GetCreatedBy().GetUser().GetAdditionalData(),
|
additionalData: item.GetCreatedBy().GetUser().GetAdditionalData(),
|
||||||
|
|||||||
@ -205,12 +205,16 @@ func driveItemWriter(
|
|||||||
return iw, ptr.Val(icu.GetUploadUrl()), nil
|
return iw, ptr.Val(icu.GetUploadUrl()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setName(orig models.ItemReferenceable, driveName string) models.ItemReferenceable {
|
func setName(orig parentReferenceable, driveName string) models.ItemReferenceable {
|
||||||
if orig == nil {
|
if orig == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
orig.SetName(&driveName)
|
mod := models.NewItemReference()
|
||||||
|
mod.SetDriveId(orig.GetDriveId())
|
||||||
|
mod.SetId(orig.GetId())
|
||||||
|
mod.SetPath(orig.GetPath())
|
||||||
|
mod.SetName(&driveName)
|
||||||
|
|
||||||
return orig
|
return mod
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,6 @@ import (
|
|||||||
"github.com/alcionai/corso/src/internal/events"
|
"github.com/alcionai/corso/src/internal/events"
|
||||||
"github.com/alcionai/corso/src/internal/kopia"
|
"github.com/alcionai/corso/src/internal/kopia"
|
||||||
kinject "github.com/alcionai/corso/src/internal/kopia/inject"
|
kinject "github.com/alcionai/corso/src/internal/kopia/inject"
|
||||||
"github.com/alcionai/corso/src/internal/m365/collection/drive"
|
|
||||||
"github.com/alcionai/corso/src/internal/model"
|
"github.com/alcionai/corso/src/internal/model"
|
||||||
"github.com/alcionai/corso/src/internal/observe"
|
"github.com/alcionai/corso/src/internal/observe"
|
||||||
"github.com/alcionai/corso/src/internal/operations/inject"
|
"github.com/alcionai/corso/src/internal/operations/inject"
|
||||||
@ -440,14 +439,14 @@ func (op *BackupOperation) do(
|
|||||||
lastBackupVersion = mans.MinBackupVersion()
|
lastBackupVersion = mans.MinBackupVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
iterations := 1
|
// iterations := 1
|
||||||
|
|
||||||
for i := 0; i < iterations; i++ {
|
// for i := 0; i < iterations; i++ {
|
||||||
// TODO(ashmrtn): This should probably just return a collection that deletes
|
// TODO(ashmrtn): This should probably just return a collection that deletes
|
||||||
// the entire subtree instead of returning an additional bool. That way base
|
// the entire subtree instead of returning an additional bool. That way base
|
||||||
// selection is controlled completely by flags and merging is controlled
|
// selection is controlled completely by flags and merging is controlled
|
||||||
// completely by collections.
|
// completely by collections.
|
||||||
cs, _, _, err := produceBackupDataCollections(
|
cs, ssmb, canUsePreviousBackup, err := produceBackupDataCollections(
|
||||||
ctx,
|
ctx,
|
||||||
op.bp,
|
op.bp,
|
||||||
op.ResourceOwner,
|
op.ResourceOwner,
|
||||||
@ -470,81 +469,80 @@ func (op *BackupOperation) do(
|
|||||||
// numItems := 0
|
// numItems := 0
|
||||||
// mapSum := 0
|
// mapSum := 0
|
||||||
|
|
||||||
for _, c := range cs {
|
// for _, c := range cs {
|
||||||
v, ok := c.(*drive.Collection)
|
// v, ok := c.(*drive.Collection)
|
||||||
if !ok {
|
// if !ok {
|
||||||
continue
|
// continue
|
||||||
}
|
|
||||||
|
|
||||||
m := v.GetDriveItemsMap()
|
|
||||||
for key := range m {
|
|
||||||
logger.Ctx(ctx).Debug(key)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get sizeof recursively using reflect
|
|
||||||
// m := v.GetDriveItemsMap()
|
|
||||||
// for _, val := range m {
|
|
||||||
// s := size.Of(val)
|
|
||||||
// sum += s
|
|
||||||
// numItems++
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// ms := size.Of(m)
|
// m := v.GetDriveItemsMap()
|
||||||
// mapSum += ms
|
// for key := range m {
|
||||||
|
// logger.Ctx(ctx).Debug(key)
|
||||||
|
// }
|
||||||
|
|
||||||
// logger.Ctx(ctx).Debugf("coll drive map size %d, num drive items %d\n", ms, len(m))
|
// // Get sizeof recursively using reflect
|
||||||
}
|
// // m := v.GetDriveItemsMap()
|
||||||
|
// // for _, val := range m {
|
||||||
|
// // s := size.Of(val)
|
||||||
|
// // sum += s
|
||||||
|
// // numItems++
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // ms := size.Of(m)
|
||||||
|
// // mapSum += ms
|
||||||
|
|
||||||
|
// // logger.Ctx(ctx).Debugf("coll drive map size %d, num drive items %d\n", ms, len(m))
|
||||||
|
// }
|
||||||
|
|
||||||
// print total sum
|
// print total sum
|
||||||
// logger.Ctx(ctx).Debugf("itemSum %d, map sum %d, total items %d, mem used per item %f mem per item in map %f \n", sum, mapSum, numItems, float64(sum)/float64(numItems), float64(mapSum)/float64(numItems))
|
// logger.Ctx(ctx).Debugf("itemSum %d, map sum %d, total items %d, mem used per item %f mem per item in map %f \n", sum, mapSum, numItems, float64(sum)/float64(numItems), float64(mapSum)/float64(numItems))
|
||||||
|
//}
|
||||||
|
|
||||||
|
// return nil, clues.New("failed")
|
||||||
|
|
||||||
|
ctx = clues.Add(
|
||||||
|
ctx,
|
||||||
|
"can_use_previous_backup", canUsePreviousBackup,
|
||||||
|
"collection_count", len(cs))
|
||||||
|
|
||||||
|
writeStats, deets, toMerge, err := consumeBackupCollections(
|
||||||
|
ctx,
|
||||||
|
op.kopia,
|
||||||
|
op.account.ID(),
|
||||||
|
reasons,
|
||||||
|
mans,
|
||||||
|
cs,
|
||||||
|
ssmb,
|
||||||
|
backupID,
|
||||||
|
op.incremental && canUseMetadata && canUsePreviousBackup,
|
||||||
|
op.Counter,
|
||||||
|
op.Errors)
|
||||||
|
if err != nil {
|
||||||
|
return nil, clues.Wrap(err, "persisting collection backups")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, clues.New("failed")
|
opStats.hasNewDetailEntries = (deets != nil && !deets.Empty()) ||
|
||||||
|
(toMerge != nil && toMerge.ItemsToMerge() > 0)
|
||||||
|
opStats.k = writeStats
|
||||||
|
|
||||||
// ctx = clues.Add(
|
err = mergeDetails(
|
||||||
// ctx,
|
ctx,
|
||||||
// "can_use_previous_backup", canUsePreviousBackup,
|
detailsStore,
|
||||||
// "collection_count", len(cs))
|
mans,
|
||||||
|
toMerge,
|
||||||
|
deets,
|
||||||
|
writeStats,
|
||||||
|
op.Selectors.PathService(),
|
||||||
|
op.Errors)
|
||||||
|
if err != nil {
|
||||||
|
return nil, clues.Wrap(err, "merging details")
|
||||||
|
}
|
||||||
|
|
||||||
// writeStats, deets, toMerge, err := consumeBackupCollections(
|
opStats.ctrl = op.bp.Wait()
|
||||||
// ctx,
|
|
||||||
// op.kopia,
|
|
||||||
// op.account.ID(),
|
|
||||||
// reasons,
|
|
||||||
// mans,
|
|
||||||
// cs,
|
|
||||||
// ssmb,
|
|
||||||
// backupID,
|
|
||||||
// op.incremental && canUseMetadata && canUsePreviousBackup,
|
|
||||||
// op.Counter,
|
|
||||||
// op.Errors)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, clues.Wrap(err, "persisting collection backups")
|
|
||||||
// }
|
|
||||||
|
|
||||||
// opStats.hasNewDetailEntries = (deets != nil && !deets.Empty()) ||
|
logger.Ctx(ctx).Debug(opStats.ctrl)
|
||||||
// (toMerge != nil && toMerge.ItemsToMerge() > 0)
|
|
||||||
// opStats.k = writeStats
|
|
||||||
|
|
||||||
// err = mergeDetails(
|
|
||||||
// ctx,
|
|
||||||
// detailsStore,
|
|
||||||
// mans,
|
|
||||||
// toMerge,
|
|
||||||
// deets,
|
|
||||||
// writeStats,
|
|
||||||
// op.Selectors.PathService(),
|
|
||||||
// op.Errors)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, clues.Wrap(err, "merging details")
|
|
||||||
// }
|
|
||||||
|
|
||||||
// opStats.ctrl = op.bp.Wait()
|
|
||||||
|
|
||||||
// logger.Ctx(ctx).Debug(opStats.ctrl)
|
|
||||||
|
|
||||||
// return deets, nil
|
|
||||||
|
|
||||||
|
return deets, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeFallbackReasons(tenant string, sel selectors.Selector) ([]identity.Reasoner, error) {
|
func makeFallbackReasons(tenant string, sel selectors.Selector) ([]identity.Reasoner, error) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user