internal virtual Task InitializeAsync(ITracer tracer, LogManagerInitialization init, TransactionalReplicatorSettings settings) { this.Tracer = tracer; this.LogFileDirectoryPath = init.dedicatedLogPath; this.MaxWriteCacheSizeInMB = DefaultWriteCacheSizeMb; this.emptyCallbackManager = new PhysicalLogWriterCallbackManager(this.EmptyFlushedRecordsCallback, tracer); return(Task.FromResult(0)); }
internal override async Task InitializeAsync(ITracer tracer, LogManagerInitialization init, TransactionalReplicatorSettings settings) { this.maxStreamSize = settings.PublicSettings.CheckpointThresholdInMB.Value * LogTruncationManager.ThrottleAfterPendingCheckpointCount; await base.InitializeAsync(tracer, init, settings).ConfigureAwait(false); }
internal override async Task InitializeAsync(ITracer inputTracer, LogManagerInitialization init, TransactionalReplicatorSettings settings) { // // Determine if we are in a container and if so then get the host namespace for the application // // When running in a container, the container will have a different file system namespace as the // host. The filenames are generated from within the container, however the KTLLogger driver will // create them while running in the host namespace. In order for the files to be created in the // correct location, the filename needs to be mapped from the container namespace to the host // namespace. This mapping is done here. // // Fabric provides the mapping into the host namespace in the environment variable named // "Fabric_HostApplicationDirectory" // string FabricHostApplicationDirectory; try { FabricHostApplicationDirectory = Environment.GetEnvironmentVariable(Constants.Fabric_HostApplicationDirectory); } catch (Exception) { FabricHostApplicationDirectory = null; } string containerDedicatedLogPath = null; if (FabricHostApplicationDirectory != null) { var message = string.Format(CultureInfo.InvariantCulture, "Mapped dedicated log path for container: From: {0} To: {1}", init.dedicatedLogPath, FabricHostApplicationDirectory); FabricEvents.Events.LogManager(inputTracer.Type, message); containerDedicatedLogPath = FabricHostApplicationDirectory; } // // Make a whole bunch of decisions about which type of log manager and logs to use. At the end // this.useStagingLog and the correct path for dedicatedLogPath will be setup for this replica. // string sharedLogPath = settings.PublicSettings.SharedLogPath; Guid sharedLogId = Guid.Parse(settings.PublicSettings.SharedLogId); bool isDefaultSettings = (settings.PublicSettings.SharedLogId == Constants.DefaultSharedLogContainerGuid); bool isInContainer = (containerDedicatedLogPath != null); if (this.physicalLogManager == null) { this.physicalLogManager = await System.Fabric.Data.Log.LogManager.OpenAsync(globalLogManagerType, CancellationToken.None).ConfigureAwait(false); } System.Fabric.Data.Log.LogManager.LoggerType logManagerType = this.physicalLogManager.GetLoggerType(); if (isDefaultSettings) { if (logManagerType == System.Fabric.Data.Log.LogManager.LoggerType.Inproc) { // // When running inproc, we must use the staging log // Format: <workDir>/<partitionId>_<replicaId>.stlog // this.useStagingLog = true; sharedLogId = Guid.NewGuid(); sharedLogPath = Path.Combine(init.workDirectory, init.partitionId.ToString() + "_" + init.replicaId.ToString() + ".stlog"); } else if (logManagerType == System.Fabric.Data.Log.LogManager.LoggerType.Driver) { // // When running with the driver then we do not use staging log // this.useStagingLog = false; if (isInContainer) { // // If running with the driver then the dedicated log path needs to be mapped // into the host namespace. // init.dedicatedLogPath = containerDedicatedLogPath; } } else { // // Only Inproc and Driver are supported, bail out // FabricEvents.Events.LogManager( inputTracer.Type, "KtlLogManager.InitializeAsync: Unknown LogManagerType " + (int)logManagerType + " " + logManagerType.ToString()); throw new InvalidOperationException(); } } else { // // If we are not using default shared log settings then the application must know what they are doing // and so just go with what they want and hope for the best. // this.useStagingLog = false; if (isInContainer) { FabricEvents.Events.LogManager( inputTracer.Type, "KtlLogManager.InitializeAsync: Default shared log is not be used within a container." + " LogManagerType: " + logManagerType.ToString() + " Shared Log: " + settings.PublicSettings.SharedLogPath + " " + settings.PublicSettings.SharedLogId.ToString()); } } FabricEvents.Events.LogManager( inputTracer.Type, "KtlLogManager.InitializeAsync: " + " globalLogManagerType: " + globalLogManagerType.ToString() + " LogManagerType: " + logManagerType.ToString() + " isDefaultSettings: " + isDefaultSettings.ToString() + " isInContainer: " + isInContainer.ToString() + " partitionId: " + init.partitionId.ToString() + " replicaId: " + init.replicaId.ToString() + " Shared Log: " + sharedLogPath + " " + sharedLogId.ToString()); await base.InitializeAsync(inputTracer, init, settings).ConfigureAwait(false); this.physicalLogName = sharedLogPath; this.physicalLogId = sharedLogId; this.maximumMetadataSizeInKB = (int)settings.PublicSettings.MaxMetadataSizeInKB; this.maximumRecordSizeInKb = settings.PublicSettings.MaxRecordSizeInKB.Value; this.maximumStreamSizeInMb = (int)settings.PublicSettings.MaxStreamSizeInMB; this.optimizeForLocalSsd = settings.PublicSettings.OptimizeForLocalSSD.Value; this.optimizeForLowerDiskUsage = settings.PublicSettings.OptimizeLogForLowerDiskUsage.Value; this.maxWriteQueueDepthInKb = (int)settings.PublicSettings.MaxWriteQueueDepthInKB; await this.EnsureSharedLogContainerAsync(this.physicalLogName, this.physicalLogId).ConfigureAwait(false); }
internal override async Task InitializeAsync(ITracer paramTracer, LogManagerInitialization init, TransactionalReplicatorSettings settings) { await base.InitializeAsync(paramTracer, init, settings).ConfigureAwait(false); }