예제 #1
0
        private void InitializeOptions()
        {
            try
            {
                SelectedRenderApiParam = RenderApiParams.First(x => x.Key == RegistrySaver.ReadStringValue(RegistrySaver.RegParamsList, RegistrySaver.RegRenderApiName));
            }
            catch (Exception)
            {
                SelectedRenderApiParam = RenderApiParams.SingleOrDefault(x => x.Key == "OpenGL3");
            }

            try
            {
                SelectedRenderModeParam = RenderModeParams.First(x => x.Key == RegistrySaver.ReadStringValue(RegistrySaver.RegParamsList, RegistrySaver.RegRenderModeName));
            }
            catch (Exception)
            {
                SelectedRenderApiParam = RenderModeParams.SingleOrDefault(x => x.Key == "Mono");
            }

            CustomCommonParams   = RegistrySaver.ReadStringValue(RegistrySaver.RegParamsList, RegistrySaver.RegAdditionalParamsName);
            IsUseAllCores        = RegistrySaver.ReadBoolValue(RegistrySaver.RegParamsList, RegistrySaver.RegIsAllCoresName);
            IsNotextureStreaming = RegistrySaver.ReadBoolValue(RegistrySaver.RegParamsList, RegistrySaver.RegIsNoTextureStreamingName);
            AppLogger.Add("Application Options initialized");
        }
예제 #2
0
 public void DeleteConfig()
 {
     Configs.Remove(SelectedConfig);
     RegistrySaver.RemoveRegistryValue(RegistrySaver.RegConfigList, SelectedConfig);
     AppLogger.Add("Configuration file [" + SelectedConfig + "] deleted");
     SelectedConfig = Configs.FirstOrDefault();
 }
예제 #3
0
        // Copies SrcDir and its content to the DestDir as a new subdirectory on a remote machine. If Node == null, local copying will be performed.
        private void DeployDir(string SrcDir, string DestDir, ClusterNode Node = null)
        {
            if (!Directory.Exists(SrcDir))
            {
                AppLogger.Add("Directory not found: " + SrcDir);
                return;
            }

            string appPath = "robocopy";
            string argList = string.Empty;

            if (Node != null)
            {
                // Build arguments with remote destination path
                argList = string.Format("{0} {1} /e", SrcDir, GenerateRemotePath(Node, DestDir));
            }
            else
            {
                // Build arguments with local destination path
                argList = string.Format("{0} {1} /e", SrcDir, DestDir);
            }

            Process proc = new Process();

            proc.StartInfo.FileName  = appPath;
            proc.StartInfo.Arguments = argList;
            proc.Start();
        }
예제 #4
0
        private void ProcessCommandStartApp(List <ClusterNode> ClusterNodes)
        {
            if (!File.Exists(SelectedConfig))
            {
                AppLogger.Add("No config file found: " + SelectedConfig);
                return;
            }

            if (!File.Exists(SelectedApplication))
            {
                AppLogger.Add("No application found: " + SelectedApplication);
                return;
            }

            // Update config files before application start
            HashSet <string> NodesSent = new HashSet <string>();

            foreach (ClusterNode Node in ClusterNodes)
            {
                if (!NodesSent.Contains(Node.address))
                {
                    NodesSent.Add(Node.address);
                    DeployFile(Path.GetFullPath(SelectedConfig), Path.GetDirectoryName(SelectedApplication), Node);
                }
            }

            // Send start command to the listeners
            foreach (ClusterNode Node in ClusterNodes)
            {
                string cmd = GenerateStartCommand(Node);
                SendDaemonCommand(Node.address, cmd);
            }
        }
예제 #5
0
        public void DeleteApplication()
        {
            Applications.Remove(SelectedApplication);
            RegistrySaver.RemoveRegistryValue(RegistrySaver.RegAppList, SelectedApplication);
            AppLogger.Add("Application [" + SelectedApplication + "] deleted");

            SelectedApplication = null;
        }
예제 #6
0
 //Reloading all config lists
 private void InitializeConfigLists()
 {
     Applications = RegistrySaver.ReadStringsFromRegistry(RegistrySaver.RegAppList);
     SetSelectedApp();
     AppLogger.Add("Applications loaded successfully");
     Configs = RegistrySaver.ReadStringsFromRegistry(RegistrySaver.RegConfigList);
     SetSelectedConfig();
     AppLogger.Add("Configs loaded successfully");
     AppLogger.Add("List of Active nodes loaded successfully");
 }
