-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #637 from Sitecore/rc/1.12.0
Release 1.12.0
- Loading branch information
Showing
82 changed files
with
1,567 additions
and
564 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace SIM | ||
{ | ||
public class SolrState | ||
{ | ||
[RenderInDataGreed] | ||
public string Name { get; set; } | ||
|
||
[RenderInDataGreed] | ||
public CurrentState State { get; set; } | ||
|
||
[RenderInDataGreed] | ||
public string Version { get; set; } | ||
|
||
[RenderInDataGreed] | ||
public string Url { get; set; } | ||
|
||
public enum CurrentState | ||
{ | ||
Running, | ||
Stopped | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.ServiceProcess; | ||
using Newtonsoft.Json; | ||
|
||
namespace SIM | ||
{ | ||
public class SolrStateResolver | ||
{ | ||
public virtual SolrState.CurrentState GetServiceState(string solrServiceName) | ||
{ | ||
ServiceControllerWrapper service = GetService(solrServiceName); | ||
|
||
if (service == null) | ||
{ | ||
return SolrState.CurrentState.Stopped; | ||
} | ||
|
||
if (service.Status != ServiceControllerStatus.Running) | ||
{ | ||
return SolrState.CurrentState.Stopped; | ||
} | ||
|
||
return SolrState.CurrentState.Running; | ||
} | ||
|
||
public virtual SolrState.CurrentState GetUrlState(string solrUrl) | ||
{ | ||
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(solrUrl); | ||
HttpWebResponse httpWebResponse; | ||
try | ||
{ | ||
httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); | ||
} | ||
catch | ||
{ | ||
return SolrState.CurrentState.Stopped; | ||
} | ||
|
||
if (httpWebResponse.StatusCode != HttpStatusCode.OK) | ||
{ | ||
return SolrState.CurrentState.Stopped; | ||
} | ||
|
||
return SolrState.CurrentState.Running; | ||
} | ||
|
||
public virtual string GetVersion(string solrUrl) | ||
{ | ||
HttpClient client = new HttpClient(); | ||
|
||
using (Stream stream = client.GetStreamAsync($"{solrUrl}/admin/info/system?wt=json").Result) | ||
using (StreamReader streamReader = new StreamReader(stream)) | ||
using (JsonReader reader = new JsonTextReader(streamReader)) | ||
{ | ||
while (reader.Read()) | ||
{ | ||
if (string.Equals(reader.Path, "lucene.solr-spec-version", StringComparison.OrdinalIgnoreCase) | ||
&& !string.Equals((string)reader.Value, "solr-spec-version", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
return (string)reader.Value; | ||
} | ||
} | ||
} | ||
|
||
return string.Empty; | ||
} | ||
|
||
public virtual ServiceControllerWrapper GetService(string serviceName) | ||
{ | ||
ServiceController service = ServiceController.GetServices().FirstOrDefault(s => s.ServiceName == serviceName); | ||
if (service == null) | ||
{ | ||
return null; | ||
} | ||
|
||
return new ServiceControllerWrapper(service); | ||
} | ||
} | ||
|
||
public class ServiceControllerWrapper | ||
{ | ||
ServiceController _service; | ||
|
||
public ServiceControllerWrapper(ServiceController service) | ||
{ | ||
this._service = service; | ||
} | ||
|
||
public virtual ServiceControllerStatus Status => this._service.Status; | ||
|
||
public virtual string ServiceName => this._service.ServiceName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.