----------------------------------------------------------- New Message on BDOTNET
----------------------------------------------------------- From: Nasha Message 1 in Discussion Hi Frndz, Continuing our discussion with LifeTime Management :- Lifetime Management has been one of the biggest challenges in distributed applications. It is difficult to detect for client and server that whether the other is available or not. To check whether the server is available or not, the least that the client can do is to ping the server . But this mechanism is fine if we are on LAN but is not suitable for Internet based applications. If the client is unable to check the presence of the server, the last thing it can do is call a method on the server object. If the server object is not present than an exception will be raised. .NET Remoting has some up with a solution for lifetime management called as the Leasing Distributed Garbge Collector i.e.LDGC. Lifetime managment becomes very important for client -activated objects as they can have state and need to be aware of resources that they use. So lease becomes very important for these objects when the lease time is reached the lease expires and the object is marked for garbage collection. All objects inherited from MarshalByRef generally do their own lifetime managment and do not reside in memeory for a long time. Inorder to implement custom lifetime managment we need to override InitializeLifetimeService(). The life time of the object is controlled by setting the lease time , lease manager and Number of sponsors. When we say number of sponsors we mean that if no sponsors are available within the SponsorshipTimeOut then the lease expires and te object is garbage collected. Lease Manager keeps a watch on the object and marks it for garbage collection when the lease expires. All the sponsors who want the object have to first register themselves with the lease manager and than renew the lease time for the remote object periodically. Inorder to handle lease of an object we need to override InitializeLifetimeService(). When we override this method the call to the base class InitializeLifetimeService() returns ILease object. We need to set properties of this object inorder to renew the object lifetime. ILease defines the following properties to control lease time of an object :- Lease Time :- Time until the object will be marked for garbage collection. The default current lease time is 5 minutes .. setting it to 0 will be setting it to infinite RenewOnCallTime :- Its the lease time set on each method call on the remote object. Default 2 minutes SponorshipTimeout :- The amount of time by which the lease manager should be able to find a sponsor for the object. If not than the lease expires and the object is marked for deletion. Default 2 mintues LeaseManagerPollTime :- Its the time interal after which the lease manager checks for object lease expiration. Default is 10 seconds. There are lot of ways for renewing object lease or liftime. a. As we saw above the object life time will be automatically renewed if the CurrentLeaseTime is less than the RenewOnCallTime once there is a method call made on that object. b. One can control the object renewal by calling Renew method. InitializeLifetimeService() which returns us an ILease object exposes a method called ILease:Renew(). c. Object renewal can be left at Sponors discretion. The sponors need to implement ISponsor interface. This mechanism need the sponsor to register by calling the Register() method of the ILease interface. When the lease is about to expire the sponsor will be asked if the lease needs to be renewed. This mechanism is best for Client-activated objects and when you want remote objects to live for a long time. .NET's approach towards lifetime management is better than other older aproaches like pinging for an object and reference counting. -- Please post your queries and comments for my articles in the user group for the benefit of all. I hope this step from my end is helpful to all of us. You can find all articles written by me at my personal blog http://spaces.msn.com/members/nasha. Regards, Namratha (Nasha) ----------------------------------------------------------- To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings. http://groups.msn.com/BDotNet/_emailsettings.msnw Need help? If you've forgotten your password, please go to Passport Member Services. http://groups.msn.com/_passportredir.msnw?ppmprop=help For other questions or feedback, go to our Contact Us page. http://groups.msn.com/contact If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list. mailto:[EMAIL PROTECTED]
