Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F29879396
raw.txt
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
CDanis
Jul 26 2019, 7:59 PM
2019-07-26 19:59:09 (UTC+0)
Size
2 KB
Referenced Files
None
Subscribers
None
raw.txt
View Options
#!/usr/bin/env php
<?php
$argc == 3 or die("usage: $argv[0] INPUTFILE DC-NAME\n");
$inputfile = $argv[1] or die;
$dc = $argv[2] or die;
include $inputfile;
$INSTANCES = [];
$SECTIONS = [];
foreach ($wgLBFactoryConf['sectionLoads'] as $section => $secinsts) {
if ($section == "DEFAULT") $section = "s3";
foreach ($secinsts as $instance => $weight) {
if ($instance === array_key_first($secinsts)) {
# First in sectionLoads --> the master. also create an associated section object.
$SECTIONS[$section] = [
'master' => $instance,
'min_slaves' => 0,
'readonly' => FALSE,
'ro_reason' => "PLACEHOLDER"
];
}
# If needed, create an initial instance object for this instance.
if (!isset($INSTANCES[$instance])) {
[$host, $port] = explode(':', $instance);
$INSTANCES[$instance] = [
'host_ip' => explode(':', $wgLBFactoryConf['hostsByName'][$instance])[0],
'sections' => [],
];
if (isset($port)) {
$INSTANCES[$instance]['port'] = intval($port);
}
}
# now append to sections
$INSTANCES[$instance]['sections'][$section] = [
'weight' => $weight,
'pooled' => TRUE,
'percentage' => 100
];
}
}
foreach ($wgLBFactoryConf['groupLoadsBySection'] as $section => $groupblob) {
if ($section == "DEFAULT") $section = "s3";
foreach ($groupblob as $group => $groupinsts) {
foreach ($groupinsts as $instance => $weight) {
#echo "$section $group $instance $weight\n";
if (!isset($INSTANCES[$instance]['sections'][$section]['groups'])) {
$INSTANCES[$instance]['sections'][$section]['groups'] = [];
}
$INSTANCES[$instance]['sections'][$section]['groups'][$group] = [
'pooled' => TRUE, 'weight' => $weight];
}
}
}
foreach ($wgLBFactoryConf['readOnlyBySection'] as $section => $reason) {
$SECTIONS[$section]['readonly'] = TRUE;
$SECTIONS[$section]['ro_reason'] = $reason;
}
ksort($INSTANCES);
ksort($SECTIONS);
{
$instfile = fopen("import/dbconfig-instance/instances-$dc.yaml", "w");
fwrite($instfile, "$dc:\n");
foreach ($INSTANCES as $instance => $data) {
fwrite($instfile, " - $instance\n");
{
$datafile = fopen("import/instances/$dc/$instance", "w");
fwrite($datafile, json_encode($data));
}
}
}
{
$secfile = fopen("import/dbconfig-section/sections-$dc.yaml", "w");
fwrite($secfile, "$dc:\n");
foreach ($SECTIONS as $section => $data) {
fwrite($secfile, " - $section\n");
{
$datafile = fopen("import/sections/$dc/$section", "w");
fwrite($datafile, json_encode($data));
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
7783009
Default Alt Text
raw.txt (2 KB)
Attached To
Mode
P8589 import.php
Attached
Detach File
Event Timeline
Log In to Comment