Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ CREATE OR REPLACE FUNCTION writetostorage(
_grainidextensionstring character varying,
_serviceid character varying,
_grainstateversion integer,
_payloadbinary bytea,
_payloadjson text,
_payloadxml xml)
_payloadbinary bytea)
RETURNS TABLE(newgrainstateversion integer)
LANGUAGE 'plpgsql'
AS $function$
Expand Down Expand Up @@ -53,8 +51,6 @@ AS $function$
UPDATE OrleansStorage
SET
PayloadBinary = _PayloadBinary,
PayloadJson = _PayloadJson,
PayloadXml = _PayloadXml,
ModifiedOn = (now() at time zone 'utc'),
Version = Version + 1

Expand Down Expand Up @@ -89,8 +85,6 @@ AS $function$
GrainIdExtensionString,
ServiceId,
PayloadBinary,
PayloadJson,
PayloadXml,
ModifiedOn,
Version
)
Expand All @@ -103,8 +97,6 @@ AS $function$
_GrainIdExtensionString,
_ServiceId,
_PayloadBinary,
_PayloadJson,
_PayloadXml,
now(),
1
WHERE NOT EXISTS
Expand Down
26 changes: 3 additions & 23 deletions src/AdoNet/Orleans.Persistence.AdoNet/MySQL-Persistence.sql
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,8 @@ CREATE TABLE OrleansStorage
GrainIdExtensionString NVARCHAR(512) NULL,
ServiceId NVARCHAR(150) NOT NULL,

-- The usage of the Payload records is exclusive in that
-- only one should be populated at any given time and two others
-- are NULL. The types are separated to advantage on special
-- processing capabilities present on database engines (not all might
-- have both JSON and XML types.
--
-- One is free to alter the size of these fields.
-- Payload
PayloadBinary BLOB NULL,
PayloadXml LONGTEXT NULL,
PayloadJson LONGTEXT NULL,

-- Informational field, no other use.
ModifiedOn DATETIME NOT NULL,
Expand Down Expand Up @@ -117,8 +109,6 @@ BEGIN
UPDATE OrleansStorage
SET
PayloadBinary = NULL,
PayloadJson = NULL,
PayloadXml = NULL,
Version = Version + 1
WHERE
GrainIdHash = _GrainIdHash AND _GrainIdHash IS NOT NULL
Expand Down Expand Up @@ -151,9 +141,7 @@ CREATE PROCEDURE WriteToStorage
in _GrainIdExtensionString NVARCHAR(512),
in _ServiceId NVARCHAR(150),
in _GrainStateVersion INT,
in _PayloadBinary BLOB,
in _PayloadJson LONGTEXT,
in _PayloadXml LONGTEXT
in _PayloadBinary BLOB
)
BEGIN
DECLARE _newGrainStateVersion INT;
Expand Down Expand Up @@ -190,8 +178,6 @@ BEGIN
UPDATE OrleansStorage
SET
PayloadBinary = _PayloadBinary,
PayloadJson = _PayloadJson,
PayloadXml = _PayloadXml,
ModifiedOn = UTC_TIMESTAMP(),
Version = Version + 1
WHERE
Expand Down Expand Up @@ -226,8 +212,6 @@ BEGIN
GrainIdExtensionString,
ServiceId,
PayloadBinary,
PayloadJson,
PayloadXml,
ModifiedOn,
Version
)
Expand All @@ -240,8 +224,6 @@ BEGIN
_GrainIdExtensionString,
_ServiceId,
_PayloadBinary,
_PayloadJson,
_PayloadXml,
UTC_TIMESTAMP(),
1) AS TMP
WHERE NOT EXISTS
Expand Down Expand Up @@ -277,8 +259,6 @@ VALUES
'ReadFromStorageKey',
'SELECT
PayloadBinary,
PayloadXml,
PayloadJson,
UTC_TIMESTAMP(),
Version
FROM
Expand All @@ -298,7 +278,7 @@ INSERT INTO OrleansQuery(QueryKey, QueryText)
VALUES
(
'WriteToStorageKey','
call WriteToStorage(@GrainIdHash, @GrainIdN0, @GrainIdN1, @GrainTypeHash, @GrainTypeString, @GrainIdExtensionString, @ServiceId, @GrainStateVersion, @PayloadBinary, @PayloadJson, @PayloadXml);'
call WriteToStorage(@GrainIdHash, @GrainIdN0, @GrainIdN1, @GrainTypeHash, @GrainTypeString, @GrainIdExtensionString, @ServiceId, @GrainStateVersion, @PayloadBinary);'
);