예제 #7
0
        private void deployAppBtn_Click(object sender, RoutedEventArgs e)
        {
            if (applicationsListBox.SelectedIndex < 0 || configsCb.SelectedIndex < 0)
            {
                AppLogger.Add("No application/config selected");
                return;
            }

            CmdRunner.ProcessCommand(Runner.ClusterCommandType.DeployApp);
        }
예제 #8
0
        private void stopDaemonsBtn_Click(object sender, RoutedEventArgs e)
        {
            if (configsCb.SelectedIndex < 0)
            {
                AppLogger.Add("No config selected");
                return;
            }

            CmdRunner.ProcessCommand(Runner.ClusterCommandType.StopListeners);
        }
예제 #9
0
        private void killBtn_Click(object sender, RoutedEventArgs e)
        {
            if (configsCb.SelectedIndex < 0)
            {
                AppLogger.Add("No config selected");
                return;
            }

            CmdRunner.ProcessCommand(Runner.ClusterCommandType.KillApp);
        }
예제 #10
0
 public void AddApplication(string appPath)
 {
     if (!Applications.Contains(appPath))
     {
         Applications.Add(appPath);
         RegistrySaver.AddRegistryValue(RegistrySaver.RegAppList, appPath);
         AppLogger.Add("Application [" + appPath + "] added to list");
     }
     else
     {
         AppLogger.Add("WARNING! Application [" + appPath + "] is already in the list");
     }
 }
예제 #11
0
 public void AddConfig(string configPath)
 {
     try
     {
         Configs.Add(configPath);
         SelectedConfig = Configs.Find(x => x == configPath);
         RegistrySaver.AddRegistryValue(RegistrySaver.RegConfigList, configPath);
         ChangeConfigSelection(configPath);
         AppLogger.Add("Configuration file [" + configPath + "] added to list");
     }
     catch (Exception)
     {
         AppLogger.Add("ERROR! Can not add configuration file [" + configPath + "] to list");
     }
 }
예제 #12
0
        public void ProcessCommand(ClusterCommandType Cmd)
        {
            List <ClusterNode> ClusterNodes = GetClusterNodes();

            if (ClusterNodes.Count < 1)
            {
                AppLogger.Add("No cluster nodes found in the config file");
                return;
            }

            switch (Cmd)
            {
            case ClusterCommandType.RunApp:
                ProcessCommandStartApp(ClusterNodes);
                break;

            case ClusterCommandType.KillApp:
                ProcessCommandKillApp(ClusterNodes);
                break;

            case ClusterCommandType.StartListeners:
                ProcessCommandStopListeners(ClusterNodes, true);
                ProcessCommandStartListeners(ClusterNodes);
                break;

            case ClusterCommandType.StopListeners:
                ProcessCommandStopListeners(ClusterNodes);
                break;

            case ClusterCommandType.ListenersStatus:
                ProcessCommandStatusListeners(ClusterNodes);
                break;

            case ClusterCommandType.DeployApp:
                ProcessCommandDeployApp(ClusterNodes);
                break;

            default:
                break;
            }
        }
예제 #13
0
 public void ChangeConfigSelection(string configPath)
 {
     try
     {
         foreach (string config in Configs)
         {
             if (config != configPath)
             {
                 RegistrySaver.UpdateRegistry(RegistrySaver.RegConfigList, config, false);
             }
             else
             {
                 RegistrySaver.UpdateRegistry(RegistrySaver.RegConfigList, config, true);
             }
         }
     }
     catch (Exception exception)
     {
         AppLogger.Add("ERROR while changing config selection. EXCEPTION: " + exception.Message);
     }
 }
