/// <summary> /// Handles the scan result from remote node. /// As scan result can be very large, it is received via parcel. /// </summary> /// <param name="parcelNotification">The parcel notification</param> /// <returns>The async task</returns> private async Task OnParcel(ParcelNotification parcelNotification) { if (parcelNotification.GetPayloadType() != typeof(Node)) { Context.System.Log.Info( "{Type}: received parcel with unexpected content of {ParcelContentType}", this.GetType().Name, parcelNotification.PayloadTypeName); return; } try { Context.System.Log.Info("{Type}: received parcel from {Sender}", this.GetType().Name, this.Sender.ToString()); var node = await parcelNotification.Receive(Context.System) as Node; this.clusterTree.Nodes[this.GetNodeName(node)] = node; } catch (Exception exception) { Context.System.Log.Error(exception, "{Type}: error while receiving parcel", this.GetType().Name); } }
/// <summary> /// Sends parcel notification /// </summary> /// <param name="parcel">The parcel</param> private void SendNotification(Parcel parcel) { var notification = new ParcelNotification { Host = this.host, Port = this.port, Uid = parcel.Uid, PayloadTypeName = parcel.Payload.GetType().AssemblyQualifiedName }; object envelope = null; foreach (var notificationEnveloper in this.envelopers) { envelope = notificationEnveloper.Envelope(parcel, notification); if (envelope != null) { break; } } parcel.Recipient.Tell(envelope ?? notification, this.Sender); }