Пример #1
0
 public Logger GetLogger(string loggerName)
 {
     return(TraceLogger.GetLogger(loggerName, TraceLogger.LoggerType.Provider));
 }
Пример #2
0
 private StatsTableDataManager()
 {
     logger = TraceLogger.GetLogger(this.GetType().Name, TraceLogger.LoggerType.Runtime);
 }
Пример #3
0
 public GlobalActionFilter()
 {
     _log = TraceLogger.GetLogger("Operation");
 }
Пример #4
0
 public ServiceRuntimeWrapper()
 {
     logger = TraceLogger.GetLogger("ServiceRuntimeWrapper");
     Initialize();
 }
Пример #5
0
 public AzureBasedReminderTable()
 {
     logger = TraceLogger.GetLogger("AzureReminderTable", TraceLogger.LoggerType.Runtime);
 }
Пример #6
0
        public OutsideRuntimeClient(ClientConfiguration cfg, GrainFactory grainFactory, bool secondary = false)
        {
            this.grainFactory = grainFactory;
            this.clientId     = GrainId.NewClientId();

            if (cfg == null)
            {
                Console.WriteLine("An attempt to create an OutsideRuntimeClient with null ClientConfiguration object.");
                throw new ArgumentException("OutsideRuntimeClient was attempted to be created with null ClientConfiguration object.", "cfg");
            }

            this.config = cfg;

            if (!TraceLogger.IsInitialized)
            {
                TraceLogger.Initialize(config);
            }
            StatisticsCollector.Initialize(config);
            SerializationManager.Initialize(config.UseStandardSerializer, cfg.SerializationProviders, config.UseJsonFallbackSerializer);
            logger    = TraceLogger.GetLogger("OutsideRuntimeClient", TraceLogger.LoggerType.Runtime);
            appLogger = TraceLogger.GetLogger("Application", TraceLogger.LoggerType.Application);

            try
            {
                LoadAdditionalAssemblies();

                PlacementStrategy.Initialize();

                callbacks    = new ConcurrentDictionary <CorrelationId, CallbackData>();
                localObjects = new ConcurrentDictionary <GuidId, LocalObjectData>();

                if (!secondary)
                {
                    UnobservedExceptionsHandlerClass.SetUnobservedExceptionHandler(UnhandledException);
                }
                AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload;

                // Ensure SerializationManager static constructor is called before AssemblyLoad event is invoked
                SerializationManager.GetDeserializer(typeof(String));

                clientProviderRuntime     = new ClientProviderRuntime(grainFactory, new DefaultServiceProvider());
                statisticsProviderManager = new StatisticsProviderManager("Statistics", clientProviderRuntime);
                var statsProviderName = statisticsProviderManager.LoadProvider(config.ProviderConfigurations)
                                        .WaitForResultWithThrow(initTimeout);
                if (statsProviderName != null)
                {
                    config.StatisticsProviderName = statsProviderName;
                }

                responseTimeout = Debugger.IsAttached ? Constants.DEFAULT_RESPONSE_TIMEOUT : config.ResponseTimeout;
                BufferPool.InitGlobalBufferPool(config);
                var localAddress = ClusterConfiguration.GetLocalIPAddress(config.PreferredFamily, config.NetInterface);

                // Client init / sign-on message
                logger.Info(ErrorCode.ClientInitializing, string.Format(
                                "{0} Initializing OutsideRuntimeClient on {1} at {2} Client Id = {3} {0}",
                                BARS, config.DNSHostName, localAddress, clientId));
                string startMsg = string.Format("{0} Starting OutsideRuntimeClient with runtime Version='{1}' in AppDomain={2}",
                                                BARS, RuntimeVersion.Current, PrintAppDomainDetails());
                startMsg = string.Format("{0} Config= " + Environment.NewLine + " {1}", startMsg, config);
                logger.Info(ErrorCode.ClientStarting, startMsg);

                if (TestOnlyThrowExceptionDuringInit)
                {
                    throw new Exception("TestOnlyThrowExceptionDuringInit");
                }

                config.CheckGatewayProviderSettings();

                var generation          = -SiloAddress.AllocateNewGeneration(); // Client generations are negative
                var gatewayListProvider = GatewayProviderFactory.CreateGatewayListProvider(config)
                                          .WithTimeout(initTimeout).Result;
                transport = new ProxiedMessageCenter(config, localAddress, generation, clientId, gatewayListProvider);

                if (StatisticsCollector.CollectThreadTimeTrackingStats)
                {
                    incomingMessagesThreadTimeTracking = new ThreadTrackingStatistic("ClientReceiver");
                }
            }
            catch (Exception exc)
            {
                if (logger != null)
                {
                    logger.Error(ErrorCode.Runtime_Error_100319, "OutsideRuntimeClient constructor failed.", exc);
                }
                ConstructorReset();
                throw;
            }
        }
 public ClientMetricsTableDataManager()
 {
     logger = TraceLogger.GetLogger(this.GetType().Name, TraceLogger.LoggerType.Runtime);
 }
