| Description: | The maximum number of milliseconds earlier than a lease would typically be renewed to allow it to be renewed in order to permit batching its renewal with that of other leases. The value must not be negative. This entry is obtained in the constructor. • | roundTripTime |   | Type: | long |   | Default: | 10 * 1000 // 10 seconds |   | Description: | The worst-case latency, expressed in milliseconds, to assume for a remote call to renew a lease. The value must be greater than zero. Unrealistically low values for this entry may result in failure to renew a lease. Leases managed by this manager should have durations exceeding the roundTripTime . This entry is obtained in the constructor. | • | taskManager |   | Type: | {@link TaskManager} |   | Default: | new TaskManager(11, 15000, 1.0f) |   | Description: | The object used to manage queuing tasks involved with renewing leases and sending notifications. The value must not be null . The default value creates a maximum of 11 threads for performing operations, waits 15 seconds before removing idle threads, and uses a load factor of 1.0 when determining whether to create a new thread. Note that the implementation of the renewal algorithm includes an assumption that the TaskManager uses a load factor of 1.0. | Logging This implementation uses the {@link Logger} namednet.jini.lease.LeaseRenewalManager to log information at the following logging levels: net.jini.lease.LeaseRenewalManager Level | Description | {@link Levels#FAILED FAILED} | Lease renewal failure events, or leases that expire before reaching the desired expiration time | {@link Levels#HANDLED HANDLED} | Lease renewal attempts that produce indefinite exceptions | {@link Level#FINE FINE} | Adding and removing leases, lease renewal attempts, and desired lease expiration events | For a way of using the FAILED and HANDLED logging levels in standard logging configuration files, see the {@link LogManager}class. The renewal algorithm The time at which a lease is scheduled for renewal is based on the expiration time of the lease, possibly adjusted to account for the latency of the remote renewal call. The configuration entry roundTripTime , which defaults to ten seconds, represents the total time to make the remote call. The following pseudocode was derived from the code which computes the renewal time. In this code, rtt represents the value of the roundTripTime : endTime = lease.getExpiration(); delta = endTime - now; if (delta <= rtt * 2) { delta = rtt; } else if (delta <= rtt * 8) { delta /= 2; } else if (delta <= 1000 * 60 * 60 * 24 * 7) { delta /= 8; } else if (delta <= 1000 * 60 * 60 * 24 * 14) { delta = 1000 * 60 * 60 * 24; } else { delta = 1000 * 60 * 60 * 24 * 3; } renew = endTime - delta; It is important to note that delta is never less than rtt when the renewal time is computed. A lease which would expire within this time range will be scheduled for immediate renewal. The use of very short lease durations (at or below rtt ) can cause the renewal manager to effectively ignore the lease duration and repeatedly schedule the lease for immediate renewal. If an attempt to renew a lease fails with an indefinite exception, a renewal is rescheduled with an updated renewal time as computed by the following pseudocode: delta = endTime - renew; if (delta > rtt) { if (delta <= rtt * 3) { delta = rtt; } else if (delta <= 1000 * 60 * 60) { delta /= 3; } else if (delta <= 1000 * 60 * 60 * 24) { delta = 1000 * 60 * 30; } else if (delta <= 1000 * 60 * 60 * 24 * 7) { delta = 1000 * 60 * 60 * 3; } else { delta = 1000 * 60 * 60 * 8; } renew += delta; } Client leases are maintained in a collection sorted by descending renewal time. A renewal thread is spawned whenever the renewal time of the last lease in the collection is reached. This renewal thread examines all of the leases in the collection whose renewal time falls within renewBatchTimeWindow milliseconds of the renewal time of the last lease. If any of these leases can be batch renewed with the last lease (as determined by calling the {@link Lease#canBatch canBatch} method ofthe last lease) then a {@link LeaseMap} is created, all eligible leasesare added to it and the {@link LeaseMap#renewAll} method is called. Otherwise, thelast lease is renewed directly. The TaskManager that manages the renewal threads has a bound on the number of simultaneous threads it will support. The renewal time of leases may be adjusted earlier in time to reduce the likelihood that the renewal of a lease will be delayed due to exhaustion of the thread pool. Actual renewal times are determined by starting with the lease with the latest (farthest off) desired renewal time and working backwards. When computing the actual renewal time for a lease, the renewals of all leases with later renewal times, which will be initiated during the round trip time of the current lease's renewal, are considered. If using the desired renewal time for the current lease would result in more in-progress renewals than the number of threads allowed, the renewal time of the current lease is shifted earlier in time, such that the maximum number of threads is not exceeded.
| = (LeaseRenewalManager)thisConfig.getEntry
(COMPONENT_NAME,
"leaseManager",
LeaseRenewalManager.class);
} catch(NoSuchEntryException e) { /* use default */
leaseRenewalMgr = new LeaseRenewalManager(thisConfig);
}
}//endif
/* Wait value for the "service discard problem". */
discardWait = ((Long)thisConfig.getEntry
(COMPONENT_NAME,
|
| leaseRenewalMgr = (LeaseRenewalManager)config.getEntry
(COMPONENT_NAME,
"leaseManager",
LeaseRenewalManager.class);
} catch(NoSuchEntryException e) { /* use default */
leaseRenewalMgr = new LeaseRenewalManager(config);
}
}//endif
renewalDuration = ((Long)config.getEntry
(COMPONENT_NAME,
"maxLeaseDuration",
|
| }
/* getLeaseRenewalManager */
methodStr = "getLeaseRenewalManager()";
logger.log(Level.FINE, "invoking "+methodStr+" ...");
try {
LeaseRenewalManager lrm
= srvcDiscoveryMgr.getLeaseRenewalManager();
logger.log(Level.FINE, ""+errStr+methodStr);
failed = true;
} catch(IllegalStateException e) {
logger.log(Level.FINE, ""+successStr+methodStr);
|
| // Announce where we are in the test
logger.log(Level.FINE, "EventTest:In setup() method.");
// capture an instance of the Properties file.
QAConfig config = (QAConfig)getConfig();
lrm = new LeaseRenewalManager(sysConfig.getConfiguration());
}
|
| * an instance of a test service and the instance of
* LeaseRenewalManager created above
* </ul>
*/
public void setup(QAConfig sysConfig) throws Exception {
leaseMgr = new LeaseRenewalManager(sysConfig.getConfiguration());
callback = new SrvcIDListener(testService);
super.setup(sysConfig);
}//end setup
|
| public void run() throws Exception {
logger.log(Level.FINE, "run()");
/* Callback join manager */
logger.log(Level.FINE, "retrieving the lease renewal manager from the "
+"callback join manager ...");
LeaseRenewalManager lrmCallback
= joinMgrCallback.getLeaseRenewalManager();
if(lrmCallback == null) {
throw new TestException("could not successfully retrieve "
+"the lease renewal manager");
}//endif
if( !lrmCallback.equals(leaseMgr) ) {
throw new TestException(
"callback join manager -- lease renewal "
+"manager returned is NOT equal to the lease "
+"renewal manager used to construct the "
+"join manager");
}//endif
logger.log(Level.FINE, "lease renewal manager retrieved "
+"equals the lease renewal manager used to "
+"construct the callback join manager");
/* Service ID join manager */
logger.log(Level.FINE, "retrieving the lease renewal manager from the "
+"service ID join manager ...");
LeaseRenewalManager lrmSrvcID
= joinMgrSrvcID.getLeaseRenewalManager();
if(lrmSrvcID == null) {
throw new TestException("could not successfully retrieve "
+"the lease renewal manager");
}//endif
if( !lrmSrvcID.equals(leaseMgr) ) {
throw new TestException(
"service ID join manager -- "
+"lease renewal manager returned is NOT "
+"equal to the lease renewal manager used to "
+"construct the join manager");
|
| ServiceTemplate cybernodes = new ServiceTemplate(null, new Class[]{Cybernode.class}, null);
ServiceTemplate eventCollectors = new ServiceTemplate(null,
new Class[]{EventCollector.class},
new Entry[]{new OperationalStringEntry(org.rioproject.config.Constants.CORE_OPSTRING)});
sdm = new ServiceDiscoveryManager(jiniClient.getDiscoveryManager(), new LeaseRenewalManager(), config);
ServiceWatcher watcher = new ServiceWatcher();
ProvisionClientEventConsumer provisionClientEventConsumer = new ProvisionClientEventConsumer();
|
| else
template = new ServiceTemplate(null, interfaces, null);
if(config==null)
config = EmptyConfiguration.INSTANCE;
sdm = new ServiceDiscoveryManager(dm, new LeaseRenewalManager(config), config);
InstantiatorResource[] irArray = provisioner.getServiceResourceSelector().getInstantiatorResources(svcElement);
List<ServiceBeanInstance> instanceList = new ArrayList<ServiceBeanInstance>();
for (InstantiatorResource ir : irArray) {
try {
ServiceBeanInstance[] sbi = ir.getInstantiator().getServiceBeanInstances(svcElement);
|
| * Perform initial discovery in a thread
*/
public void run() {
try {
if(config == null)
sdm = new ServiceDiscoveryManager(dm, new LeaseRenewalManager());
else
sdm = new ServiceDiscoveryManager(dm, new LeaseRenewalManager(config), config);
lCache = sdm.createLookupCache(template, null, this);
if(!assignBackup())
peerLogger.debug("ProvisionMonitorPeer: No backup");
} catch(Exception e) {
peerLogger.warn("ProvisionMonitor discovery", e);
|
| }
attrList.addAll(context.getServiceBeanConfig().getAdditionalEntries());
if(logger.isTraceEnabled())
logger.trace("[{}] do the join", ServiceElementUtil.getLoggingName(context));
LeaseRenewalManager lrm = null;
/*
* The advertise call may be invoked via the MBeanServer. If it is, the
* context classloader will not be the classloader which loaded this
* bean. If the context classloader is not a ServiceClassLoader, then
* set the current context classloader to be the classloader which
* loaded this class. This is needed to load the configuration file
*/
final Thread currentThread = Thread.currentThread();
final ClassLoader cCL = AccessController.doPrivileged(
new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
return (currentThread.getContextClassLoader());
}
});
boolean swapCLs = !(cCL instanceof ServiceClassLoader);
try {
final ClassLoader myCL = AccessController.doPrivileged(
new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
return (getClass().getClassLoader());
}
});
if(swapCLs) {
AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
currentThread.setContextClassLoader(myCL);
return (null);
}
});
}
lrm = new LeaseRenewalManager(context.getConfiguration());
} catch(Exception e) {
logger.warn("Creating LeaseRenewalManager", e);
lrm = new LeaseRenewalManager();
} finally {
if(swapCLs) {
AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
currentThread.setContextClassLoader(cCL);
|
Related Classes of net.jini.lease.LeaseRenewalManager
Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.
|