cstamas commented on a change in pull request #77:
URL: https://github.com/apache/maven-resolver/pull/77#discussion_r605522828



##########
File path: 
maven-resolver-named-locks/src/main/java/org/eclipse/aether/named/support/NamedLockFactorySupport.java
##########
@@ -0,0 +1,88 @@
+package org.eclipse.aether.named.support;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.eclipse.aether.named.NamedLockFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Support class for {@link NamedLockFactory} implementations providing 
reference counting.
+ *
+ * @param <L> the actual implementation, subclass of {@link NamedLockSupport}.
+ */
+public abstract class NamedLockFactorySupport<L extends NamedLockSupport>
+    implements NamedLockFactory
+{
+  protected final Logger log = LoggerFactory.getLogger( getClass() );
+
+  private final ConcurrentHashMap<String, L> locks;

Review comment:
       This is a local variable.

##########
File path: 
maven-resolver-named-locks/src/main/java/org/eclipse/aether/named/providers/FileLockNamedLock.java
##########
@@ -0,0 +1,171 @@
+package org.eclipse.aether.named.providers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
+import java.util.ArrayDeque;
+import java.util.Collection;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.aether.named.support.NamedLockSupport;
+
+/**
+ * Named lock that uses {@link FileLock}.
+ */
+public final class FileLockNamedLock
+    extends NamedLockSupport
+{
+    private static final long LOCK_POSITION = 0L;
+
+    private static final long LOCK_SIZE = 1L;
+
+    private final HashMap<Thread, Deque<FileLock>> threadSteps;

Review comment:
       This is a local variable.

##########
File path: 
maven-resolver-named-locks-redisson/src/main/java/org/eclipse/aether/named/redisson/RedissonSemaphoreNamedLockFactory.java
##########
@@ -0,0 +1,69 @@
+package org.eclipse.aether.named.redisson;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.eclipse.aether.named.support.AdaptedSemaphoreNamedLock;
+import org.redisson.api.RSemaphore;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Provider of {@link RedissonSemaphoreNamedLockFactory} using Redisson and 
{@link org.redisson.api.RSemaphore}.
+ */
+@Singleton
+@Named( RedissonSemaphoreNamedLockFactory.NAME )
+public class RedissonSemaphoreNamedLockFactory
+    extends RedissonNamedLockFactorySupport<AdaptedSemaphoreNamedLock>
+{
+  public static final String NAME = "semaphore-redisson";
+
+  @Override
+  protected AdaptedSemaphoreNamedLock createLock( final String name )
+  {
+    return new AdaptedSemaphoreNamedLock(
+            name, this, new RedissonSemaphore( redissonClient.getSemaphore( 
NAME_PREFIX + name ) )
+    );
+  }
+
+  private static final class RedissonSemaphore implements 
AdaptedSemaphoreNamedLock.AdaptedSemaphore
+  {
+    private final RSemaphore semaphore;
+
+    private RedissonSemaphore( final RSemaphore semaphore )
+    {
+      semaphore.addPermits( Integer.MAX_VALUE );
+      this.semaphore = semaphore;
+    }
+
+    @Override
+    public boolean tryAcquire( final int perms, final long time, final 
TimeUnit unit ) throws InterruptedException

Review comment:
       fixed

##########
File path: 
maven-resolver-named-locks-redisson/src/main/java/org/eclipse/aether/named/redisson/RedissonReadWriteLockNamedLockFactory.java
##########
@@ -0,0 +1,50 @@
+package org.eclipse.aether.named.redisson;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.eclipse.aether.named.support.AdaptedReadWriteLockNamedLock;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+/**
+ * Provider of {@link RedissonReadWriteLockNamedLockFactory} using Redisson 
and {@link org.redisson.api.RReadWriteLock}.
+ */
+@Singleton
+@Named( RedissonReadWriteLockNamedLockFactory.NAME )
+public class RedissonReadWriteLockNamedLockFactory
+    extends RedissonNamedLockFactorySupport<AdaptedReadWriteLockNamedLock>
+{
+  public static final String NAME = "rwlock-redisson";
+
+  private static final String NAME_PREFIX = "maven:resolver:";

Review comment:
       fixed, this was a mistake.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to