internal static void Assert(bool condition, string format, ReplicationMetadata param1, Metadata param2) { if (condition == false) { var failFastMessage = string.Format(System.Globalization.CultureInfo.InvariantCulture, format, param1, param2); FailFast(failFastMessage); // AMW - Force break into debugger for ease of debugging Debugger.Break(); } }
public static void SerializeRedoData( ReplicationMetadata replicationMetadata, string traceType, InMemoryBinaryWriter writer) { try { writer.Write(replicationMetadata.Type); writer.WriteNullable(replicationMetadata.InitializationContext); writer.Write(replicationMetadata.ParentStateProviderId); } catch (Exception e) { StateManagerStructuredEvents.TraceException(traceType, "ReplicationMetadata.Serialize", string.Empty, e); throw; } }
/// <summary> /// Serializes replication metadata. /// </summary> public static void SerializeMetaData( ReplicationMetadata replicationMetadata, string traceType, InMemoryBinaryWriter writer) { try { writer.Write(replicationMetadata.Version); writer.Write(replicationMetadata.StateProviderId); writer.Write(replicationMetadata.Name); writer.Write((byte)replicationMetadata.StateManagerApplyType); } catch (Exception e) { StateManagerStructuredEvents.TraceException(traceType, "ReplicationMetadata.Serialize", string.Empty, e); throw; } }
/// <summary> /// Deserializes replication metadata and the redodata. /// </summary> public static ReplicationMetadata Deserialize( InMemoryBinaryReader metaDataReader, InMemoryBinaryReader redoDataReader, string traceType, int currentVersion) { try { // Read meta data first long stateProviderId; Uri name; StateManagerApplyType operationType; int version; DeserializeMetadata( metaDataReader, traceType, currentVersion, out stateProviderId, out name, out operationType, out version); if (redoDataReader == null) { return(new ReplicationMetadata( name, stateProviderId, DynamicStateManager.StateManagerId, version, operationType)); } // Read Data Next string typeName; Type type = redoDataReader.ReadType(out typeName); Utility.Assert(type != null, SR.Assert_SM_TypeNotFound, traceType, typeName, name.ToString()); byte[] initializationParameters = redoDataReader.ReadNullableBytes(); long parentStateProviderId = redoDataReader.ReadInt64(); // Since this is used in redo only scenarios, it is safe to assuem apply type is same as the original opeartion type. ReplicationMetadata replicationMetadata = new ReplicationMetadata( name, type, initializationParameters, stateProviderId, parentStateProviderId, version, operationType); return(replicationMetadata); } catch (Exception e) { StateManagerStructuredEvents.TraceException( traceType, "ReplicationMetadata.Deserialize", string.Empty, e); throw; } }