Exemple #1
0
        public async Task <IProcessingResult> OpenCaptureAsync(Uri uri)
        {
            IProcessingResult processingResult;

            using (var system = ActorSystem.Create("NTPAC-Cluster", this._akkaSettings.IsDebug ? DebugConfig : Config))
            {
                var settings = new LoadBalancerSettings
                {
                    BatchSize = 5000,
                    BatchRawCapturesSizeLimitBytes           = 200_000,
                    BatchFlushInterval                       = TimeSpan.FromSeconds(10),
                    ParallelBatchTransmissionsPerReassembler = 4
                };

                var offlineLoadBalancerActor = this._offlineLoadBalancerActorFactory.Create(system, settings);
                var startProcessingRequest   = new CaptureProcessingRequest {
                    CaptureInfo = new CaptureInfo(uri)
                };

                processingResult = await offlineLoadBalancerActor.Ask <ProcessingResult>(startProcessingRequest).ConfigureAwait(false);

                await CoordinatedShutdown.Get(system).Run(CoordinatedShutdown.ClusterLeavingReason.Instance).ConfigureAwait(false);
            }

            return(processingResult);
        }
    }
Exemple #2
0
        public async Task <IProcessingResult> OpenCaptureAsync(Uri uri)
        {
            IProcessingResult processingResult;

            var captureInfo = new CaptureInfo(uri);

            var settings = new LoadBalancerSettings(BaseConfig);

            var config    = this.ClusterSettings.Config.WithFallback(BaseConfig);
            var seedNodes = config.GetStringList("akka.cluster.seed-nodes");

            using (var system = ActorSystem.Create("NTPAC-Cluster", config))
            {
                var loadBalancerActor      = this._onlineLoadBalancerActorFactory.Create(system, settings);
                var startProcessingRequest = new CaptureProcessingRequest {
                    CaptureInfo = captureInfo
                };

                processingResult = await loadBalancerActor.Ask <ProcessingResult>(startProcessingRequest).ConfigureAwait(false);

                await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);

                await CoordinatedShutdown.Get(system).Run(CoordinatedShutdown.ClusterLeavingReason.Instance).ConfigureAwait(false);

//        Console.WriteLine("Pre-dispose delay");
                await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);
            }

//      Console.WriteLine("Post-dispose delay");
            await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);

            return(processingResult);
        }
Exemple #3
0
        public async Task <IProcessingResult> OpenCaptureAsync(Uri uri)
        {
            IProcessingResult processingResult;

            var captureInfo = new CaptureInfo(uri);

            var settings = new LoadBalancerSettings(BaseConfig);

            var config = this.ClusterSettings.Config.WithFallback(BaseConfig);

//      var seedNodes     = config.GetStringList("akka.cluster.seed-nodes");
            using (var system = ActorSystem.Create("NTPAC-Cluster", config))
            {
                var loadBalancerActor      = this._onlineLoadBalancerActorFactory.Create(system, settings);
                var startProcessingRequest = new CaptureProcessingRequest {
                    CaptureInfo = captureInfo
                };

                processingResult = await loadBalancerActor.Ask <ProcessingResult>(startProcessingRequest).ConfigureAwait(false);

                await Akka.Cluster.Cluster.Get(system).LeaveAsync();

                await system.Terminate();
            }

            return(processingResult);
        }
        private void OnCaptureProcessingRequest(CaptureProcessingRequest request)
        {
            this._captureInfo = request.CaptureInfo;
            this._contractor  = this.Sender;

            this.askProxy = new AskableReassemblerEntityMessageProxy(this.Self, this._clusterProxy);

            this.Become(this.ProcessingCaptureBehaviour);
            this.TryStartProcessingAsync().PipeTo(this.Self);


            this.Become(this.ProcessingCaptureBehaviour);
        }
        private void OnStartProcessingRequest(CaptureProcessingRequest request)
        {
            this.Contractor            = this.Sender;
            this.SelfLoadBalancerActor = this.Self;
            this.CaptureInfo           = request.CaptureInfo;

            this.DistributionSw          = new Stopwatch();
            this.TotalSw                 = new Stopwatch();
            this.ReassemblerMessageProxy = new AskableReassemblerEntityMessageProxy(this.SelfLoadBalancerActor, this.ClusterProxy);

            this.Become(this.ProcessingCaptureBehaviour);
            this.TryStartProcessingAsync().PipeTo(this.Self);
        }
Exemple #6
0
        private void OnStartProcessingRequest(CaptureProcessingRequest request)
        {
            this.Contractor            = this.Sender;
            this.SelfLoadBalancerActor = this.Self;
            this.CaptureInfo           = request.CaptureInfo;

            this.DistributionSw = new Stopwatch();
            this.TotalSw        = new Stopwatch();
            this.IPIpv4DefragmentationEngine =
                new Ipv4DefragmentationEngine(new AkkaLoggingAdapter <Ipv4DefragmentationEngine>(Context.GetLogger()));
            this.ReassemblerMessageProxy = new AskableReassemblerEntityMessageProxy(this.SelfLoadBalancerActor, this.ClusterProxy);

            this.Become(this.ProcessingCaptureBehaviour);
            this.TryStartProcessingAsync().PipeTo(this.Self);
        }
        public async Task Send_StartProcessingRequest_StartProcessingInitiated()
        {
            //Arrange

            var uri = new Uri(@"test://");
            var captureProcessingRequest = new CaptureProcessingRequest {
                CaptureInfo = new CaptureInfo(uri)
            };

            //Act
            this._offlineLoadBalancerActorRefSUT.Tell(captureProcessingRequest);

            //Assert
            await Task.Delay(50);

            this._rawPacketBatchParserFactoryMock.Verify(
                factory => factory.Create(It.IsAny <IActorContext>(), It.IsAny <IActorRef>(), It.IsAny <CaptureInfo>()), Times.Once);
            this._batchSenderMock.Verify(
                sender => sender.Initialize(this._offlineLoadBalancerActorRefSUT, this._rawPacketBatchActorTestProbe), Times.Once);
            this._batchLoaderMock.Verify(loader => loader.Open(uri), Times.Once);
            this._batchLoaderMock.Verify(loader => loader.LoadBatch(It.IsAny <Int32>()), Times.Once);
        }