public override void Connect(IReadOnlyCollection <Component> instanceComponents)
        {
            Logger.Instance.Log(LogLevel.Info, "\nConfiguring components ({0}, {1}, {2}, {3}) to work with component({4}):\n", ESAgentComponentId, ESIndexComponentId, ESZookeeperComponentId, ESFileProcessorComponentId, DatabaseComponentId);

            ESAgentComponent         esAgent           = instanceComponents.Single(c => c.Id == ESAgentComponentId) as ESAgentComponent;
            ESIndexComponent         esIndex           = instanceComponents.Single(c => c.Id == ESIndexComponentId) as ESIndexComponent;
            ESZooKeeperComponent     esZooKeeper       = instanceComponents.Single(c => c.Id == ESZookeeperComponentId) as ESZooKeeperComponent;
            ESFileProcessorComponent esFileProcessor   = instanceComponents.Single(c => c.Id == ESFileProcessorComponentId) as ESFileProcessorComponent;
            DatabaseComponent        databaseComponent = instanceComponents.Single(c => c.Id == DatabaseComponentId) as DatabaseComponent;

            DropSolrIndex(esIndex);

            string serviceNameXPath = "/configuration/ServiceName";

            esFileProcessor.ServiceName = FileSystemFactory.GetFileSystem(esFileProcessor.ServerName).XmlHelper.XmlPeek(esFileProcessor.PathToConfig, serviceNameXPath);
            WindowsServiceHelper.StopService(esFileProcessor.ServerName, esFileProcessor.ServiceName);

            esAgent.ServiceName = FileSystemFactory.GetFileSystem(esAgent.ServerName).XmlHelper.XmlPeek(esAgent.PathToConfig, serviceNameXPath);
            WindowsServiceHelper.StopService(esAgent.ServerName, esAgent.ServiceName);

            esIndex.ServiceName = FileSystemFactory.GetFileSystem(esIndex.ServerName).XmlHelper.XmlPeek(esIndex.PathToConfig, serviceNameXPath);
            WindowsServiceHelper.StopService(esIndex.ServerName, esIndex.ServiceName);

            esZooKeeper.ServiceName = FileSystemFactory.GetFileSystem(esZooKeeper.ServerName).XmlHelper.XmlPeek(esZooKeeper.PathToConfig, serviceNameXPath);
            WindowsServiceHelper.StopService(esZooKeeper.ServerName, esZooKeeper.ServiceName);

            //Wait Until services are stopped for 30 seconds
            Thread.Sleep(30000);

            HttpServerConnection connection = IomFactory.CreateHttpServerConnection(databaseComponent.InnovatorUrl, databaseComponent.DatabaseName, databaseComponent.LoginOfRootInnovatorUser, databaseComponent.PasswordOfRootInnovatorUser.Value);

            try
            {
                connection.Login();

                Innovator innovator = new Innovator(connection);

                EditVariable(innovator, "ES_SolrUrl", esIndex.ESAIClusterUrl);
                EditVariable(innovator, "ES_AIClusterUrl", esIndex.ESAIClusterUrl);
                EditCryptoPwd(innovator, esAgent);
            }
            finally
            {
                connection.Logout();
            }

            UpdateESZooKeeperServiceConfig(esZooKeeper, databaseComponent);
            WindowsServiceHelper.StartService(esZooKeeper.ServerName, esZooKeeper.ServiceName);

            UpdateESIndexServiceConfig(esIndex, databaseComponent);
            WindowsServiceHelper.StartService(esIndex.ServerName, esIndex.ServiceName);

            UpdateESAgentServiceConfig(esAgent, databaseComponent);
            WindowsServiceHelper.StartService(esAgent.ServerName, esAgent.ServiceName);

            UpdateESFileProcessorServiceConfig(esFileProcessor, databaseComponent);
            WindowsServiceHelper.StartService(esFileProcessor.ServerName, esFileProcessor.ServiceName);

            ReloadSolrCollection(esIndex);
        }
예제 #2
0
 protected override void OnAfterInstall(IDictionary savedState)
 {
     Trace.WriteLine("ERMT: ServiceStartAndStop OnAfterInstall");
     try
     {
         WindowsServiceHelper.StartService(Context.Parameters["ServiceName"]);
     }
     catch (Exception ex)
     {
         Context.LogMessage("The service couldn't be started. Please start it manually from the services console. Exception message: " + ex.Message);
     }
     base.OnAfterInstall(savedState);
 }