public ClusterMarkFile( FileInfo file, ClusterComponentType type, int errorBufferLength, IEpochClock epochClock, long timeoutMs) { var markFileExists = file.Exists; markFile = new MarkFile( file, markFileExists, MarkFileHeaderDecoder.VersionEncodingOffset(), MarkFileHeaderDecoder.ActivityTimestampEncodingOffset(), HEADER_LENGTH + errorBufferLength, timeoutMs, epochClock, (version) => { if (version != MarkFileHeaderDecoder.SCHEMA_VERSION) { throw new ClusterException("mark file version " + version + " does not match software:" + MarkFileHeaderDecoder.SCHEMA_VERSION); } }, null); buffer = markFile.Buffer(); errorBuffer = new UnsafeBuffer(buffer, HEADER_LENGTH, errorBufferLength); headerEncoder.Wrap(buffer, 0); headerDecoder.Wrap(buffer, 0, MarkFileHeaderDecoder.BLOCK_LENGTH, MarkFileHeaderDecoder.SCHEMA_VERSION); if (markFileExists) { var existingErrorBuffer = new UnsafeBuffer( buffer, headerDecoder.HeaderLength(), headerDecoder.ErrorBufferLength()); SaveExistingErrors(file, existingErrorBuffer, Console.Error); errorBuffer.SetMemory(0, errorBufferLength, 0); } else { headerEncoder.CandidateTermId(Aeron.Aeron.NULL_VALUE); } var existingType = headerDecoder.ComponentType(); if (existingType != ClusterComponentType.NULL && existingType != type) { throw new InvalidOperationException("existing Mark file type " + existingType + " not same as required type " + type); } headerEncoder.ComponentType(type); headerEncoder.HeaderLength(HEADER_LENGTH); headerEncoder.ErrorBufferLength(errorBufferLength); headerEncoder.Pid(Process.GetCurrentProcess().Id); headerEncoder.StartTimestamp(epochClock.Time()); }
public ClusterMarkFile(FileInfo file, ClusterComponentType type, int totalFileLength, IEpochClock epochClock, long timeoutMs) { markFile = new MarkFile(file, file.Exists, MarkFileHeaderDecoder.VersionEncodingOffset(), MarkFileHeaderDecoder.ActivityTimestampEncodingOffset(), totalFileLength, timeoutMs, epochClock, (version) => { if (version != MarkFileHeaderDecoder.SCHEMA_VERSION) { throw new ArgumentException("Mark file version " + version + " does not match software:" + MarkFileHeaderDecoder.SCHEMA_VERSION); } }, null); buffer = markFile.Buffer(); headerEncoder.Wrap(buffer, 0); headerDecoder.Wrap(buffer, 0, MarkFileHeaderDecoder.BLOCK_LENGTH, MarkFileHeaderDecoder.SCHEMA_VERSION); var existingType = headerDecoder.ComponentType(); if (existingType != ClusterComponentType.NULL && existingType != type) { throw new InvalidOperationException("existing Mark file type " + existingType + " not same as required type " + type); } headerEncoder.ComponentType(type); headerEncoder.Pid(Process.GetCurrentProcess().Id); }
public ClusterMarkFile(DirectoryInfo directory, string filename, IEpochClock epochClock, long timeoutMs, Action <string> logger) { markFile = new MarkFile(directory, filename, MarkFileHeaderDecoder.VersionEncodingOffset(), MarkFileHeaderDecoder.ActivityTimestampEncodingOffset(), timeoutMs, epochClock, (version) => { if (version != MarkFileHeaderDecoder.SCHEMA_VERSION) { throw new ArgumentException("Mark file version " + version + " does not match software:" + MarkFileHeaderDecoder.SCHEMA_VERSION); } }, logger); buffer = markFile.Buffer(); headerDecoder.Wrap(buffer, 0, MarkFileHeaderDecoder.BLOCK_LENGTH, MarkFileHeaderDecoder.SCHEMA_VERSION); }
public ClusterMarkFile(DirectoryInfo directory, string filename, IEpochClock epochClock, long timeoutMs, Action <string> logger) { markFile = new MarkFile( directory, filename, MarkFileHeaderDecoder.VersionEncodingOffset(), MarkFileHeaderDecoder.ActivityTimestampEncodingOffset(), timeoutMs, epochClock, (version) => { if (SemanticVersion.Major(version) != AeronCluster.Configuration.MAJOR_VERSION) { throw new ArgumentException("mark file major version " + SemanticVersion.Major(version) + " does not match software:" + AeronCluster.Configuration.MAJOR_VERSION); } }, logger); buffer = markFile.Buffer(); headerDecoder.Wrap(buffer, 0, MarkFileHeaderDecoder.BLOCK_LENGTH, MarkFileHeaderDecoder.SCHEMA_VERSION); errorBuffer = new UnsafeBuffer(buffer, headerDecoder.HeaderLength(), headerDecoder.ErrorBufferLength()); }
public ClusterMarkFile( FileInfo file, ClusterComponentType type, int errorBufferLength, IEpochClock epochClock, long timeoutMs) { var markFileExists = file.Exists; markFile = new MarkFile( file, markFileExists, MarkFileHeaderDecoder.VersionEncodingOffset(), MarkFileHeaderDecoder.ActivityTimestampEncodingOffset(), HEADER_LENGTH + errorBufferLength, timeoutMs, epochClock, (version) => { if (VERSION_FAILED == version && markFileExists) { Console.WriteLine("mark file version -1 indicates error on previous startup."); } else if (SemanticVersion.Major(version) != AeronCluster.Configuration.MAJOR_VERSION) { throw new ArgumentException("mark file major version " + SemanticVersion.Major(version) + " does not match software:" + AeronCluster.Configuration.MAJOR_VERSION); } }, null); buffer = markFile.Buffer(); errorBuffer = new UnsafeBuffer(buffer, HEADER_LENGTH, errorBufferLength); headerEncoder.Wrap(buffer, 0); headerDecoder.Wrap(buffer, 0, MarkFileHeaderDecoder.BLOCK_LENGTH, MarkFileHeaderDecoder.SCHEMA_VERSION); if (markFileExists) { var existingErrorBuffer = new UnsafeBuffer( buffer, headerDecoder.HeaderLength(), headerDecoder.ErrorBufferLength()); SaveExistingErrors(file, existingErrorBuffer, Console.Error); errorBuffer.SetMemory(0, errorBufferLength, 0); } else { headerEncoder.CandidateTermId(Aeron.Aeron.NULL_VALUE); } var existingType = headerDecoder.ComponentType(); if (existingType != ClusterComponentType.NULL && existingType != type) { if (existingType != ClusterComponentType.BACKUP || ClusterComponentType.CONSENSUS_MODULE != type) { throw new InvalidOperationException( "existing Mark file type " + existingType + " not same as required type " + type); } } headerEncoder.ComponentType(type); headerEncoder.HeaderLength(HEADER_LENGTH); headerEncoder.ErrorBufferLength(errorBufferLength); headerEncoder.Pid(Process.GetCurrentProcess().Id); headerEncoder.StartTimestamp(epochClock.Time()); }