private Task CreateAndSendCallMessageAsync(CallInfo callInfo, ResolvedCallee callee, PropagationKind propKind) { var callMessageInfo = new CallMessageInfo(callInfo.Caller, callee.Method, callee.ReceiverType, callInfo.ArgumentsPossibleTypes, callInfo.CallNode, callInfo.LHS, propKind); var source = new MethodEntityDescriptor(callInfo.Caller); var callerMessage = new CallerMessage(source, callMessageInfo); return(this.AnalyzeCalleeAsync(callMessageInfo.Callee, callerMessage, propKind)); }
public async Task PropagateAndProcessAsync(CallMessageInfo callMessageInfo) { await StatsHelper.RegisterMsg("MethodEntityGrain::PropagateAndProcess", this.GrainFactory); var effects = await this.methodEntityPropagator.PropagateAsync(callMessageInfo); // await this.PropagateAsync(callMessageInfo); await StatsHelper.RegisterPropagationUpdates(effects.NumberOfUpdates, effects.WorkListInitialSize, this.GrainFactory); await ProcessEffectsAsync(effects); }
public async Task <PropagationEffects> PropagateAsync(CallMessageInfo callMessageInfo) { this.methodEntity.PropGraph.ResetUpdateCount(); Logger.LogS("MethodEntityGrain", "PropagateAsync-call", "Propagation for {0} ", callMessageInfo.Callee); if (!this.methodEntity.CanBeAnalized) { var calleesInfo = new HashSet <CallInfo>(); return(new PropagationEffects(calleesInfo, false)); } if (this.methodEntity.ThisRef != null && callMessageInfo.ReceiverType != null) { var receiverPossibleTypes = new TypeDescriptor[] { callMessageInfo.ReceiverType }; await this.methodEntity.PropGraph.DiffPropAsync(receiverPossibleTypes, this.methodEntity.ThisRef, callMessageInfo.PropagationKind); } for (var i = 0; i < this.methodEntity.ParameterNodes.Count; i++) { var parameterNode = this.methodEntity.ParameterNodes[i]; if (parameterNode != null) { //TODO: Hack. Remove later! var argumentPossibleTypes = new HashSet <TypeDescriptor>(); if (i < callMessageInfo.ArgumentsPossibleTypes.Count) { argumentPossibleTypes.UnionWith(callMessageInfo.ArgumentsPossibleTypes[i]); } else { argumentPossibleTypes.Add(parameterNode.Type); } await this.methodEntity.PropGraph.DiffPropAsync(argumentPossibleTypes, parameterNode, callMessageInfo.PropagationKind); } } var context = new CallContext(callMessageInfo.Caller, callMessageInfo.LHS, callMessageInfo.CallNode); this.methodEntity.AddToCallers(context); var effects = await InternalPropagateAsync(callMessageInfo.PropagationKind); Logger.LogS("MethodEntityGrain", "PropagateAsync-call", "End Propagation for {0} ", callMessageInfo.Callee); return(effects); }
private Task CreateAndSendCallMessageAsync(CallInfo callInfo, ResolvedCallee callee, PropagationKind propKind) { var callMessageInfo = new CallMessageInfo(callInfo.Caller, callee.Method, callee.ReceiverType, callInfo.ArgumentsPossibleTypes, callInfo.CallNode, callInfo.LHS, propKind); var source = new MethodEntityDescriptor(callInfo.Caller); var callerMessage = new CallerMessage(source, callMessageInfo); //Logger.LogWarning(GrainClient.Logger, "Orchestrator", "CreateAndSendCallMsg", "Enqueuing: {0}", callee); //await WaitQueue(QUEUE_THRESHOLD); this.messageWorkList.Enqueue(callerMessage); //this.messageWorkList.Add(callerMessage); return(Task.CompletedTask); //return AnalyzeCalleeAsync(callMessageInfo.Callee, callerMessage, propKind); }
public async Task <PropagationEffects> PropagateAsync(CallMessageInfo callMessageInfo) { await StatsHelper.RegisterMsg("MethodEntityGrain::PropagateCall", this.GrainFactory); //if (status.Equals(EntityGrainStatus.Busy)) //{ // await Task.Delay(WAIT_TIME); // if (status.Equals(EntityGrainStatus.Busy)) // { // return new PropagationEffects(); // } //} var propagationEffects = await this.methodEntityPropagator.PropagateAsync(callMessageInfo); propagationEffects.SiloAddress = StatsHelper.GetMyIPAddr(); await StatsHelper.RegisterPropagationUpdates(propagationEffects.NumberOfUpdates, propagationEffects.WorkListInitialSize, this.GrainFactory); return(propagationEffects); }
internal CallerMessage(IEntityDescriptor source, CallMessageInfo messageInfo) : base(source) { this.CallMessageInfo = messageInfo; }
private async Task HandleCallEventAsync(CallMessageInfo callMessage) { if (MethodEntity.CanBeAnalized) { Contract.Assert(callMessage.ArgumentValues.Count() == this.MethodEntity.ParameterNodes.Count()); if (this.Verbose) { Logger.Instance.Log("MethodEntityProcessor", "HandleCallEventAsync", "Reached {0} via call {1}", this.MethodEntity.MethodDescriptor, callMessage); } // This is the node in the caller where info of ret-value should go var lhs = callMessage.LHS; // Save caller info var callContext = new CallContext(callMessage.Caller, callMessage.LHS, callMessage.CallNode); /// Loop detected due to recursion //if (MethodEntity.NodesProcessing.Contains(callMessage.CallNode)) //if (MethodEntity.NodesProcessing.Contains(callContext)) //{ // if (this.Verbose) // { // Logger.Instance.Log(string.Format("Recursion loop {0} ", this.Method.ToString())); // } // //lock (this.MethodEntity) // //{ // // MethodEntity.NodesProcessing.Remove(callContext); // // //MethodEntity.NodesProcessing.Remove(callMessage.CallNode); // //} // //EndOfPropagationEventAsync(callMessage.PropagationKind); // return new Task(() => { }); //} // Just a test to try to block the Entity to a single simultaneous caller //while (this.MethodEntity.CurrentContext != null) //{ // Logger.Instance.Log(string.Format("Waiting: {0} to finish", this.Method)); // Thread.Sleep(10); //} //lock (this.MethodEntity) { //this.MethodEntity.CurrentContext = callContext; // Here is when I register the caller this.MethodEntity.AddToCallers(callContext); if (this.MethodEntity.ThisRef != null) { await this.MethodEntity.PropGraph.DiffPropAsync(Demarshaler.Demarshal(callMessage.Receivers), this.MethodEntity.ThisRef, callMessage.PropagationKind); } var pairIterator = new PairIterator<PropGraphNodeDescriptor, ISet<TypeDescriptor>> (this.MethodEntity.ParameterNodes, callMessage.ArgumentValues); foreach (var pair in pairIterator) { var parameterNode = pair.Item1; //PropGraph.Add(pn, argumentValues[i]); if (parameterNode != null) { await this.MethodEntity.PropGraph.DiffPropAsync( Demarshaler.Demarshal(pair.Item2), parameterNode, callMessage.PropagationKind); } } } switch (callMessage.PropagationKind) { case PropagationKind.ADD_TYPES: await PropagateAsync(); break; case PropagationKind.REMOVE_TYPES: await PropagateDeleteAsync(); break; } } else { await EndOfPropagationEventAsync(callMessage.PropagationKind,false); } }
public Task PropagateAndProcessAsync(CallMessageInfo callMessageInfo) { this.SetRequestContext(); return(methodEntityGrain.PropagateAndProcessAsync(callMessageInfo)); }
public Task <PropagationEffects> PropagateAsync(CallMessageInfo callMessageInfo) { this.SetRequestContext(); return(methodEntityGrain.PropagateAsync(callMessageInfo)); }
private void HandleCallEvent(CallMessageInfo callMessage) { if (MethodEntity.CanBeAnalized) { Contract.Assert(callMessage.ArgumentValues.Count() == this.MethodEntity.ParameterNodes.Count()); if (this.Verbose) { Logger.Instance.Log("MethodEntityProcessor", "HandleCallEvent", "Reached {0} via call", this.MethodEntity.MethodDescriptor); } // This tries to check that the invocation is repeated (didn't work: need to check) //if (MethodEntity.Callers.Where(cs => cs.Invocation.Equals(callMessage.CallNode)).Count()>0) // This check if the method is already in caller list if (MethodEntity.Callers.Where(cs => cs.Caller.Equals(callMessage.Caller)).Count() > 0) { if (this.Verbose) { Logger.Instance.Log("MethodEntityProcessor", "HandleCallEvent", "Recursion loop {0} ", this.MethodEntity.MethodDescriptor); } EndOfPropagationEvent(callMessage.PropagationKind, false); return; } // Save caller info var context = new CallContext(callMessage.Caller, callMessage.LHS, callMessage.CallNode); this.MethodEntity.AddToCallers(context); // Propagate type info in method //PropGraph.Add(thisRef, receivers); if (this.MethodEntity.ThisRef != null) { this.MethodEntity.PropGraph.DiffProp(Demarshaler.Demarshal(callMessage.Receivers), this.MethodEntity.ThisRef, callMessage.PropagationKind); } var pairEnumerable = new PairIterator<PropGraphNodeDescriptor, ISet<TypeDescriptor>>( this.MethodEntity.ParameterNodes, callMessage.ArgumentValues); foreach (var pair in pairEnumerable) { var parameterNode = pair.Item1; //PropGraph.Add(pn, argumentValues[i]); if (parameterNode != null) { this.MethodEntity.PropGraph.DiffProp( Demarshaler.Demarshal(pair.Item2), parameterNode, callMessage.PropagationKind); } } if (callMessage.PropagationKind == PropagationKind.ADD_TYPES) { Propagate(); } if (callMessage.PropagationKind == PropagationKind.REMOVE_TYPES) { PropagateDelete(); } } else { EndOfPropagationEvent(callMessage.PropagationKind, false); } }