public override void Start(ServiceElement options) { if (options == null) { throw new ArgumentNullException("options"); } this.baseDir = options.BaseDir; this.maxStorageSizeMB = options.Uhurufs.MaxStorageSize; this.useVhd = options.Uhurufs.UseVHD; this.vhdFixedSize = options.Uhurufs.VHDFixedSize; this.useFsrm = options.Uhurufs.UseFsrm; if (this.useFsrm) { this.dirAccounting = new DirectoryAccounting(); } else { this.dirAccounting = null; } ProvisionedService.Initialize(options.LocalDB); HashSet<string> sharesCache = new HashSet<string>(WindowsShare.GetShares()); foreach (ProvisionedService instance in ProvisionedService.GetInstances()) { this.capacity -= this.CapacityUnit(); // This check will make initialization faster. if (!sharesCache.Contains(instance.Name)) { // This will setup the instance with new config changes or if the OS is fresh. // Don't want to fail if an instance is inconsistent or has errors. try { this.InstanceSystemSetup(instance); foreach (ServiceBinding binding in instance.Bindings) { try { Bind(instance, binding); } catch (Exception ex) { Logger.Error("Error binding instance {0} with {1}. Exception: {2}", instance.Name, binding.User, ex.ToString()); } } } catch (Exception ex) { Logger.Error("Error setting up instance {0}. Exception: {1}", instance.Name, ex.ToString()); } } } TimerHelper.RecurringCall( StorageQuotaInterval, delegate { this.EnforceStorageQuota(); }); // initialize qps counter this.provisionServed = 0; this.bindingServed = 0; base.Start(options); }
/// <summary> /// Starts the service using the specified options. /// </summary> /// <param name="options">The configuration options.</param> public virtual void Start(ServiceElement options) { if (options == null) { throw new ArgumentNullException("options"); } this.localIP = NetworkInterface.GetLocalIPAddress(options.LocalRoute); Logger.Info(Strings.InitializingLogMessage, this.ServiceDescription()); this.nodeNats = ReactorFactory.GetReactor(typeof(Reactor)); this.nodeNats.OnError += new EventHandler<ReactorErrorEventArgs>(this.NatsErrorHandler); this.nodeNats.Start(new Uri(options.MBus)); this.OnConnectNode(); this.vcapComponent = new VCAPComponent(); this.vcapComponent.Register( new Dictionary<string, object> { { "nats", this.nodeNats }, { "type", this.ServiceDescription() }, { "host", this.localIP }, { "index", options.Index }, { "config", options }, { "statusPort", options.StatusPort } }); int zInterval = options.ZInterval; TimerHelper.RecurringCall( zInterval, delegate { this.UpdateVarz(); }); // give service a chance to wake up TimerHelper.DelayedCall( 5 * 1000, delegate { this.UpdateVarz(); }); }
/// <summary> /// Starts the node. /// </summary> /// <param name="options">The configuration options for the node.</param> public override void Start(ServiceElement options) { if (options == null) { throw new ArgumentNullException("options"); } this.nodeId = options.NodeId; this.plan = options.Plan; this.migrationNfs = options.MigrationNFS; this.maxCapacity = options.Capacity; this.capacity += options.Capacity; this.fqdnHosts = options.FqdnHosts; this.operationTimeLimit = options.OperationTimeLimit; this.defaultVersion = options.SupportedVersions.DefaultVersion; this.supportedVersions = new Collection<string>(); foreach (SupportedVersionElement version in options.SupportedVersions) { this.supportedVersions.Add(version.Name); } base.Start(options); }
/// <summary> /// Starts the node. /// </summary> /// <param name="options">The configuration options for the node.</param> public override void Start(ServiceElement options) { if (options == null) { throw new ArgumentNullException("options"); } this.mssqlConfig.Host = options.MSSql.Host; this.mssqlConfig.User = options.MSSql.User; this.mssqlConfig.Port = options.MSSql.Port; this.mssqlConfig.Password = options.MSSql.Password; this.mssqlConfig.LogicalStorageUnits = options.MSSql.LogicalStorageUnits; this.mssqlConfig.InitialDataSize = options.MSSql.InitialDataSize; this.mssqlConfig.InitialLogSize = options.MSSql.InitialLogSize; this.mssqlConfig.MaxDataSize = options.MSSql.MaxDataSize; this.mssqlConfig.MaxLogSize = options.MSSql.MaxLogSize; this.mssqlConfig.DataFileGrowth = options.MSSql.DataFileGrowth; this.mssqlConfig.LogFileGrowth = options.MSSql.LogFileGrowth; this.maxDbSize = options.MSSql.MaxDBSize * 1024 * 1024; this.maxLongQuery = options.MSSql.MaxLengthyQuery; this.maxLongTx = options.MSSql.MaxLengthTX; this.maxUserConnections = options.MSSql.MaxUserConnections; this.connection = this.ConnectMSSql(); TimerHelper.RecurringCall( KeepAliveInterval, delegate { this.KeepAliveMSSql(); }); if (this.maxLongQuery > 0) { TimerHelper.RecurringCall( this.maxLongQuery / 2, delegate { this.KillLongTransactions(); }); } if (this.maxLongTx > 0) { TimerHelper.RecurringCall( this.maxLongTx / 2, delegate { this.KillLongQueries(); }); } else { Logger.Info(Strings.LongTXKillerDisabledInfoMessage); } TimerHelper.RecurringCall( StorageQuotaInterval, delegate { this.EnforceStorageQuota(); }); this.baseDir = options.BaseDir; if (!string.IsNullOrEmpty(this.baseDir)) { Directory.CreateDirectory(this.baseDir); } ProvisionedService.Initialize(options.LocalDB); this.CheckDBConsistency(); this.capacity = -this.CapacityUnit() * ProvisionedService.GetInstances().Count(); this.queriesServed = 0; this.qpsLastUpdated = DateTime.Now; // initialize qps counter this.GetQPS(); this.longQueriesKilled = 0; this.longTxKilled = 0; this.provisionServed = 0; this.bindingServed = 0; base.Start(options); }