public static bool RemoveGroupStorage(IDxStoreEventLogger eventLogger, InstanceGroupConfig group)
        {
            bool flag;

            if (Directory.Exists(group.Settings.PaxosStorageDir))
            {
                flag = (Utils.RunOperation(group.Identity, "Removing Paxos directory", delegate
                {
                    Directory.Delete(group.Settings.PaxosStorageDir, true);
                }, eventLogger, LogOptions.LogException | LogOptions.LogStart | LogOptions.LogSuccess | LogOptions.LogPeriodic | group.Settings.AdditionalLogOptions, true, null, null, null, null, null) == null);
            }
            else
            {
                flag = true;
            }
            bool flag2;

            if (Directory.Exists(group.Settings.SnapshotStorageDir))
            {
                flag2 = (Utils.RunOperation(group.Identity, "Removing Snapshot directory", delegate
                {
                    Directory.Delete(group.Settings.SnapshotStorageDir, true);
                }, eventLogger, LogOptions.LogException | LogOptions.LogStart | LogOptions.LogSuccess | LogOptions.LogPeriodic | group.Settings.AdditionalLogOptions, true, null, null, null, null, null) == null);
            }
            else
            {
                flag2 = true;
            }
            return(flag && flag2);
        }
 // Token: 0x06000ED6 RID: 3798 RVA: 0x0003F49C File Offset: 0x0003D69C
 public DistributedStoreTopologyProvider(IDxStoreEventLogger eventLogger, string self = null, bool isZeroboxMode = false)
 {
     this.eventLogger    = eventLogger;
     this.versionChecker = new DistributedStoreDagVersionChecker(this, "DxStoreStartCheck", RegistryParameters.DistributedStoreStartupMinimumRequiredVersionAcrossDag);
     base.DefaultInstanceProcessFullPath = Path.Combine(isZeroboxMode ? "C:\\EXCHANGE" : ExchangeSetupContext.InstallPath, "bin\\Microsoft.Exchange.DxStore.HA.Instance.exe");
     base.Initialize("ExchangeHA", self, null, eventLogger, isZeroboxMode);
 }
 public static void Log(this IDxStoreEventLogger logger, string periodicKey, TimeSpan?periodicDuration, DxEventSeverity severity, int id, string formatString, params object[] args)
 {
     if (periodicKey != null)
     {
         logger.LogPeriodic(periodicKey, periodicDuration.Value, severity, id, formatString, args);
         return;
     }
     logger.Log(severity, id, formatString, args);
 }
Example #4
0
        public static void LogInfo(string formatString, params object[] args)
        {
            IDxStoreEventLogger instance = EventLogger.Instance;

            if (instance != null)
            {
                instance.Log(DxEventSeverity.Info, 0, formatString, args);
            }
        }
 public DxStoreInstance(InstanceGroupConfig groupConfig, IDxStoreEventLogger eventLogger)
 {
     this.Identity           = groupConfig.Identity;
     this.IdentityHash       = groupConfig.Identity.GetHashCode();
     this.EventLogger        = eventLogger;
     this.GroupConfig        = groupConfig;
     this.LocalProcessInfo   = new ProcessBasicInfo(true);
     this.StopEvent          = new ManualResetEvent(false);
     this.StopCompletedEvent = new ManualResetEvent(false);
     this.State = InstanceState.Initialized;
 }
Example #6
0
 public static void LogFinishedEvent(string identity, string label, IDxStoreEventLogger logger, bool isPeriodic, string periodicKey, TimeSpan?periodicDuration, string context)
 {
     if (logger != null)
     {
         logger.Log((isPeriodic && periodicDuration != null) ? (periodicKey + "Finished") : null, periodicDuration, DxEventSeverity.Info, 0, "{0}: Operation {1} ({2}) successfuly completed", new object[]
         {
             identity,
             label,
             context ?? string.Empty
         });
     }
 }
