/** * Find a lease entry, throw exception if not found or expired * normally */ private Entry findEntry(Lease lease) throws UnknownLeaseException { Entry e = findEntryDo(lease); if (e != null && (e.renew < e.endTime || System.currentTimeMillis() < e.endTime)) { return e; } throw new UnknownLeaseException(); }
} catch (UnknownLeaseException e) { if (_logger.isLoggable(Level.FINE)) _logger.log(Level.FINE, "unsubscribe() cancel ND lease: " + e.toString(), e); } catch (RemoteException e) { if (_logger.isLoggable(Level.FINE))
@Override public void inCancelEntryLeaseByUID(IReplicationInContext context, String typeName, String uid, boolean isTransient, int routingValue) { if (_isPrimaryBackupSpace && ignoreOperation(isTransient)) return; try { // this entry holder is safe to read from and will not be modified after this method returns IEntryHolder entryHolder = getLeaseManager().cancel(uid, typeName, ObjectTypes.ENTRY, true /* fromRepl */, false /*origin*/, false /* isFromGateway */); if (context.getContentContext() != null) { if (entryHolder != null) { IEntryData entryData = entryHolder.getEntryData(); context.getContentContext().setMainEntryData(entryData); } else if (context.getContextLogger().isLoggable(Level.FINE)) context.getContextLogger().log(Level.FINE, "Cancellation of entry lease did not return an associated entry: Type name:" + typeName + " UID: " + uid); } } catch (UnknownLeaseException ex) { if (getConflictingOperationPolicy().isOverride()) return; if (context.getContextLogger().isLoggable(Level.WARNING)) { context.getContextLogger().log(Level.WARNING, "Replicator: " + ex.getClass().getName() + ". Failed to cancel Entry lease: " + typeName + " UID: " + uid + " ObjectType: " + ObjectTypes.ENTRY + " in target [" + _engine.getFullSpaceName() + "] space." + "\n" + ex.getMessage()); } } }
@Override public void inEntryLeaseExpiredByUID(IReplicationInContext context, String typeName, String uid, boolean isTransient, OperationID operationID) { if (_isPrimaryBackupSpace && ignoreOperation(isTransient)) return; try { // this entry holder is safe to read from and will not be modified after this method returns IEntryHolder entryHolder = getLeaseManager().cancel(uid, typeName, ObjectTypes.ENTRY, true /* fromRepl */, false /*origin*/, true /*leaseExpired*/, operationID, false /* isFromReplication */); if (context.getContentContext() != null) { if (entryHolder != null) { IEntryData entryData = entryHolder.getEntryData(); context.getContentContext().setMainEntryData(entryData); } else if (context.getContextLogger().isLoggable(Level.FINE)) context.getContextLogger().log(Level.FINE, "Expiration of entry lease did not return an associated entry: Type name:" + typeName + " UID: " + uid); } } catch (UnknownLeaseException ex) { if (getConflictingOperationPolicy().isOverride()) return; Level logLevel = getLeaseManager().isSlaveLeaseManagerForEntries() ? Level.FINE : Level.WARNING; if (context.getContextLogger().isLoggable(logLevel)) { context.getContextLogger().log(logLevel, "Replicator: " + ex.getClass().getName() + ". Failed to expire Entry lease: " + typeName + " UID: " + uid + " ObjectType: " + ObjectTypes.ENTRY + " in target [" + _engine.getFullSpaceName() + "] space." + "\n" + ex.getMessage()); } } }
/** * The code that does the real work of cancelEventLease. */ private void cancelEventLeaseDo(long eventID, Uuid leaseID) throws UnknownLeaseException { long now = SystemTime.timeMillis(); EventReg reg = eventByID.get(eventID); if (reg == null || reg.leaseExpiration <= now) throw new UnknownLeaseException(); deleteEvent(null, reg); }
/** * The code that does the real work of cancelEventLease. */ private void cancelEventLeaseDo(long eventID, Uuid leaseID) throws UnknownLeaseException { long now = System.currentTimeMillis(); EventReg reg = (EventReg) eventByID.get(new Long(eventID)); if (reg == null || reg.leaseExpiration <= now) throw new UnknownLeaseException(); deleteEvent(reg); /* wake up thread if this might be the (only) earliest time */ if (reg.leaseExpiration == minEventExpiration) concurrentObj.waiterNotify(eventNotifier); }
/** * cancel local xtn lease. */ void cancelLocalXtn(TransactionManager mgr, ServerTransaction st) throws UnknownLeaseException { if (!(mgr instanceof LocalTransactionManagerImpl)) throw new RuntimeException("cancel local xtn lease: invalid transaction manager"); LocalTransactionManagerImpl ltx = (LocalTransactionManagerImpl) mgr; //call abort form this xtn try { abortSA(mgr, st, true /*from cancel-lease*/, false/*verifyExpiredXtn*/, false, null/* operationID */); } catch (UnknownTransactionException ex) { throw new UnknownLeaseException("cancel:unknown transaction at space-server transaction-id= " + st + " manager=" + ltx.getManagerID()); } }
/** * Find a lease entry, throw exception if not found or expired normally */ private Entry findEntry(Lease lease) throws UnknownLeaseException { Entry e = findEntryDo(lease); if (e != null && (e.renew < e.endTime || SystemTime.timeMillis() < e.endTime)) { return e; } throw new UnknownLeaseException(); }
private void verifyLeaseUuid(Uuid uuid) throws UnknownLeaseException { /* * Note: Lease Uuid contains * - Most Sig => the least sig bits of topUuid * - Least Sig => the txn id */ // Check to if this server granted the resource if (uuid.getMostSignificantBits() != topUuid.getLeastSignificantBits()) { throw new UnknownLeaseException(); } }
private long renewEventLeaseInt(long eventID, Uuid leaseID, long renewDuration, long now) throws UnknownLeaseException { if (renewDuration == Lease.ANY) renewDuration = maxEventLease; else if (renewDuration < 0) throw new IllegalArgumentException("negative lease duration"); EventReg reg = (EventReg) eventByID.get(new Long(eventID)); if (reg == null || !reg.leaseID.equals(leaseID) || reg.leaseExpiration <= now) throw new UnknownLeaseException(); if (renewDuration > maxEventLease && renewDuration > reg.leaseExpiration - now) renewDuration = Math.max(reg.leaseExpiration - now, maxEventLease); long renewExpiration = now + renewDuration; /* force a re-sort: must remove before changing, then reinsert */ eventByTime.remove(reg); reg.leaseExpiration = renewExpiration; eventByTime.put(reg, reg); /* see if the expire thread needs to wake up earlier */ if (renewExpiration < minEventExpiration) { minEventExpiration = renewExpiration; concurrentObj.waiterNotify(eventNotifier); } return renewExpiration; }
|| ( !(regInfo.leaseID).equals(leaseID) ) || (regInfo.leaseExpiration <= curTime) ) { throw new UnknownLeaseException();
final EventReg reg = eventByID.get(eventID); if (reg == null) throw new UnknownLeaseException("trying to renew unknown lease, event id: " + eventID); if (!reg.leaseID.equals(leaseID)) throw new UnknownLeaseException("Lease id: " + leaseID + " does not match event: " + eventID + " lease id: " + reg.leaseID); if (reg.leaseExpiration <= now) throw new UnknownLeaseException("Lease id: " + leaseID + " for event: " + eventID + " already expired"); synchronized (reg) {
!reg.leaseID.equals(leaseID) || reg.leaseExpiration <= now) throw new UnknownLeaseException(); if (renewDuration > maxServiceLease && renewDuration > reg.leaseExpiration - now)
/** * The code that does the real work of cancelServiceLease. */ private void cancelServiceLeaseDo(ServiceID serviceID, Uuid leaseID) throws UnknownLeaseException { if (serviceID.equals(myServiceID)) throw new SecurityException("privileged service id"); long now = SystemTime.timeMillis(); SvcReg reg = serviceByID.get(serviceID); if (reg == null || !reg.leaseID.equals(leaseID) || reg.leaseExpiration <= now) throw new UnknownLeaseException(); deleteService(null, reg, now); }
/** * The code that does the real work of cancelServiceLease. */ private void cancelServiceLeaseDo(ServiceID serviceID, Uuid leaseID) throws UnknownLeaseException { if (serviceID.equals(myServiceID)) throw new SecurityException("privileged service id"); long now = System.currentTimeMillis(); SvcReg reg = (SvcReg) serviceByID.get(serviceID); if (reg == null || !reg.leaseID.equals(leaseID) || reg.leaseExpiration <= now) throw new UnknownLeaseException(); deleteService(reg, now); /* wake up thread if this might be the (only) earliest time */ if (reg.leaseExpiration == minSvcExpiration) concurrentObj.waiterNotify(serviceNotifier); }
!reg.leaseID.equals(leaseID) || reg.leaseExpiration <= now) { throw new UnknownLeaseException();
@Override public void renew(long duration) throws LeaseDeniedException, UnknownLeaseException, RemoteException { synchronized (_lock) { if (_cancelled) throw new UnknownLeaseException("Lease is already cancelled"); if (duration < 0) return; if (duration == Lease.FOREVER) { if (_currentTask != null) { _currentTask.stop(10, TimeUnit.MILLISECONDS); _currentTask = null; } updateLeaseAndExpiration(Lease.FOREVER); return; } restartLeaseExpirationReaper(duration); } }
"Lease for {0} was NOT renewed", cookie); throw new UnknownLeaseException("Not managing requested lease");
throw new UnknownLeaseException("Not managing requested lease");