예제 #14
0
        private int SendDaemonCommand(string nodeAddress, string cmd, bool bQuiet = false)
        {
            int       ResponseCode = 1;
            TcpClient nodeClient   = new TcpClient();

            if (!bQuiet)
            {
                AppLogger.Add(string.Format("Sending command {0} to {1}...", cmd, nodeAddress));
            }

            try
            {
                // Connect to the listener
                nodeClient.Connect(nodeAddress, DefaultListenerPort);
                NetworkStream networkStream = nodeClient.GetStream();

                byte[] OutData = System.Text.Encoding.ASCII.GetBytes(cmd);
                networkStream.Write(OutData, 0, OutData.Length);

                byte[] InData       = new byte[1024];
                int    InBytesCount = networkStream.Read(InData, 0, InData.Length);

                // Receive response
                ResponseCode = BitConverter.ToInt32(InData, 0);
            }
            catch (Exception ex)
            {
                if (!bQuiet)
                {
                    AppLogger.Add("An error occurred while sending a command to " + nodeAddress + ". EXCEPTION: " + ex.Message);
                }
            }
            finally
            {
                nodeClient.Close();
            }

            return(ResponseCode);
        }
예제 #15
0
        private bool SpawnRemoteProcess(string Name, string Dest, string Path, string Args, bool bQuiet = false)
        {
            bool bPassed = false;

            Process proc = new Process();

            proc.StartInfo.FileName               = Path;
            proc.StartInfo.Arguments              = Args;
            proc.StartInfo.CreateNoWindow         = true;
            proc.StartInfo.UseShellExecute        = false;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.Start();
            bool failed = true;

            if (!bQuiet)
            {
                while (!proc.StandardOutput.EndOfStream)
                {
                    string line = proc.StandardOutput.ReadLine();
                    if (line.IndexOf("ReturnValue = ") >= 0)
                    {
                        int    result = -1;
                        string value  = line.Split('=')[1].Replace(';', ' ');
                        if (int.TryParse(value, out result) && result == 0)
                        {
                            AppLogger.Add(String.Format("{0} successfull on {1}", Name, Dest));
                            failed = false;
                            break;
                        }
                    }
                }
                if (failed)
                {
                    AppLogger.Add(String.Format("ERROR! {0} failed on {1}", Name, Dest));
                }
            }

            return(bPassed);
        }
예제 #16
0
        private void ProcessCommandStartListeners(List <ClusterNode> ClusterNodes)
        {
            if (String.IsNullOrEmpty(SelectedApplication))
            {
                AppLogger.Add("ERROR! No selected application");
                return;
            }

            // It supposed that listener application is exist alongside the application. Let's check it out.
            string ListenerFilePath = Path.Combine(Path.GetDirectoryName(SelectedApplication), ListenerAppName);

            if (!File.Exists(ListenerFilePath))
            {
                AppLogger.Add(string.Format("Listener application {0} not found", ListenerFilePath));
                return;
            }

            // Ok, we have listener application available on the local PC. It's possible that some remote machine has no listener available.
            // To make sure it's available everywhere we deploy listener application.
            HashSet <string> NodesSent = new HashSet <string>();

            // Add local IPs so we don't copy on current host
            IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
            foreach (var LocalIP in localIPs)
            {
                NodesSent.Add(LocalIP.ToString());
            }

            // Upload listener
            foreach (ClusterNode Node in ClusterNodes)
            {
                if (!NodesSent.Contains(Node.address))
                {
                    // Deploy the listener application if it doesn't exist on remote machine
                    string RemoteListenerPath = GenerateRemotePath(Node, ListenerFilePath);
                    if (!File.Exists(RemoteListenerPath))
                    {
                        DeployFile(ListenerFilePath, Path.GetDirectoryName(ListenerFilePath), Node);
                    }
                }
            }

            // Now we're ready to start listeners remotely
            KeyValuePair <string, string>[] SchTaskCmds = new KeyValuePair <string, string>[]
            {
                new KeyValuePair <string, string>(
                    String.Format("SCHTASKS /Create /TN StartClusterListener /TR \\\"{0}\\\" /SC ONEVENT /EC Application /MO *[System/EventID=777] /f", ListenerFilePath),
                    "Task registration"),

                new KeyValuePair <string, string>(
                    "SCHTASKS /RUN /TN StartClusterListener",
                    "Task activation")
            };

            NodesSent.Clear();
            foreach (ClusterNode Node in ClusterNodes)
            {
                if (!NodesSent.Contains(Node.address))
                {
                    foreach (var Cmd in SchTaskCmds)
                    {
                        NodesSent.Add(Node.address);

                        string appPath = "wmic";
                        string argList = string.Format("/node:\"{0}\" process call create \"{1}\"", Node.address, Cmd.Key);

                        SpawnRemoteProcess(Cmd.Value, Node.address, appPath, argList);
                    }
                }
            }

            // Finally, let's check if all listeners have been started successfully
            NodesSent.Clear();
            foreach (ClusterNode Node in ClusterNodes)
            {
                if (!NodesSent.Contains(Node.address))
                {
                    NodesSent.Add(Node.address);

                    int ResponseCode = SendDaemonCommand(Node.address, CommandStatus);
                    if (ResponseCode != 0)
                    {
                        AppLogger.Add("Couldn't start the listener on " + Node.address);
                    }
                }
            }
        }
