public GingerNodeProxy(GingerNodeInfo GNI, bool RemoteGrid = false)
 {
     mGingerNodeInfo = GNI;
     if (RemoteGrid)
     {
         isLocalGrid = false;
     }
 }
Exemple #2
0
        private void GingerSocketServerMessageHandler(GingerSocketInfo gingerSocketInfo)
        {
            NewPayLoad p = gingerSocketInfo.DataAsPayload;

            switch (p.Name)
            {
            case "List":      //TODO: use const
            {
                NewPayLoad RC = new NewPayLoad("RC");
                RC.AddValue("OK");

                //TODO: return the list of GingerNodeInfo

                RC.ClosePackage();
                gingerSocketInfo.Response = RC;
                break;
            }

            case SocketMessages.Register:
            {
                string NodeName      = p.GetValueString();
                string NodeServiceID = p.GetValueString();
                string NodeOS        = p.GetValueString();
                string NodeHost      = p.GetValueString();
                string NodeIP        = p.GetValueString();

                NewPayLoad RC = new NewPayLoad("SessionID", gingerSocketInfo.SessionID);
                gingerSocketInfo.Response = RC;

                // add the info of the new node to the grid list
                mGingerNodeInfo.Add(new GingerNodeInfo()
                    {
                        Name = NodeName, ServiceId = NodeServiceID, OS = NodeOS, Host = NodeHost, IP = NodeIP, SessionID = gingerSocketInfo.SessionID, Status = GingerNodeInfo.eStatus.Ready
                    });
                break;
            }

            case SocketMessages.Unregister:
            {
                Guid           SessionID = p.GetGuid();
                GingerNodeInfo GNI       = (from x in mGingerNodeInfo where x.SessionID == SessionID select x).FirstOrDefault();
                if (GNI == null)
                {
                    gingerSocketInfo.Response = new NewPayLoad("Error", "Ginger node info not found for session id " + SessionID.ToString());
                }

                mGingerNodeInfo.Remove(GNI);

                NewPayLoad RC = new NewPayLoad("OK");
                RC.ClosePackage();
                gingerSocketInfo.Response = RC;
                break;
            }

            default:
                throw new Exception("GingerSocketServerMessageHandler: Unknown Message type: " + p.Name);
            }
        }
Exemple #3
0
        public GingerNodeProxy CreateGingerNodeAgent(GingerNodeInfo GNI)
        {
            ////TODO: cache?
            //GingerNodeProxy GNA = new GingerNodeProxy(GNI);
            //GNA.GingerGrid = this;
            //return GNA;

            return(null);
        }
Exemple #4
0
        public bool IsAlive()
        {
            GingerNodeInfo gingerNodeInfo = (from x in WorkSpace.Instance.LocalGingerGrid.NodeList where x == this select x).SingleOrDefault();

            if (gingerNodeInfo != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #5
0
        public GingerNodeProxy GetNodeProxy(GingerNodeInfo gingerNodeInfo)
        {
            GingerNodeProxy gingerNodeProxy = null;
            bool            b = GingerNodeProxyDictionary.TryGetValue(gingerNodeInfo, out gingerNodeProxy);

            if (!b)
            {
                gingerNodeProxy            = new GingerNodeProxy(gingerNodeInfo);
                gingerNodeProxy.GingerGrid = this;
                GingerNodeProxyDictionary.Add(gingerNodeInfo, gingerNodeProxy);
            }
            return(gingerNodeProxy);
        }
Exemple #6
0
        private void GingerSocketServerMessageHandler(GingerSocketInfo gingerSocketInfo)
        {
            NewPayLoad p = gingerSocketInfo.DataAsPayload;

            switch (p.Name)
            {
            case "List":      //TODO: use const
            {
                NewPayLoad RC = new NewPayLoad("RC");
                RC.AddValue("OK");

                //TODO: return the list of GingerNodeInfo

                RC.ClosePackage();
                gingerSocketInfo.Response = RC;
                break;
            }

            case SocketMessages.Register:
            {
                string NodeName      = p.GetValueString();
                string NodeServiceID = p.GetValueString();
                string NodeOS        = p.GetValueString();
                string NodeHost      = p.GetValueString();
                string NodeIP        = p.GetValueString();

                NewPayLoad RC = new NewPayLoad("SessionID", gingerSocketInfo.SessionID);
                gingerSocketInfo.Response = RC;

                // add the info of the new node to the grid list
                mGingerNodeInfo.Add(new GingerNodeInfo()
                    {
                        Name = NodeName, ServiceId = NodeServiceID, OS = NodeOS, Host = NodeHost, IP = NodeIP, SessionID = gingerSocketInfo.SessionID, Status = GingerNodeInfo.eStatus.Ready
                    });
                break;
            }

            case SocketMessages.Unregister:
            {
                Guid           SessionID = p.GetGuid();
                GingerNodeInfo GNI       = (from x in mGingerNodeInfo where x.SessionID == SessionID select x).FirstOrDefault();
                if (GNI == null)
                {
                    gingerSocketInfo.Response = new NewPayLoad("Error", "Ginger node info not found for session id " + SessionID.ToString());
                }

                mGingerNodeInfo.Remove(GNI);

                NewPayLoad RC = new NewPayLoad("OK");
                RC.ClosePackage();
                gingerSocketInfo.Response = RC;
                break;
            }


            // Combine find and send to one - send session id or how to find
            // Change to reserve node
            case SocketMessages.FindNode:      // Find node which match criteria, used for remote grid
                string ServiceID = p.GetValueString();

                // !!! find first or use better algorithm
                GingerNodeInfo gingerNodeInfo1 = (from x in NodeList where x.ServiceId == ServiceID select x).FirstOrDefault();

                // Reserve
                // TODO: lock !!!!!!!!!!!!!!!!!!!!
                gingerNodeInfo1.Status = GingerNodeInfo.eStatus.Reserved;     // TODO: release !!!!!!!!!!!!!!!!
                NewPayLoad RC2 = new NewPayLoad("NodeInfo", gingerNodeInfo1.SessionID);
                gingerSocketInfo.Response = RC2;
                break;

            case SocketMessages.SendToNode:      // Send action to Node, used when Grid is remote
                Guid           SessionID2               = p.GetGuid();
                GingerNodeInfo gingerNodeInfo           = (from x in NodeList where x.SessionID == SessionID2 select x).SingleOrDefault();
                NewPayLoad     actionPayload            = p.ReadPayload();
                NewPayLoad     remoteNodeActionResponce = SendRequestPayLoad(gingerNodeInfo.SessionID, actionPayload);
                remoteNodeActionResponce.Truncate();
                gingerSocketInfo.Response = remoteNodeActionResponce;
                gingerNodeInfo.Status     = GingerNodeInfo.eStatus.Ready;  //TODO: in case of session to do not release
                break;

            default:
                throw new Exception("GingerSocketServerMessageHandler: Unknown Message type: " + p.Name);
            }
        }
Exemple #7
0
 public GingerNodeProxy(GingerNodeInfo GNI)
 {
     mGingerNodeInfo = GNI;
 }