Generation createGeneration() throws BundleException { synchronized (this.infoMonitor) { if (generationLocks == null) { generationLocks = new LockSet<>(); } boolean lockedID; try { lockedID = generationLocks.tryLock(nextGenerationId, 5, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new BundleException("Failed to obtain id locks for generation.", BundleException.STATECHANGE_ERROR, e); //$NON-NLS-1$ } if (!lockedID) { throw new BundleException("Failed to obtain id locks for generation.", BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ } Generation newGeneration = new Generation(nextGenerationId++); return newGeneration; } }
void unlockGeneration(Generation generation) { synchronized (this.infoMonitor) { if (generationLocks == null) { throw new IllegalStateException("The generation id was not locked."); //$NON-NLS-1$ } generationLocks.unlock(generation.getGenerationId()); } }
locationLocked = locationLocks.tryLock(location, 5, TimeUnit.SECONDS); nameLocked = name != null && nameLocks.tryLock(name, 5, TimeUnit.SECONDS); if (!locationLocked) { throw new BundleException("Failed to obtain location lock for installation: " + location, BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ } finally { if (locationLocked) locationLocks.unlock(location); if (nameLocked) nameLocks.unlock(name);
private Long getNextRootID() throws BundleException { // Try up to 500 times for (int i = 0; i < 500; i++) { moduleDatabase.readLock(); try { Long nextID = moduleDatabase.getNextId(); try { if (idLocks.tryLock(nextID, 0, TimeUnit.SECONDS)) { return nextID; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new BundleException("Failed to obtain id locks for installation.", BundleException.STATECHANGE_ERROR, e); //$NON-NLS-1$ } } finally { moduleDatabase.readUnlock(); } // sleep to allow another thread to get the database lock try { Thread.sleep(50); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } throw new BundleException("Failed to obtain id locks for installation.", BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ }
locationLocked = locationLocks.tryLock(location, 5, TimeUnit.SECONDS); nameLocked = name != null && nameLocks.tryLock(name, 5, TimeUnit.SECONDS); if (!locationLocked) { throw new BundleException("Failed to obtain location lock for installation: " + location, BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ } finally { if (locationLocked) locationLocks.unlock(location); if (nameLocked) nameLocks.unlock(name);
private Long getNextRootID() throws BundleException { // Try up to 500 times for (int i = 0; i < 500; i++) { moduleDatabase.readLock(); try { Long nextID = moduleDatabase.getNextId(); try { if (idLocks.tryLock(nextID, 0, TimeUnit.SECONDS)) { return nextID; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new BundleException("Failed to obtain id locks for installation.", BundleException.STATECHANGE_ERROR, e); //$NON-NLS-1$ } } finally { moduleDatabase.readUnlock(); } // sleep to allow another thread to get the database lock try { Thread.sleep(10); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } throw new BundleException("Failed to obtain id locks for installation.", BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ }
locationLocked = locationLocks.tryLock(location, 5, TimeUnit.SECONDS); nameLocked = name != null && nameLocks.tryLock(name, 5, TimeUnit.SECONDS); if (!locationLocked) { throw new BundleException("Failed to obtain location lock for installation: " + location, BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ } finally { if (locationLocked) locationLocks.unlock(location); if (nameLocked) nameLocks.unlock(name);
Generation createGeneration() throws BundleException { synchronized (this.infoMonitor) { if (generationLocks == null) { generationLocks = new LockSet<Long>(); } boolean lockedID; try { lockedID = generationLocks.tryLock(nextGenerationId, 5, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new BundleException("Failed to obtain id locks for generation.", BundleException.STATECHANGE_ERROR, e); //$NON-NLS-1$ } if (!lockedID) { throw new BundleException("Failed to obtain id locks for generation.", BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ } Generation newGeneration = new Generation(nextGenerationId++); return newGeneration; } }
void unlockGeneration(Generation generation) { synchronized (this.infoMonitor) { if (generationLocks == null) { throw new IllegalStateException("The generation id was not locked."); //$NON-NLS-1$ } generationLocks.unlock(generation.getGenerationId()); } }
private Long getNextRootID() throws BundleException { // Try up to 500 times for (int i = 0; i < 500; i++) { moduleDatabase.readLock(); try { Long nextID = moduleDatabase.getNextId(); try { if (idLocks.tryLock(nextID, 0, TimeUnit.SECONDS)) { return nextID; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new BundleException("Failed to obtain id locks for installation.", BundleException.STATECHANGE_ERROR, e); //$NON-NLS-1$ } } finally { moduleDatabase.readUnlock(); } // sleep to allow another thread to get the database lock try { Thread.sleep(50); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } throw new BundleException("Failed to obtain id locks for installation.", BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ }
locationLocked = locationLocks.tryLock(location, 5, TimeUnit.SECONDS); nameLocked = name != null && nameLocks.tryLock(name, 5, TimeUnit.SECONDS); if (!locationLocked) { throw new BundleException("Failed to obtain location lock for installation: " + location, BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ } finally { if (locationLocked) locationLocks.unlock(location); if (nameLocked) nameLocks.unlock(name);
Generation createGeneration() throws BundleException { synchronized (this.infoMonitor) { if (generationLocks == null) { generationLocks = new LockSet<Long>(); } boolean lockedID; try { lockedID = generationLocks.tryLock(nextGenerationId, 5, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new BundleException("Failed to obtain id locks for generation.", BundleException.STATECHANGE_ERROR, e); //$NON-NLS-1$ } if (!lockedID) { throw new BundleException("Failed to obtain id locks for generation.", BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ } Generation newGeneration = new Generation(nextGenerationId++); return newGeneration; } }
void unlockGeneration(Generation generation) { synchronized (this.infoMonitor) { if (generationLocks == null) { throw new IllegalStateException("The generation id was not locked."); //$NON-NLS-1$ } generationLocks.unlock(generation.getGenerationId()); } }
private Long getNextRootID() throws BundleException { // Try up to 500 times for (int i = 0; i < 500; i++) { moduleDatabase.readLock(); try { Long nextID = moduleDatabase.getNextId(); try { if (idLocks.tryLock(nextID, 0, TimeUnit.SECONDS)) { return nextID; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new BundleException("Failed to obtain id locks for installation.", BundleException.STATECHANGE_ERROR, e); //$NON-NLS-1$ } } finally { moduleDatabase.readUnlock(); } // sleep to allow another thread to get the database lock try { Thread.sleep(50); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } throw new BundleException("Failed to obtain id locks for installation.", BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ }
locationLocked = locationLocks.tryLock(location, 5, TimeUnit.SECONDS); nameLocked = name != null && nameLocks.tryLock(name, 5, TimeUnit.SECONDS); if (!locationLocked) { throw new BundleException("Failed to obtain location lock for installation: " + location, BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ } finally { if (locationLocked) locationLocks.unlock(location); if (nameLocked) nameLocks.unlock(name);
Generation createGeneration() throws BundleException { synchronized (this.infoMonitor) { if (generationLocks == null) { generationLocks = new LockSet<Long>(); } boolean lockedID; try { lockedID = generationLocks.tryLock(nextGenerationId, 5, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new BundleException("Failed to obtain id locks for generation.", BundleException.STATECHANGE_ERROR, e); //$NON-NLS-1$ } if (!lockedID) { throw new BundleException("Failed to obtain id locks for generation.", BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ } Generation newGeneration = new Generation(nextGenerationId++); return newGeneration; } }
void unlockGeneration(Generation generation) { synchronized (this.infoMonitor) { if (generationLocks == null) { throw new IllegalStateException("The generation id was not locked."); //$NON-NLS-1$ } generationLocks.unlock(generation.getGenerationId()); } }
locationLocked = locationLocks.tryLock(location, 5, TimeUnit.SECONDS); nameLocked = name != null && nameLocks.tryLock(name, 5, TimeUnit.SECONDS); if (!locationLocked) { throw new BundleException("Failed to obtain location lock for installation: " + location, BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ } finally { if (locationLocked) locationLocks.unlock(location); if (nameLocked) nameLocks.unlock(name);
Generation createGeneration() throws BundleException { synchronized (this.infoMonitor) { if (generationLocks == null) { generationLocks = new LockSet<Long>(); } boolean lockedID; try { lockedID = generationLocks.tryLock(nextGenerationId, 5, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new BundleException("Failed to obtain id locks for generation.", BundleException.STATECHANGE_ERROR, e); //$NON-NLS-1$ } if (!lockedID) { throw new BundleException("Failed to obtain id locks for generation.", BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ } Generation newGeneration = new Generation(nextGenerationId++); return newGeneration; } }
void unlockGeneration(Generation generation) { synchronized (this.infoMonitor) { if (generationLocks == null) { throw new IllegalStateException("The generation id was not locked."); //$NON-NLS-1$ } generationLocks.unlock(generation.getGenerationId()); } }