The method for processing BackupInstanceFaulty from nodes
        and removing replicas with performance were degraded
        :param backup_faulty: BackupInstanceFaulty message with instances for removing
        :param frm:
        :return:
557718
def process_backup_instance_faulty_msg(self,
                                           backup_faulty: BackupInstanceFaulty,
                                           frm: str) -> None:
        '''
        
        '''
        logger.debug("{} receive BackupInstanceFaulty "
                     "from {}: {}".format(self.node, frm, backup_faulty))
        instances = getattr(backup_faulty, f.INSTANCES.nm)
        if getattr(backup_faulty, f.VIEW_NO.nm) != self.node.viewNo or \
                self.node.master_replica.instId in instances:
            return

        # Don't process BackupInstanceFaulty if strategy for this reason is not need quorum
        reason = Suspicions.get_by_code(getattr(backup_faulty, f.REASON.nm))
        if (
                reason == Suspicions.BACKUP_PRIMARY_DISCONNECTED and
                not self.is_quorum_strategy(self.node.config.REPLICAS_REMOVING_WITH_PRIMARY_DISCONNECTED)
        ) or (
                reason == Suspicions.BACKUP_PRIMARY_DEGRADED and
                not self.is_quorum_strategy(self.node.config.REPLICAS_REMOVING_WITH_DEGRADATION)
        ):
            return

        for inst_id in getattr(backup_faulty, f.INSTANCES.nm):
            if inst_id not in self.node.replicas.keys():
                continue
            self.backup_instances_faulty.setdefault(inst_id, dict()).setdefault(frm, 0)
            self.backup_instances_faulty[inst_id][frm] += 1
            all_nodes_condition = self.node.quorums.backup_instance_faulty.is_reached(
                len(self.backup_instances_faulty[inst_id].keys()))
            this_node_condition = (self.node.name in self.backup_instances_faulty[inst_id] and
                                   self.node.quorums.backup_instance_faulty.is_reached(
                                       self.backup_instances_faulty[inst_id][self.node.name]))
            if all_nodes_condition or this_node_condition:
                self.node.replicas.remove_replica(inst_id)
                self.backup_instances_faulty.pop(inst_id)
1329646
public Task revertToCurrentSnapshot_Task(HostSystem host) throws VmConfigFault, SnapshotFault, TaskInProgress, InvalidState, InsufficientResourcesFault, NotFound, RuntimeFault, RemoteException {
        return revertToCurrentSnapshot_Task(host, null);
    }
671962
def cli(env, volume_id, replicant_id):
    """"""
    file_storage_manager = SoftLayer.FileStorageManager(env.client)

    success = file_storage_manager.failback_from_replicant(
        volume_id,
        replicant_id
    )

    if success:
        click.echo("Failback from replicant is now in progress.")
    else:
        click.echo("Failback operation could not be initiated.")
124889
def remove
      with_retry(cluster) do
        cluster.with_primary do |node|
          node.remove(
            operation.database,
            operation.collection,
            operation.basic_selector,
            write_concern,
            flags: [ :remove_first ]
          )
        end
      end
    end
1054310
def process_instance_change_msg(self, instChg: InstanceChange, frm: str) -> None:
        
        if frm not in self.provider.connected_nodes():
            self.provider.discard(
                instChg,
                "received instance change request: {} from {} "
                "which is not in connected list: {}".format(
                    instChg, frm, self.provider.connected_nodes()), logger.info)
            return

        logger.info("{} received instance change request: {} from {}".format(self, instChg, frm))

        # TODO: add sender to blacklist?
        if not isinstance(instChg.viewNo, int):
            self.provider.discard(
                instChg, "{}field view_no has incorrect type: {}".format(
                    VIEW_CHANGE_PREFIX, type(instChg.viewNo)))
        elif instChg.viewNo <= self.view_no:
            self.provider.discard(
                instChg,
                "Received instance change request with view no {} "
                "which is not more than its view no {}".format(
                    instChg.viewNo, self.view_no), logger.info)
        else:
            # Record instance changes for views but send instance change
            # only when found master to be degraded. if quorum of view changes
            #  found then change view even if master not degraded
            self._on_verified_instance_change_msg(instChg, frm)

            if self.instance_changes.has_inst_chng_from(instChg.viewNo, self.name):
                logger.info("{} received instance change message {} but has already "
                            "sent an instance change message".format(self, instChg))
            elif not self.provider.is_master_degraded():
                logger.info("{} received instance change message {} but did not "
                            "find the master to be slow".format(self, instChg))
            else:
                logger.display("{}{} found master degraded after receiving instance change"
                               " message from {}".format(VIEW_CHANGE_PREFIX, self, frm))
                self.sendInstanceChange(instChg.viewNo)
