Skip to content

Commit

Permalink
Fix javadoc formatting broken by previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
aaime committed Apr 8, 2024
1 parent c545cf2 commit cdc84de
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@
*/
package org.geowebcache.locks;

import org.geotools.util.logging.Logging;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.geotools.util.logging.Logging;

/**
* An in memory lock provider.
* <p>
* This provider does not constrain the number of locks that can be held at any given time.
* Because any one thread can hold multiple locks at a time, a more appropriate approach
* to constraining resource usage would be to limit the number of concurrent threads instead.
* <p>
* One objective of this class is to <a href="https://github.com/GeoWebCache/geowebcache/issues/1226">support
* nested locking scenarios</a>. This class used to use a striped lock algorithm which
* would cause deadlocks for nested locking because of the non-predictable manner in
* which any lock can be arbitrarily locked by another unrelated lock. An example use case of
* nested locks, in pseudocode, would be:
*
* <p>This provider does not constrain the number of locks that can be held at any given time.
* Because any one thread can hold multiple locks at a time, a more appropriate approach to
* constraining resource usage would be to limit the number of concurrent threads instead.
*
* <p>One objective of this class is to <a
* href="https://github.com/GeoWebCache/geowebcache/issues/1226">support nested locking
* scenarios</a>. This class used to use a striped lock algorithm which would cause deadlocks for
* nested locking because of the non-predictable manner in which any lock can be arbitrarily locked
* by another unrelated lock. An example use case of nested locks, in pseudocode, would be:
*
* <pre>
* lock(metatile);
* try {
Expand All @@ -54,7 +54,7 @@
*/
public class MemoryLockProvider implements LockProvider {

private final static Logger LOGGER = Logging.getLogger(MemoryLockProvider.class.getName());
private static final Logger LOGGER = Logging.getLogger(MemoryLockProvider.class.getName());

ConcurrentHashMap<String, LockAndCounter> lockAndCounters = new ConcurrentHashMap<>();

Expand Down Expand Up @@ -93,8 +93,10 @@ public void release() {
// Attempt to remove lock if no other thread is waiting for it
if (lockAndCounter.counter.decrementAndGet() == 0) {

// Try to remove the lock, but we have to check the count AGAIN inside of "compute"
// so that we know it hasn't been incremented since the if-statement above was evaluated
// Try to remove the lock, but we have to check the count AGAIN inside of
// "compute"
// so that we know it hasn't been incremented since the if-statement above
// was evaluated
lockAndCounters.compute(
lockKey,
(key, existingLockAndCounter) -> {
Expand All @@ -113,8 +115,8 @@ public void release() {
}

/**
* A ReentrantLock with a counter to track how many threads are waiting on this lock
* so we know if it's safe to remove it during a release.
* A ReentrantLock with a counter to track how many threads are waiting on this lock so we know
* if it's safe to remove it during a release.
*/
private static class LockAndCounter {
private final java.util.concurrent.locks.Lock lock = new ReentrantLock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@
/** See BlobStore interface description for details */
public class FileBlobStore implements BlobStore {

interface Writer {
/**
* Interface for writing files. This is used to abstract the writing of files to allow different
* types of file writes, while keeping the same general machinery (write on temp file, rename to
* final file).
*/
interface FileWriter {
void write(File file) throws IOException;
}

Expand Down Expand Up @@ -606,7 +611,8 @@ private void writeTile(File target, TileObject stObj, boolean existed) throws St
*
* @throws StorageException
*/
private void writeFile(File target, boolean existed, Writer writer) throws StorageException {
private void writeFile(File target, boolean existed, FileWriter writer)
throws StorageException {
// first write to temp file
tmp.mkdirs();
File temp = new File(tmp, tmpGenerator.newName());
Expand Down

0 comments on commit cdc84de

Please sign in to comment.