|
4 | 4 | use DBA\Factory; |
5 | 5 |
|
6 | 6 | use DBA\Agent; |
| 7 | +use DBA\Aggregation; |
7 | 8 | use DBA\Assignment; |
8 | 9 | use DBA\Chunk; |
9 | 10 | use DBA\CrackerBinary; |
@@ -162,32 +163,35 @@ protected function createObject(array $data): int { |
162 | 163 |
|
163 | 164 | //TODO make aggregate data queryable and not included by default |
164 | 165 | static function aggregateData(object $object): array { |
| 166 | + $qF = new QueryFilter(Assignment::TASK_ID, $object->getId(), "="); |
| 167 | + $activeAgents = Factory::getAssignmentFactory()->countFilter([Factory::FILTER => $qF]); |
| 168 | + $aggregatedData["activeAgents"] = $activeAgents; |
| 169 | + |
165 | 170 | $keyspace = $object->getKeyspace(); |
166 | 171 | $keyspaceProgress = $object->getKeyspaceProgress(); |
167 | 172 |
|
| 173 | + $qF1 = new QueryFilter(Chunk::TASK_ID, $object->getId(), "="); |
| 174 | + $agg1 = new Aggregation(Chunk::CHECKPOINT, Aggregation::SUM); |
| 175 | + $agg2 = new Aggregation(Chunk::SKIP, Aggregation::SUM); |
| 176 | + $agg3 = new Aggregation(Chunk::DISPATCH_TIME, Aggregation::MAX); |
| 177 | + $agg4 = new Aggregation(Chunk::SOLVE_TIME, Aggregation::MAX); |
| 178 | + $results = Factory::getChunkFactory()->multicolAggregationFilter([Factory::FILTER => $qF1], [$agg1, $agg2, $agg3, $agg4]); |
| 179 | + |
| 180 | + $progress = $results[$agg1->getName()] - $results[$agg2->getName()]; |
| 181 | + $maxTime = max($results[$agg3->getName()], $results[$agg4->getName()]); |
| 182 | + |
| 183 | + //status 1 is running, 2 is idle and 3 is completed |
| 184 | + $status = 2; |
| 185 | + if (time() - $maxTime < SConfig::getInstance()->getVal(DConfig::CHUNK_TIMEOUT) && ($progress < $object->getKeyspace() || $object->getUsePreprocessor() && $object->getKeyspace() == DPrince::PRINCE_KEYSPACE)) { |
| 186 | + $status = 1; |
| 187 | + } |
168 | 188 | $aggregatedData["dispatched"] = Util::showperc($keyspaceProgress, $keyspace); |
169 | 189 | $aggregatedData["searched"] = Util::showperc(TaskUtils::getTaskProgress($object), $keyspace); |
170 | 190 |
|
171 | | - $qF = new QueryFilter(Chunk::TASK_ID, $object->getId(), "="); |
172 | | - $chunks = Factory::getChunkFactory()->filter([Factory::FILTER => $qF]); |
173 | | - |
174 | | - $activeAgents = []; |
175 | | - foreach ($chunks as $chunk) { |
176 | | - if (time() - max($chunk->getSolveTime(), $chunk->getDispatchTime()) < SConfig::getInstance()->getVal(DConfig::CHUNK_TIMEOUT) && $chunk->getProgress() < 10000) { |
177 | | - $activeAgents[$chunk->getAgentId()] = true; |
178 | | - } |
179 | | - } |
180 | | - |
181 | | - //status 1 is running, 2 is idle and 3 is completed |
182 | | - $status = 2; |
183 | 191 | if ($keyspaceProgress >= $keyspace && $keyspaceProgress > 0) { |
184 | 192 | $status = 3; |
185 | 193 | } |
186 | | - elseif (count($activeAgents) > 0) { |
187 | | - $status = 1; |
188 | | - } |
189 | 194 |
|
190 | | - $aggregatedData["activeAgents"] = array_keys($activeAgents); |
191 | 195 | $aggregatedData["status"] = $status; |
192 | 196 |
|
193 | 197 | return $aggregatedData; |
|
0 commit comments