/// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='format'> /// Specifies response output format /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <object> PostAsync(this IPing operations, string format = "json", CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.PostWithHttpMessagesAsync(format, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public void MissingProbe() { IPing grain = Silo.CreateGrain <PingGrain>(1); //There should not be an exception, since we are using loose grain generation grain.Invoking(p => p.Ping()).ShouldNotThrow(); }
public void StartService() { #pragma warning disable 618 var binding = new NetPeerTcpBinding #pragma warning restore 618 { Security = { Mode = SecurityMode.None } }; var endpoint = new ServiceEndpoint( ContractDescription.GetContract(typeof(IPing)), binding, new EndpointAddress("net.p2p://SimpleP2P")); Host = new PingImplementation(); _factory = new DuplexChannelFactory <IPing>( new InstanceContext(Host), endpoint); var channel = _factory.CreateChannel(); ((ICommunicationObject)channel).Open(); // wait until after the channel is open to allow access. Channel = channel; }
public async Task MissingProbe() { IPing grain = await Silo.CreateGrainAsync <PingGrain>(1); //There should not be an exception, since we are using loose grain generation grain.Invoking(p => p.Ping()).Should().NotThrow(); }
private static PingEntity Map(IPing c, WorldEntity world, PlayerEntity player) { var result = new PingEntity(); Fill(result, world, player); return(result); }
/// <summary> /// Negotiates between sending and receiving pings /// </summary> /// <param name="ping"></param> public PingStream(IPing ping) { _ping = ping; _ping.Change += new ChangedEventHandler(pingCaptured); PingList.Add(System.DateTime.Now.Ticks); }
/// <inheritdoc/> public DynamicServerListLoadBalancer(string name, IRule rule, IPing ping, IServerList <Server> serverList, IServerListUpdater serverListUpdater, IServerListFilter <Server> serverListFilter, ILoadBalancerSettings settings, ILogger logger = null) : base(name, rule, ping, settings, logger) { _serverList = serverList; _serverListUpdater = serverListUpdater; _serverListFilter = serverListFilter; UpdateListOfServersAsync().GetAwaiter().GetResult(); if (serverListUpdater != null) { var updateProcessing = false; serverListUpdater.Start(async() => { if (updateProcessing) { return; } updateProcessing = true; try { await UpdateListOfServersAsync(); } finally { updateProcessing = false; } }); } }
public PingTest() { var loggerFactortMoq = new Mock <ILoggerFactory>().Object; _logger = loggerFactortMoq.CreateLogger <PingController>(); _operationalUnit = new OperationalUnit( environment: "Mock", assembly: $"{Environment.MachineName} {this.GetType().Assembly.FullName} V{this.GetType().Assembly.GetName().Version}"); _localConfigurationMock = new Mock <MiddlewareConfiguration>().Object; _publisherMock = new Mock <IMessageCommand>().Object; _mediatorMock = new Mock <IMediator>().Object; _ping = new PingController(_logger, _mediatorMock, _publisherMock, _operationalUnit, _localConfigurationMock); _mediatorMock = new Mock <IMediator>().Object; _vehicleId = Guid.NewGuid().ToString(); _pingRequest = new PingRequest { Status = VehicleStatus.active, Message = "new vehicle!" }; }
public ThriftyClient(ThriftyClientOptions swiftyClientOptions) { _swiftyClientOptions = swiftyClientOptions ?? new ThriftyClientOptions(); var loggerFactory = _swiftyClientOptions.LoggerFactory; _logger = loggerFactory?.CreateLogger(typeof(ThriftyClient)) ?? NullLogger.Instance; _thriftClientManager = new ThriftClientManager(new ThriftCodecManager(), new NiftyClient(swiftyClientOptions.NettyClientConfig ?? new NettyClientConfig(), _swiftyClientOptions.LoggerFactory), Enumerable.Empty <ThriftClientEventHandler>(), loggerFactory: _swiftyClientOptions.LoggerFactory); _swiftyPing = new ThriftyPing(_thriftClientManager); _timeoutTimer = new Lazy <HashedWheelEvictionTimer>(() => { var timer = Utils.Timer; return(new HashedWheelEvictionTimer(timer)); }, true); _channelPools = swiftyClientOptions.ConnectionPoolEnabled ? new NiftyClientChannelPool(_thriftClientManager, _timeoutTimer.Value, swiftyClientOptions) : (IClientConnectionPool) new NoneClientChannelPool(_thriftClientManager, swiftyClientOptions); if (_swiftyClientOptions.EurekaEnabled) { var eureka = _swiftyClientOptions.Eureka; DiscoveryManager.Instance.Initialize(eureka, loggerFactory); var interval = eureka.RegistryFetchIntervalSeconds * 1000 / 2;//TODO last的事件处理 _timeoutTimer.Value.Schedule(this.RefreshServers, TimeSpan.FromMilliseconds(interval)); } }
public void CreateNewPingResultIsNotNull() { IPingFactory pingFactory = new PingFactory(this._mapper); IPing ping = pingFactory.CreateNewPing(); Assert.IsNotNull(ping); }
public void CreateNewPingResultIsCorrectType() { IPingFactory pingFactory = new PingFactory(this._mapper); IPing ping = pingFactory.CreateNewPing(); Assert.IsInstanceOf(typeof(IPing), ping); }
public GuidPingActor(GuidTestResults testResults, int maxPings) { _testResults = testResults; _maxPings = maxPings; _pong = ChildActorFor <IPong>(() => new GuidPongActor(testResults)); _pings = 0; _ping = SelfAs <IPing>(); }
public LoadBalancerConfig(Func <ILoadBalancerRule> ruleFactory, IPing ping, IServerSource serverSource) { ParameterChecker.NotNull(serverSource, "serverSource"); this.RuleFactory = ruleFactory; this.Ping = ping; this.ServerSource = serverSource; }
public ExecutePingAsync(IPing ping) { _Ping = ping ?? throw new ArgumentNullException(nameof(ping)); DefaultPingIntervalTimeSpan = TimeSpan.FromMilliseconds(DEFAULT_PING_INTERVAL); NewPingNeeded += ExecutePingUsingTask_NewPingNeeded; }
public BestAvailableRuleTest() : base("BestAvailableRule") { _ping = new EasyHttpPing(_factory, 20); var collector = new DefaultServerStatusCollector(); var rule = new BestAvailableRule(collector); _loadBalancer = new BaseLoadBalancer(1 * 1000, base._name, rule, _ping, new SerialPingStrategy(), _factory); _command = new LoadBalancerCommand(_loadBalancer, collector, null, null); }
public async Task SetupCompoundProbe() { IPing grain = await Silo.CreateGrainAsync <PingGrain>(1); var pong = Silo.AddProbe <IPongCompound>(44, keyExtension: "Test"); await grain.PingCompound(); pong.Verify(p => p.Pong(), Times.Once); }
public async Task SetupProbe() { IPing grain = await Silo.CreateGrainAsync <PingGrain>(1); var pong = Silo.AddProbe <IPong>(22); await grain.Ping(); pong.Verify(p => p.Pong(), Times.Once); }
public WeightedResponseTimeRuleTest() : base("WeightedResponseTimeRule") { _ping = new EasyHttpPing(_factory, 20); var collector = new DefaultServerStatusCollector(); var accumulater = new DefaultServerWeightAccumulater(collector); var rule = new WeightedResponseTimeRule(accumulater); _loadBalancer = new BaseLoadBalancer(1 * 1000, base._name, rule, _ping, new SerialPingStrategy(), _factory); _command = new LoadBalancerCommand(_loadBalancer, collector, null, null); }
private bool IsAlive(IPing ping, Server server) { try { return(ping.IsAlive(server)); } catch { return(false); } }
public async Task InvalidProbeType() { IPing grain = await Silo.CreateGrainAsync <PingGrain>(1); //This correct id, but a different grain type var pong = Silo.AddProbe <IPong2>(22); grain.Invoking(p => p.Ping()).Should().NotThrow(); pong.Verify(p => p.Pong2(), Times.Never); }
public async Task InvalidProbe() { IPing grain = await Silo.CreateGrainAsync <PingGrain>(1); //This uses the wrong id for the IPong since this is hard coded within PingGrain var pong = Silo.AddProbe <IPong>(0); grain.Invoking(p => p.Ping()).Should().NotThrow(); pong.Verify(p => p.Pong(), Times.Never); }
public async Task InvalidProbeType() { IPing grain = await Silo.CreateGrainAsync <PingGrain>(1); //This uses the correct id, but the wrong grain type var pong = Silo.AddProbe <IPong2>(22); await grain.Invoking(p => p.Ping()).Should().ThrowExactlyAsync <Exception>(); pong.Verify(p => p.Pong2(), Times.Never); }
public void InvalidProbeType() { IPing grain = Silo.CreateGrain <PingGrain>(1); //This uses the correct id, but the wrong grain type var pong = Silo.AddProbe <IPong2>(22); grain.Invoking(p => p.Ping()).ShouldThrowExactly <Exception>(); pong.Verify(p => p.Pong2(), Times.Never); }
public void InvalidProbe() { IPing grain = Silo.CreateGrain <PingGrain>(1); //This uses the wrong id for the IPong since this is hard coded within PingGrain var pong = Silo.AddProbe <IPong>(0); grain.Invoking(p => p.Ping()).ShouldThrowExactly <Exception>(); pong.Verify(p => p.Pong(), Times.Never); }
public void AddPing(IPing ping) { queue.Enqueue(ping); if (processing) { return; } processing = true; UpdateManager.BeginInvoke(ProceedQueue); }
public DefaultListeningManager(ILogger logger, IAlarmState alarmState, IWasListener wasListener, IClientListener clientListener, IPing ping) { this.mLogger = logger; this.mAlarmState = alarmState; this.mWasListener = wasListener; this.mClientListener = clientListener; this.mPing = ping; TaskScheduler.UnobservedTaskException += (object sender, UnobservedTaskExceptionEventArgs ex) => { this.mLogger.LogError("(ListeningManager/Constructor/UnobservedTaskException)", ErrorType.ListeningManager_UnobservedTaskException, ex.Exception); }; }
public BaseTest() { var count = 20; var start = 57000; _loggerFactory = new LoggerFactory(); _ping = new EasyHttpPing(_loggerFactory); _servers = Enumerable.Range(start, count).Select(p => new Server("localhost", p)).ToArray(); _httpServers = new List <HttpServer>(from server in _servers where server.Port % 2 == 0 select new HttpServer(server)); _httpServers.ForEach(x => x.Start()); }
public void Installer_OnlyIPing() { var serviceCollection = new ServiceCollection(); serviceCollection.Install(install => install.AddInstallers(new Installer())); Assert.Single(serviceCollection); ServiceProvider provider = serviceCollection.BuildServiceProvider(); IPing ping = provider.GetService <IPing>(); Assert.NotNull(ping); }
public DefaultListeningManager(params INinjectModule[] modules) { using (StandardKernel kernel = new StandardKernel(modules)) { this.mLogger = kernel.Get <ILogger>(); this.mAlarmState = kernel.Get <IAlarmState>(); this.mWasListener = kernel.Get <IWasListener>(); this.mClientListener = kernel.Get <IClientListener>(); this.mPing = kernel.Get <IPing>(); } TaskScheduler.UnobservedTaskException += (object sender, UnobservedTaskExceptionEventArgs ex) => { this.mLogger.LogError("(ListeningManager/Constructor/UnobservedTaskException)", ErrorType.ListeningManager_UnobservedTaskException, ex.Exception); }; }
private bool Ping(string host) { try { IPing myPing = this._pingFactory.CreateNewPing(); byte[] buffer = new byte[32]; int timeout = 1000; PingOptions pingOptions = this._pingFactory.CreateNewPingOptions(); IPingReply reply = myPing.Send(host, timeout, buffer, pingOptions); return(reply.Status == IPStatus.Success); } catch (Exception ex) { return(false); } }
public void InstallerAndConventions_OnlyOneIPing() { var serviceCollection = new ServiceCollection(); serviceCollection.Install(install => install .AddInstallers(new Installer()) .InstallByConvention(c => c .AddFromAssemblyOfThis <IPing>())); Assert.Single(serviceCollection); ServiceProvider provider = serviceCollection.BuildServiceProvider(); IPing ping = provider.GetService <IPing>(); Assert.NotNull(ping); }
public PingClient(IPing pingProxy) { this.ping = pingProxy; }
public BandwidthClient(IBandwidth bandwidthActorProxy, IPing ping) { this.proxy = bandwidthActorProxy; this.ping = ping; }