fn check_consistency(&self) -> Result<()> {
        let s = self.get();
        // ID consistency
        if s.id.get_session_id() != s.session.get_id() {
            bail!("ID and Session ID mismatch in {:?}", s);
        }
        // reference symmetries
        for wr in s.assigned.iter() {
            if !wr.get().assigned_objects.contains(self) {
                bail!("assigned asymmetry in {:?}", s);
            }
        }
        for wr in s.scheduled.iter() {
            if !wr.get().scheduled_objects.contains(self) {
                bail!("scheduled asymmetry in {:?}", s);
            }
        }
        for wr in s.located.iter() {
            if !wr.get().located_objects.contains(self) {
                bail!("located asymmetry in {:?}", s);
            }
            if !s.assigned.contains(wr) {
                bail!("located at not-assigned governor in {:?}", s);
            }
        }
        if !s.session.get().objects.contains(self) {
            bail!("session assymetry in {:?}", s);
        }
        if let Some(ref tr) = s.producer {
            if !tr.get().outputs.contains(self) {
                bail!("object missing in producer {:?} outputs in {:?}", tr, s);
            }
        }
        // producer consistency
        if let Some(ref pr) = s.producer {
            let p = pr.get();
            if s.state == DataObjectState::Unfinished && p.state == TaskState::Finished {
                bail!("producer finished state inconsistency in {:?}", s);
            }
            if s.state == DataObjectState::Finished && p.state != TaskState::Finished {
                bail!("producer not finished state inconsistency in {:?}", s);
            }
            // Not relevant anyomre:
/*            if let Some(ref swr) = p.scheduled {
                if !s.scheduled.contains(swr) {
                    bail!("not scheduled to producer governor in {:?}");
                }
            }
  */            if let Some(ref swr) = p.assigned {
                if !s.assigned.contains(swr) {
                    bail!("not assigned to producer governor in {:?}");
                }
            }
        } else {
            /* When session is cleared, the following invariant is not true
            if s.state == DataObjectState::Finished {
                if s.data.is_none() {
                    bail!("no data present for object without producer in {:?}", s);
                }
            }*/
        }
        // state consistency
        if !match s.state {
            DataObjectState::Unfinished => s.scheduled.len() <= 1 && s.assigned.len() <= 1,
            // NOTE: Can't check s.producer.is_some() in case the session is being destroyed,
            DataObjectState::Finished => {
                s.data.is_some() || (s.located.len() >= 1 && s.assigned.len() >= 1)
            }
            DataObjectState::Removed => {
                s.located.is_empty() && s.scheduled.is_empty() && s.assigned.is_empty()
                    && s.finish_hooks.is_empty()
            } /* &&  Why this?? s.size.is_some()*/
              /* This is not true when session failed && s.data.is_none()*/
        } {
            bail!("state inconsistency in {:?}", s);
        }
        // data consistency
        if let Some(_) = s.data {
            if s.size.is_none()
            /*|| dr.len() != s.size.unwrap()*/
            {
                bail!("size and uploaded data mismatch in {:?}", s);
            }
        }
        // finish hooks
        if !s.finish_hooks.is_empty() && s.state != DataObjectState::Unfinished {
            bail!("finish hooks for finished/removed object in {:?}", s);
        }
        // keepflag and empty assigned (via Removed state)
        // NOTE: Finished state already requires nonemplty locations
        if s.client_keep && s.state == DataObjectState::Removed {
            bail!("client_keep flag on removed object {:?}", s);
        }

        // used or kept objects must be assigned when their producers are
        if (s.client_keep || !s.consumers.is_empty()) && s.assigned.is_empty()
            && s.state == DataObjectState::Unfinished
        {
            if let Some(ref prod) = s.producer {
                let p = prod.get();
                if p.state == TaskState::Assigned || p.state == TaskState::Running {
                    bail!(
                        "Unfinished object is not assigned when it's producer task is in {:?}",
                        s
                    );
                }
            }
        }
        Ok(())
    }
