示例#1
0
        private void SchedulePostFetchJob(List <string> packIndexes)
        {
            if (packIndexes.Count == 0)
            {
                return;
            }

            // We make a best-effort request to run MIDX and commit-graph writes
            using (NamedPipeClient pipeClient = new NamedPipeClient(this.Context.Enlistment.NamedPipeName))
            {
                if (!pipeClient.Connect())
                {
                    this.Context.Tracer.RelatedWarning(
                        metadata: this.CreateEventMetadata(),
                        message: "Failed to connect to GSD.Mount process. Skipping post-fetch job request.",
                        keywords: Keywords.Telemetry);
                    return;
                }

                NamedPipeMessages.RunPostFetchJob.Request request = new NamedPipeMessages.RunPostFetchJob.Request(packIndexes);
                if (pipeClient.TrySendRequest(request.CreateMessage()))
                {
                    NamedPipeMessages.Message response;

                    if (pipeClient.TryReadResponse(out response))
                    {
                        this.Context.Tracer.RelatedInfo("Requested post-fetch job with resonse '{0}'", response.Header);
                    }
                    else
                    {
                        this.Context.Tracer.RelatedWarning(
                            metadata: this.CreateEventMetadata(),
                            message: "Requested post-fetch job failed to respond",
                            keywords: Keywords.Telemetry);
                    }
                }
                else
                {
                    this.Context.Tracer.RelatedWarning(
                        metadata: this.CreateEventMetadata(),
                        message: "Message to named pipe failed to send, skipping post-fetch job request.",
                        keywords: Keywords.Telemetry);
                }
            }
        }
示例#2
0
        private static bool TrySchedulePostFetchJob(ITracer tracer, string namedPipeName, List <string> packIndexes)
        {
            // We make a best-effort request to run MIDX and commit-graph writes
            using (NamedPipeClient pipeClient = new NamedPipeClient(namedPipeName))
            {
                if (!pipeClient.Connect())
                {
                    tracer.RelatedWarning(
                        metadata: null,
                        message: "Failed to connect to GVFS.Mount process. Skipping post-fetch job request.",
                        keywords: Keywords.Telemetry);
                    return(false);
                }

                NamedPipeMessages.RunPostFetchJob.Request request = new NamedPipeMessages.RunPostFetchJob.Request(packIndexes);
                if (pipeClient.TrySendRequest(request.CreateMessage()))
                {
                    NamedPipeMessages.Message response;

                    if (pipeClient.TryReadResponse(out response))
                    {
                        tracer.RelatedInfo("Requested post-fetch job with resonse '{0}'", response.Header);
                        return(true);
                    }
                    else
                    {
                        tracer.RelatedWarning(
                            metadata: null,
                            message: "Requested post-fetch job failed to respond",
                            keywords: Keywords.Telemetry);
                    }
                }
                else
                {
                    tracer.RelatedWarning(
                        metadata: null,
                        message: "Message to named pipe failed to send, skipping post-fetch job request.",
                        keywords: Keywords.Telemetry);
                }
            }

            return(false);
        }
示例#3
0
        private void HandlePostFetchJobRequest(NamedPipeMessages.Message message, NamedPipeServer.Connection connection)
        {
            NamedPipeMessages.RunPostFetchJob.Request request = new NamedPipeMessages.RunPostFetchJob.Request(message);

            this.tracer.RelatedInfo("Received post-fetch job request with body {0}", message.Body);

            NamedPipeMessages.RunPostFetchJob.Response response;
            if (this.currentState == MountState.Ready)
            {
                List <string> packIndexes = JsonConvert.DeserializeObject <List <string> >(message.Body);
                this.maintenanceScheduler.EnqueueOneTimeStep(new PostFetchStep(this.context, packIndexes));

                response = new NamedPipeMessages.RunPostFetchJob.Response(NamedPipeMessages.RunPostFetchJob.QueuedResult);
            }
            else
            {
                response = new NamedPipeMessages.RunPostFetchJob.Response(NamedPipeMessages.RunPostFetchJob.MountNotReadyResult);
            }

            connection.TrySendResponse(response.CreateMessage());
        }
        private void HandlePostFetchJobRequest(NamedPipeMessages.Message message, NamedPipeServer.Connection connection)
        {
            NamedPipeMessages.RunPostFetchJob.Request request = new NamedPipeMessages.RunPostFetchJob.Request(message);

            this.tracer.RelatedInfo("Received post-fetch job request with body {0}", message.Body);

            NamedPipeMessages.RunPostFetchJob.Response response;
            if (this.currentState == MountState.Ready)
            {
                List <string> packIndexes = JsonConvert.DeserializeObject <List <string> >(message.Body);
                this.fileSystemCallbacks.LaunchPostFetchJob(packIndexes);

                response = new NamedPipeMessages.RunPostFetchJob.Response(NamedPipeMessages.RunPostFetchJob.QueuedResult);
            }
            else
            {
                response = new NamedPipeMessages.RunPostFetchJob.Response(NamedPipeMessages.RunPostFetchJob.MountNotReadyResult);
            }

            connection.TrySendResponse(response.CreateMessage());
        }
