private Task BuildReplicaAsyncHelper(ReplicaInformation replicaInfo, CancellationToken cancellationToken)
 {
     return(Utility.WrapNativeAsyncInvoke(
                (callback) => this.BuildReplicaBeginWrapper(replicaInfo, callback),
                this.BuildReplicaEndWrapper,
                cancellationToken,
                "FabricReplicator.BuildReplica"));
 }
Esempio n. 2
0
        internal static unsafe ReplicaInformation[] FromNativeArray(uint replicaCount, IntPtr replicaInfosIntPtr)
        {
            ReplicaInformation[] replicaInfos = new ReplicaInformation[(int)replicaCount];
            var nativeInfos = (NativeTypes.FABRIC_REPLICA_INFORMATION *)replicaInfosIntPtr;

            for (int i = 0; i < replicaInfos.Length; i++)
            {
                replicaInfos[i] = ReplicaInformation.FromNative((IntPtr)(&nativeInfos[i]));
            }

            return(replicaInfos);
        }
        private NativeCommon.IFabricAsyncOperationContext BuildReplicaBeginWrapper(ReplicaInformation replicaInfo, NativeCommon.IFabricAsyncOperationCallback callback)
        {
            using (var pin = new PinCollection())
            {
                NativeTypes.FABRIC_REPLICA_INFORMATION nativeReplica;
                replicaInfo.ToNative(pin, out nativeReplica);

                unsafe
                {
                    return(this.PrimaryReplicator.BeginBuildReplica((IntPtr)(&nativeReplica), callback));
                }
            }
        }
Esempio n. 4
0
        internal static unsafe ReplicaInformation FromNative(IntPtr replicaInfoIntPtr)
        {
            var nativeInfo = (NativeTypes.FABRIC_REPLICA_INFORMATION *)replicaInfoIntPtr;
            var info       = new ReplicaInformation();

            info.Id                = nativeInfo->Id;
            info.Role              = (System.Fabric.ReplicaRole)nativeInfo->Role;
            info.Status            = (System.Fabric.ReplicaStatus)nativeInfo->Status;
            info.ReplicatorAddress = NativeTypes.FromNativeString(nativeInfo->ReplicatorAddress);
            info.CatchUpCapability = nativeInfo->CatchUpCapability;
            info.CurrentProgress   = nativeInfo->CurrentProgress;

            ReleaseAssert.AssertIf(nativeInfo->Reserved == IntPtr.Zero, "ReplicaInfo->Reserved cannot be null");

            var ex1 = (NativeTypes.FABRIC_REPLICA_INFORMATION_EX1 *)nativeInfo->Reserved;

            info.MustCatchup = NativeTypes.FromBOOLEAN(ex1->MustCatchup);

            return(info);
        }
Esempio n. 5
0
        internal static unsafe ReplicaSetConfiguration FromNative(IntPtr replicaSetIntPtr)
        {
            var nativeConfiguration = (NativeTypes.FABRIC_REPLICA_SET_CONFIGURATION *)replicaSetIntPtr;

            if (nativeConfiguration == null)
            {
                return(null);
            }

            var configuration = new ReplicaSetConfiguration();

            configuration.WriteQuorum = (long)nativeConfiguration->WriteQuorum;

            configuration.Replicas = new List <ReplicaInformation>();
            IntPtr replicas    = nativeConfiguration->Replicas;
            var    nativeInfos = (NativeTypes.FABRIC_REPLICA_INFORMATION *)replicas;

            for (int i = 0; i < nativeConfiguration->ReplicaCount; i++)
            {
                configuration.Replicas.Add(ReplicaInformation.FromNative((IntPtr)(&nativeInfos[i])));
            }

            return(configuration);
        }
Esempio n. 6
0
        private Task BeginBuildReplicaAsync(IntPtr replica, CancellationToken cancellationToken)
        {
            ReplicaInformation replicaInfo = ReplicaInformation.FromNative(replica);

            return(this.replicator.BuildReplicaAsync(replicaInfo, cancellationToken));
        }
 Task IPrimaryReplicator.BuildReplicaAsync(ReplicaInformation replicaInfo, CancellationToken cancellationToken)
 {
     return(this.BuildReplicaAsyncHelper(replicaInfo, cancellationToken));
 }