INSERT INTO OrleansQuery(QueryKey, QueryText)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Orleans.Configuration
/// <summary>
/// Options for AdonetGrainStorage
/// </summary>
public class AdoNetGrainStorageOptions
public class AdoNetGrainStorageOptions : IStorageProviderSerializerOptions
{
/// <summary>
/// Connection string for AdoNet storage.
Expand All @@ -35,22 +35,8 @@ public class AdoNetGrainStorageOptions
/// </summary>
public string Invariant { get; set; } = DEFAULT_ADONET_INVARIANT;

/// <summary>
/// Whether storage string payload should be formatted in JSON.
/// <remarks>If neither <see cref="UseJsonFormat"/> nor <see cref="UseXmlFormat"/> is set to true, then BinaryFormatSerializer will be configured to format storage string payload.</remarks>
/// </summary>
public bool UseJsonFormat { get; set; }
public bool UseFullAssemblyNames { get; set; }
public bool IndentJson { get; set; }
public TypeNameHandling? TypeNameHandling { get; set; }

public Action<JsonSerializerSettings> ConfigureJsonSerializerSettings { get; set; }

/// <summary>
/// Whether storage string payload should be formatted in Xml.
/// <remarks>If neither <see cref="UseJsonFormat"/> nor <see cref="UseXmlFormat"/> is set to true, then BinaryFormatSerializer will be configured to format storage string payload.</remarks>
/// </summary>
public bool UseXmlFormat { get; set; }
/// <inheritdoc/>
public IGrainStorageSerializer GrainStorageSerializer { get; set; }
}

/// <summary>
Expand Down Expand Up @@ -84,11 +70,6 @@ public void ValidateConfiguration()
{
throw new OrleansConfigurationException($"Invalid {nameof(AdoNetGrainStorageOptions)} values for {nameof(AdoNetGrainStorage)} \"{name}\". {nameof(options.ConnectionString)} is required.");
}

if (options.UseXmlFormat&&options.UseJsonFormat)
{
throw new OrleansConfigurationException($"Invalid {nameof(AdoNetGrainStorageOptions)} values for {nameof(AdoNetGrainStorage)} \"{name}\". {nameof(options.UseXmlFormat)} and {nameof(options.UseJsonFormat)} cannot both be set to true");
}
}
}
}
29 changes: 6 additions & 23 deletions src/AdoNet/Orleans.Persistence.AdoNet/Oracle-Persistence.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,9 @@ CREATE TABLE "ORLEANSSTORAGE"
"GRAINIDEXTENSIONSTRING" NVARCHAR2(512),
"SERVICEID" NVARCHAR2(150) NOT NULL ENABLE,


