protected internal RemoteStorage(IEnumerable <ServerInfo> servers, int connPerServer, MemoryCloud mc, int partitionId, bool nonblocking)
        {
            this.m_memorycloud = mc;
            this.PartitionId   = partitionId;

            var connect_async_task = Task.Factory.StartNew(() =>
            {
                for (int k = 0; k < connPerServer; k++) // make different server connections interleaved
                {
                    foreach (var s in servers)
                    {
                        Connect(s);
                    }
                }
                if (mc != null && partitionId != -1)
                {
                    BackgroundThread.AddBackgroundTask(new BackgroundTask(Heartbeat, TrinityConfig.HeartbeatInterval));
                    mc.ReportServerConnectedEvent(this);
                }
            });

            if (!nonblocking)
            {
                try { connect_async_task.Wait(); }
                catch (AggregateException ex) { ExceptionDispatchInfo.Capture(ex.InnerException).Throw(); }
            }
        }
Exemple #2
0
        internal RemoteStorage(AvailabilityGroup trinityServer, int connPerServer, MemoryCloud mc, int serverId, bool nonblocking)
        {
            this.memory_cloud = mc;
            this.MyServerId   = serverId;
            retry             = 3;

            var connect_async_task = Task.Factory.StartNew(() =>
            {
                for (int k = 0; k < connPerServer; k++) // make different server connections interleaved
                {
                    for (int i = 0; i < trinityServer.ServerInstances.Count; i++)
                    {
                        ConnectIPEndPoint(trinityServer.ServerInstances[i].EndPoint);
                    }
                }
                BackgroundThread.AddBackgroundTask(new BackgroundTask(Heartbeat, TrinityConfig.HeartbeatInterval));
                mc.ReportServerConnectedEvent(serverId);
            });

            if (!nonblocking)
            {
                try { connect_async_task.Wait(); }
                catch (AggregateException ex) { ExceptionDispatchInfo.Capture(ex.InnerException).Throw(); }
            }
        }
Exemple #3
0
        static Log()
        {
            TrinityC.Init();
            try
            {
                TrinityConfig.LoadTrinityConfig();
            }
            catch
            {
                Log.WriteLine(LogLevel.Error, "Failure to load config file, falling back to default log behavior");
            }

            string unitTestAssemblyName = "Microsoft.VisualStudio.QualityTools.UnitTestFramework";
            bool   isInUnitTest         = AppDomain.CurrentDomain.GetAssemblies()
                                          .Any(a => a.FullName.StartsWith(unitTestAssemblyName, StringComparison.Ordinal));

            if (isInUnitTest)
            {
                WriteLine(LogLevel.Info, "UnitTestFramework detected. Enabling echo callback.");
                var LogFilename = Path.Combine(TrinityConfig.LogDirectory, "trinity-[" + DateTime.Now.ToStringForFilename() + "].log");
                new Thread(_unitTestLogEchoThread).Start(LogFilename);
            }

            BackgroundThread.AddBackgroundTask(new BackgroundTask(CollectLogEntries, c_LogEntryCollectorIdleInterval));
        }
Exemple #4
0
        static Log()
        {
            TrinityC.Init();
            try
            {
                TrinityConfig.LoadTrinityConfig();
            }
            catch
            {
                Log.WriteLine(LogLevel.Error, "Failure to load config file, falling back to default log behavior");
            }

            BackgroundThread.AddBackgroundTask(new BackgroundTask(CollectLogEntries, c_LogEntryCollectorIdleInterval));
        }
Exemple #5
0
 internal static void Initialize()
 {
     lock (s_init_lock)
     {
         if (s_initialized)
         {
             return;
         }
         TrinityConfig.EnsureConfig();
         CLogInitialize();
         s_bgtask = new BackgroundTask(CollectLogEntries, c_LogEntryCollectorIdleInterval);
         BackgroundThread.AddBackgroundTask(s_bgtask);
         s_initialized = true;
         s_logtofile   = LoggingConfig.Instance.LogToFile;
         SetLogDirectory(LoggingConfig.Instance.LogDirectory);
     }
 }
Exemple #6
0
 static Index()
 {
     BackgroundIndexUpdater();
     BackgroundThread.AddBackgroundTask(new BackgroundTask(BackgroundIndexUpdater, s_BackgroundIndexUpdateInterval));
 }