예제 #17
0
        //Config file parser
        public static VRConfig Parse(string filePath, VRConfig currentConfig)
        {
            // refactoring needed
            List <string> inputLines       = new List <string>();
            List <string> sceneNodeLines   = new List <string>();
            List <string> screenLines      = new List <string>();
            List <string> viewportLines    = new List <string>();
            List <string> clusterNodeLines = new List <string>();
            List <string> cameraLines      = new List <string>();
            List <string> generalLines     = new List <string>();
            List <string> stereoLines      = new List <string>();
            List <string> debugLines       = new List <string>();

            try
            {
                foreach (string line in File.ReadLines(filePath))
                {
                    if (line == string.Empty || line.First() == '#')
                    {
                        //Do nothing
                    }
                    else
                    {
                        if (line.ToLower().Contains("[input]"))
                        {
                            inputLines.Add(line);
                        }
                        if (line.ToLower().Contains("[scene_node]"))
                        {
                            sceneNodeLines.Add(line);
                        }
                        if (line.ToLower().Contains("[screen]"))
                        {
                            screenLines.Add(line);
                        }
                        if (line.ToLower().Contains("[viewport]"))
                        {
                            viewportLines.Add(line);
                        }
                        if (line.ToLower().Contains("[cluster_node]"))
                        {
                            clusterNodeLines.Add(line);
                        }
                        if (line.ToLower().Contains("[camera]"))
                        {
                            cameraLines.Add(line);
                        }
                        if (line.ToLower().Contains("[general]"))
                        {
                            generalLines.Add(line);
                        }
                        if (line.ToLower().Contains("[stereo]"))
                        {
                            stereoLines.Add(line);
                        }
                        if (line.ToLower().Contains("[debug]"))
                        {
                            debugLines.Add(line);
                        }
                        if (line.ToLower().Contains("[render]"))
                        {
                            //todo
                        }
                        if (line.ToLower().Contains("[custom]"))
                        {
                            //todo
                        }
                    }
                }
                foreach (string line in viewportLines)
                {
                    currentConfig.ViewportParse(line);
                }
                foreach (string line in generalLines)
                {
                    currentConfig.GeneralParse(line);
                }
                foreach (string line in stereoLines)
                {
                    currentConfig.StereoParse(line);
                }
                foreach (string line in debugLines)
                {
                    currentConfig.DebugParse(line);
                }
                foreach (string line in inputLines)
                {
                    currentConfig.InputsParse(line);
                }
                foreach (string line in cameraLines)
                {
                    currentConfig.CameraParse(line);
                }
                foreach (string line in sceneNodeLines)
                {
                    currentConfig.SceneNodeParse(line);
                }
                foreach (string line in screenLines)
                {
                    currentConfig.ScreenParse(line);
                }
                foreach (string line in clusterNodeLines)
                {
                    currentConfig.ClusterNodeParse(line);
                }

                currentConfig.sceneNodesView = currentConfig.ConvertSceneNodeList(currentConfig.sceneNodes);
                currentConfig.name           = Path.GetFileNameWithoutExtension(filePath);
                //AppLogger.Add("Config " + currentConfig.name + " loaded");
                RegistrySaver.AddRegistryValue(RegistrySaver.RegConfigName, filePath);
            }
            catch (FileNotFoundException)
            {
                AppLogger.Add("ERROR! Config " + currentConfig.name + "not found!");
            }
            catch (System.ArgumentException)
            {
                AppLogger.Add("ERROR! Config " + currentConfig.name + "not found!");
            }

            return(currentConfig);
        }