This file is indexed.

/usr/share/doc/swift-doc/html/ring.html is in swift-doc 1.13.1-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Partitioned Consistent Hash Ring &mdash; swift 1.13.1 documentation</title>
    
    <link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="_static/tweaks.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '1.13.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="swift 1.13.1 documentation" href="index.html" />
    <link rel="next" title="Proxy" href="proxy.html" />
    <link rel="prev" title="Logs" href="logs.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="proxy.html" title="Proxy"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="logs.html" title="Logs"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">swift 1.13.1 documentation</a> &raquo;</li> 
      </ul>
    </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3><a href="index.html">Table Of Contents</a></h3>
            <ul>
<li><a class="reference internal" href="#">Partitioned Consistent Hash Ring</a><ul>
<li><a class="reference internal" href="#ring">Ring</a></li>
<li><a class="reference internal" href="#module-swift.common.ring.builder">Ring Builder</a></li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="logs.html"
                                  title="previous chapter">Logs</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="proxy.html"
                                  title="next chapter">Proxy</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="_sources/ring.txt"
                     rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <form class="search" action="search.html" method="get">
                <input type="text" name="q" size="18" />
                <input type="submit" value="Go" />
                <input type="hidden" name="check_keywords" value="yes" />
                <input type="hidden" name="area" value="default" />
              </form>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="partitioned-consistent-hash-ring">
