Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOOLS-912 Decouple number parallel collections from numThreads in mon… #40

Merged
merged 1 commit into from
Sep 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
TOOLS-912 Decouple number parallel collections from numThreads in mon…
…godump
  • Loading branch information
Tess Avitabile committed Sep 29, 2015
commit e9ded82254c3c97236f7d7a138c4e52c58d00725
12 changes: 7 additions & 5 deletions mongodump/mongodump.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ func (dump *MongoDump) ValidateOptions() error {
return fmt.Errorf("--out not allowed when --archive is specified")
case dump.OutputOptions.Out == "-" && dump.OutputOptions.Gzip:
return fmt.Errorf("compression can't be used when dumping a single collection to standard output")
case dump.OutputOptions.NumParallelCollections <= 0:
return fmt.Errorf("numParallelCollections must be positive")
}
return nil
}
Expand Down Expand Up @@ -395,18 +397,18 @@ func (dump *MongoDump) Dump() (err error) {
func (dump *MongoDump) DumpIntents() error {
resultChan := make(chan error)

var jobs int
if dump.ToolOptions != nil && dump.ToolOptions.HiddenOptions != nil {
jobs = dump.ToolOptions.HiddenOptions.MaxProcs
jobs := dump.OutputOptions.NumParallelCollections
if numIntents := len(dump.manager.Intents()); jobs > numIntents {
jobs = numIntents
}
jobs = util.MaxInt(jobs, 1)

if jobs > 1 {
dump.manager.Finalize(intents.LongestTaskFirst)
} else {
dump.manager.Finalize(intents.Legacy)
}

log.Logf(log.Info, "dumping with %v job threads", jobs)
log.Logf(log.Info, "dumping up to %v collections in parallel", jobs)

// start a goroutine for each job thread
for i := 0; i < jobs; i++ {
Expand Down
1 change: 1 addition & 0 deletions mongodump/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type OutputOptions struct {
DumpDBUsersAndRoles bool `long:"dumpDbUsersAndRoles" description:"dump user and role definitions for the specified database"`
ExcludedCollections []string `long:"excludeCollection" value-name:"<collection-name>" description:"collection to exclude from the dump (may be specified multiple times to exclude additional collections)"`
ExcludedCollectionPrefixes []string `long:"excludeCollectionsWithPrefix" value-name:"<collection-prefix>" description:"exclude all collections from the dump that have the given prefix (may be specified multiple times to exclude additional prefixes)"`
NumParallelCollections int `long:"numParallelCollections" short:"j" description:"number of collections to dump in parallel (4 by default)" default:"4" default-mask:"-"`
}

// Name returns a human-readable group name for output options.
Expand Down