Differential D18693 Diff 44881 src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php
Show First 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | public function synchronizeWorkingCopyBeforeRead() { | ||||
} else { | } else { | ||||
// If no version records exist yet, we need to be careful, because we | // If no version records exist yet, we need to be careful, because we | ||||
// can not tell which nodes are leaders. | // can not tell which nodes are leaders. | ||||
// There might be several nodes with arbitrary existing data, and we have | // There might be several nodes with arbitrary existing data, and we have | ||||
// no way to tell which one has the "right" data. If we pick wrong, we | // no way to tell which one has the "right" data. If we pick wrong, we | ||||
// might erase some or all of the data in the repository. | // might erase some or all of the data in the repository. | ||||
// Since this is dangeorus, we refuse to guess unless there is only one | // Since this is dangerous, we refuse to guess unless there is only one | ||||
// device. If we're the only device in the group, we obviously must be | // device. If we're the only device in the group, we obviously must be | ||||
// a leader. | // a leader. | ||||
$service = $repository->loadAlmanacService(); | $service = $repository->loadAlmanacService(); | ||||
if (!$service) { | if (!$service) { | ||||
throw new Exception(pht('Failed to load repository cluster service.')); | throw new Exception(pht('Failed to load repository cluster service.')); | ||||
} | } | ||||
$bindings = $service->getActiveBindings(); | $bindings = $service->getActiveBindings(); | ||||
$device_map = array(); | $device_map = array(); | ||||
foreach ($bindings as $binding) { | foreach ($bindings as $binding) { | ||||
$device_map[$binding->getDevicePHID()] = true; | $device_map[$binding->getDevicePHID()] = true; | ||||
} | } | ||||
if (count($device_map) > 1) { | if (count($device_map) > 1) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Repository "%s" exists on more than one device, but no device '. | 'Repository "%s" exists on more than one device, but no device '. | ||||
'has any repository version information. Phabricator can not '. | 'has any repository version information. Phabricator can not '. | ||||
'guess which copy of the existing data is authoritative. Promote '. | 'guess which copy of the existing data is authoritative. Promote '. | ||||
'a device or see "Ambigous Leaders" in the documentation.', | 'a device or see "Ambiguous Leaders" in the documentation.', | ||||
$repository->getDisplayName())); | $repository->getDisplayName())); | ||||
} | } | ||||
if (empty($device_map[$device->getPHID()])) { | if (empty($device_map[$device->getPHID()])) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Repository "%s" is being synchronized on device "%s", but '. | 'Repository "%s" is being synchronized on device "%s", but '. | ||||
'this device is not bound to the corresponding cluster '. | 'this device is not bound to the corresponding cluster '. | ||||
▲ Show 20 Lines • Show All 503 Lines • Show Last 20 Lines |