示例#5
0
        private void PrefetchCommits(ITracer tracer, GVFSEnlistment enlistment, GitObjectsHttpRequestor objectRequestor, CacheServerInfo cacheServer)
        {
            bool               success;
            string             error       = string.Empty;
            PhysicalFileSystem fileSystem  = new PhysicalFileSystem();
            GitRepo            repo        = new GitRepo(tracer, enlistment, fileSystem);
            GVFSContext        context     = new GVFSContext(tracer, fileSystem, repo, enlistment);
            GitObjects         gitObjects  = new GVFSGitObjects(context, objectRequestor);
            List <string>      packIndexes = null;

            if (this.Verbose)
            {
                success = this.TryPrefetchCommitsAndTrees(tracer, enlistment, fileSystem, gitObjects, out error, out packIndexes);
            }
            else
            {
                success = this.ShowStatusWhileRunning(
                    () => this.TryPrefetchCommitsAndTrees(tracer, enlistment, fileSystem, gitObjects, out error, out packIndexes),
                    "Fetching commits and trees " + this.GetCacheServerDisplay(cacheServer));
            }

            if (success)
            {
                if (packIndexes.Count == 0)
                {
                    return;
                }

                // We make a best-effort request to run MIDX and commit-graph writes
                using (NamedPipeClient pipeClient = new NamedPipeClient(enlistment.NamedPipeName))
                {
                    if (!pipeClient.Connect())
                    {
                        tracer.RelatedWarning(
                            metadata: null,
                            message: "Failed to connect to GVFS. Skipping post-fetch job request.",
                            keywords: Keywords.Telemetry);
                        return;
                    }

                    NamedPipeMessages.RunPostFetchJob.Request request = new NamedPipeMessages.RunPostFetchJob.Request(packIndexes);
                    if (pipeClient.TrySendRequest(request.CreateMessage()))
                    {
                        NamedPipeMessages.Message response;

                        if (pipeClient.TryReadResponse(out response))
                        {
                            tracer.RelatedInfo("Requested post-fetch job with resonse '{0}'", response.Header);
                        }
                        else
                        {
                            tracer.RelatedWarning(
                                metadata: null,
                                message: "Requested post-fetch job failed to respond",
                                keywords: Keywords.Telemetry);
                        }
                    }
                    else
                    {
                        tracer.RelatedWarning(
                            metadata: null,
                            message: "Message to named pipe failed to send, skipping post-fetch job request.",
                            keywords: Keywords.Telemetry);
                    }
                }
            }
            else
            {
                this.ReportErrorAndExit(tracer, "Prefetching commits and trees failed: " + error);
            }
        }
示例#6
0
        public static bool TryPrefetchCommitsAndTrees(
            ITracer tracer,
            GVFSEnlistment enlistment,
            PhysicalFileSystem fileSystem,
            GitObjects gitObjects,
            out string error)
        {
            List <string> packIndexes;

            using (FileBasedLock prefetchLock = new FileBasedLock(
                       fileSystem,
                       tracer,
                       Path.Combine(enlistment.GitPackRoot, PrefetchCommitsAndTreesLock),
                       enlistment.EnlistmentRoot,
                       overwriteExistingLock: true))
            {
                WaitUntilLockIsAcquired(tracer, prefetchLock);
                long maxGoodTimeStamp;

                gitObjects.DeleteStaleTempPrefetchPackAndIdxs();

                if (!TryGetMaxGoodPrefetchTimestamp(tracer, enlistment, fileSystem, gitObjects, out maxGoodTimeStamp, out error))
                {
                    return(false);
                }

                if (!gitObjects.TryDownloadPrefetchPacks(maxGoodTimeStamp, out packIndexes))
                {
                    error = "Failed to download prefetch packs";
                    return(false);
                }
            }

            if (packIndexes == null || packIndexes.Count == 0)
            {
                return(true);
            }

            // We make a best-effort request to run MIDX and commit-graph writes
            using (NamedPipeClient pipeClient = new NamedPipeClient(enlistment.NamedPipeName))
            {
                if (!pipeClient.Connect())
                {
                    tracer.RelatedWarning(
                        metadata: null,
                        message: "Failed to connect to GVFS. Skipping post-fetch job request.",
                        keywords: Keywords.Telemetry);
                    return(true);
                }

                NamedPipeMessages.RunPostFetchJob.Request request = new NamedPipeMessages.RunPostFetchJob.Request(packIndexes);
                if (pipeClient.TrySendRequest(request.CreateMessage()))
                {
                    NamedPipeMessages.Message response;

                    if (pipeClient.TryReadResponse(out response))
                    {
                        tracer.RelatedInfo("Requested post-fetch job with resonse '{0}'", response.Header);
                        return(true);
                    }
                    else
                    {
                        tracer.RelatedWarning(
                            metadata: null,
                            message: "Requested post-fetch job failed to respond",
                            keywords: Keywords.Telemetry);
                    }
                }
                else
                {
                    tracer.RelatedWarning(
                        metadata: null,
                        message: "Message to named pipe failed to send, skipping post-fetch job request.",
                        keywords: Keywords.Telemetry);
                }
            }

            return(false);
        }