/// Check for state and relationships consistency. Only explores adjacent objects but still
/// may be slow.
Check for state and relationships consistency. Only explores adjacent objects but still
may be slow.
Check for state and relationships consistency . Only explores adjacent objects but still may be slow .
fn check_consistency(&self) -> Result<()> {
        let s = self.get();
        // ID consistency
        if s.id.get_session_id() != s.session.get_id() {
            bail!("ID and Session ID mismatch in {:?}", s);
        }
        // reference symmetries
        for wr in s.assigned.iter() {
            if !wr.get().assigned_objects.contains(self) {
                bail!("assigned asymmetry in {:?}", s);
            }
        }
        for wr in s.scheduled.iter() {
            if !wr.get().scheduled_objects.contains(self) {
                bail!("scheduled asymmetry in {:?}", s);
            }
        }
        for wr in s.located.iter() {
            if !wr.get().located_objects.contains(self) {
                bail!("located asymmetry in {:?}", s);
            }
            if !s.assigned.contains(wr) {
                bail!("located at not-assigned governor in {:?}", s);
            }
        }
        if !s.session.get().objects.contains(self) {
            bail!("session assymetry in {:?}", s);
        }
        if let Some(ref tr) = s.producer {
            if !tr.get().outputs.contains(self) {
                bail!("object missing in producer {:?} outputs in {:?}", tr, s);
            }
        }
        // producer consistency
        if let Some(ref pr) = s.producer {
            let p = pr.get();
            if s.state == DataObjectState::Unfinished && p.state == TaskState::Finished {
                bail!("producer finished state inconsistency in {:?}", s);
            }
            if s.state == DataObjectState::Finished && p.state != TaskState::Finished {
                bail!("producer not finished state inconsistency in {:?}", s);
            }
            // Not relevant anyomre:
/*            if let Some(ref swr) = p.scheduled {
                if !s.scheduled.contains(swr) {
                    bail!("not scheduled to producer governor in {:?}");
                }
            }
  */            if let Some(ref swr) = p.assigned {
                if !s.assigned.contains(swr) {
                    bail!("not assigned to producer governor in {:?}");
                }
            }
        } else {
            /* When session is cleared, the following invariant is not true
            if s.state == DataObjectState::Finished {
                if s.data.is_none() {
                    bail!("no data present for object without producer in {:?}", s);
                }
            }*/
        }
        // state consistency
        if !match s.state {
            DataObjectState::Unfinished => s.scheduled.len() <= 1 && s.assigned.len() <= 1,
            // NOTE: Can't check s.producer.is_some() in case the session is being destroyed,
            DataObjectState::Finished => {
                s.data.is_some() || (s.located.len() >= 1 && s.assigned.len() >= 1)
            }
            DataObjectState::Removed => {
                s.located.is_empty() && s.scheduled.is_empty() && s.assigned.is_empty()
                    && s.finish_hooks.is_empty()
            } /* &&  Why this?? s.size.is_some()*/
              /* This is not true when session failed && s.data.is_none()*/
        } {
            bail!("state inconsistency in {:?}", s);
        }
        // data consistency
        if let Some(_) = s.data {
            if s.size.is_none()
            /*|| dr.len() != s.size.unwrap()*/
            {
                bail!("size and uploaded data mismatch in {:?}", s);
            }
        }
        // finish hooks
        if !s.finish_hooks.is_empty() && s.state != DataObjectState::Unfinished {
            bail!("finish hooks for finished/removed object in {:?}", s);
        }
        // keepflag and empty assigned (via Removed state)
        // NOTE: Finished state already requires nonemplty locations
        if s.client_keep && s.state == DataObjectState::Removed {
            bail!("client_keep flag on removed object {:?}", s);
        }
        // used or kept objects must be assigned when their producers are
        if (s.client_keep || !s.consumers.is_empty()) && s.assigned.is_empty()
            && s.state == DataObjectState::Unfinished
        {
            if let Some(ref prod) = s.producer {
                let p = prod.get();
                if p.state == TaskState::Assigned || p.state == TaskState::Running {
                    bail!(
                        "Unfinished object is not assigned when it's producer task is in {:?}",
                        s
                    );
                }
            }
        }
        Ok(())
    }