1068728
protected void onAfterBackupSession( @Nonnull final MemcachedBackupSession session, final boolean backupWasForced,
            @Nonnull final Future<BackupResult> result, @Nonnull final String requestId,
            @Nonnull final BackupSessionService backupSessionService ) {

        if ( !_sessionIdFormat.isValid( session.getIdInternal() ) ) {
            return;
        }

        try {

            final long start = System.currentTimeMillis();

            final int maxInactiveInterval = session.getMaxInactiveInterval();
            final byte[] validityData = encode( maxInactiveInterval, session.getLastAccessedTimeInternal(),
                    session.getThisAccessedTimeInternal() );
            final String validityKey = _sessionIdFormat.createValidityInfoKeyName( session.getIdInternal() );
            // fix for #88, along with the change in session.getMemcachedExpirationTimeToSet
            final int expiration = maxInactiveInterval <= 0 ? 0 : maxInactiveInterval;
            final Future<Boolean> validityResult = _storage.set( validityKey, toMemcachedExpiration(expiration), validityData );
            if ( !_manager.isSessionBackupAsync() ) {
                // TODO: together with session backup wait not longer than sessionBackupTimeout.
                // Details: Now/here we're waiting the whole session backup timeout, even if (perhaps) some time
                // was spent before when waiting for session backup result.
                // For sync session backup it would be better to set both the session data and
                // validity info and afterwards wait for both results (but in sum no longer than sessionBackupTimeout)
                validityResult.get( _manager.getSessionBackupTimeout(), TimeUnit.MILLISECONDS );
            }
            if ( _log.isDebugEnabled() ) {
                _log.debug( "Stored session validity info for session " + session.getIdInternal() );
            }

            /* The following task are performed outside of the request thread (includes waiting for the backup result):
             * - ping session if the backup was skipped (depends on the backup result)
             * - save secondary session backup if session was modified (backup not skipped)
             * - ping secondary session backup if the backup was skipped
             * - save secondary validity backup
             */
            final boolean pingSessionIfBackupWasSkipped = !backupWasForced;
            final boolean performAsyncTasks = pingSessionIfBackupWasSkipped || _storeSecondaryBackup;

            if ( performAsyncTasks ) {
                final Callable<?> backupSessionTask = new OnAfterBackupSessionTask( session, result,
                        pingSessionIfBackupWasSkipped, backupSessionService, _storeSecondaryBackup, validityKey, validityData );
                _executor.submit( backupSessionTask );
            }

            _stats.registerSince( NON_STICKY_AFTER_BACKUP, start );

        } catch( final Throwable e ) {
            _log.warn( "An error occurred during onAfterBackupSession.", e );
        }

    }
269496
def _clean_tmp_dirs(self):
        

        def onerror(fnc, path, excinfo):
            # we might not have rights to do this, the files could be owned by root
            self.logger.info("we were not able to remove temporary file %s: %s", path, excinfo[1])

        shutil.rmtree(self.tmpdir, onerror=onerror)
        self.tmpdir = None
        global _backend_tmpdir
        _backend_tmpdir = None
