88use Flowpack \ElasticSearch \ContentRepositoryQueueIndexer \LoggerTrait ;
99use Flowpack \ElasticSearch \ContentRepositoryQueueIndexer \UpdateAliasJob ;
1010use Flowpack \JobQueue \Common \Job \JobManager ;
11+ use Flowpack \JobQueue \Common \Queue \QueueManager ;
1112use TYPO3 \Flow \Annotations as Flow ;
1213use TYPO3 \Flow \Cli \CommandController ;
1314use TYPO3 \Flow \Persistence \PersistenceManagerInterface ;
15+ use TYPO3 \Flow \Utility \Files ;
1416use TYPO3 \TYPO3CR \Domain \Repository \WorkspaceRepository ;
1517
1618/**
@@ -22,12 +24,20 @@ class NodeIndexQueueCommandController extends CommandController
2224{
2325 use LoggerTrait;
2426
27+ const QUEUE_NAME = 'Flowpack.ElasticSearch.ContentRepositoryQueueIndexer ' ;
28+
2529 /**
2630 * @Flow\Inject
2731 * @var JobManager
2832 */
2933 protected $ jobManager ;
3034
35+ /**
36+ * @var QueueManager
37+ * @Flow\Inject
38+ */
39+ protected $ queueManager ;
40+
3141 /**
3242 * @var PersistenceManagerInterface
3343 * @Flow\Inject
@@ -92,6 +102,26 @@ public function buildCommand($workspace = null)
92102 $ this ->outputLine (sprintf ('Indexing jobs created for queue %s with success ... ' , $ queueName ));
93103 }
94104
105+ /**
106+ * Flush the index queue
107+ */
108+ public function flushCommand ()
109+ {
110+ $ this ->queueManager ->getQueue (self ::QUEUE_NAME )->flush ();
111+ $ this ->outputSystemReport ();
112+ $ this ->outputLine ();
113+ }
114+
115+ protected function outputSystemReport ()
116+ {
117+ $ this ->outputLine ();
118+ $ this ->outputLine ('Memory Usage : %s ' , [Files::bytesToSizeString (memory_get_peak_usage (true ))]);
119+ $ time = microtime (true ) - $ _SERVER ["REQUEST_TIME_FLOAT " ];
120+ $ this ->outputLine ('Execution time : %s seconds ' , [$ time ]);
121+ $ this ->outputLine ('Indexing Queue : %s ' , [self ::QUEUE_NAME ]);
122+ $ this ->outputLine ('Pending Jobs : %s ' , [$ this ->queueManager ->getQueue (self ::QUEUE_NAME )->count ()]);
123+ }
124+
95125 /**
96126 * @param string $workspaceName
97127 * @param string $indexPostfix
0 commit comments