Example #1
0
 /// <summary>
 ///
 /// </summary>
 public StorageManager(List <StorageLocation> InLocations, ManifestDownloadManager InDownloadManager, BuildManifestRegistry Registry, AsyncIOQueue InIOQueue, ManifestStorageHeuristic Heuristic, List <Guid> KeepBuilds, List <Guid> DeleteBuilds)
 {
     IOQueue          = InIOQueue;
     ManifestRegistry = Registry;
     DownloadManager  = InDownloadManager;
     Locations        = InLocations;
     StoredLocations  = new List <StorageLocation>(Locations);
     StorageHeuristic = Heuristic;
     StoragePrioritizeKeepingBuildTagIds  = KeepBuilds;
     StoragePrioritizeDeletingBuildTagIds = DeleteBuilds;
 }
Example #2
0
        /// <summary>
        /// </summary>
        /// <param name="InManifestDownloader"></param>
        /// <param name="Config"></param>
        public void Start(ManifestDownloadManager InManifestDownloader, DownloadStateCollection ResumeStateCollection, VirtualFileSystem FileSystem, ScmManager InScmManager, DateTime InReplicationNewestTime)
        {
            ManifestDownloader = InManifestDownloader;
            ManifestDownloader.OnDownloadError += DownloadError;

            ReplicationNewerThanTime = InReplicationNewestTime;

            if (ReplicationNewerThanTime.Equals(new DateTime(0)))
            {
                ReplicationNewerThanTime = DateTime.UtcNow;
            }

            ScmManager = InScmManager;

            StateCollection = ResumeStateCollection;
            BuildFileSystem = FileSystem;
            if (StateCollection == null)
            {
                StateCollection = new DownloadStateCollection();
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="Client"></param>
 public RemoteActionClient(Client InClient, ManifestDownloadManager InDownloadManager)
 {
     DownloadManager = InDownloadManager;
     Client          = InClient;
     Client.OnRequestRemoteActionRecieved  += RequestRecieved;
     Client.OnCancelRemoteActionRecieved   += CancelRecieved;
     Client.OnSolicitRemoteActionRecieved  += SolicitRemoteActionRecieved;
     Client.OnRemoteActionProgressRecieved += (NetMessage_RemoteActionProgress Msg) =>
     {
         RemoteActionClientState Action = GetActionState(Msg.ActionId);
         if (Action != null)
         {
             Action.Completed          = Msg.Completed;
             Action.Failed             = Msg.Failed;
             Action.ResultMessage      = Msg.ResultMessage;
             Action.Progress           = Msg.Progress;
             Action.ProgressText       = Msg.ProgressText;
             Action.LastUpdateRecieved = TimeUtils.Ticks;
         }
     };
 }
Example #4
0
        /// <summary>
        /// </summary>
        public static void OnStart()
        {
            Statistic.Instantiate();

            ScmManager = new ScmManager();
            IOQueue    = new AsyncIOQueue();
            ManifestDownloadManager = new ManifestDownloadManager();

            DownloadManager = new DownloadManager();
            DownloadManager.OnRequestReplicatedBuilds += (List <Guid> SelectTags, List <Guid> IgnoreTags, DateTime NewerThan) =>
            {
                NetClient.RequestFilteredBuilds(SelectTags, IgnoreTags, NewerThan);

                Settings.ReplicationNewerThanTime = DownloadManager.ReplicationNewerThanTime;
                SaveSettings();
            };

            Logger.Log(LogLevel.Info, LogCategory.Main, "OnStart: Initializing settings");
            InitSettings();

            NetClient          = new Core.Client.Client();
            RemoteActionClient = new RemoteActionClient(NetClient, ManifestDownloadManager);

            TagRegistry   = new TagRegistry();
            RouteRegistry = new RouteRegistry(null, TagRegistry);
            BuildRegistry = new BuildManifestRegistry(TagRegistry);

            StorageManager = new StorageManager(Settings.StorageLocations, ManifestDownloadManager, BuildRegistry, IOQueue, Settings.StorageHeuristic, Settings.PrioritizeKeepingBuildTagIds, Settings.PrioritizeDeletingBuildTagIds);

            Logger.Log(LogLevel.Info, LogCategory.Main, "OnStart: Setting up network client");
            BuildRegistry.Open(Path.Combine(AppDataDir, "Manifests"), int.MaxValue);

            Logger.Log(LogLevel.Info, LogCategory.Main, "OnStart: Setting up network client");
            NetClient.Start(
                Settings.ServerHostname,
                Settings.ServerPort,
                Settings.ClientPortRangeMin,
                Settings.ClientPortRangeMax,
                Settings.AllowRemoteActions,
                Settings.TagIds,
                BuildRegistry,
                StorageManager,
                ManifestDownloadManager,
                TagRegistry,
                RouteRegistry
                );
            NetClient.TagIds = new List <Guid>(Settings.TagIds);

            // Setup the virtual file system we will store our available builds in.
            Logger.Log(LogLevel.Info, LogCategory.Main, "OnStart: Setting up build file system");

            BuildFileSystem = new VirtualFileSystem();
            NetClient.OnClientTagsUpdatedByServer += () =>
            {
                Settings.TagIds = NetClient.TagIds;

                NetClient.RestartConnections();
                SaveSettings();
            };
            NetClient.OnTagListRecieved += (List <Tag> InTags) =>
            {
                TagRenderer.InvalidateResources();
            };
            NetClient.OnPermissionsUpdated += () =>
            {
                BuildFileSystem.ForceRefresh();
                DownloadManager.ForceRefresh();
            };
            NetClient.OnBuildPublished += (string Path, Guid Id) =>
            {
                BuildFileSystem.ForceRefresh();
                DownloadManager.ForceRefresh();
            };
            NetClient.OnBuildUpdated += (string Path, Guid Id) =>
            {
                BuildFileSystem.ForceRefresh();
                DownloadManager.ForceRefresh();
            };
            NetClient.OnConnectedToServer      += () => { BuildFileSystem.ForceRefresh(); };
            NetClient.OnFilteredBuildsRecieved += (Builds) =>
            {
                DownloadManager.RecieveReplicatedBuilds(Builds);
            };
            NetClient.OnBuildsRecieved += (RootPath, Builds) =>
            {
                List <VirtualFileSystemInsertChild> NewChildren = new List <VirtualFileSystemInsertChild>();
                foreach (NetMessage_GetBuildsResponse.BuildInfo Build in Builds)
                {
                    NewChildren.Add(
                        new VirtualFileSystemInsertChild
                    {
                        VirtualPath = Build.VirtualPath,
                        CreateTime  = Build.Guid == Guid.Empty ? DateTime.UtcNow : Build.CreateTime,
                        Metadata    = Build
                    }
                        );
                }

                BuildFileSystem.ReconcileChildren(RootPath, NewChildren);
            };
            BuildFileSystem.OnRequestChildren += (FileSystem, Path) =>
            {
                if (NetClient.IsConnected)
                {
                    NetClient.RequestBuilds(Path);
                }
            };
            BuildFileSystem.Init();

            // Setup download managers for the manifest and app level.
            Logger.Log(LogLevel.Info, LogCategory.Main, "OnStart: Setting up manifest download manager");

            ManifestDownloadManager.Start(
                StorageManager,
                Settings.ManifestDownloadStates,
                BuildRegistry,
                IOQueue
                );

            Logger.Log(LogLevel.Info, LogCategory.Main, "OnStart: Setting up download manager");

            DownloadManager.Start(
                ManifestDownloadManager,
                Settings.DownloadStates,
                BuildFileSystem,
                ScmManager,
                Settings.ReplicationNewerThanTime
                );

            Logger.Log(LogLevel.Info, LogCategory.Main, "OnStart: Setting up update download");

            // Ensure we are downloading the latest update.
            string UpdateDownloadName = "$ Buildsync Update $";

            foreach (DownloadState State in DownloadManager.States.States)
            {
                if (State.Name == UpdateDownloadName)
                {
                    InternalUpdateDownload = State;
                    break;
                }
            }

            if (InternalUpdateDownload == null)
            {
                InternalUpdateDownload = DownloadManager.AddDownload(UpdateDownloadName, "$Internal$/Updates", 2, BuildSelectionRule.Newest, BuildSelectionFilter.None, "", "", true, false, "", "", new List <Guid>(), new List <Guid>());
            }

            // Make sure we have to get the latest manifest id before updating.
            InternalUpdateDownload.ActiveManifestId = Guid.Empty;

            // Clean up any orphan builds.
            StorageManager.CleanUpOrphanBuilds();

            Logger.Log(LogLevel.Info, LogCategory.Main, "OnStart: Complete");
        }