public LbAddApplicationInstancesResponse AddApplicationInstances(LbAddApplicationInstancesRequest request)
        {
            try
            {
                Log.Debug(this, "AddApplicationInstances()");

                Authenticate(request);
                foreach (ApplicationInstance instance in request.AppInstances)
                {
                    if (!Database.GetInstance().RoutingMesh.Exists(x => (x.NodeId == instance.NodeId) && (x.ApplicationId == instance.ApplicationId) && (x.Id == instance.Id)))
                    {
                        Database.GetInstance().RoutingMesh.Add(instance);
                        Database.GetInstance().RoutingMeshHistory.Add(instance.Clone());
                        Log.Debug(this, "Added application instance_: " + instance);
                    }
                }
                LbAddApplicationInstancesResponse response = new LbAddApplicationInstancesResponse();
                return response;
            }
            catch (Exception e)
            {
                Log.Error(this, e);
                throw e;
            }
        }
Esempio n. 2
0
        public ApStartApplicationResponse StartApplication(ApStartApplicationRequest request)
        {
            Log.Info(this, "StartApplication()");

            try
            {
                Authenticate(request);
                ApStartApplicationResponse response = new ApStartApplicationResponse();
                List<Node> nodes = FindAvailableNodes();
                foreach (Node node in nodes)
                {
                    if (!ApplicationExistsInNode(request.ApplicationId, node))
                    {
                        // Upload application to node
                        UploadApplicationToNode(request.ApplicationId, node);
                    }

                    NcStartApplicationInstancesRequest ncRequest = new NcStartApplicationInstancesRequest(Credentials);
                    ncRequest.ApplicationId = request.ApplicationId;
                    ncRequest.TenantName = request.TenantName;
                    ncRequest.NumberOfInstances = request.NumberOfInstances;
                    NcStartApplicationInstancesResponse ncResponse = EndPoints.GetNcApplicationGridService(node).StartApplicationInstances(ncRequest);
                    response.Urls = ncResponse.Urls;

                    // Update Routing Mesh in Load Balancer
                    LbAddApplicationInstancesRequest request2 = new LbAddApplicationInstancesRequest(Credentials);
                    request2.AppInstances = ncResponse.ApplicationInstances;
                    EndPoints.GetLbApplicationGridService().AddApplicationInstances(request2);
                }
                return response;
            }
            catch(Exception e)
            {
                Log.Error(this, e);
                throw e;
            }
        }