Beispiel #1
0
        public async Task TestGetComponentPackages()
        {
            var componentSettings = (await _componentSettingsDataAccess.GetComponentPackagesAsync()).ToArray();

            Assert.IsNotNull(componentSettings);
            Assert.IsTrue(componentSettings.Count() > 0);
            Assert.AreEqual("fileWatcherPackage", componentSettings[0].Name);
            Assert.AreEqual("C:\\repos\\Integration Platform\\TDIE.ComponentHost.WebApi\\TDIE.ComponentHost.WebApi\\bin\\Release\\netcoreapp2.2\\p2.zip", componentSettings[0].PackagePath);

            Assert.AreEqual("quartzSchedulerPackage", componentSettings[1].Name);
            Assert.AreEqual("C:\\repos\\Integration Platform\\TDIE.ComponentHost.WebApi\\TDIE.ComponentHost.WebApi\\bin\\Release\\netcoreapp2.2\\p3.zip", componentSettings[1].PackagePath);

            Assert.AreEqual("basicMessagePublisher", componentSettings[2].Name);
            Assert.AreEqual("C:\\repos\\Integration Platform\\TDIE.ComponentHost.WebApi\\TDIE.ComponentHost.WebApi\\bin\\Release\\netcoreapp2.2\\p4.zip", componentSettings[2].PackagePath);
        }
Beispiel #2
0
        private async Task SynchronizeComonentHostInstancesAndPackagesAsync(NodeServer node)
        {
            // get expected instances on node
            // get instances currently on node
            // request to end all instances and start them again
            // if there's a discrepency
            INodeAccessService nodeAccess = NodeAccessFactory.Get(node);
            IComponentHostSettingsDataAccess componentSettingsDataAccess = ComponentHostSettingsDataAccessFactory.Get();

            IEnumerable <ComponentHostInstanceSettings> requiredComponentHostInstances = await componentSettingsDataAccess.GetComponentInstanceSettingsAsync(node);

            IEnumerable <Package> requiredComponentHostPackages = await componentSettingsDataAccess.GetComponentPackagesAsync(node);


            ComponentHostInstanceSettings primerComponentHost = requiredComponentHostInstances.First();

            // start host process
            string hostPackageName = await NodeSettingsAccessFactory.Get().GetComponentHostPackageName();

            NodeBasicProcessInformation primerHostProcess = await nodeAccess.StartProcessAsync(hostPackageName, (id : 0, args : new Dictionary <string, string> {
                { "--port", "4999" }
            }));

            IComponentHostAccessService  primerHostProcessAccess     = ComponentHostAccessFactory.Get(primerHostProcess.ProcessUri);
            IEnumerable <PackageDetails> remoteComponentHostPackages = await primerHostProcessAccess.GetComponentHostPackageConfigurationAsync();

            try
            {
                requiredComponentHostPackages
                //.AsParallel()
                //.ForAll
                .Select(package =>
                {
                    var remoteInstallation        = remoteComponentHostPackages?.Where(x => string.Compare(package.Name, x.PackageName, true) == 0).ToList() ?? default;
                    PackageDetails packageDetails = null;
                    using (var packageStream = File.OpenRead(package.PackagePath))
                    {
                        if (remoteInstallation is null || !remoteInstallation.Any())
                        {// component host doesn't have required package
                            packageDetails = primerHostProcessAccess.UploadComponentHostPackageAsync(packageStream).Result;
                        }
                        else if (!remoteInstallation.Any(x => x.PackageVersion == package.Version))
                        {
                            // check if any instances are running with the loaded package
                            packageDetails = primerHostProcessAccess.UpdateComponentHostPackageAsync(packageStream).Result;
                        }
                    }