/** * 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(); }
/** * 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; }
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); } }
!reg.leaseID.equals(leaseID) || reg.leaseExpiration <= now) throw new UnknownLeaseException(); Item pre = (Item) reg.item.clone(); EntryRep[] sets = reg.item.attributeSets;
@Override public void cancel(Uuid cookie) throws UnknownLeaseException { ready.check(); final LeaseSet set = (LeaseSet) setTable.get(cookie); if (set == null) throw new UnknownLeaseException("No lease for cookie:" + cookie); try { store.acquireMutatorLock(); synchronized (set) { if (!isCurrent(set)) { //Someone else beat us to it, just return return; } removeSet(set); } } finally { store.releaseMutatorLock(); } }
/** * The code that does the real work of setAttributes. Replace all attributes of item with * attrSets, updating serviceByAttr as necessary, incrementing the number of EntryClass * instances, and updating entryClasses as necessary. */ private void setAttributesDo(ServiceID serviceID, Uuid leaseID, EntryRep[] attrSets) throws UnknownLeaseException { if (attrSets == null) attrSets = emptyAttrs; else attrSets = (EntryRep[]) removeDups(attrSets); long now = System.currentTimeMillis(); SvcReg reg = (SvcReg) serviceByID.get(serviceID); if (reg == null || !reg.leaseID.equals(leaseID) || reg.leaseExpiration <= now) throw new UnknownLeaseException(); Item pre = (Item) reg.item.clone(); EntryRep[] entries = reg.item.attributeSets; for (int i = entries.length; --i >= 0; ) { deleteAttrs(reg, entries[i], false); } reg.item.attributeSets = attrSets; for (int i = attrSets.length; --i >= 0; ) { addAttrs(reg, attrSets[i]); } generateEvents(pre, reg.item, now); }
!reg.leaseID.equals(leaseID) || reg.leaseExpiration <= now) throw new UnknownLeaseException(); Item pre = (Item) reg.item.clone(); EntryRep[] sets = reg.item.attributeSets;
final LeaseSet set = (LeaseSet) setTable.get(cookie); if (set == null) throw new UnknownLeaseException("No lease for cookie:" + cookie); try { store.acquireMutatorLock(); if (!isCurrent(set)) { throw new UnknownLeaseException( "Lease has already expired");
/** * The code that does the real work of setAttributes. Replace all attributes of item with * attrSets, updating serviceByAttr as necessary, incrementing the number of EntryClass * instances, and updating entryClasses as necessary. */ private void setAttributesDo(ServiceID serviceID, Uuid leaseID, EntryRep[] attrSets) throws UnknownLeaseException { if (attrSets == null) attrSets = emptyAttrs; else attrSets = (EntryRep[]) removeDups(attrSets); long now = SystemTime.timeMillis(); SvcReg reg = serviceByID.get(serviceID); if (reg == null || !reg.leaseID.equals(leaseID) || reg.leaseExpiration <= now) throw new UnknownLeaseException(); Item pre = (Item) reg.item.clone(); EntryRep[] entries = reg.item.attributeSets; for (int i = entries.length; --i >= 0; ) { deleteAttrs(reg, entries[i], false); } reg.item.attributeSets = attrSets; for (int i = attrSets.length; --i >= 0; ) { addAttrs(reg, attrSets[i]); } refreshServiceFromLookupCache(reg.item, false); generateEvents(pre, reg.item, now); }