示例#1
0
 public Throttle(RoleName node, RoleName target, ThrottleTransportAdapter.Direction direction, float rateMBit)
 {
     _node      = node;
     _target    = target;
     _direction = direction;
     _rateMBit  = rateMBit;
 }
示例#2
0
        private bool Throttle(ThrottleTransportAdapter.Direction direction, ThrottleMode mode)
        {
            var rootBAddress = new Address("akka", "systemB", "localhost", RootB.Address.Port.Value);
            var transport    =
                Sys.AsInstanceOf <ExtendedActorSystem>().Provider.AsInstanceOf <RemoteActorRefProvider>().Transport;
            var task = transport.ManagementCommand(new SetThrottle(rootBAddress, direction, mode));

            task.Wait(TimeSpan.FromSeconds(3));
            return(task.Result);
        }
示例#3
0
        public static Proto.Msg.InjectFailure.Types.Direction Direction2Proto(ThrottleTransportAdapter.Direction dir)
        {
            switch (dir)
            {
            case ThrottleTransportAdapter.Direction.Send: return(Proto.Msg.InjectFailure.Types.Direction.Send);

            case ThrottleTransportAdapter.Direction.Receive: return(Proto.Msg.InjectFailure.Types.Direction.Receive);

            case ThrottleTransportAdapter.Direction.Both:
            default: return(Proto.Msg.InjectFailure.Types.Direction.Both);
            }
        }
示例#4
0
        public static TCP.Direction Direction2Proto(ThrottleTransportAdapter.Direction dir)
        {
            switch (dir)
            {
            case ThrottleTransportAdapter.Direction.Send: return(Direction.Send);

            case ThrottleTransportAdapter.Direction.Receive: return(Direction.Receive);

            case ThrottleTransportAdapter.Direction.Both:
            default:
                return(Direction.Both);
            }
        }
 private Task <SetThrottleAck> SetMode(ThrottlerHandle handle, ThrottleMode mode,
                                       ThrottleTransportAdapter.Direction direction)
 {
     if (direction == ThrottleTransportAdapter.Direction.Both ||
         direction == ThrottleTransportAdapter.Direction.Send)
     {
         handle.OutboundThrottleMode.Value = mode;
     }
     if (direction == ThrottleTransportAdapter.Direction.Both ||
         direction == ThrottleTransportAdapter.Direction.Receive)
     {
         return(AskModeWithDeathCompletion(handle.ThrottlerActor, mode, ActorTransportAdapter.AskTimeout));
     }
     else
     {
         return(Task.FromResult(SetThrottleAck.Instance));
     }
 }
示例#6
0
 /// <summary>
 /// Creates a new SetThrottle message.
 /// </summary>
 /// <param name="address">The address of the throttle.</param>
 /// <param name="direction">The direction of the throttle.</param>
 /// <param name="mode">The mode of the throttle.</param>
 public SetThrottle(Address address, ThrottleTransportAdapter.Direction direction, ThrottleMode mode)
 {
     _address   = address;
     _direction = direction;
     _mode      = mode;
 }
示例#7
0
 /// <summary>
 /// Switch the Helios pipeline of the remote support into pass through mode for
 /// sending and/or receiving.
 ///
 /// ====Note====
 /// To use this feature you must activate the failure injector and throttler
 /// transport adapters by specifying `testTransport(on = true)` in your MultiNodeConfig.
 /// </summary>
 /// <param name="node">is the symbolic name of the node which is to be affected</param>
 /// <param name="target">is the symbolic name of the other node to which connectivity shall be impeded</param>
 /// <param name="direction">can be either `Direction.Send`, `Direction.Receive` or `Direction.Both`</param>
 /// <returns></returns>
 public Task <Done> PassThrough(RoleName node, RoleName target, ThrottleTransportAdapter.Direction direction)
 {
     return(Throttle(node, target, direction, -1f));
 }
示例#8
0
 /// <summary>
 /// Switch the helios pipeline of the remote support into blackhole mode for
 /// sending and/or receiving: it will just drop all messages right before
 /// submitting them to the Socket or right after receiving them from the
 /// Socket.
 ///
 ///  ====Note====
 /// To use this feature you must activate the failure injector and throttler
 /// transport adapters by specifying `testTransport(on = true)` in your MultiNodeConfig.
 /// </summary>
 /// <param name="node">is the symbolic name of the node which is to be affected</param>
 /// <param name="target">is the symbolic name of the other node to which connectivity shall be impeded</param>
 /// <param name="direction">can be either `Direction.Send`, `Direction.Receive` or `Direction.Both`</param>
 /// <returns></returns>
 public Task <Done> Blackhole(RoleName node, RoleName target, ThrottleTransportAdapter.Direction direction)
 {
     return(Throttle(node, target, direction, 0f));
 }
示例#9
0
 /// <summary>
 /// Make the remoting pipeline on the node throttle data sent to or received
 /// from the given remote peer. Throttling works by delaying packet submission
 /// within the netty pipeline until the packet would have been completely sent
 /// according to the given rate, the previous packet completion and the current
 /// packet length. In case of large packets they are split up if the calculated
 /// end pause would exceed `akka.testconductor.packet-split-threshold`
 /// (roughly). All of this uses the system’s scheduler, which is not
 /// terribly precise and will execute tasks later than they are schedule (even
 /// on average), but that is countered by using the actual execution time for
 /// determining how much to send, leading to the correct output rate, but with
 /// increased latency.
 ///
 /// ====Note====
 /// To use this feature you must activate the failure injector and throttler
 /// transport adapters by specifying `testTransport(on = true)` in your MultiNodeConfig.
 /// </summary>
 /// <param name="node">is the symbolic name of the node which is to be affected</param>
 /// <param name="target">is the symbolic name of the other node to which connectivity shall be throttled</param>
 /// <param name="direction">can be either `Direction.Send`, `Direction.Receive` or `Direction.Both`</param>
 /// <param name="rateMBit">is the maximum data rate in MBit</param>
 /// <returns></returns>
 public Task <Done> Throttle(RoleName node, RoleName target, ThrottleTransportAdapter.Direction direction,
                             float rateMBit)
 {
     RequireTestConductorTransport();
     return(Controller.Ask <Done>(new Throttle(node, target, direction, rateMBit)));
 }
示例#10
0
 public ThrottleMsg(Address target, ThrottleTransportAdapter.Direction direction, float rateMBit)
 {
     _target    = target;
     _direction = direction;
     _rateMBit  = rateMBit;
 }
 public SetThrottle(Address address, ThrottleTransportAdapter.Direction direction, ThrottleMode mode)
 {
     _address = address;
     _direction = direction;
     _mode = mode;
 }