class Farm
{
protected static $_outPDF = [];
- //protected static $_forceServer = false;
+ protected static $_forceServer = false;
- protected static $_forceServer = 'alphaville';
+ //protected static $_forceServer = 'alphaville';
+
+ const LOCAL_SERVER = "dracula";
protected static $_region = Region::EUROPE;
protected static $_farmServers = [
['name' => 'alphaville', 'host' => 'fluidbook-processfarm', 'port' => 9000, 'weight' => 12, 'region' => Region::EUROPE],
['name' => 'brazil', 'host' => 'brazil.cubedesigners.com', 'weight' => 6, 'region' => Region::USA],
- ['name' => 'dracula', 'host' => 'dracula.cubedesigners.com', 'weight' => 4, 'region' => Region::EUROPE],
+ ['name' => 'dracula', 'host' => 'dracula.cubedesigners.com', 'weight' => 1, 'region' => Region::EUROPE],
['name' => 'dobermann', 'host' => 'dobermann.cubedesigners.com', 'weight' => 6, 'region' => Region::EUROPE],
['name' => 'elephantman', 'host' => 'paris.cubedesigners.com', 'weight' => 2, 'region' => Region::EUROPE],
['name' => 'fastandfurious', 'host' => 'fastandfurious.cubedesigners.com', 'weight' => 2, 'region' => Region::EUROPE],
- ['name' => 'godzilla', 'host' => 'godzilla.cubedesigners.com', 'weight' => 1, 'region' => Region::EUROPE],
+ //['name' => 'godzilla', 'host' => 'godzilla.cubedesigners.com', 'weight' => 1, 'region' => Region::EUROPE],
['name' => 'her', 'host' => 'her2.cubedesigners.com', 'weight' => 4, 'region' => Region::EUROPE],
['name' => 'isleofdogs', 'host' => 'paris.cubedesigners.com', 'port' => 9458, 'weight' => 2, 'region' => Region::EUROPE],
['name' => 'jumanji', 'host' => 'paris.cubedesigners.com', 'port' => 9459, 'weight' => 2, 'region' => Region::EUROPE],
return self::$_farmServers;
}
- public static function pickOneServer()
+ public static function pickOneServer($preferLocal)
{
$hat = [];
$pingCache = self::_pingCache();
if (self::$_forceServer && $farmServer['name'] === self::$_forceServer) {
return $farmServer;
}
+ if ($preferLocal && $farmServer['name'] === self::LOCAL_SERVER) {
+ $hat = [$k];
+ break;
+ }
for ($i = 0; $i < $farmServer['weight']; $i++) {
if ($farmServer['region'] === self::getRegion()) {
$hat[] = $k;
{
return self::_getFile(['operation' => 'fixpdf',
'pdf' => $pdf,
- 'out' => $out], 0,false);
+ 'out' => $out], 0, false, true);
}
public static function cutPDF($pdf, $mode, $out)
'pdf' => $pdf,
'out' => $out,
'mode' => $mode,
- ], 0,false);
+ ], 0, false, true);
}
public static function trimPDF($pdf, $out)
return self::_getFile(['operation' => 'trimpdf',
'pdf' => $pdf,
'out' => $out,
- ], 0,false);
+ ], 0, false, true);
}
public static function splitPDF($pdf, $out)
{
return self::_getFile(['operation' => 'splitpdf',
'pdf' => $pdf,
- 'out' => $out], 0,false);
+ 'out' => $out], 0, false, true);
}
public static function extractLinks($pdf, $out)
{
return self::_getFile(['operation' => 'extractlinks',
'pdf' => $pdf,
- 'out' => $out], 0,false);
+ 'out' => $out], 0, false, true);
}
public static function extractTexts($pdf, $out, $mode, $extractionMethod, $ignoreSeparators)
'out' => $out,
'mode' => $mode,
'method' => $extractionMethod,
- 'ignoreseparators' => $ignoreSeparators], 0,false);
+ 'ignoreseparators' => $ignoreSeparators], 0, false, true);
}
public static function extractHighlightsData($pdf, $out, $mode, $ignoreSeparators)
'pdf' => $pdf,
'out' => $out,
'mode' => $mode,
- 'ignoreseparators' => $ignoreSeparators], 0,false);
+ 'ignoreseparators' => $ignoreSeparators], 0, false, true);
}
/**
* @throws \Exception
*/
- protected static function _getFile($params, $attempts = 3, $checkOutput = true)
+ protected static function _getFile($params, $attempts = 3, $checkOutput = true, $preferLocal = false)
{
$start = microtime(true);
- $farmer = self::pickOneServer();
+ $farmer = self::pickOneServer($preferLocal);
$params['toolbox'] = '1';