Ejemplo n.º 1
0
        internal StatefulServiceReplicaAdapter(
            StatefulServiceContext context,
            IStatefulUserServiceReplica userServiceReplica)
        {
            this.serviceContext = context;
            this.traceId        = ServiceTrace.GetTraceIdForReplica(context.PartitionId, context.ReplicaId);
            this.serviceHelper  = new ServiceHelper(TraceType, this.traceId);

            this.servicePartition       = null;
            this.replicaListeners       = null;
            this.communicationListeners = null;
            this.endpointCollection     = new ServiceEndpointCollection();

            this.runAsynCancellationTokenSource = null;
            this.executeRunAsyncTask            = null;

            this.userServiceReplica           = userServiceReplica;
            this.userServiceReplica.Addresses = this.endpointCollection.ToReadOnlyDictionary();

            // The state provider replica should ideally be initialized
            // here (this.stateProviderReplica.Initialize()) with ServiceContext.
            // However the initialize function takes in StatefulServiceInitializationParameter
            // and resides in the DATA layer. DATA layer lies below SERVICES layer
            // and is agnostic of services and ServiceContext lies in SERVICES layer.
            // For now state provider replica is initialized when runtime calls
            // IStatefulServiceReplica.Initialize(StatefulServiceInitializationParameters initializationParameters)
            this.stateProviderReplica = this.userServiceReplica.CreateStateProviderReplica();
        }
        internal StatelessServiceInstanceAdapter(
            StatelessServiceContext context,
            IStatelessUserServiceInstance userServiceInstance)
        {
            this.serviceContext = context;
            this.traceId        = ServiceTrace.GetTraceIdForReplica(context.PartitionId, context.InstanceId);
            this.serviceHelper  = new ServiceHelper(TraceType, this.traceId);

            this.servicePartition       = null;
            this.instanceListeners      = null;
            this.communicationListeners = null;
            this.endpointCollection     = new ServiceEndpointCollection();

            this.runAsynCancellationTokenSource = null;
            this.executeRunAsyncTask            = null;

            this.userServiceInstance           = userServiceInstance;
            this.userServiceInstance.Addresses = this.endpointCollection.ToReadOnlyDictionary();
        }
 internal static string GetTraceIdForReplica(Guid partitionId, long replicaId)
 {
     return(ServiceTrace.GetTraceIdForReplica(partitionId, replicaId));
 }