Beispiel #1
0
        private Task <PushFileResult> PushCheckpointFileAsync(OperationContext context, ContentHashWithSize hashWithSize)
        {
            return(context.PerformOperationAsync(Tracer, async() =>
            {
                var destinationMachineResult = _locationStore.ClusterState.GetRandomMachineLocation(Array.Empty <MachineLocation>());
                if (!destinationMachineResult.Succeeded)
                {
                    return new PushFileResult(destinationMachineResult, "Failed to get a location to proactively copy the checkpoint file.");
                }

                var destionationMachine = destinationMachineResult.Value;

                var streamResult = await _privateCas.OpenStreamAsync(context, hashWithSize.Hash, pinRequest: null);
                if (!streamResult.Succeeded)
                {
                    return new PushFileResult(streamResult, "Should have been able to open the stream from the local CAS");
                }

                using var stream = streamResult.Stream !;
                return await _copier.PushFileAsync(
                    context,
                    hashWithSize,
                    destionationMachine,
                    stream,
                    isInsideRing: false,
                    CopyReason.ProactiveCheckpointCopy,
                    ProactiveCopyLocationSource.Random,
                    attempt: 0);
            },
 public Task ContentAdded(ContentHashWithSize item)
 {
     ContentAddedCalled = true;
     return(Task.FromResult(0));
 }
Beispiel #3
0
        private async Task <Unit> SetLocationBitAndExpireAsync(OperationContext context, IBatch batch, RedisKey key, ContentHashWithSize hash, MachineId machineId)
        {
            var tasks = new List <Task>();

            // NOTE: The order here matters. KeyExpire must be after creation of the entry. SetBit creates the entry if needed.
            tasks.Add(batch.StringSetBitAsync(key, machineId.GetContentLocationEntryBitOffset(), true));
            tasks.Add(batch.KeyExpireAsync(key, _configuration.LocationEntryExpiry));

            // NOTE: We don't set the size when using optimistic location registration because the entry should have already been created at this point (the prior set
            // if not exists call failed indicating the entry already exists).
            // There is a small race condition if the entry was near-expiry and this call ends up recreating the entry without the size being set. We accept
            // this possibility since we have to handle unknown size and either case and the occurrence of the race should be rare. Also, we can mitigate by
            // applying the size from the local database which should be known if the entry is that old.
            if (!_configuration.UseOptimisticRegisterLocalLocation && hash.Size >= 0)
            {
                tasks.Add(batch.StringSetRangeAsync(key, 0, ContentLocationEntry.ConvertSizeToRedisRangeBytes(hash.Size)));
            }

            await Task.WhenAll(tasks);

            return(Unit.Void);
        }
 public Task <PutResult> PutTrustedFileAsync(Context context, AbsolutePath path, FileRealizationMode realizationMode, ContentHashWithSize contentHash, PinRequest?pinContext = null)
 {
     throw new NotImplementedException();
 }
Beispiel #5
0
 public Task ContentEvicted(ContentHashWithSize item)
 {
     _onContentEvicted?.Invoke(item);
     return(Task.FromResult(0));
 }
Beispiel #6
0
 public Task ContentEvicted(ContentHashWithSize item)
 {
     return(Task.FromResult(0));
 }
        /// <inheritdoc />
        public Task <PutResult> PutTrustedFileAsync(Context context, ContentHashWithSize contentHashWithSize, AbsolutePath path, FileRealizationMode realizationMode, CancellationToken cts, UrgencyHint urgencyHint)
        {
            var session = GetCache <ITrustedContentSession>(path);

            return(session.PutTrustedFileAsync(context, contentHashWithSize, path, realizationMode, cts, urgencyHint));
        }