145134
def rollback(self, verbose=False):
        
        for ns, insts in self.instances.items():
            insts.reverse()
            for inst in insts:
                try:
                    if verbose:
                        print(_format("Deleting instance {0}", inst.path))
                    self.conn.DeleteInstance(inst.path)
                except CIMError as ce:
                    print(_format("Error deleting instance {0}", inst.path))
                    print(_format("     {0} {1}",
                                  ce.status_code, ce.status_description))
        for ns, cnames in self.class_names.items():
            self.default_namespace = ns
            cnames.reverse()
            for cname in cnames:
                try:
                    if verbose:
                        print(_format("Deleting class {0!A}:{1!A}",
                                      ns, cname))
                    self.conn.DeleteClass(cname)
                except CIMError as ce:
                    print(_format("Error deleting class {0!A}:{1!A}",
                                  ns, cname))
                    print(_format("     {0} {1}",
                                  ce.status_code, ce.status_description))
234569
def reset(self):
        """"""
        if self._topology_type == TOPOLOGY_TYPE.ReplicaSetWithPrimary:
            topology_type = TOPOLOGY_TYPE.ReplicaSetNoPrimary
        else:
            topology_type = self._topology_type

        # The default ServerDescription's type is Unknown.
        sds = dict((address, ServerDescription(address))
                   for address in self._server_descriptions)

        return TopologyDescription(
            topology_type,
            sds,
            self._replica_set_name,
            self._max_set_version,
            self._max_election_id,
            self._topology_settings)
603093
def snapshot(cls, cluster_id_label, s3_location, backup_type):
        
        conn = Qubole.agent(version=Cluster.api_version)
        parameters = {}
        parameters['s3_location'] = s3_location
        if backup_type:
            parameters['backup_type'] = backup_type
        return conn.post(cls.element_path(cluster_id_label) + "/snapshots", data=parameters)
957651
void deleteReplica(Storable replica) throws PersistException {
        // Prevent trigger from being invoked by deleting replica.
        TriggerManager tm = mTriggerManager;
        tm.locallyDisableDelete();
        try {
            replica.delete();
        } finally {
            tm.locallyEnableDelete();
        }
    }
1267301
def invalidate(self):
        
        if hasattr(self, '_avail_backups'):
            del self._avail_backups
        if hasattr(self, '_ips'):
            del self._ips

        Base.invalidate(self)
1254495
def _writeFault(self, fail, request):
        
        response = fault.FaultFromException(fail.value, False, fail.tb).AsSOAP() 
        self._writeResponse(response, request, status=500)
547124
def synchronizeReplica(self,
                           replicaID,
                           transportType="esriTransportTypeUrl",
                           replicaServerGen=None,
                           returnIdsForAdds=False,
                           edits=None,
                           returnAttachmentDatabyURL=False,
                           async=False,
                           syncDirection="snapshot",
                           syncLayers="perReplica",
                           editsUploadID=None,
                           editsUploadFormat=None,
                           dataFormat="json",
                           rollbackOnFailure=True):
        
        params = {
            "f" : "json",
            "replicaID" : replicaID,
            "transportType" : transportType,
            "dataFormat" : dataFormat,
            "rollbackOnFailure" : rollbackOnFailure,
            "async" : async,
            "returnIdsForAdds": returnIdsForAdds,
            "syncDirection" : syncDirection,
            "returnAttachmentDatabyURL" : returnAttachmentDatabyURL
        }
        return
350935
void removeUnknownMembers() {
        ClusterServiceImpl clusterService = node.getClusterService();

        for (InternalPartitionImpl partition : partitions) {
            for (int i = 0; i < InternalPartition.MAX_REPLICA_COUNT; i++) {
                PartitionReplica replica = partition.getReplica(i);
                if (replica == null) {
                    continue;
                }

                if (clusterService.getMember(replica.address(), replica.uuid()) == null) {
                    partition.setReplica(i, null);
                    if (logger.isFinestEnabled()) {
                        logger.finest("PartitionId=" + partition.getPartitionId() + " " + replica
                                + " is removed from replica index: " + i + ", partition: " + partition);
                    }
                }
            }
        }
    }
