From 4a6a0632fe8c002dafb46b1b7944bac60a8407a9 Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 9 Jul 2012 16:30:44 -0700 Subject: [PATCH] [FileBackend] Added "ratefile" option for backend copy script. * This can be used to control the concurrency dynamically. Change-Id: I7ebdbffa144928f559c34c4a4684b03597f616ce --- maintenance/copyFileBackend.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/maintenance/copyFileBackend.php b/maintenance/copyFileBackend.php index 530b5cabb4..78ffb20205 100644 --- a/maintenance/copyFileBackend.php +++ b/maintenance/copyFileBackend.php @@ -42,6 +42,7 @@ class CopyFileBackend extends Maintenance { $this->addOption( 'dst', 'Backend where files should be copied to', true, true ); $this->addOption( 'containers', 'Pipe separated list of containers', true, true ); $this->addOption( 'subdir', 'Only do items in this child directory', false, true ); + $this->addOption( 'ratefile', 'File to check periodically for batch size.', false, true ); $this->setBatchSize( 50 ); } @@ -51,6 +52,8 @@ class CopyFileBackend extends Maintenance { $containers = explode( '|', $this->getOption( 'containers' ) ); $subDir = $this->getOption( rtrim( 'subdir', '/' ), '' ); + $rateFile = $this->getOption( 'ratefile' ); + $count = 0; foreach ( $containers as $container ) { if ( $subDir != '' ) { @@ -69,6 +72,11 @@ class CopyFileBackend extends Maintenance { $batchPaths = array(); foreach ( $srcPathsRel as $srcPathRel ) { + // Check up on the rate file periodically to adjust the concurrency + if ( $rateFile && ( !$count || ( $count % 500 ) == 0 ) ) { + $this->mBatchSize = max( 1, (int)file_get_contents( $rateFile ) ); + $this->output( "Batch size is now {$this->mBatchSize}.\n" ); + } $batchPaths[$srcPathRel] = 1; // remove duplicates if ( count( $batchPaths ) >= $this->mBatchSize ) { $this->copyFileBatch( array_keys( $batchPaths ), $backendRel, $src, $dst ); -- 2.20.1