<span id="consistent-hashing-ring"></span><h1>Partitioned Consistent Hash Ring<a class="headerlink" href="#partitioned-consistent-hash-ring" title="Permalink to this headline"></a></h1>
<div class="section" id="ring">
<span id="id1"></span><h2>Ring<a class="headerlink" href="#ring" title="Permalink to this headline"></a></h2>
<span class="target" id="module-swift.common.ring.ring"></span><dl class="class">
<dt id="swift.common.ring.ring.Ring">
<em class="property">class </em><tt class="descclassname">swift.common.ring.ring.</tt><tt class="descname">Ring</tt><big>(</big><em>serialized_path</em>, <em>reload_time=15</em>, <em>ring_name=None</em><big>)</big><a class="headerlink" href="#swift.common.ring.ring.Ring" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
<p>Partitioned consistent hashing ring.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>serialized_path</strong> &#8211; path to serialized RingData instance</li>
<li><strong>reload_time</strong> &#8211; time interval in seconds to check for a ring change</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="swift.common.ring.ring.Ring.devs">
<tt class="descname">devs</tt><a class="headerlink" href="#swift.common.ring.ring.Ring.devs" title="Permalink to this definition"></a></dt>
<dd><p>devices in the ring</p>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.ring.Ring.get_more_nodes">
<tt class="descname">get_more_nodes</tt><big>(</big><em>part</em><big>)</big><a class="headerlink" href="#swift.common.ring.ring.Ring.get_more_nodes" title="Permalink to this definition"></a></dt>
<dd><p>Generator to get extra nodes for a partition for hinted handoff.</p>
<p>The handoff nodes will try to be in zones other than the
primary zones, will take into account the device weights, and
will usually keep the same sequences of handoffs even with
ring changes.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>part</strong> &#8211; partition to get handoff nodes for</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">generator of node dicts</td>
</tr>
</tbody>
</table>
<p>See <a class="reference internal" href="#swift.common.ring.ring.Ring.get_nodes" title="swift.common.ring.ring.Ring.get_nodes"><tt class="xref py py-func docutils literal"><span class="pre">get_nodes()</span></tt></a> for a description of the node dicts.</p>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.ring.Ring.get_nodes">
<tt class="descname">get_nodes</tt><big>(</big><em>account</em>, <em>container=None</em>, <em>obj=None</em><big>)</big><a class="headerlink" href="#swift.common.ring.ring.Ring.get_nodes" title="Permalink to this definition"></a></dt>
<dd><p>Get the partition and nodes for an account/container/object.
If a node is responsible for more than one replica, it will
only appear in the output once.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>account</strong> &#8211; account name</li>
<li><strong>container</strong> &#8211; container name</li>
<li><strong>obj</strong> &#8211; object name</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">a tuple of (partition, list of node dicts)</p>
</td>
</tr>
</tbody>
</table>
<p>Each node dict will have at least the following keys:</p>
<table border="1" class="docutils">
<colgroup>
<col width="9%" />
<col width="91%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td>id</td>
<td>unique integer identifier amongst devices</td>
</tr>
<tr class="row-even"><td>weight</td>
<td>a float of the relative weight of this device as compared to
others; this indicates how many partitions the builder will try
to assign to this device</td>
</tr>
<tr class="row-odd"><td>zone</td>
<td>integer indicating which zone the device is in; a given
partition will not be assigned to multiple devices within the
same zone</td>
</tr>
<tr class="row-even"><td>ip</td>
<td>the ip address of the device</td>
</tr>
<tr class="row-odd"><td>port</td>
<td>the tcp port of the device</td>
</tr>
<tr class="row-even"><td>device</td>
<td>the device&#8217;s name on disk (sdb1, for example)</td>
</tr>
<tr class="row-odd"><td>meta</td>
<td>general use &#8216;extra&#8217; field; for example: the online date, the
hardware description</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.ring.Ring.get_part">
<tt class="descname">get_part</tt><big>(</big><em>account</em>, <em>container=None</em>, <em>obj=None</em><big>)</big><a class="headerlink" href="#swift.common.ring.ring.Ring.get_part" title="Permalink to this definition"></a></dt>
<dd><p>Get the partition for an account/container/object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>account</strong> &#8211; account name</li>
<li><strong>container</strong> &#8211; container name</li>
<li><strong>obj</strong> &#8211; object name</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">the partition number</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.ring.Ring.get_part_nodes">
<tt class="descname">get_part_nodes</tt><big>(</big><em>part</em><big>)</big><a class="headerlink" href="#swift.common.ring.ring.Ring.get_part_nodes" title="Permalink to this definition"></a></dt>
<dd><p>Get the nodes that are responsible for the partition. If one
node is responsible for more than one replica of the same
partition, it will only appear in the output once.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>part</strong> &#8211; partition to get nodes for</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">list of node dicts</td>
</tr>
</tbody>
</table>
<p>See <a class="reference internal" href="#swift.common.ring.ring.Ring.get_nodes" title="swift.common.ring.ring.Ring.get_nodes"><tt class="xref py py-func docutils literal"><span class="pre">get_nodes()</span></tt></a> for a description of the node dicts.</p>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.ring.Ring.has_changed">
<tt class="descname">has_changed</tt><big>(</big><big>)</big><a class="headerlink" href="#swift.common.ring.ring.Ring.has_changed" title="Permalink to this definition"></a></dt>
<dd><p>Check to see if the ring on disk is different than the current one in
memory.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">True if the ring on disk has changed, False otherwise</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="swift.common.ring.ring.Ring.partition_count">
<tt class="descname">partition_count</tt><a class="headerlink" href="#swift.common.ring.ring.Ring.partition_count" title="Permalink to this definition"></a></dt>
<dd><p>Number of partitions in the ring.</p>
</dd></dl>

