public MainHub(ILogger <MainHub> logger, ITaskHandlerService taskHandlerService, ILoadBalancerService loadBalancerService) { _logger = logger; _taskHandlerService = taskHandlerService; _loadBalancerService = loadBalancerService; if (string.IsNullOrEmpty(HubGUID)) { HubGUID = Guid.NewGuid().ToString(); _logger.LogInformation($"Guid of current Hub for this session: \'{HubGUID}\'"); } if (UserGroup == null) { UserGroup = new Dictionary <string, string>(); } if (Modules == null) { Modules = new List <ModuleHubWrapper>(); } if (TaskHistory == null) { TaskHistory = new List <DNet_DataContracts.Processing.Task>(); } }
public LoadBalancerModule(ITaskExecutor taskExecutor, ILoadBalancerService loadBalancerService) { Post["/loadbalancer/change"] = _ => { var command = this.Bind <ChangeLoadBalancerStateCommand>(); taskExecutor.AddTask(new ChangeLoadBalancerStateTask(command, loadBalancerService, new NodeFront())); return("OK"); }; }
public LoadBalancerModule(ITaskExecutor taskExecutor, ILoadBalancerService loadBalancerService) { Post["/loadbalancer/change"] = _ => { var command = this.Bind<ChangeLoadBalancerStateCommand>(); taskExecutor.AddTask(new ChangeLoadBalancerStateTask(command, loadBalancerService, new NodeFront())); return "OK"; }; }
public HeartbeatService(IAsimovConfig config, ILoadBalancerService loadBalancerService) { _config = config; _loadBalancerService = loadBalancerService; _intervalMs = config.HeartbeatIntervalSeconds * 1000; _hostControlUrl = config.WebControlUrl.ToString(); _config = config; _config.ApiKey = Guid.NewGuid().ToString(); }
public HeartbeatService(IAsimovConfig config, ILoadBalancerService loadBalancerService) { _config = config; _loadBalancerService = loadBalancerService; _nodeFrontUri = new Uri(new Uri(config.NodeFrontUrl), "/agent/heartbeat"); _intervalMs = config.HeartbeatIntervalSeconds * 1000; _hostControlUrl = config.WebControlUrl.ToString(); _config = config; _config.ApiKey = Guid.NewGuid().ToString(); }
static void Main(string[] args) { ChannelFactory <ILoadBalancerService> factory = new ChannelFactory <ILoadBalancerService>(typeof(ILoadBalancerService).ToString()); ILoadBalancerService proxy = factory.CreateChannel(); Brojilo br = new Brojilo("123", "Niki", "Velickovic", "666"); double x; int t = 0; // while (t < 3) { x = proxy.Process_Id(666); t++; Console.WriteLine("{0} poziv = {1}", t, x); } Console.ReadKey(); }
public TestChangeLoadBalancerStateTask(ChangeLoadBalancerStateCommand command, ILoadBalancerService loadBalancerService, INotifier nodeFront) : base(command, loadBalancerService, nodeFront) { _config = new AsimovConfig(); }
public ChangeEntity1(ClientProxy Clientproxy, EnumType _type) { type = _type; proxy = Clientproxy; InitializeComponent(); }
/// <summary> /// Gets all existing load balancer nodes through a series of asynchronous operations, /// each of which requests a subset of the available nodes. /// </summary> /// <param name="provider">The load balancer service.</param> /// <param name="limit">The maximum number of <see cref="Node"/> to return from a single task. If this value is <c>null</c>, a provider-specific default is used.</param> /// <returns> /// A collection of <see cref="Node"/> objects, each of which represents a subset /// of the available load balancer nodes. /// </returns> /// <exception cref="ArgumentNullException"> /// If <paramref name="provider"/> is <c>null</c>. /// <para>-or-</para> /// <para>If <paramref name="loadBalancerId"/> is <c>null</c>.</para> /// </exception> /// <exception cref="ArgumentException">If <paramref name="loadBalancerId"/> is empty.</exception> /// <exception cref="ArgumentOutOfRangeException">If <paramref name="limit"/> is less than or equal to 0.</exception> private static IEnumerable<Node> ListAllLoadBalancerNodes(ILoadBalancerService provider, LoadBalancerId loadBalancerId, int? limit, CancellationToken cancellationToken) { if (provider == null) throw new ArgumentNullException("provider"); if (limit <= 0) throw new ArgumentOutOfRangeException("limit"); // this API call is not currently paginated IEnumerable<Node> loadBalancers = provider.ListNodesAsync(loadBalancerId, cancellationToken).Result; return loadBalancers; }
private static IEnumerable<NodeServiceEvent> ListAllNodeServiceEvents(ILoadBalancerService provider, LoadBalancerId loadBalancerId, int? limit, CancellationToken cancellationToken) { if (limit <= 0) throw new ArgumentOutOfRangeException("limit"); NodeServiceEvent lastServiceEvent = null; do { NodeServiceEventId marker = lastServiceEvent != null ? lastServiceEvent.Id : null; IEnumerable<NodeServiceEvent> serviceEvents = provider.ListNodeServiceEventsAsync(loadBalancerId, marker, limit, cancellationToken).Result; lastServiceEvent = null; foreach (NodeServiceEvent serviceEvent in serviceEvents) { yield return serviceEvent; lastServiceEvent = serviceEvent; } } while (lastServiceEvent != null); }
/// <summary> /// Gets all existing load balancers through a series of asynchronous operations, /// each of which requests a subset of the available load balancers. /// </summary> /// <param name="provider">The load balancer service.</param> /// <param name="limit">The maximum number of <see cref="LoadBalancer"/> objects to return from a single task. If this value is <c>null</c>, a provider-specific default is used.</param> /// <returns> /// A collection of <see cref="LoadBalancer"/> objects describing the available load /// balancers. /// </returns> /// <exception cref="ArgumentNullException">If <paramref name="provider"/> is <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException">If <paramref name="limit"/> is less than or equal to 0.</exception> private static IEnumerable<LoadBalancer> ListAllLoadBalancers(ILoadBalancerService provider, int? limit, CancellationToken cancellationToken) { if (limit <= 0) throw new ArgumentOutOfRangeException("limit"); LoadBalancer lastLoadBalancer = null; do { LoadBalancerId marker = lastLoadBalancer != null ? lastLoadBalancer.Id : null; IEnumerable<LoadBalancer> loadBalancers = provider.ListLoadBalancersAsync(marker, limit, cancellationToken).Result; lastLoadBalancer = null; foreach (LoadBalancer loadBalancer in loadBalancers) { yield return loadBalancer; lastLoadBalancer = loadBalancer; } // pagination for this call does not match the documentation. } while (false && lastLoadBalancer != null); }
public async Task TestCreatePtrRecords() { string domainName = CreateRandomDomainName(); string loadBalancerName = UserLoadBalancerTests.CreateRandomLoadBalancerName(); IDnsService provider = CreateProvider(); ILoadBalancerService loadBalancerProvider = UserLoadBalancerTests.CreateProvider(); using (CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TestTimeout(TimeSpan.FromSeconds(60)))) { IEnumerable <LoadBalancingProtocol> protocols = await loadBalancerProvider.ListProtocolsAsync(cancellationTokenSource.Token); LoadBalancingProtocol httpProtocol = protocols.First(i => i.Name.Equals("HTTP", StringComparison.OrdinalIgnoreCase)); LoadBalancerConfiguration loadBalancerConfiguration = new LoadBalancerConfiguration( name: loadBalancerName, nodes: null, protocol: httpProtocol, virtualAddresses: new[] { new LoadBalancerVirtualAddress(LoadBalancerVirtualAddressType.Public) }, algorithm: LoadBalancingAlgorithm.RoundRobin); LoadBalancer loadBalancer = await loadBalancerProvider.CreateLoadBalancerAsync(loadBalancerConfiguration, AsyncCompletionOption.RequestCompleted, cancellationTokenSource.Token, null); Assert.IsNotNull(loadBalancer.VirtualAddresses); Assert.IsTrue(loadBalancer.VirtualAddresses.Count > 0); string originalData = loadBalancer.VirtualAddresses[0].Address.ToString(); string originalName = string.Format("www.{0}", domainName); string updatedName = string.Format("www2.{0}", domainName); string originalCommentValue = "Integration test record"; string updatedCommentValue = "Integration test record 2"; TimeSpan?originalTimeToLive; TimeSpan?updatedTimeToLive = TimeSpan.FromMinutes(12); DnsDomainRecordConfiguration[] recordConfigurations = { new DnsDomainRecordConfiguration( type: DnsRecordType.Ptr, name: string.Format("www.{0}",domainName), data: originalData, timeToLive: null, comment: originalCommentValue, priority: null) }; string serviceName = "cloudLoadBalancers"; Uri deviceResourceUri = await((UserLoadBalancerTests.TestCloudLoadBalancerProvider)loadBalancerProvider).GetDeviceResourceUri(loadBalancer, cancellationTokenSource.Token); DnsJob <DnsRecordsList> recordsResponse = await provider.AddPtrRecordsAsync(serviceName, deviceResourceUri, recordConfigurations, AsyncCompletionOption.RequestCompleted, cancellationTokenSource.Token, null); Assert.IsNotNull(recordsResponse.Response); Assert.IsNotNull(recordsResponse.Response.Records); DnsRecord[] records = recordsResponse.Response.Records.ToArray(); Assert.AreEqual(recordConfigurations.Length, records.Length); originalTimeToLive = records[0].TimeToLive; Assert.AreNotEqual(originalTimeToLive, updatedTimeToLive); Assert.AreEqual(originalData, records[0].Data); Assert.AreEqual(originalTimeToLive, records[0].TimeToLive); Assert.AreEqual(originalCommentValue, records[0].Comment); foreach (var record in records) { Console.WriteLine(); Console.WriteLine("Record: {0} ({1})", record.Name, record.Id); Console.WriteLine(); Console.WriteLine(await JsonConvert.SerializeObjectAsync(record, Formatting.Indented)); } // update the comment and verify nothing else changed DnsDomainRecordUpdateConfiguration recordUpdateConfiguration = new DnsDomainRecordUpdateConfiguration(records[0], originalName, originalData, comment: updatedCommentValue); await provider.UpdatePtrRecordsAsync(serviceName, deviceResourceUri, new[] { recordUpdateConfiguration }, AsyncCompletionOption.RequestCompleted, cancellationTokenSource.Token, null); DnsRecord updatedRecord = await provider.ListPtrRecordDetailsAsync(serviceName, deviceResourceUri, records[0].Id, cancellationTokenSource.Token); Assert.IsNotNull(updatedRecord); Assert.AreEqual(originalData, updatedRecord.Data); Assert.AreEqual(originalName, updatedRecord.Name); Assert.AreEqual(originalTimeToLive, updatedRecord.TimeToLive); Assert.AreEqual(updatedCommentValue, updatedRecord.Comment); // update the TTL and verify nothing else changed recordUpdateConfiguration = new DnsDomainRecordUpdateConfiguration(records[0], originalName, originalData, timeToLive: updatedTimeToLive); await provider.UpdatePtrRecordsAsync(serviceName, deviceResourceUri, new[] { recordUpdateConfiguration }, AsyncCompletionOption.RequestCompleted, cancellationTokenSource.Token, null); updatedRecord = await provider.ListPtrRecordDetailsAsync(serviceName, deviceResourceUri, records[0].Id, cancellationTokenSource.Token); Assert.IsNotNull(updatedRecord); Assert.AreEqual(originalData, updatedRecord.Data); Assert.AreEqual(originalName, updatedRecord.Name); Assert.AreEqual(updatedTimeToLive, updatedRecord.TimeToLive); Assert.AreEqual(updatedCommentValue, updatedRecord.Comment); // update the name and verify nothing else changed recordUpdateConfiguration = new DnsDomainRecordUpdateConfiguration(records[0], updatedName, originalData); await provider.UpdatePtrRecordsAsync(serviceName, deviceResourceUri, new[] { recordUpdateConfiguration }, AsyncCompletionOption.RequestCompleted, cancellationTokenSource.Token, null); updatedRecord = await provider.ListPtrRecordDetailsAsync(serviceName, deviceResourceUri, records[0].Id, cancellationTokenSource.Token); Assert.IsNotNull(updatedRecord); Assert.AreEqual(originalData, updatedRecord.Data); Assert.AreEqual(updatedName, updatedRecord.Name); Assert.AreEqual(updatedTimeToLive, updatedRecord.TimeToLive); Assert.AreEqual(updatedCommentValue, updatedRecord.Comment); // remove the PTR record // TODO: verify result? await provider.RemovePtrRecordsAsync(serviceName, deviceResourceUri, loadBalancer.VirtualAddresses[0].Address, AsyncCompletionOption.RequestCompleted, cancellationTokenSource.Token, null); /* Cleanup */ await loadBalancerProvider.RemoveLoadBalancerAsync(loadBalancer.Id, AsyncCompletionOption.RequestCompleted, cancellationTokenSource.Token, null); } }
public DeleteEntity(ClientProxy clientproxy) { factory = clientproxy; InitializeComponent(); }
public ChangeLoadBalancerStateTask(ChangeLoadBalancerStateCommand command, ILoadBalancerService loadBalancerService) { _command = command; this.loadBalancerService = loadBalancerService; }
public ChangeLoadBalancerStateTask(ChangeLoadBalancerStateCommand command, ILoadBalancerService loadBalancerService, INotifier nodeFront) { _command = command; this.loadBalancerService = loadBalancerService; _nodefront = nodeFront; }
public LoadBalancerController(ILoadBalancerService service) { _service = service; }
public ID_Process(ClientProxy clientproxt) { factory = clientproxt; InitializeComponent(); }
public addCounter(ClientProxy Clientproxy) { proxy = Clientproxy; InitializeComponent(); }