Пример #8
0
 public override Task OnActivateAsync()
 {
     logger = TraceLogger.GetLogger("ManagementGrain", TraceLogger.LoggerType.Runtime);
     return(TaskDone.Done);
 }
Пример #9
0
        internal override void Load(XmlElement root)
        {
            var logger = TraceLogger.GetLogger("OrleansConfiguration", TraceLogger.LoggerType.Runtime);

            SeedNodes = new List <IPEndPoint>();

            XmlElement child;

            foreach (XmlNode c in root.ChildNodes)
            {
                child = c as XmlElement;
                if (child != null && child.LocalName == "Networking")
                {
                    Subnet = child.HasAttribute("Subnet")
                        ? ConfigUtilities.ParseSubnet(child.GetAttribute("Subnet"), "Invalid Subnet")
                        : null;
                }
            }
            foreach (XmlNode c in root.ChildNodes)
            {
                child = c as XmlElement;
                if (child == null)
                {
                    continue;                // Skip comment lines
                }
                switch (child.LocalName)
                {
                case "Liveness":
                    if (child.HasAttribute("LivenessEnabled"))
                    {
                        LivenessEnabled = ConfigUtilities.ParseBool(child.GetAttribute("LivenessEnabled"),
                                                                    "Invalid boolean value for the LivenessEnabled attribute on the Liveness element");
                    }
                    if (child.HasAttribute("ProbeTimeout"))
                    {
                        ProbeTimeout = ConfigUtilities.ParseTimeSpan(child.GetAttribute("ProbeTimeout"),
                                                                     "Invalid time value for the ProbeTimeout attribute on the Liveness element");
                    }
                    if (child.HasAttribute("TableRefreshTimeout"))
                    {
                        TableRefreshTimeout = ConfigUtilities.ParseTimeSpan(child.GetAttribute("TableRefreshTimeout"),
                                                                            "Invalid time value for the TableRefreshTimeout attribute on the Liveness element");
                    }
                    if (child.HasAttribute("DeathVoteExpirationTimeout"))
                    {
                        DeathVoteExpirationTimeout = ConfigUtilities.ParseTimeSpan(child.GetAttribute("DeathVoteExpirationTimeout"),
                                                                                   "Invalid time value for the DeathVoteExpirationTimeout attribute on the Liveness element");
                    }
                    if (child.HasAttribute("NumMissedProbesLimit"))
                    {
                        NumMissedProbesLimit = ConfigUtilities.ParseInt(child.GetAttribute("NumMissedProbesLimit"),
                                                                        "Invalid integer value for the NumMissedIAmAlive attribute on the Liveness element");
                    }
                    if (child.HasAttribute("NumProbedSilos"))
                    {
                        NumProbedSilos = ConfigUtilities.ParseInt(child.GetAttribute("NumProbedSilos"),
                                                                  "Invalid integer value for the NumProbedSilos attribute on the Liveness element");
                    }
                    if (child.HasAttribute("NumVotesForDeathDeclaration"))
                    {
                        NumVotesForDeathDeclaration = ConfigUtilities.ParseInt(child.GetAttribute("NumVotesForDeathDeclaration"),
                                                                               "Invalid integer value for the NumVotesForDeathDeclaration attribute on the Liveness element");
                    }
                    if (child.HasAttribute("UseLivenessGossip"))
                    {
                        UseLivenessGossip = ConfigUtilities.ParseBool(child.GetAttribute("UseLivenessGossip"),
                                                                      "Invalid boolean value for the UseLivenessGossip attribute on the Liveness element");
                    }
                    if (child.HasAttribute("IAmAliveTablePublishTimeout"))
                    {
                        IAmAliveTablePublishTimeout = ConfigUtilities.ParseTimeSpan(child.GetAttribute("IAmAliveTablePublishTimeout"),
                                                                                    "Invalid time value for the IAmAliveTablePublishTimeout attribute on the Liveness element");
                    }
                    if (child.HasAttribute("NumMissedTableIAmAliveLimit"))
                    {
                        NumMissedTableIAmAliveLimit = ConfigUtilities.ParseInt(child.GetAttribute("NumMissedTableIAmAliveLimit"),
                                                                               "Invalid integer value for the NumMissedTableIAmAliveLimit attribute on the Liveness element");
                    }
                    if (child.HasAttribute("MaxJoinAttemptTime"))
                    {
                        MaxJoinAttemptTime = ConfigUtilities.ParseTimeSpan(child.GetAttribute("MaxJoinAttemptTime"),
                                                                           "Invalid time value for the MaxJoinAttemptTime attribute on the Liveness element");
                    }
                    if (child.HasAttribute("ExpectedClusterSize"))
                    {
                        int expectedClusterSize = ConfigUtilities.ParseInt(child.GetAttribute("ExpectedClusterSize"),
                                                                           "Invalid integer value for the ExpectedClusterSize attribute on the Liveness element");
                        ExpectedClusterSizeConfigValue = new ConfigValue <int>(expectedClusterSize, false);
                    }
                    break;

                case "Azure":
                case "SystemStore":
                    if (child.LocalName == "Azure")
                    {
                        // Log warning about deprecated <Azure> element, but then continue on to parse it for connection string info
                        logger.Warn(ErrorCode.SiloConfigDeprecated, "The Azure element has been deprecated -- use SystemStore element instead.");
                    }

                    if (child.HasAttribute("SystemStoreType"))
                    {
                        var sst = child.GetAttribute("SystemStoreType");
                        if (!"None".Equals(sst, StringComparison.InvariantCultureIgnoreCase))
                        {
                            LivenessType = (LivenessProviderType)Enum.Parse(typeof(LivenessProviderType), sst);
                            SetReminderServiceType((ReminderServiceProviderType)Enum.Parse(typeof(ReminderServiceProviderType), sst));
                        }
                    }
                    if (child.HasAttribute("ServiceId"))
                    {
                        ServiceId = ConfigUtilities.ParseGuid(child.GetAttribute("ServiceId"),
                                                              "Invalid Guid value for the ServiceId attribute on the Azure element");
                    }
                    if (child.HasAttribute("DeploymentId"))
                    {
                        DeploymentId = child.GetAttribute("DeploymentId");
                    }
                    if (child.HasAttribute(Constants.DATA_CONNECTION_STRING_NAME))
                    {
                        DataConnectionString = child.GetAttribute(Constants.DATA_CONNECTION_STRING_NAME);
                        if (String.IsNullOrWhiteSpace(DataConnectionString))
                        {
                            throw new FormatException("SystemStore.DataConnectionString cannot be blank");
                        }
                    }
                    if (child.HasAttribute("MaxStorageBusyRetries"))
                    {
                        int maxBusyRetries = ConfigUtilities.ParseInt(child.GetAttribute("MaxStorageBusyRetries"),
                                                                      "Invalid integer value for the MaxStorageBusyRetries attribute on the SystemStore element");
                        AzureTableDefaultPolicies.MaxBusyRetries = maxBusyRetries;
                    }
                    if (child.HasAttribute("UseMockReminderTable"))
                    {
                        MockReminderTableTimeout = ConfigUtilities.ParseTimeSpan(child.GetAttribute("UseMockReminderTable"), "Invalid timeout value");
                        UseMockReminderTable     = true;
                    }
                    break;

                case "SeedNode":
                    SeedNodes.Add(ConfigUtilities.ParseIPEndPoint(child, Subnet));
                    break;

                case "Messaging":
                    base.Load(child);
                    break;

                case "Application":
                    Application.Load(child, logger);
                    break;

                case "PlacementStrategy":
                    if (child.HasAttribute("DefaultPlacementStrategy"))
                    {
                        DefaultPlacementStrategy = child.GetAttribute("DefaultPlacementStrategy");
                    }
                    if (child.HasAttribute("DeploymentLoadPublisherRefreshTime"))
                    {
                        DeploymentLoadPublisherRefreshTime = ConfigUtilities.ParseTimeSpan(child.GetAttribute("DeploymentLoadPublisherRefreshTime"),
                                                                                           "Invalid time span value for PlacementStrategy.DeploymentLoadPublisherRefreshTime");
                    }
                    if (child.HasAttribute("ActivationCountBasedPlacementChooseOutOf"))
                    {
                        ActivationCountBasedPlacementChooseOutOf = ConfigUtilities.ParseInt(child.GetAttribute("ActivationCountBasedPlacementChooseOutOf"),
                                                                                            "Invalid ActivationCountBasedPlacementChooseOutOf setting");
                    }
                    break;

                case "Caching":
                    if (child.HasAttribute("CacheSize"))
                    {
                        CacheSize = ConfigUtilities.ParseInt(child.GetAttribute("CacheSize"),
                                                             "Invalid integer value for Caching.CacheSize");
                    }

                    if (child.HasAttribute("InitialTTL"))
                    {
                        InitialCacheTTL = ConfigUtilities.ParseTimeSpan(child.GetAttribute("InitialTTL"),
                                                                        "Invalid time value for Caching.InitialTTL");
                    }

                    if (child.HasAttribute("MaximumTTL"))
                    {
                        MaximumCacheTTL = ConfigUtilities.ParseTimeSpan(child.GetAttribute("MaximumTTL"),
                                                                        "Invalid time value for Caching.MaximumTTL");
                    }

                    if (child.HasAttribute("TTLExtensionFactor"))
                    {
                        CacheTTLExtensionFactor = ConfigUtilities.ParseDouble(child.GetAttribute("TTLExtensionFactor"),
                                                                              "Invalid double value for Caching.TTLExtensionFactor");
                    }
                    if (CacheTTLExtensionFactor <= 1.0)
                    {
                        throw new FormatException("Caching.TTLExtensionFactor must be greater than 1.0");
                    }

                    if (child.HasAttribute("DirectoryCachingStrategy"))
                    {
                        DirectoryCachingStrategy = ConfigUtilities.ParseEnum <DirectoryCachingStrategyType>(child.GetAttribute("DirectoryCachingStrategy"),
                                                                                                            "Invalid value for Caching.Strategy");
                    }

                    break;

                case "Directory":
                    if (child.HasAttribute("DirectoryLazyDeregistrationDelay"))
                    {
                        DirectoryLazyDeregistrationDelay = ConfigUtilities.ParseTimeSpan(child.GetAttribute("DirectoryLazyDeregistrationDelay"),
                                                                                         "Invalid time span value for Directory.DirectoryLazyDeregistrationDelay");
                    }
                    break;

                default:
                    if (child.LocalName.EndsWith("Providers", StringComparison.Ordinal))
                    {
                        var providerConfig = new ProviderCategoryConfiguration();
                        providerConfig.Load(child);
                        ProviderConfigurations.Add(providerConfig.Name, providerConfig);
                    }
                    break;
                }
            }
        }
