Skip to content

Commit

Permalink
https://github.com/affandar/durabletask/issues/11
Browse files Browse the repository at this point in the history
  • Loading branch information
affandar committed Apr 9, 2015
1 parent 5826ec6 commit 1d9cecf
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Framework/FrameworkConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,8 @@ internal class FrameworkConstants
public const string CompressionTypePropertyName = "CompressionType";
public const string CompressionTypeGzipPropertyValue = "gzip";
public const string CompressionTypeNonePropertyValue = "none";

// instance store constants
public const int MaxStringLengthForAzureTableColumn = 1024 * 15; // cut off at 15k * 2 bytes
}
}
4 changes: 2 additions & 2 deletions Framework/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("1d626d8b-330b-4c6a-b689-c0fefbeb99cd")]
[assembly: AssemblyVersion("1.0.0.3")]
[assembly: AssemblyFileVersion("1.0.0.3")]
[assembly: AssemblyVersion("1.0.0.4")]
[assembly: AssemblyFileVersion("1.0.0.4")]
[assembly: InternalsVisibleTo("FrameworkUnitTests")]
6 changes: 2 additions & 4 deletions Framework/Tracking/OrchestrationHistoryEventEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ namespace DurableTask.Tracking

public class OrchestrationHistoryEventEntity : CompositeTableEntity
{
const int MaxStringLengthForAzureTableColumn = 1024*15; // cut off at 15k * 2 bytes

public OrchestrationHistoryEventEntity()
{
}
Expand Down Expand Up @@ -75,10 +73,10 @@ public override IDictionary<string, EntityProperty> WriteEntity(OperationContext
// note that this makes the history stored in the instance store unreplayable. so any replay logic
// that we build will have to especially check for this event and flag the orchestration as unplayable if it sees this event
if (!string.IsNullOrEmpty(serializedHistoryEvent) &&
serializedHistoryEvent.Length > MaxStringLengthForAzureTableColumn)
serializedHistoryEvent.Length > FrameworkConstants.MaxStringLengthForAzureTableColumn)
{
serializedHistoryEvent = JsonConvert.SerializeObject(new GenericEvent(HistoryEvent.EventId,
serializedHistoryEvent.Substring(0, MaxStringLengthForAzureTableColumn) + " ....(truncated)..]"),
serializedHistoryEvent.Substring(0, FrameworkConstants.MaxStringLengthForAzureTableColumn) + " ....(truncated)..]"),
new JsonSerializerSettings
{
Formatting = Formatting.Indented,
Expand Down
6 changes: 4 additions & 2 deletions Framework/Tracking/OrchestrationStateEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ namespace DurableTask.Tracking
{
using System;
using System.Collections.Generic;
using DurableTask.History;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using Newtonsoft.Json;

public class OrchestrationStateEntity : CompositeTableEntity
{
Expand Down Expand Up @@ -72,8 +74,8 @@ public override IDictionary<string, EntityProperty> WriteEntity(OperationContext
retVals.Add("LastUpdatedTime", new EntityProperty(State.LastUpdatedTime));
retVals.Add("Size", new EntityProperty(State.Size));
retVals.Add("CompressedSize", new EntityProperty(State.CompressedSize));
retVals.Add("Input", new EntityProperty(State.Input));
retVals.Add("Output", new EntityProperty(State.Output));
retVals.Add("Input", new EntityProperty(State.Input.Truncate(FrameworkConstants.MaxStringLengthForAzureTableColumn)));
retVals.Add("Output", new EntityProperty(State.Output.Truncate(FrameworkConstants.MaxStringLengthForAzureTableColumn)));

return retVals;
}
Expand Down
9 changes: 9 additions & 0 deletions Framework/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ internal static class Utils

static readonly byte[] GzipHeader = {0x1f, 0x8b};

public static string Truncate(this string input, int maxLength)
{
if (!string.IsNullOrEmpty(input) && input.Length > maxLength)
{
return input.Substring(0, maxLength);
}
return input;
}

public static BrokeredMessage GetBrokeredMessageFromObject(object serializableObject,
CompressionSettings compressionSettings)
{
Expand Down

0 comments on commit 1d9cecf

Please sign in to comment.