983047
def _resume(self):
        # type: (Descriptor) -> int
        
        if self._resume_mgr is None or self._offset > 0:
            return None
        # check if path exists in resume db
        rr = self._resume_mgr.get_record(self._dst_ase)
        if rr is None:
            logger.debug('no resume record for {}'.format(self._dst_ase.path))
            return None
        # ensure lengths are the same
        if rr.length != self._src_ase.size:
            logger.warning('resume length mismatch {} -> {}'.format(
                rr.length, self._src_ase.size))
            return None
        # compute replica factor
        if blobxfer.util.is_not_empty(self._dst_ase.replica_targets):
            replica_factor = 1 + len(self._dst_ase.replica_targets)
        else:
            replica_factor = 1
        # set offsets if completed
        if rr.completed:
            with self._meta_lock:
                logger.debug('{} upload already completed'.format(
                    self._dst_ase.path))
                self._offset = rr.offset
                self._src_block_list = rr.src_block_list
                self._chunk_num = rr.total_chunks
                self._chunk_size = rr.chunk_size
                self._total_chunks = rr.total_chunks
                self._completed_chunks.int = rr.completed_chunks
                self._outstanding_ops = 0
                return self._src_ase.size * replica_factor
        # re-hash from 0 to offset if needed
        _cc = bitstring.BitArray(length=rr.total_chunks)
        _cc.int = rr.completed_chunks
        curr_chunk = _cc.find('0b0')[0]
        del _cc
        # set values from resume
        with self._meta_lock:
            self._offset = rr.offset
            self._src_block_list = rr.src_block_list
            self._chunk_num = curr_chunk
            self._chunk_size = rr.chunk_size
            self._total_chunks = rr.total_chunks
            self._completed_chunks = bitstring.BitArray(length=rr.total_chunks)
            self._completed_chunks.set(True, range(0, curr_chunk + 1))
            self._outstanding_ops = (
                (rr.total_chunks - curr_chunk) * replica_factor
            )
            logger.debug(
                ('resuming file {} from byte={} chunk={} chunk_size={} '
                 'total_chunks={} outstanding_ops={}').format(
                     self._src_ase.path, self._offset, self._chunk_num,
                     self._chunk_size, self._total_chunks,
                     self._outstanding_ops))
            return rr.offset * replica_factor
97873
def get_dump_best_secondary(self, max_repl_lag=None):
        
        secondary_lag_tuples = []

        primary_member = self.get_primary_member()
        if not primary_member:
            raise MongoctlException("Unable to determine primary member for"
                                    " cluster '%s'" % self.id)

        master_status = primary_member.get_server().get_member_rs_status()

        if not master_status:
            raise MongoctlException("Unable to determine replicaset status for"
                                    " primary member '%s'" %
                                    primary_member.get_server().id)

        for member in self.get_members():
            if member.get_server().is_secondary():
                repl_lag = member.get_server().get_repl_lag(master_status)
                if max_repl_lag and  repl_lag > max_repl_lag:
                    log_info("Excluding member '%s' because it's repl lag "
                             "(in seconds)%s is more than max %s. " %
                             (member.get_server().id,
                              repl_lag, max_repl_lag))
                    continue
                secondary_lag_tuples.append((member,repl_lag))

        def best_secondary_comp(x, y):
            x_mem, x_lag = x
            y_mem, y_lag = y
            if x_mem.is_passive():
                if y_mem.is_passive():
                    return x_lag - y_lag
                else:
                    return -1
            elif y_mem.is_passive():
                return 1
            else:
                return x_lag - y_lag

        if secondary_lag_tuples:
            secondary_lag_tuples.sort(best_secondary_comp)
            return secondary_lag_tuples[0][0]