fn check_consistency ( & self ) -> Result < ( ) > { let s = self . get ( ) ; // ID consistency if s . id . get_session_id ( ) != s . session . get_id ( ) { bail ! ( " " s ) ; } // reference symmetries for wr in s . assigned . iter ( ) { if ! wr . get ( ) . assigned_objects . contains ( self ) { bail ! ( " " s ) ; } } for wr in s . scheduled . iter ( ) { if ! wr . get ( ) . scheduled_objects . contains ( self ) { bail ! ( " " s ) ; } } for wr in s . located . iter ( ) { if ! wr . get ( ) . located_objects . contains ( self ) { bail ! ( " " s ) ; } if ! s . assigned . contains ( wr ) { bail ! ( " " s ) ; } } if ! s . session . get ( ) . objects . contains ( self ) { bail ! ( " " s ) ; } if let Some ( ref tr ) = s . producer { if ! tr . get ( ) . outputs . contains ( self ) { bail ! ( " " tr s ) ; } } // producer consistency if let Some ( ref pr ) = s . producer { let p = pr . get ( ) ; if s . state == DataObjectState :: Unfinished && p . state == TaskState :: Finished { bail ! ( " " s ) ; } if s . state == DataObjectState :: Finished && p . state != TaskState :: Finished { bail ! ( " " s ) ; } // Not relevant anyomre: /*            if let Some(ref swr) = p.scheduled {
                if !s.scheduled.contains(swr) {
                    bail!("not scheduled to producer governor in {:?}");
                }
            }
  */ if let Some ( ref swr ) = p . assigned { if ! s . assigned . contains ( swr ) { bail ! ( " " ) ; } } } else { /* When session is cleared, the following invariant is not true
            if s.state == DataObjectState::Finished {
                if s.data.is_none() {
                    bail!("no data present for object without producer in {:?}", s);
                }
            }*/ } // state consistency if ! match s . state { DataObjectState :: Unfinished => s . scheduled . len ( ) <= 1 && s . assigned . len ( ) <= 1 , // NOTE: Can't check s.producer.is_some() in case the session is being destroyed, DataObjectState :: Finished => { s . data . is_some ( ) || ( s . located . len ( ) >= 1 && s . assigned . len ( ) >= 1 ) } DataObjectState :: Removed => { s . located . is_empty ( ) && s . scheduled . is_empty ( ) && s . assigned . is_empty ( ) && s . finish_hooks . is_empty ( ) } /* &&  Why this?? s.size.is_some()*/ /* This is not true when session failed && s.data.is_none()*/ } { bail ! ( " " s ) ; } // data consistency if let Some ( _ ) = s . data { if s . size . is_none ( ) /*|| dr.len() != s.size.unwrap()*/ { bail ! ( " " s ) ; } } // finish hooks if ! s . finish_hooks . is_empty ( ) && s . state != DataObjectState :: Unfinished { bail ! ( " " s ) ; } // keepflag and empty assigned (via Removed state) // NOTE: Finished state already requires nonemplty locations if s . client_keep && s . state == DataObjectState :: Removed { bail ! ( " " s ) ; } // used or kept objects must be assigned when their producers are if ( s . client_keep || ! s . consumers . is_empty ( ) ) && s . assigned . is_empty ( ) && s . state == DataObjectState :: Unfinished { if let Some ( ref prod ) = s . producer { let p = prod . get ( ) ; if p . state == TaskState :: Assigned || p . state == TaskState :: Running { bail ! ( " " s ) ; } } } Ok ( ( ) ) }
Check for state and relationships consistency.
Check for state and relationships consistency .
&self
&self