private void TryIntializeServer(TimeSpan timeout) { try { ConsoleTraceProvider traceProvider = EnableTracing ? new ConsoleTraceProvider() : null; ((RemoteCacheServer)cacheServer).Initialize(traceProvider); } catch (Exception e) { if (retries-- > 0) { Start(timeout); System.Threading.Thread.Sleep(3000); TryIntializeServer(timeout); } else { throw new ManagementException(e.Message, e); } } finally { retries = 1; } }
/// <summary> /// Create Elastic Context /// </summary> /// <param name="connectionString"> /// Connection string which is used as the base URL for the HttpClient /// </param> /// <param name="elasticSerializerConfiguration"> /// Configuration class for the context. The default settings can be oset here. This /// class contains an IElasticMappingResolver /// </param> /// <param name="credentials"> /// Basic auth credentials for logging into the server. /// </param> /// <param name="isAllowDeleteForIndex"> </param> public ElasticContext(string connectionString, ElasticSerializerConfiguration elasticSerializerConfiguration, NetworkCredential credentials = null, bool isAllowDeleteForIndex = false) { if (credentials != null) { SetBasicAuthHeader(credentials); } _elasticSerializerConfiguration = elasticSerializerConfiguration; _connectionString = connectionString; if (EnvironmentHelper.IsDevelopment()) { TraceProvider = new ConsoleTraceProvider(); TraceProvider.Trace(TraceEventType.Verbose, "{1}: new ElasticContext with connection string: {0}", connectionString, "ElasticContext"); } AllowDeleteForIndex = isAllowDeleteForIndex; InitialContext(); }