/// <nodoc /> public BoolResult SetMachineStates(BitMachineIdSet inactiveMachines, BitMachineIdSet closedMachines = null) { bool updateBinManager = false; if (inactiveMachines != null) { _inactiveMachinesSet = inactiveMachines; InactiveMachines = inactiveMachines.EnumerateMachineIds().ToArray(); updateBinManager = true; } if (closedMachines != null) { _closedMachinesSet = closedMachines; ClosedMachines = closedMachines.EnumerateMachineIds().ToArray(); } if (EnableBinManagerUpdates && BinManager != null && updateBinManager) { // Closed machines aren't included in the bin manager's update because they are expected to be back // soon, so it doesn't make much sense to reorganize the stamp because of them. var activeMachines = _idByLocationMap.Values.Except(InactiveMachines).ToArray(); return(BinManager.UpdateAll(activeMachines, InactiveMachines)); } return(BoolResult.Success); }
/// <nodoc /> public void SetInactiveMachines(BitMachineIdSet inactiveMachines) { _inactiveMachinesSet = inactiveMachines; InactiveMachines = inactiveMachines.EnumerateMachineIds().ToArray(); if (EnableBinManagerUpdates && BinManager != null) { var activeMachines = _idByLocationMap.Values.Except(InactiveMachines).ToArray(); BinManager.UpdateAll(activeMachines, InactiveMachines); } }
/// <summary> /// Gets the set of locations designated for a hash. This is relevant for proactive copies and eviction. /// </summary> internal Result <MachineLocation[]> GetDesignatedLocations(ContentHash hash, bool includeExpired) { if (BinManager == null) { return(new Result <MachineLocation[]>("Could not get designated locations because BinManager is null")); } var locations = BinManager.GetDesignatedLocations(hash, includeExpired); return(locations .Where(machineId => !_inactiveMachinesSet[machineId]) .Select(id => _locationByIdMap[id.Index]) .ToArray()); }
/// <summary> /// Gets whether the given machine is a designated location for the hash /// </summary> internal bool IsDesignatedLocation(MachineId machineId, ContentHash hash, bool includeExpired) { if (BinManager == null) { return(false); } var locations = BinManager.GetDesignatedLocations(hash, includeExpired); if (!locations) { return(false); } return(locations.Value !.Contains(machineId)); }
/// <summary> /// This should only be used from the master. /// </summary> internal Result <MachineId[][]> GetBinMappings() => BinManager?.GetBins() ?? new Result <MachineId[][]>("Failed to get mappings since BinManager is null");
/// <summary> /// Gets whether the given machine is a designated location for the hash /// </summary> internal bool IsDesignatedLocation(MachineId machineId, ContentHash hash, bool includeExpired) { return(BinManager?.GetDesignatedLocations(hash, includeExpired).Contains(machineId) == true); }