Пример #1
0
        internal static unsafe KeyValueStoreReplicaStatus CreateFromNative(IntPtr nativeKvs)
        {
            if (nativeKvs == IntPtr.Zero)
            {
                return(null);
            }

            var castedKvs = (NativeTypes.FABRIC_KEY_VALUE_STORE_STATUS_QUERY_RESULT *)nativeKvs;

            var managedKvs = new KeyValueStoreReplicaStatus();

            managedKvs.DatabaseRowCountEstimate         = castedKvs->DatabaseRowCountEstimate;
            managedKvs.DatabaseLogicalSizeEstimate      = castedKvs->DatabaseLogicalSizeEstimate;
            managedKvs.CopyNotificationCurrentKeyFilter = NativeTypes.FromNativeString(castedKvs->CopyNotificationCurrentKeyFilter);
            managedKvs.CopyNotificationCurrentProgress  = castedKvs->CopyNotificationCurrentProgress;
            managedKvs.StatusDetails = NativeTypes.FromNativeString(castedKvs->StatusDetails);

            if (castedKvs->Reserved != IntPtr.Zero)
            {
                var castedEx1 = (NativeTypes.FABRIC_KEY_VALUE_STORE_STATUS_QUERY_RESULT_EX1 *)castedKvs->Reserved;

                managedKvs.ProviderKind    = (KeyValueStoreProviderKind)castedEx1->ProviderKind;
                managedKvs.MigrationStatus = KeyValueStoreMigrationStatus.CreateFromNative(castedEx1->MigrationStatus);
            }

            return(managedKvs);
        }
        internal static unsafe DeployedServiceReplicaDetail CreateFromNative(
            NativeTypes.FABRIC_DEPLOYED_STATEFUL_SERVICE_REPLICA_DETAIL_QUERY_RESULT_ITEM nativeResultItem)
        {
            var rv = new DeployedStatefulServiceReplicaDetail
            {
                CurrentReplicatorOperation          = (ReplicatorOperationName)nativeResultItem.CurrentReplicatorOperation,
                CurrentServiceOperation             = (ServiceOperationName)nativeResultItem.CurrentServiceOperation,
                CurrentServiceOperationStartTimeUtc = NativeTypes.FromNativeFILETIME(nativeResultItem.CurrentServiceOperationStartTimeUtc),
                PartitionId  = nativeResultItem.PartitionId,
                ReadStatus   = (PartitionAccessStatus)nativeResultItem.ReadStatus,
                ReplicaId    = nativeResultItem.ReplicaId,
                ReportedLoad = LoadMetricReport.CreateFromNativeList((NativeTypes.FABRIC_LOAD_METRIC_REPORT_LIST *)nativeResultItem.ReportedLoad),
                ServiceName  = new Uri(NativeTypes.FromNativeString(nativeResultItem.ServiceName)),
                WriteStatus  = (PartitionAccessStatus)nativeResultItem.WriteStatus
            };

            if (nativeResultItem.ReplicatorStatus != IntPtr.Zero)
            {
                rv.ReplicatorStatus = ReplicatorStatus.FromNative((NativeTypes.FABRIC_REPLICATOR_STATUS_QUERY_RESULT *)nativeResultItem.ReplicatorStatus);
            }

            if (nativeResultItem.Reserved != IntPtr.Zero)
            {
                var ex1           = (NativeTypes.FABRIC_DEPLOYED_STATEFUL_SERVICE_REPLICA_DETAIL_QUERY_RESULT_ITEM_EX1 *)nativeResultItem.Reserved;
                var replicaStatus = (NativeTypes.FABRIC_REPLICA_STATUS_QUERY_RESULT *)ex1->ReplicaStatus;

                if (replicaStatus != null && replicaStatus->Kind == NativeTypes.FABRIC_SERVICE_REPLICA_KIND.FABRIC_SERVICE_REPLICA_KIND_KEY_VALUE_STORE)
                {
                    rv.ReplicaStatus = KeyValueStoreReplicaStatus.CreateFromNative(replicaStatus->Value);
                }

                if (ex1->Reserved != IntPtr.Zero)
                {
                    var extended2 = (NativeTypes.FABRIC_DEPLOYED_STATEFUL_SERVICE_REPLICA_DETAIL_QUERY_RESULT_ITEM_EX2 *)ex1->Reserved;

                    var deployedServiceReplica = *(NativeTypes.FABRIC_DEPLOYED_STATEFUL_SERVICE_REPLICA_QUERY_RESULT_ITEM *)extended2->DeployedServiceReplica;
                    rv.DeployedServiceReplica = DeployedStatefulServiceReplica.FromNative(deployedServiceReplica);
                }
            }

            return(rv);
        }