-- The usage of the Payload records is exclusive in that
-- only one should be populated at any given time and two others
-- are NULL. The types are separated to advantage on special
-- processing capabilities present on database engines (not all might
-- have both JSON and XML types.
--
-- One is free to alter the size of these fields.
-- Payload
"PAYLOADBINARY" BLOB,
"PAYLOADXML" CLOB,
"PAYLOADJSON" CLOB,

-- Informational field, no other use.
"MODIFIEDON" TIMESTAMP (6) NOT NULL ENABLE,
-- The version of the stored payload.
Expand All @@ -89,8 +81,7 @@ COMPRESS;
/

CREATE OR REPLACE FUNCTION WriteToStorage(PARAM_GRAINIDHASH IN NUMBER, PARAM_GRAINIDN0 IN NUMBER, PARAM_GRAINIDN1 IN NUMBER, PARAM_GRAINTYPEHASH IN NUMBER, PARAM_GRAINTYPESTRING IN NVARCHAR2,
PARAM_GRAINIDEXTENSIONSTRING IN NVARCHAR2, PARAM_SERVICEID IN VARCHAR2, PARAM_GRAINSTATEVERSION IN NUMBER, PARAM_PAYLOADBINARY IN BLOB,
PARAM_PAYLOADJSON IN CLOB, PARAM_PAYLOADXML IN CLOB)
PARAM_GRAINIDEXTENSIONSTRING IN NVARCHAR2, PARAM_SERVICEID IN VARCHAR2, PARAM_GRAINSTATEVERSION IN NUMBER, PARAM_PAYLOADBINARY IN BLOB)
RETURN NUMBER IS
rowcount NUMBER;
newGrainStateVersion NUMBER := PARAM_GRAINSTATEVERSION;
Expand Down Expand Up @@ -119,8 +110,6 @@ CREATE OR REPLACE FUNCTION WriteToStorage(PARAM_GRAINIDHASH IN NUMBER, PARAM_GRA
UPDATE OrleansStorage
SET
PayloadBinary = PARAM_PAYLOADBINARY,
PayloadJson = PARAM_PAYLOADJSON,
PayloadXml = PARAM_PAYLOADXML,
ModifiedOn = sys_extract_utc(systimestamp),
Version = Version + 1
WHERE
Expand Down Expand Up @@ -155,8 +144,6 @@ CREATE OR REPLACE FUNCTION WriteToStorage(PARAM_GRAINIDHASH IN NUMBER, PARAM_GRA
GrainIdExtensionString,
ServiceId,
PayloadBinary,
PayloadJson,
PayloadXml,
ModifiedOn,
Version
)
Expand All @@ -169,8 +156,6 @@ CREATE OR REPLACE FUNCTION WriteToStorage(PARAM_GRAINIDHASH IN NUMBER, PARAM_GRA
PARAM_GRAINIDEXTENSIONSTRING,
PARAM_SERVICEID,
PARAM_PAYLOADBINARY,
PARAM_PAYLOADJSON,
PARAM_PAYLOADXML,
sys_extract_utc(systimestamp),
1 FROM DUAL
WHERE NOT EXISTS
Expand Down Expand Up @@ -209,8 +194,6 @@ CREATE OR REPLACE FUNCTION ClearStorage(PARAM_GRAINIDHASH IN NUMBER, PARAM_GRAIN
UPDATE OrleansStorage
SET
PayloadBinary = NULL,
PayloadJson = NULL,
PayloadXml = NULL,
ModifiedOn = sys_extract_utc(systimestamp),
Version = Version + 1
WHERE GrainIdHash = PARAM_GRAINIDHASH AND PARAM_GRAINIDHASH IS NOT NULL
Expand All @@ -233,8 +216,8 @@ VALUES
(
'WriteToStorageKey','
SELECT WriteToStorage(:GrainIdHash, :GrainIdN0, :GrainIdN1, :GrainTypeHash, :GrainTypeString,
:GrainIdExtensionString, :ServiceId, :GrainStateVersion, :PayloadBinary,
:PayloadJson, :PayloadXml) AS NewGrainStateVersion FROM DUAL
:GrainIdExtensionString, :ServiceId, :GrainStateVersion, :PayloadBinary)
AS NewGrainStateVersion FROM DUAL
');
/

Expand All @@ -252,7 +235,7 @@ VALUES
(
'ReadFromStorageKey',
'
SELECT PayloadBinary, PayloadXml, PayloadJson, Version
SELECT PayloadBinary, Version
FROM OrleansStorage
WHERE GrainIdHash = :GrainIdHash AND :GrainIdHash IS NOT NULL
AND (GrainIdN0 = :GrainIdN0 OR :GrainIdN0 IS NULL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ CREATE TABLE OrleansStorage
grainidextensionstring character varying(512) ,
serviceid character varying(150) NOT NULL,
payloadbinary bytea,
payloadxml xml,
payloadjson text,
modifiedon timestamp without time zone NOT NULL,
version integer
);
Expand All @@ -27,9 +25,7 @@ CREATE OR REPLACE FUNCTION writetostorage(
_grainidextensionstring character varying,
_serviceid character varying,
_grainstateversion integer,
_payloadbinary bytea,
_payloadjson text,
_payloadxml xml)
_payloadbinary bytea)
RETURNS TABLE(newgrainstateversion integer)
LANGUAGE 'plpgsql'
AS $function$
Expand Down Expand Up @@ -62,8 +58,6 @@ AS $function$
UPDATE OrleansStorage
SET
PayloadBinary = _PayloadBinary,
PayloadJson = _PayloadJson,
PayloadXml = _PayloadXml,
ModifiedOn = (now() at time zone 'utc'),
Version = Version + 1

Expand Down Expand Up @@ -98,8 +92,6 @@ AS $function$
GrainIdExtensionString,
ServiceId,
PayloadBinary,
PayloadJson,
PayloadXml,
ModifiedOn,
Version
)
Expand All @@ -112,8 +104,6 @@ AS $function$
_GrainIdExtensionString,
_ServiceId,
_PayloadBinary,
_PayloadJson,
_PayloadXml,
(now() at time zone 'utc'),
1
WHERE NOT EXISTS
Expand Down Expand Up @@ -148,7 +138,7 @@ VALUES
(
'WriteToStorageKey','

select * from WriteToStorage(@GrainIdHash, @GrainIdN0, @GrainIdN1, @GrainTypeHash, @GrainTypeString, @GrainIdExtensionString, @ServiceId, @GrainStateVersion, @PayloadBinary, @PayloadJson, CAST(@PayloadXml AS xml));
select * from WriteToStorage(@GrainIdHash, @GrainIdN0, @GrainIdN1, @GrainTypeHash, @GrainTypeString, @GrainIdExtensionString, @ServiceId, @GrainStateVersion, @PayloadBinary);
');

INSERT INTO OrleansQuery(QueryKey, QueryText)
Expand All @@ -157,8 +147,6 @@ VALUES
'ReadFromStorageKey','
SELECT
PayloadBinary,
PayloadXml,
PayloadJson,
(now() at time zone ''utc''),
Version
FROM
Expand All @@ -180,8 +168,6 @@ VALUES
UPDATE OrleansStorage
SET
PayloadBinary = NULL,
PayloadJson = NULL,
PayloadXml = NULL,
Version = Version + 1
WHERE
GrainIdHash = @GrainIdHash AND @GrainIdHash IS NOT NULL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,8 @@ CREATE TABLE OrleansStorage
GrainIdExtensionString NVARCHAR(512) NULL,
ServiceId NVARCHAR(150) NOT NULL,

-- The usage of the Payload records is exclusive in that
-- only one should be populated at any given time and two others
-- are NULL. The types are separated to advantage on special
-- processing capabilities present on database engines (not all might
-- have both JSON and XML types.
--
-- One is free to alter the size of these fields.
-- Payload
PayloadBinary VARBINARY(MAX) NULL,
PayloadXml XML NULL,
PayloadJson NVARCHAR(MAX) NULL,

-- Informational field, no other use.
ModifiedOn DATETIME2(3) NOT NULL,
Expand Down Expand Up @@ -131,8 +123,6 @@ VALUES
UPDATE OrleansStorage
SET
PayloadBinary = @PayloadBinary,
PayloadJson = @PayloadJson,
PayloadXml = @PayloadXml,
ModifiedOn = GETUTCDATE(),
Version = Version + 1,
@NewGrainStateVersion = Version + 1,
Expand Down Expand Up @@ -163,8 +153,6 @@ VALUES
GrainIdExtensionString,
ServiceId,
PayloadBinary,
PayloadJson,
PayloadXml,
ModifiedOn,
Version
)
Expand All @@ -177,8 +165,6 @@ VALUES
@GrainIdExtensionString,
@ServiceId,
@PayloadBinary,
@PayloadJson,
@PayloadXml,
GETUTCDATE(),
1
WHERE NOT EXISTS
Expand Down Expand Up @@ -216,8 +202,6 @@ VALUES
UPDATE OrleansStorage
SET
PayloadBinary = NULL,
PayloadJson = NULL,
PayloadXml = NULL,
ModifiedOn = GETUTCDATE(),
Version = Version + 1,
@NewGrainStateVersion = Version + 1
Expand Down Expand Up @@ -249,8 +233,6 @@ VALUES
-- should guarantee the execution time is robustly basically the same from query-to-query.
SELECT
PayloadBinary,
PayloadXml,
PayloadJson,
Version
FROM
OrleansStorage
Expand Down
Loading