Example #7
0
 public static void LogStartingEvent(string identity, string label, IDxStoreEventLogger logger, bool isPeriodic, string periodicKey, TimeSpan?periodicDuration, string context)
 {
     if (logger != null)
     {
         logger.Log((isPeriodic && periodicDuration != null) ? (periodicKey + "Starting") : null, periodicDuration, DxEventSeverity.Info, 0, "{0}: Starting operation {1} ({2})", new object[]
         {
             identity,
             label,
             context ?? string.Empty
         });
     }
 }
        private DxStoreStateMachine CreateStateMachine(Round <string>?leaderHint, PaxosBasicInfo referencePaxos)
        {
            Policy policy = new Policy
            {
                DebugName = this.GroupConfig.Self
            };
            bool flag = false;

            string[] array = (from m in this.GroupConfig.Members
                              select m.Name).ToArray <string>();
            if (referencePaxos != null && referencePaxos.IsMember(this.GroupConfig.Self))
            {
                array = referencePaxos.Members;
                flag  = true;
            }
            IDxStoreEventLogger eventLogger = this.EventLogger;
            DxEventSeverity     severity    = DxEventSeverity.Info;
            int    id           = 0;
            string formatString = "{0}: Creating state machine with membership '{1}' (IsUsingReferencePaxos: {2}, IsReferencePaxosLeader: {3}, GroupConfig.Members: {4}";

            object[] array2 = new object[5];
            array2[0] = this.GroupConfig.Identity;
            array2[1] = array.JoinWithComma("<null>");
            array2[2] = flag;
            array2[3] = (flag ? referencePaxos.IsLeader.ToString() : "<unknown>");
            array2[4] = (from m in this.GroupConfig.Members
                         select m.Name).JoinWithComma("<null>");
            eventLogger.Log(severity, id, formatString, array2);
            Dictionary <string, ServiceEndpoint> membersInstanceClientEndPoints = this.GetMembersInstanceClientEndPoints(array);
            NodeEndPointsBase <ServiceEndpoint>  nodeEndPointsBase = new NodeEndPointsBase <ServiceEndpoint>(this.GroupConfig.Self, membersInstanceClientEndPoints);

            this.PerfCounters = new Counters(this.GroupConfig.Identity);
            Configuration <string> configuration = new Configuration <string>(nodeEndPointsBase.Nodes, nodeEndPointsBase.Nodes, nodeEndPointsBase.Nodes, null);
            GroupMembersMesh       mesh          = new GroupMembersMesh(this.Identity, nodeEndPointsBase, this.GroupConfig);
            EsentStorage <string, DxStoreCommand> esentStorage = new EsentStorage <string, DxStoreCommand>(this.GroupConfig.Settings.PaxosStorageDir, this.PerfCounters, null, null, true);

            esentStorage.TryInitialize(configuration);
            return(new DxStoreStateMachine(policy, this, nodeEndPointsBase, esentStorage, mesh, this.PerfCounters, leaderHint));
        }
Example #9
0
 public static void LogErrorEvent(string identity, string label, Exception exception, LogOptions logOptions, IDxStoreEventLogger logger, bool isPeriodic, string periodicKey, TimeSpan?periodicDuration, string context)
 {
     if (logger != null)
     {
         string name    = exception.GetType().Name;
         string message = exception.Message;
         string text    = string.Empty;
         if ((logOptions & LogOptions.LogExceptionFull) == LogOptions.LogExceptionFull)
         {
             text = exception.ToString();
         }
         logger.Log((isPeriodic && periodicDuration != null) ? (periodicKey + "Exception") : null, periodicDuration, DxEventSeverity.Error, 0, "{0}: Operation {1} ({2}) failed. (Category: {3}, Message: {4}, Full: {5})", new object[]
         {
             identity,
             label,
             context ?? string.Empty,
             name,
             message,
             text
         });
     }
 }