<dl class="attribute">
<dt id="swift.common.ring.ring.Ring.replica_count">
<tt class="descname">replica_count</tt><a class="headerlink" href="#swift.common.ring.ring.Ring.replica_count" title="Permalink to this definition"></a></dt>
<dd><p>Number of replicas (full or partial) used in the ring.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="swift.common.ring.ring.RingData">
<em class="property">class </em><tt class="descclassname">swift.common.ring.ring.</tt><tt class="descname">RingData</tt><big>(</big><em>replica2part2dev_id</em>, <em>devs</em>, <em>part_shift</em><big>)</big><a class="headerlink" href="#swift.common.ring.ring.RingData" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
<p>Partitioned consistent hashing ring data (used for serialization).</p>
<dl class="classmethod">
<dt id="swift.common.ring.ring.RingData.deserialize_v1">
<em class="property">classmethod </em><tt class="descname">deserialize_v1</tt><big>(</big><em>gz_file</em><big>)</big><a class="headerlink" href="#swift.common.ring.ring.RingData.deserialize_v1" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="classmethod">
<dt id="swift.common.ring.ring.RingData.load">
<em class="property">classmethod </em><tt class="descname">load</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#swift.common.ring.ring.RingData.load" title="Permalink to this definition"></a></dt>
<dd><p>Load ring data from a file.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>filename</strong> &#8211; Path to a file serialized by the save() method.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A RingData instance containing the loaded data.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.ring.RingData.save">
<tt class="descname">save</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#swift.common.ring.ring.RingData.save" title="Permalink to this definition"></a></dt>
<dd><p>Serialize this RingData instance to disk.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>filename</strong> &#8211; File into which this instance should be serialized.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.ring.RingData.serialize_v1">
<tt class="descname">serialize_v1</tt><big>(</big><em>file_obj</em><big>)</big><a class="headerlink" href="#swift.common.ring.ring.RingData.serialize_v1" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="swift.common.ring.ring.RingData.to_dict">
<tt class="descname">to_dict</tt><big>(</big><big>)</big><a class="headerlink" href="#swift.common.ring.ring.RingData.to_dict" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="module-swift.common.ring.builder">
<span id="id2"></span><span id="ring-builder"></span><h2>Ring Builder<a class="headerlink" href="#module-swift.common.ring.builder" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="swift.common.ring.builder.RingBuilder">
<em class="property">class </em><tt class="descclassname">swift.common.ring.builder.</tt><tt class="descname">RingBuilder</tt><big>(</big><em>part_power</em>, <em>replicas</em>, <em>min_part_hours</em><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
<p>Used to build swift.common.ring.RingData instances to be written to disk
and used with swift.common.ring.Ring instances. See bin/swift-ring-builder
for example usage.</p>
<p>The instance variable devs_changed indicates if the device information has
changed since the last balancing. This can be used by tools to know whether
a rebalance request is an isolated request or due to added, changed, or
removed devices.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>part_power</strong> &#8211; number of partitions = 2**part_power.</li>
<li><strong>replicas</strong> &#8211; number of replicas for each partition</li>
<li><strong>min_part_hours</strong> &#8211; minimum number of hours between partition changes</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="swift.common.ring.builder.RingBuilder.add_dev">
<tt class="descname">add_dev</tt><big>(</big><em>dev</em><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.add_dev" title="Permalink to this definition"></a></dt>
<dd><p>Add a device to the ring. This device dict should have a minimum of the
following keys:</p>
<table border="1" class="docutils">
<colgroup>
<col width="9%" />
<col width="91%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td>id</td>
<td>unique integer identifier amongst devices. Defaults to the next
id if the &#8216;id&#8217; key is not provided in the dict</td>
</tr>
<tr class="row-even"><td>weight</td>
<td>a float of the relative weight of this device as compared to
others; this indicates how many partitions the builder will try
to assign to this device</td>
</tr>
<tr class="row-odd"><td>region</td>
<td>integer indicating which region the device is in</td>
</tr>
<tr class="row-even"><td>zone</td>
<td>integer indicating which zone the device is in; a given
partition will not be assigned to multiple devices within the
same (region, zone) pair if there is any alternative</td>
</tr>
<tr class="row-odd"><td>ip</td>
<td>the ip address of the device</td>
</tr>
<tr class="row-even"><td>port</td>
<td>the tcp port of the device</td>
</tr>
<tr class="row-odd"><td>device</td>
<td>the device&#8217;s name on disk (sdb1, for example)</td>
</tr>
<tr class="row-even"><td>meta</td>
<td>general use &#8216;extra&#8217; field; for example: the online date, the
hardware description</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This will not rebalance the ring immediately as you may want to
make multiple changes for a single rebalance.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>dev</strong> &#8211; device dict</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">id of device</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.builder.RingBuilder.change_min_part_hours">
<tt class="descname">change_min_part_hours</tt><big>(</big><em>min_part_hours</em><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.change_min_part_hours" title="Permalink to this definition"></a></dt>
<dd><p>Changes the value used to decide if a given partition can be moved
again. This restriction is to give the overall system enough time to
settle a partition to its new location before moving it to yet another
location. While no data would be lost if a partition is moved several
times quickly, it could make that data unreachable for a short period
of time.</p>
<p>This should be set to at least the average full partition replication
time. Starting it at 24 hours and then lowering it to what the
replicator reports as the longest partition cycle is best.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>min_part_hours</strong> &#8211; new value for min_part_hours</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.builder.RingBuilder.copy_from">
<tt class="descname">copy_from</tt><big>(</big><em>builder</em><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.copy_from" title="Permalink to this definition"></a></dt>
<dd><p>Reinitializes this RingBuilder instance from data obtained from the
builder dict given. Code example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">b</span> <span class="o">=</span> <span class="n">RingBuilder</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>  <span class="c"># Dummy values</span>
<span class="n">b</span><span class="o">.</span><span class="n">copy_from</span><span class="p">(</span><span class="n">builder</span><span class="p">)</span>
</pre></div>
</div>
<p>This is to restore a RingBuilder that has had its b.to_dict()
previously saved.</p>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.builder.RingBuilder.get_balance">
<tt class="descname">get_balance</tt><big>(</big><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.get_balance" title="Permalink to this definition"></a></dt>
<dd><p>Get the balance of the ring. The balance value is the highest
percentage off the desired amount of partitions a given device
wants. For instance, if the &#8220;worst&#8221; device wants (based on its
weight relative to the sum of all the devices&#8217; weights) 123
partitions and it has 124 partitions, the balance value would
be 0.83 (1 extra / 123 wanted * 100 for percentage).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">balance of the ring</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.builder.RingBuilder.get_part_devices">
<tt class="descname">get_part_devices</tt><big>(</big><em>part</em><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.get_part_devices" title="Permalink to this definition"></a></dt>
<dd><p>Get the devices that are responsible for the partition,
filtering out duplicates.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>part</strong> &#8211; partition to get devices for</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">list of device dicts</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.builder.RingBuilder.get_ring">
<tt class="descname">get_ring</tt><big>(</big><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.get_ring" title="Permalink to this definition"></a></dt>
<dd><p>Get the ring, or more specifically, the swift.common.ring.RingData.
This ring data is the minimum required for use of the ring. The ring
builder itself keeps additional data such as when partitions were last
moved.</p>
</dd></dl>

<dl class="classmethod">
<dt id="swift.common.ring.builder.RingBuilder.load">
<em class="property">classmethod </em><tt class="descname">load</tt><big>(</big><em>builder_file</em>, <em>open=&lt;built-in function open&gt;</em><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.load" title="Permalink to this definition"></a></dt>
<dd><p>Obtain RingBuilder instance of the provided builder file</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>builder_file</strong> &#8211; path to builder file to load</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">RingBuilder instance</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.builder.RingBuilder.pretend_min_part_hours_passed">
<tt class="descname">pretend_min_part_hours_passed</tt><big>(</big><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.pretend_min_part_hours_passed" title="Permalink to this definition"></a></dt>
<dd><p>Override min_part_hours by marking all partitions as having been moved
255 hours ago. This can be used to force a full rebalance on the next
call to rebalance.</p>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.builder.RingBuilder.rebalance">
<tt class="descname">rebalance</tt><big>(</big><em>seed=None</em><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.rebalance" title="Permalink to this definition"></a></dt>
<dd><p>Rebalance the ring.</p>
<p>This is the main work function of the builder, as it will assign and
reassign partitions to devices in the ring based on weights, distinct
zones, recent reassignments, etc.</p>
<p>The process doesn&#8217;t always perfectly assign partitions (that&#8217;d take a
lot more analysis and therefore a lot more time &#8211; I had code that did
that before). Because of this, it keeps rebalancing until the device
skew (number of partitions a device wants compared to what it has) gets
below 1% or doesn&#8217;t change by more than 1% (only happens with ring that
can&#8217;t be balanced no matter what &#8211; like with 3 zones of differing
weights with replicas set to 3).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">(number_of_partitions_altered, resulting_balance)</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.builder.RingBuilder.remove_dev">
<tt class="descname">remove_dev</tt><big>(</big><em>dev_id</em><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.remove_dev" title="Permalink to this definition"></a></dt>
<dd><p>Remove a device from the ring.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This will not rebalance the ring immediately as you may want to
make multiple changes for a single rebalance.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>dev_id</strong> &#8211; device id</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.builder.RingBuilder.save">
<tt class="descname">save</tt><big>(</big><em>builder_file</em><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.save" title="Permalink to this definition"></a></dt>
<dd><p>Serialize this RingBuilder instance to disk.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>builder_file</strong> &#8211; path to builder file to save</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.builder.RingBuilder.search_devs">
<tt class="descname">search_devs</tt><big>(</big><em>search_values</em><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.search_devs" title="Permalink to this definition"></a></dt>
<dd><p>Search devices by parameters.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>search_values</strong> &#8211; a dictionary with search values to filter
devices, supported parameters are id,
region, zone, ip, port, replication_ip,
replication_port, device, weight, meta</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">list of device dicts</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.builder.RingBuilder.set_dev_weight">
<tt class="descname">set_dev_weight</tt><big>(</big><em>dev_id</em>, <em>weight</em><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.set_dev_weight" title="Permalink to this definition"></a></dt>
<dd><p>Set the weight of a device. This should be called rather than just
altering the weight key in the device dict directly, as the builder
will need to rebuild some internal state to reflect the change.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This will not rebalance the ring immediately as you may want to
make multiple changes for a single rebalance.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>dev_id</strong> &#8211; device id</li>
<li><strong>weight</strong> &#8211; new weight for device</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.builder.RingBuilder.set_replicas">
<tt class="descname">set_replicas</tt><big>(</big><em>new_replica_count</em><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.set_replicas" title="Permalink to this definition"></a></dt>
<dd><p>Changes the number of replicas in this ring.</p>
<p>If the new replica count is sufficiently different that
self._replica2part2dev will change size, sets
self.devs_changed. This is so tools like
bin/swift-ring-builder can know to write out the new ring
rather than bailing out due to lack of balance change.</p>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.builder.RingBuilder.to_dict">
<tt class="descname">to_dict</tt><big>(</big><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.to_dict" title="Permalink to this definition"></a></dt>
<dd><p>Returns a dict that can be used later with copy_from to
restore a RingBuilder. swift-ring-builder uses this to
pickle.dump the dict to a file and later load that dict into
copy_from.</p>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.builder.RingBuilder.validate">
<tt class="descname">validate</tt><big>(</big><em>stats=False</em><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.validate" title="Permalink to this definition"></a></dt>
<dd><p>Validate the ring.</p>
<p>This is a safety function to try to catch any bugs in the building
process. It ensures partitions have been assigned to real devices,
aren&#8217;t doubly assigned, etc. It can also optionally check the even
distribution of partitions across devices.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>stats</strong> &#8211; if True, check distribution of partitions across devices</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">if stats is True, a tuple of (device_usage, worst_stat), else
(None, None). device_usage[dev_id] will equal the number of
partitions assigned to that device. worst_stat will equal the
number of partitions the worst device is skewed from the
number it should have.</td>
</tr>
<tr class="field-odd field"><th class="field-name" colspan="2">Raises RingValidationError:</th></tr>
<tr class="field-odd field"><td>&nbsp;</td><td class="field-body">problem was found with the ring.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="swift.common.ring.builder.RingBuilder.weight_of_one_part">
<tt class="descname">weight_of_one_part</tt><big>(</big><big>)</big><a class="headerlink" href="#swift.common.ring.builder.RingBuilder.weight_of_one_part" title="Permalink to this definition"></a></dt>
<dd><p>Returns the weight of each partition as calculated from the
total weight of all the devices.</p>
</dd></dl>

</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="proxy.html" title="Proxy"
             >next</a> |</li>
        <li class="right" >
          <a href="logs.html" title="Logs"
             >previous</a> |</li>
        <li><a href="index.html">swift 1.13.1 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2014, OpenStack Foundation.
      Last updated on Apr 17, 2014.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
    </div>
  </body>
</html>