protected sealed override object getValue(IActorContext context, IActorRef self, IActorRef sender)
        {
            var actorPath = ActorPath.GetValueAsObject();

            if (actorPath is ActorPath)
            {
                return(context.ActorSelection(actorPath as ActorPath));
            }
            else if (actorPath is string)
            {
                var anchorRef = AnchorRef.GetValue();

                if (anchorRef != null)
                {
                    return(context.ActorSelection(anchorRef, actorPath as string));
                }
                else
                {
                    return(context.ActorSelection(actorPath as string));
                }
            }
            else
            {
                return(null);
            }
        }
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                var value = reader.Value.ToString();

                ActorSelection selection = _context.ActorSelection(value);

                return(selection.Anchor);
            }
Beispiel #3
0
        private void Send(long deliveryId, Delivery delivery, DateTime timestamp)
        {
            ActorSelection destination = _context.ActorSelection(delivery.Destination);

            destination.Tell(delivery.Message);

            _unconfirmed = _unconfirmed.SetItem(deliveryId,
                                                new Delivery(delivery.Destination, delivery.Message, timestamp, delivery.Attempt + 1));
        }
        /// <summary>
        /// Gets path to web descriptor for node with role "web"
        /// </summary>
        /// <param name="context">The actor context</param>
        /// <param name="nodeAddress">The web node</param>
        /// <returns>Path to web descriptor</returns>
        public static ICanTell GetApiPublisher(this IActorContext context, [NotNull] Address nodeAddress)
        {
            if (nodeAddress == null)
            {
                throw new ArgumentNullException(nameof(nodeAddress));
            }

            return(context.ActorSelection($"{nodeAddress}/user/KlusterKite/API/Publisher"));
        }
        private void Send(long deliveryId, Delivery delivery, DateTime timestamp)
        {
            ActorSelection destination = _context.ActorSelection(delivery.Destination);

            destination.Tell(delivery.Message);

            var dcopy = new Delivery(delivery.Destination, delivery.Message, timestamp, delivery.Attempt + 1);

            _unconfirmed.AddOrUpdate(deliveryId, dcopy, (id, d) => dcopy);
        }
        public SqlPersistentRepresentation(AkkaStorageItem item, IActorContext context)
        {
            var payloadType = Type.GetType(item.PayloadType);

            Payload       = JsonConvert.DeserializeObject(item.PayloadJson, payloadType);
            Manifest      = item.Manifest;
            PersistenceId = item.PersistenceId;
            SequenceNr    = item.SequenceNr;
            WriterGuid    = item.WriterGuid;
            Sender        = context.ActorSelection(item.Path)?.Anchor;
        }
Beispiel #7
0
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                var value = reader?.Value?.ToString();

                if (string.IsNullOrEmpty(value))
                {
                    return(null);
                }
                else
                {
                    ActorSelection selection = _context.ActorSelection(value);
                    return(selection.Anchor);
                }
            }
Beispiel #8
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="path">TBD</param>
 /// <param name="context">TBD</param>
 /// <returns>TBD</returns>
 internal Routee RouteeFor(string path, IActorContext context)
 {
     return(new ActorSelectionRoutee(context.ActorSelection(path)));
 }
Beispiel #9
0
        public override async Task ReplayMessagesAsync(
            IActorContext context,
            string persistenceId,
            long fromSequenceNr,
            long toSequenceNr,
            long max,
            Action <IPersistentRepresentation> recoveryCallback)
        {
            try
            {
                if (toSequenceNr < fromSequenceNr || max == 0)
                {
                    return;
                }

                if (fromSequenceNr == toSequenceNr)
                {
                    max = 1;
                }

                if (toSequenceNr > fromSequenceNr && max == toSequenceNr)
                {
                    max = toSequenceNr - fromSequenceNr + 1;
                }

                var count = 0L;

                var start = fromSequenceNr <= 0
                        ? 0
                        : fromSequenceNr - 1;

                var localBatchSize = _settings.ReadBatchSize;

                StreamEventsSlice slice;
                do
                {
                    if (max == long.MaxValue && toSequenceNr > fromSequenceNr)
                    {
                        max = toSequenceNr - fromSequenceNr + 1;
                    }

                    if (max < localBatchSize)
                    {
                        localBatchSize = (int)max;
                    }

                    slice = await _conn.ReadStreamEventsForwardAsync(persistenceId, start, localBatchSize, false);

                    foreach (var @event in slice.Events)
                    {
                        var representation = _eventAdapter.Adapt(@event, s =>
                        {
                            //TODO: Is this correct?
                            var selection = context.ActorSelection(s);
                            return(selection.Anchor);
                        });

                        recoveryCallback(representation);
                        count++;

                        if (count == max)
                        {
                            return;
                        }
                    }

                    start = slice.NextEventNumber;
                } while (!slice.IsEndOfStream);
            }
            catch (Exception e)
            {
                _log.Error(e, "Error replaying messages for: {0}", persistenceId);
                throw;
            }
        }
Beispiel #10
0
        public static ICanTell GetNodeManager([NotNull] this IActorContext context)
        {
            var path = GetNodeManagerPath(context.System.Settings.Config);

            return(context.ActorSelection(path));
        }
Beispiel #11
0
        public static ICanTell GetParcelManager([NotNull] this IActorContext context)
        {
            var path = GetParcelManagerPath(context.System);

            return(context.ActorSelection(path));
        }
Beispiel #12
0
 public ActorSelection Select(IActorContext context = null)
 {
     return(context == null?
            ActorSystem.ActorSelection(ActorMetaData.Path) :
                context.ActorSelection(ActorMetaData.Path));
 }