Пример #10
0
 public ActivationCountPlacementDirector()
 {
     logger = TraceLogger.GetLogger(this.GetType().Name);
 }
Пример #11
0
        public LocalGrainDirectory(Silo silo)
        {
            log = TraceLogger.GetLogger("Orleans.GrainDirectory.LocalGrainDirectory");

            MyAddress          = silo.LocalMessageCenter.MyAddress;
            Scheduler          = silo.LocalScheduler;
            membershipRingList = new List <SiloAddress>();
            membershipCache    = new HashSet <SiloAddress>();

            silo.OrleansConfig.OnConfigChange("Globals/Caching", () =>
            {
                lock (membershipCache)
                {
                    DirectoryCache = GrainDirectoryCacheFactory <List <Tuple <SiloAddress, ActivationId> > > .CreateGrainDirectoryCache(silo.GlobalConfig);
                }
            });
            maintainer = GrainDirectoryCacheFactory <List <Tuple <SiloAddress, ActivationId> > > .CreateGrainDirectoryCacheMaintainer(this, DirectoryCache);

            if (silo.GlobalConfig.SeedNodes.Count > 0)
            {
                seed = silo.GlobalConfig.SeedNodes.Contains(MyAddress.Endpoint) ? MyAddress : SiloAddress.New(silo.GlobalConfig.SeedNodes[0], 0);
            }

            stopPreparationResolver = new TaskCompletionSource <bool>();
            DirectoryPartition      = new GrainDirectoryPartition();
            HandoffManager          = new GrainDirectoryHandoffManager(this, silo.GlobalConfig);

            RemGrainDirectory = new RemoteGrainDirectory(this, Constants.DirectoryServiceId);
            CacheValidator    = new RemoteGrainDirectory(this, Constants.DirectoryCacheValidatorId);

            // add myself to the list of members
            AddServer(MyAddress);

            Func <SiloAddress, string> siloAddressPrint = (SiloAddress addr) =>
                                                          String.Format("{0}/{1:X}", addr.ToLongString(), addr.GetConsistentHashCode());

            localLookups   = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_LOOKUPS_LOCAL_ISSUED);
            localSuccesses = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_LOOKUPS_LOCAL_SUCCESSES);
            fullLookups    = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_LOOKUPS_FULL_ISSUED);

            RemoteLookupsSent     = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_LOOKUPS_REMOTE_SENT);
            RemoteLookupsReceived = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_LOOKUPS_REMOTE_RECEIVED);

            LocalDirectoryLookups   = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_LOOKUPS_LOCALDIRECTORY_ISSUED);
            LocalDirectorySuccesses = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_LOOKUPS_LOCALDIRECTORY_SUCCESSES);

            cacheLookups   = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_LOOKUPS_CACHE_ISSUED);
            cacheSuccesses = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_LOOKUPS_CACHE_SUCCESSES);
            StringValueStatistic.FindOrCreate(StatisticNames.DIRECTORY_LOOKUPS_CACHE_HITRATIO, () =>
            {
                long delta1, delta2;
                long curr1 = cacheSuccesses.GetCurrentValueAndDelta(out delta1);
                long curr2 = cacheLookups.GetCurrentValueAndDelta(out delta2);
                return(String.Format("{0}, Delta={1}",
                                     (curr2 != 0 ? (float)curr1 / (float)curr2 : 0)
                                     , (delta2 != 0 ? (float)delta1 / (float)delta2 : 0)));
            });

            CacheValidationsSent     = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_VALIDATIONS_CACHE_SENT);
            CacheValidationsReceived = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_VALIDATIONS_CACHE_RECEIVED);

            registrationsIssued                  = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_REGISTRATIONS_ISSUED);
            RegistrationsLocal                   = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_REGISTRATIONS_LOCAL);
            RegistrationsRemoteSent              = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_REGISTRATIONS_REMOTE_SENT);
            RegistrationsRemoteReceived          = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_REGISTRATIONS_REMOTE_RECEIVED);
            registrationsSingleActIssued         = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_REGISTRATIONS_SINGLE_ACT_ISSUED);
            RegistrationsSingleActLocal          = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_REGISTRATIONS_SINGLE_ACT_LOCAL);
            RegistrationsSingleActRemoteSent     = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_REGISTRATIONS_SINGLE_ACT_REMOTE_SENT);
            RegistrationsSingleActRemoteReceived = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_REGISTRATIONS_SINGLE_ACT_REMOTE_RECEIVED);
            unregistrationsIssued                = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_UNREGISTRATIONS_ISSUED);
            UnregistrationsLocal                 = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_UNREGISTRATIONS_LOCAL);
            UnregistrationsRemoteSent            = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_UNREGISTRATIONS_REMOTE_SENT);
            UnregistrationsRemoteReceived        = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_UNREGISTRATIONS_REMOTE_RECEIVED);
            unregistrationsManyIssued            = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_UNREGISTRATIONS_MANY_ISSUED);
            UnregistrationsManyRemoteSent        = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_UNREGISTRATIONS_MANY_REMOTE_SENT);
            UnregistrationsManyRemoteReceived    = CounterStatistic.FindOrCreate(StatisticNames.DIRECTORY_UNREGISTRATIONS_MANY_REMOTE_RECEIVED);

            directoryPartitionCount = IntValueStatistic.FindOrCreate(StatisticNames.DIRECTORY_PARTITION_SIZE, () => DirectoryPartition.Count);
            IntValueStatistic.FindOrCreate(StatisticNames.DIRECTORY_RING_MYPORTION_RINGDISTANCE, () => RingDistanceToSuccessor());
            FloatValueStatistic.FindOrCreate(StatisticNames.DIRECTORY_RING_MYPORTION_RINGPERCENTAGE, () => (((float)RingDistanceToSuccessor()) / ((float)(int.MaxValue * 2L))) * 100);
            FloatValueStatistic.FindOrCreate(StatisticNames.DIRECTORY_RING_MYPORTION_AVERAGERINGPERCENTAGE, () => membershipRingList.Count == 0 ? 0 : ((float)100 / (float)membershipRingList.Count));
            IntValueStatistic.FindOrCreate(StatisticNames.DIRECTORY_RING_RINGSIZE, () => membershipRingList.Count);
            StringValueStatistic.FindOrCreate(StatisticNames.DIRECTORY_RING, () =>
            {
                lock (membershipCache)
                {
                    return(Utils.EnumerableToString(membershipRingList, siloAddressPrint));
                }
            });
            StringValueStatistic.FindOrCreate(StatisticNames.DIRECTORY_RING_PREDECESSORS, () => Utils.EnumerableToString(FindPredecessors(MyAddress, 1), siloAddressPrint));
            StringValueStatistic.FindOrCreate(StatisticNames.DIRECTORY_RING_SUCCESSORS, () => Utils.EnumerableToString(FindSuccessors(MyAddress, 1), siloAddressPrint));
        }
Пример #12
0
 public ProviderLoader()
 {
     logger    = TraceLogger.GetLogger("ProviderLoader/" + typeof(TProvider).Name, TraceLogger.LoggerType.Runtime);
     providers = new Dictionary <string, TProvider>();
 }
 public AzureMembershipTableTests()
 {
     logger = TraceLogger.GetLogger("AzureMembershipTableTests", TraceLogger.LoggerType.Application);
 }