public void ActorMessage <TState>(StatefulActor <TState> actor, string message, params object[] args) where TState : class
 {
     try
     {
         if (this.IsEnabled())
         {
             string finalMessage = string.Format(message, args);
             this.ActorMessage(
                 actor.GetType().ToString(),
                 actor.Id.ToString(),
                 actor.ActorService.ServiceInitializationParameters.CodePackageActivationContext.ApplicationTypeName,
                 actor.ActorService.ServiceInitializationParameters.CodePackageActivationContext.ApplicationName,
                 actor.ActorService.ServiceInitializationParameters.ServiceTypeName,
                 actor.ActorService.ActorTypeInformation.ServiceName,
                 actor.ActorService.ServiceInitializationParameters.PartitionId,
                 actor.ActorService.ServiceInitializationParameters.ReplicaId,
                 FabricRuntime.GetNodeContext().NodeName,
                 finalMessage);
         }
     }
     catch
     {
         // We don't want a failure to trace to crash the process. We can improve this handling later.
     }
 }
        object SetState(object instance)
        {
            StatefulActor <S> actor = instance as StatefulActor <S>;

            if (actor != null)
            {
                actor.GetType().InvokeMember("State", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetProperty, null, actor, new object[] { State });
            }
            return(instance);
        }
Beispiel #3
0
 public void Message <TState>(StatefulActor <TState> actor, string message, params object[] args) where TState : class
 {
     if (this.IsEnabled())
     {
         string finalMessage = string.Format(message, args);
         this.ActorMessage(
             actor.GetType().ToString(),
             actor.Id.ToString(),
             actor.ActorService.ServiceInitializationParameters.CodePackageActivationContext.ApplicationTypeName,
             actor.ActorService.ServiceInitializationParameters.CodePackageActivationContext.ApplicationName,
             actor.ActorService.ServiceInitializationParameters.ServiceTypeName,
             actor.ActorService.ServiceInitializationParameters.ServiceName.ToString(),
             actor.ActorService.ServiceInitializationParameters.PartitionId,
             actor.ActorService.ServiceInitializationParameters.ReplicaId,
             finalMessage);
     }
 }
Beispiel #4
0
        void MockEnvironment <I, S>(I callee, Action <I> callerMock, S state, params object[] mocks) where I : class
            where S : class, new()
        {
            try
            {
                IClientChannel channel = callee as IClientChannel;
                if ((state != null) && (channel == null) && (callee is IActor))
                {
                    StatefulActor <S> actor = callee as StatefulActor <S>;
                    actor.GetType().InvokeMember("State", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetProperty, null, actor, new object[] { state });
                }

                RegisterMocks(mocks);
                using (callee as IDisposable)
                {
                    callerMock(callee);
                }
                UnregisterMocks();
            }
            finally
            {
                IClientChannel channel = callee as IClientChannel;
                if (channel != null)
                {
                    if (channel.State != CommunicationState.Closed && channel.State != CommunicationState.Faulted)
                    {
                        try
                        {
                            channel.Close();
                        }
                        catch
                        {
                            channel.Abort();
                        }
                    }
                }
            }
        }
Beispiel #5
0
 public void ActorDeactivatedStop <T>(StatefulActor <T> a) where T : class
 {
     this.ActorActivatedStop(a.GetType().ToString(), a.Id.ToString(), a.ActorService.ServicePartition.PartitionInfo.Id);
 }