public void TestHzCloudDiscovery_invalidToken() { var hzCloudDiscovery = new HazelcastCloudDiscovery(DiscoveryTokenInvalid, int.MaxValue, LocalTestBaseUrl); var result = hzCloudDiscovery.DiscoverNodes(); Assert.IsNull(result); }
public AddressProvider(ClientConfig clientConfig) { var networkConfig = clientConfig.GetNetworkConfig(); var configAddressList = networkConfig.GetAddresses(); var cloudConfig = networkConfig.GetCloudConfig(); //Fail fast validate multiple setup if (configAddressList.Count > 0 && cloudConfig != null && cloudConfig.IsEnabled()) { throw new ConfigurationException("Only one address configuration method can be enabled at a time."); } if (cloudConfig != null && cloudConfig.IsEnabled()) { var token = cloudConfig.GetDiscoveryToken(); var connectionTimeoutInMillis = networkConfig.GetConnectionTimeout(); connectionTimeoutInMillis = connectionTimeoutInMillis == 0 ? int.MaxValue : connectionTimeoutInMillis; var urlBase = Environment.GetEnvironmentVariable(HazelcastCloudDiscovery.CloudUrlBaseProperty); _hzCloudDiscovery = new HazelcastCloudDiscovery(token, connectionTimeoutInMillis, urlBase ?? HazelcastCloudDiscovery.CloudUrlBase); _addressProviderFn = GetHzCloudConfigAddresses; _canTranslate = true; } else { _configAddresses = configAddressList.Count > 0 ? configAddressList : new List <string> { "localhost" }; _addressProviderFn = GetHzConfigAddresses; } }
public AddressProvider(NetworkConfig networkConfig, HazelcastProperties properties) { var configAddressList = networkConfig.Addresses; var cloudConfig = networkConfig.HazelcastCloudConfig; //Fail fast validate multiple setup if (configAddressList.Count > 0 && cloudConfig != null && cloudConfig.Enabled) { throw new InvalidConfigurationException("Only one address configuration method can be enabled at a time."); } if (cloudConfig != null && cloudConfig.Enabled) { var token = cloudConfig.DiscoveryToken; var connectionTimeoutInMillis = networkConfig.ConnectionTimeout; connectionTimeoutInMillis = connectionTimeoutInMillis == 0 ? int.MaxValue : connectionTimeoutInMillis; var urlBase = properties.StringValue(HazelcastProperties.CloudUrlBase); _hzCloudDiscovery = new HazelcastCloudDiscovery(token, connectionTimeoutInMillis, urlBase); _addressProviderFn = GetHzCloudConfigAddresses; _canTranslate = true; } else { _configAddresses = configAddressList.Count > 0 ? configAddressList : new List <string> { "localhost" }; _addressProviderFn = GetHzConfigAddresses; } }
public void TestHzCloudDiscovery() { var hzCloudDiscovery = new HazelcastCloudDiscovery(DiscoveryToken, int.MaxValue, LocalTestBaseUrl); var result = hzCloudDiscovery.DiscoverNodes(); Assert.IsNotEmpty(result); foreach (var kv in result) { Assert.True(Addresses.ContainsKey(kv.Key) && Addresses[kv.Key].Equals(kv.Value)); } }