Exemplo n.º 1
0
        public NativeRuntime.IFabricStatefulServiceReplica CreateReplica(
            IntPtr nativeServiceType,
            IntPtr nativeServiceName,
            uint initializationDataLength,
            IntPtr nativeInitializationData,
            FABRIC_PARTITION_ID partitionId,
            FABRIC_REPLICA_ID replicaId)
        {
            Func <IStatefulServiceFactory, ServiceInitializationParameters, IStatefulServiceReplica> creationFunc = (factory, initParams) =>
            {
                return(factory.CreateReplica(initParams.ServiceTypeName, initParams.ServiceName, initParams.InitializationData, partitionId, replicaId));
            };

            ServiceInitializationParameters initializationParameters = new StatefulServiceInitializationParameters(this.codePackageActivationContext)
            {
                ReplicaId = replicaId
            };
            IStatefulServiceReplica statefulService = this.CreateHelper <IStatefulServiceFactory, IStatefulServiceReplica>(
                nativeServiceType,
                nativeServiceName,
                initializationDataLength,
                nativeInitializationData,
                partitionId,
                creationFunc,
                (inst, initParams) => inst.Initialize(initParams as StatefulServiceInitializationParameters),
                initializationParameters);

            return(new StatefulServiceReplicaBroker(statefulService, initializationParameters, replicaId));
        }
        public void Initialize_OverrideNativeKeyValueStore(StatefulServiceInitializationParameters initParams)
        {
            using (var pin = new PinCollection())
            {
                var kvsSettings       = this.KeyValueStoreReplicaSettings_V2;
                var nativeKvsSettings = kvsSettings.ToNative(pin);

                // Microsoft.ServiceFabric.Internal does not have friend access to System.Fabric.
                // Use reflection to access hook and override underlying native store implementation.
                //
                var method = typeof(KeyValueStoreReplica).GetMethod(
                    "OverrideNativeKeyValueStore_V2",
                    BindingFlags.NonPublic | BindingFlags.Instance);

                // We are invoking a method on KeyValueStoreReplica in System.Fabric.dll from
                // Microsoft.ServiceFabric.Internal.dll so the argument must be a type common to both dlls.
                //
                method.Invoke(this, new object[] { nativeKvsSettings });

                this.Initialize(initParams);
            }
        }
Exemplo n.º 3
0
 public void Initialize(System.Fabric.StatefulServiceInitializationParameters initializationParameters)
 {
 }