Example #10
0
        public static Exception RunOperation(string identity, string label, Action action, IDxStoreEventLogger logger, LogOptions options, bool isBestEffort = false, TimeSpan?timeout = null, TimeSpan?periodicDuration = null, string periodicKey = null, Action <Exception> exitAction = null, string context = null)
        {
            bool flag       = false;
            bool flag2      = false;
            bool flag3      = false;
            bool isPeriodic = false;

            if ((options & LogOptions.LogNever) != LogOptions.LogNever)
            {
                flag  = ((options & LogOptions.LogStart) == LogOptions.LogStart);
                flag2 = ((options & LogOptions.LogException) == LogOptions.LogException);
                flag3 = ((options & LogOptions.LogSuccess) == LogOptions.LogSuccess);
                if ((options & LogOptions.LogAlways) == LogOptions.LogAlways)
                {
                    isPeriodic = ((options & LogOptions.LogPeriodic) == LogOptions.LogPeriodic);
                }
            }
            periodicKey = (periodicKey ?? string.Format("{0}-{1}", identity, label));
            Exception ex = null;

            try
            {
                ExTraceGlobals.RunOperationTracer.TraceDebug <string, string>((long)identity.GetHashCode(), "{0}: Attempting to run {1}", identity, label);
                if (flag)
                {
                    Utils.LogStartingEvent(identity, label, logger, isPeriodic, periodicKey, periodicDuration, context);
                }
                if (timeout != null)
                {
                    Task task = Task.Factory.StartNew(action);
                    if (!task.Wait(timeout.Value))
                    {
                        ExTraceGlobals.RunOperationTracer.TraceError <string, string, TimeSpan?>((long)identity.GetHashCode(), "{0}: Operation {1} timed out after {2}", identity, label, timeout);
                        throw new TimeoutException();
                    }
                }
                else
                {
                    action();
                }
            }
            catch (Exception ex2)
            {
                ex = ex2;
                ExTraceGlobals.RunOperationTracer.TraceError <string, string, Exception>((long)identity.GetHashCode(), "{0}: Operation {1} failed with {2}", identity, label, ex2);
                if (flag2)
                {
                    Utils.LogErrorEvent(identity, label, ex, options, logger, isPeriodic, periodicKey, periodicDuration, context);
                }
                if (!isBestEffort)
                {
                    throw;
                }
            }
            finally
            {
                if (ex == null)
                {
                    ExTraceGlobals.RunOperationTracer.TraceDebug <string, string>((long)identity.GetHashCode(), "{0}: Operation {1} successful", identity, label);
                    if (flag3)
                    {
                        Utils.LogFinishedEvent(identity, label, logger, isPeriodic, periodicKey, periodicDuration, context);
                    }
                }
                if (exitAction != null)
                {
                    exitAction(ex);
                }
            }
            return(ex);
        }
Example #11
0
 public void Initialize(string componentName, string self = null, string baseComponentKeyName = null, IDxStoreEventLogger eventLogger = null, bool isZeroboxMode = false)
 {
     this.componentName = componentName;
     this.Self          = ((!string.IsNullOrEmpty(self)) ? self : Environment.MachineName);
     this.isZeroboxMode = isZeroboxMode;
     if (string.IsNullOrEmpty(this.DefaultStorageBaseDir))
     {
         this.DefaultStorageBaseDir = Utils.CombinePathNullSafe(isZeroboxMode ? "C:\\Exchange" : ExchangeSetupContext.InstallPath, string.Format("DxStore\\Database\\{0}", this.componentName));
         if (isZeroboxMode)
         {
             this.DefaultStorageBaseDir = this.DefaultStorageBaseDir + "\\ZeroBox\\" + this.Self;
         }
     }
     if (string.IsNullOrEmpty(baseComponentKeyName))
     {
         baseComponentKeyName = string.Format("SOFTWARE\\Microsoft\\ExchangeServer\\{0}\\DxStore\\{1}", "v15", this.componentName);
         if (isZeroboxMode)
         {
             baseComponentKeyName = baseComponentKeyName + "\\Zerobox\\" + this.Self;
         }
     }
     this.eventLogger          = eventLogger;
     this.ManagerConfigKeyName = baseComponentKeyName;
     this.ManagerConfig        = this.GetManagerConfig();
 }
 public void Initialize(string self, InstanceClientFactory instanceClientFactory, InstanceGroupConfig groupConfig, IDxStoreEventLogger eventLogger, double requiredSuccessPercent)
 {
     this.EventLogger            = eventLogger;
     this.self                   = self;
     this.instanceClientFactory  = instanceClientFactory;
     this.GroupStatusInfo        = new GroupStatusInfo();
     this.groupConfig            = groupConfig;
     this.completionEvent        = new ManualResetEvent(false);
     this.requiredSuccessPercent = requiredSuccessPercent;
 }
 public GroupStatusCollector(string self, InstanceClientFactory instanceClientFactory, InstanceGroupConfig groupConfig, IDxStoreEventLogger eventLogger, double requiredSuccessPercent)
 {
     this.Initialize(self, instanceClientFactory, groupConfig, eventLogger, requiredSuccessPercent);
 }
Example #14
0
 public DxStoreManager(IDxStoreConfigProvider configProvider, IDxStoreEventLogger eventLogger)
 {
     this.EventLogger    = eventLogger;
     this.ConfigProvider = configProvider;
     this.instanceMap    = new Dictionary <string, Tuple <InstanceGroupConfig, DxStoreInstanceChecker> >();
 }