Пример #1
0
        public override void Run()
        {

            autoscaler = EnterpriseLibraryContainer.Current.GetInstance<Autoscaler>();
            autoscaler.Start();

            Trace.WriteLine("AzureAutoscale.Worker entry point called", "Information");

            while (true)
            {
                Thread.Sleep(10000);
                Trace.WriteLine("Working", "Information");
            }
        }
        /// <summary>Snippet for UpdateAsync</summary>
        public async Task UpdateAsync()
        {
            // Snippet: UpdateAsync(string, string, Autoscaler, CallSettings)
            // Additional: UpdateAsync(string, string, Autoscaler, CancellationToken)
            // Create client
            RegionAutoscalersClient regionAutoscalersClient = await RegionAutoscalersClient.CreateAsync();

            // Initialize request argument(s)
            string     project            = "";
            string     region             = "";
            Autoscaler autoscalerResource = new Autoscaler();
            // Make the request
            Operation response = await regionAutoscalersClient.UpdateAsync(project, region, autoscalerResource);

            // End snippet
        }
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetAsync()
        {
            // Snippet: GetAsync(string, string, string, CallSettings)
            // Additional: GetAsync(string, string, string, CancellationToken)
            // Create client
            RegionAutoscalersClient regionAutoscalersClient = await RegionAutoscalersClient.CreateAsync();

            // Initialize request argument(s)
            string project    = "";
            string region     = "";
            string autoscaler = "";
            // Make the request
            Autoscaler response = await regionAutoscalersClient.GetAsync(project, region, autoscaler);

            // End snippet
        }
 /// <summary>Snippet for Get</summary>
 public void GetRequestObject()
 {
     // Snippet: Get(GetRegionAutoscalerRequest, CallSettings)
     // Create client
     RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.Create();
     // Initialize request argument(s)
     GetRegionAutoscalerRequest request = new GetRegionAutoscalerRequest
     {
         Region     = "",
         Project    = "",
         Autoscaler = "",
     };
     // Make the request
     Autoscaler response = regionAutoscalersClient.Get(request);
     // End snippet
 }
        public async stt::Task GetAsync()
        {
            moq::Mock <Autoscalers.AutoscalersClient> mockGrpcClient = new moq::Mock <Autoscalers.AutoscalersClient>(moq::MockBehavior.Strict);
            GetAutoscalerRequest request = new GetAutoscalerRequest
            {
                Zone       = "zone255f4ea8",
                Project    = "projectaa6ff846",
                Autoscaler = "autoscaleradfcda44",
            };
            Autoscaler expectedResponse = new Autoscaler
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                Zone = "zone255f4ea8",
                CreationTimestamp = "creation_timestamp235e59a1",
                Region            = "regionedb20d96",
                Status            = Autoscaler.Types.Status.Pending,
                Target            = "targetaefbae42",
                AutoscalingPolicy = new AutoscalingPolicy(),
                RecommendedSize   = 213286470,
                StatusDetails     =
                {
                    new AutoscalerStatusDetails(),
                },
                Description           = "description2cf9da67",
                SelfLink              = "self_link7e87f12d",
                ScalingScheduleStatus =
                {
                    {
                        "key8a0b6e3c",
                        new ScalingScheduleStatus()
                    },
                },
            };

            mockGrpcClient.Setup(x => x.GetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Autoscaler>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            AutoscalersClient client = new AutoscalersClientImpl(mockGrpcClient.Object, null);
            Autoscaler        responseCallSettings = await client.GetAsync(request.Project, request.Zone, request.Autoscaler, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Autoscaler responseCancellationToken = await client.GetAsync(request.Project, request.Zone, request.Autoscaler, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void GetRequestObject()
        {
            moq::Mock <RegionAutoscalers.RegionAutoscalersClient> mockGrpcClient = new moq::Mock <RegionAutoscalers.RegionAutoscalersClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetRegionAutoscalerRequest request = new GetRegionAutoscalerRequest
            {
                Region     = "regionedb20d96",
                Project    = "projectaa6ff846",
                Autoscaler = "autoscaleradfcda44",
            };
            Autoscaler expectedResponse = new Autoscaler
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                Zone = "zone255f4ea8",
                CreationTimestamp = "creation_timestamp235e59a1",
                Region            = "regionedb20d96",
                Status            = "status5444cb9a",
                Target            = "targetaefbae42",
                AutoscalingPolicy = new AutoscalingPolicy(),
                RecommendedSize   = 213286470,
                StatusDetails     =
                {
                    new AutoscalerStatusDetails(),
                },
                Description           = "description2cf9da67",
                SelfLink              = "self_link7e87f12d",
                ScalingScheduleStatus =
                {
                    {
                        "key8a0b6e3c",
                        new ScalingScheduleStatus()
                    },
                },
            };

            mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            RegionAutoscalersClient client = new RegionAutoscalersClientImpl(mockGrpcClient.Object, null);
            Autoscaler response            = client.Get(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetRequestObjectAsync()
        {
            // Snippet: GetAsync(GetAutoscalerRequest, CallSettings)
            // Additional: GetAsync(GetAutoscalerRequest, CancellationToken)
            // Create client
            AutoscalersClient autoscalersClient = await AutoscalersClient.CreateAsync();

            // Initialize request argument(s)
            GetAutoscalerRequest request = new GetAutoscalerRequest
            {
                Zone       = "",
                Project    = "",
                Autoscaler = "",
            };
            // Make the request
            Autoscaler response = await autoscalersClient.GetAsync(request);

            // End snippet
        }
Пример #8
0
        public override void Run()
        {
            int timeout = 1000;

            // Это образец реализации рабочего процесса. Замените его собственной логикой.
            Trace.WriteLine("WarSpot.Cloud.Computer entry point called", "Information");

#if false
            this.autoscaler = EnterpriseLibraryContainer.Current.GetInstance <Autoscaler>();
            this.autoscaler.Start();
#endif

            /*while (true)
             * {
             * Thread.Sleep(10000);
             * Trace.WriteLine("Working", "Information");
             * }*/

            //todo rewrite this

            TaskHandler _handler = new TaskHandler();

            _handler.Start();
            while (true)
            {
                _are.WaitOne(timeout);

                /*
                 * var msg = _queue.GetMessage();
                 * if (msg != null)
                 * {
                 * //обработка сообщения
                 *
                 * //а затем удаление
                 * // we need to delete message before it'll apeared in queue 'cause timeout
                 * _queue.DeleteMessage(msg);
                 *
                 * // todo start here the match
                 * }
                 * Thread.Sleep(100);*/
            }
        }
        /// <summary>
        /// Updates an autoscaler in the specified project using the data included in the request.
        /// Documentation https://developers.google.com/compute/alpha/reference/autoscalers/update
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Compute service.</param>
        /// <param name="project">Project ID for this request.</param>
        /// <param name="zone">Name of the zone for this request.</param>
        /// <param name="body">A valid Compute alpha body.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>OperationResponse</returns>
        public static Operation Update(ComputeService service, string project, string zone, Autoscaler body, AutoscalersUpdateOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (zone == null)
                {
                    throw new ArgumentNullException(zone);
                }

                // Building the initial request.
                var request = service.Autoscalers.Update(body, project, zone);

                // Applying optional parameters to the request.
                request = (AutoscalersResource.UpdateRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Autoscalers.Update failed.", ex);
            }
        }
Пример #10
0
        /// <summary>
        /// Updates an autoscaler in the specified project using the data included in the request. This method supports patch semantics.
        /// Documentation https://developers.google.com/compute/alpha/reference/regionAutoscalers/patch
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated compute service.</param>
        /// <param name="project">Project ID for this request.</param>
        /// <param name="region">Name of the region scoping this request.</param>
        /// <param name="autoscaler">Name of the autoscaler to update.</param>
        /// <param name="body">A valid compute alpha body.</param>
        /// <returns>OperationResponse</returns>
        public static Operation Patch(computeService service, string project, string region, string autoscaler, Autoscaler body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (region == null)
                {
                    throw new ArgumentNullException(region);
                }
                if (autoscaler == null)
                {
                    throw new ArgumentNullException(autoscaler);
                }

                // Make the request.
                return(service.RegionAutoscalers.Patch(body, project, region, autoscaler).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request RegionAutoscalers.Patch failed.", ex);
            }
        }
Пример #11
0
        /// <summary>
        /// Creates an autoscaler in the specified project using the data included in the request.
        /// Documentation https://developers.google.com/compute/v1/reference/autoscalers/insert
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated compute service.</param>
        /// <param name="project">Project ID for this request.</param>
        /// <param name="zone">Name of the zone for this request.</param>
        /// <param name="body">A valid compute v1 body.</param>
        /// <returns>OperationResponse</returns>
        public static Operation Insert(computeService service, string project, string zone, Autoscaler body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (zone == null)
                {
                    throw new ArgumentNullException(zone);
                }

                // Make the request.
                return(service.Autoscalers.Insert(body, project, zone).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Autoscalers.Insert failed.", ex);
            }
        }
Пример #12
0
        /// <summary>
        /// Updates an autoscaler in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
        /// Documentation https://developers.google.com/compute/v1/reference/regionAutoscalers/patch
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Compute service.</param>
        /// <param name="project">Project ID for this request.</param>
        /// <param name="region">Name of the region scoping this request.</param>
        /// <param name="body">A valid Compute v1 body.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>OperationResponse</returns>
        public static Operation Patch(ComputeService service, string project, string region, Autoscaler body, RegionAutoscalersPatchOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (region == null)
                {
                    throw new ArgumentNullException(region);
                }

                // Building the initial request.
                var request = service.RegionAutoscalers.Patch(body, project, region);

                // Applying optional parameters to the request.
                request = (RegionAutoscalersResource.PatchRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request RegionAutoscalers.Patch failed.", ex);
            }
        }