2012-03-05 21:14:03 +00:00
|
|
|
things we need to do:
|
|
|
|
- decide what nodes to decode and encode
|
|
|
|
- of the resulting (and existing) chunks,
|
|
|
|
decide which to keep on the server
|
|
|
|
- decide what uploads and downloads to start
|
|
|
|
|
|
|
|
==============================
|
|
|
|
|
2012-03-08 22:42:44 +00:00
|
|
|
MC::classify()
|
|
|
|
classify nodes as PRESENT/RECOVERABLE/UNRECOVERABLE,
|
|
|
|
and compute recovery sets and recovery cost
|
2012-03-05 21:14:03 +00:00
|
|
|
|
2012-03-08 22:42:44 +00:00
|
|
|
NOTE: recovery cost should take into account uploads in progress
|
|
|
|
(treat them as zero cost)
|
2012-03-05 21:14:03 +00:00
|
|
|
|
2012-03-08 22:42:44 +00:00
|
|
|
for each chunk C
|
|
|
|
C.new_present_on_server = C.present_on_server
|
|
|
|
if C.status == PRESENT and need more replicas or download in progress
|
|
|
|
C.keep_present = true
|
2012-03-05 21:14:03 +00:00
|
|
|
|
2012-03-06 04:53:38 +00:00
|
|
|
// set need_recon, needed_by_parent, keep_present, need_present
|
|
|
|
//
|
2012-03-08 22:42:44 +00:00
|
|
|
MC::decide_reconstruct
|
2012-03-05 21:14:03 +00:00
|
|
|
if some child is UNREC
|
|
|
|
if PRESENT
|
|
|
|
need_recon = true
|
2012-03-08 22:42:44 +00:00
|
|
|
else if RECOVERABLE
|
2012-03-06 04:53:38 +00:00
|
|
|
need_present = true
|
|
|
|
for children C in recovery set
|
2012-03-08 22:42:44 +00:00
|
|
|
if C is PRESENT
|
|
|
|
C.keep_present = true
|
|
|
|
else
|
|
|
|
C.need_present = true;
|
|
|
|
if needed_by_parent
|
|
|
|
need_recon = true
|
|
|
|
if need_recon and not bottom-level
|
|
|
|
mark N PRESENT children as needed_by_parent
|
2012-03-05 21:14:03 +00:00
|
|
|
if keep_present
|
|
|
|
mark N PRESENT children as keep_present
|
2012-03-06 04:53:38 +00:00
|
|
|
if not bottom-level
|
|
|
|
recurse
|
2012-03-05 21:14:03 +00:00
|
|
|
|
2012-03-06 04:53:38 +00:00
|
|
|
// - do encoding and decoding;
|
|
|
|
// - delete all meta-chunk files when done;
|
|
|
|
// - delete unneeded chunks
|
|
|
|
// - set new_present_on_server
|
|
|
|
//
|
2012-03-08 22:42:44 +00:00
|
|
|
MC::reconstruct_and_cleanup
|
|
|
|
recurse
|
|
|
|
if need_recon
|
|
|
|
decode
|
2012-03-06 04:53:38 +00:00
|
|
|
this.expand()
|
2012-03-08 22:42:44 +00:00
|
|
|
if !needed_by_parent
|
|
|
|
delete this
|
|
|
|
if bottom level
|
2012-03-06 04:53:38 +00:00
|
|
|
npresent = M
|
|
|
|
for each child C
|
2012-03-08 22:42:44 +00:00
|
|
|
if C.status != UNREC && !C.keep_present
|
2012-03-06 04:53:38 +00:00
|
|
|
if !keep_present or npresent > N
|
|
|
|
delete C
|
|
|
|
npresent--
|
|
|
|
C.new_present_on_server = false
|
2012-03-08 22:42:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
// called if this unit has been reconstructed.
|
|
|
|
// Expand (i.e. encode) it if needed, and recurse.
|
|
|
|
// Clean up unneeded files.
|
|
|
|
//
|
|
|
|
MC::expand
|
|
|
|
if bottom-level
|
|
|
|
if some child C is not PRESENT and needs more replicas
|
|
|
|
encode
|
2012-03-06 04:53:38 +00:00
|
|
|
for each child C
|
2012-03-08 22:42:44 +00:00
|
|
|
if need more replicas or download in progress
|
|
|
|
C.new_present_on_server = true
|
|
|
|
else
|
|
|
|
C.new_present_on_server = false
|
|
|
|
delete C
|
|
|
|
else
|
|
|
|
if some child is UNREC
|
|
|
|
encode
|
|
|
|
for each child C with status != UNREC
|
|
|
|
delete C
|
|
|
|
for each child C with status == UNREC
|
2012-03-06 04:53:38 +00:00
|
|
|
C.expand()
|
2012-03-08 22:42:44 +00:00
|
|
|
delete C
|
|
|
|
|
|
|
|
start_xfers_and_update_db
|
|
|
|
for each chunk C
|
|
|
|
if C.new_present_on_server and need more replicas
|
|
|
|
start downloads of C
|
|
|
|
if C.need_present
|
|
|
|
start upload(s) of C
|
|
|
|
if C.new_present_on_server != C.present_on_server
|
|
|
|
C.update()
|
|
|
|
|
|
|
|
MC::compute_min_failures
|
|
|
|
recurse
|
|
|
|
present, recoverable: lists of chunks
|
|
|
|
if bottom-level
|
2012-03-05 21:14:03 +00:00
|
|
|
for each child C
|
2012-03-08 22:42:44 +00:00
|
|
|
if C.new_present_on_server
|
|
|
|
add C to present
|
|
|
|
else if C has N replicas
|
|
|
|
C.min_failures = N
|
|
|
|
add C to recoverable
|
2012-03-05 21:14:03 +00:00
|
|
|
else
|
2012-03-08 22:42:44 +00:00
|
|
|
for each child C
|
|
|
|
if PRESENT, add C to present
|
|
|
|
if RECO, add C to recoverable
|
|
|
|
if size(present) >= N
|
|
|
|
status = PRESENT
|
|
|
|
min_failures = INT_MAX
|
|
|
|
else if size(present) + size(recoverable)
|