Skip to content

Commit

Permalink
Cassandra based distributed locking mechanism # 741
Browse files Browse the repository at this point in the history
- Cassandra tables called lock and lock_priority,
 to manage task execution and synchronization across
 multiple nodes.
  • Loading branch information
sajid riaz committed Nov 6, 2024
1 parent 93634aa commit 71d8b33
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Version 1.0.0 (Not yet Released)

* Cassandra-Based Distributed Locks #741
* Investigate Creation of RepairScheduler and ScheduleManager #714
* Implement ScheduledJobQueue for Prioritized Job Management and Execution - Issue #740
* Implement RepairGroup Class for Managing and Executing Repair Tasks - Issue #738
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.Row;
import com.ericsson.bss.cassandra.ecchronos.core.utils.LockException;
import com.ericsson.bss.cassandra.ecchronos.utils.exceptions.LockException;

/**
* Represents a container for builder configurations and state for the CASLock.
Expand Down Expand Up @@ -213,5 +213,4 @@ int getFailedAttempts()
{
return myFailedUpdateAttempts.get();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import com.datastax.oss.driver.api.core.metadata.TokenMap;
import com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata;
import com.datastax.oss.driver.api.core.metadata.schema.TableMetadata;
import com.ericsson.bss.cassandra.ecchronos.core.utils.LockException;
import com.ericsson.bss.cassandra.ecchronos.core.locks.HostStates;
import com.ericsson.bss.cassandra.ecchronos.core.locks.LockFactory;
import com.ericsson.bss.cassandra.ecchronos.utils.exceptions.LockException;
import com.ericsson.bss.cassandra.ecchronos.core.locks.HostStates;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.slf4j.Logger;
Expand Down Expand Up @@ -140,9 +140,9 @@ private int getDefaultTimeToLiveFromLockTable()

@Override
public DistributedLock tryLock(final String dataCenter,
final String resource,
final int priority,
final Map<String, String> metadata)
final String resource,
final int priority,
final Map<String, String> metadata)
throws LockException
{
return myCasLockFactoryCacheContext.getLockCache()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
package com.ericsson.bss.cassandra.ecchronos.core.impl.locks;

import static com.ericsson.bss.cassandra.ecchronos.core.locks.LockFactory.DistributedLock;

import com.ericsson.bss.cassandra.ecchronos.core.utils.LockException;
import com.ericsson.bss.cassandra.ecchronos.utils.exceptions.LockException;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
* Contains utilities classes.
*/
package com.ericsson.bss.cassandra.ecchronos.core.impl.utils;

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.ericsson.bss.cassandra.ecchronos.core.impl.utils.ConsistencyType;
import com.ericsson.bss.cassandra.ecchronos.core.locks.HostStates;
import com.ericsson.bss.cassandra.ecchronos.core.locks.LockFactory;
import com.ericsson.bss.cassandra.ecchronos.utils.exceptions.LockException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -69,8 +70,6 @@
import org.junit.Before;
import org.junit.Test;

import com.ericsson.bss.cassandra.ecchronos.core.utils.LockException;

import net.jcip.annotations.NotThreadSafe;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
package com.ericsson.bss.cassandra.ecchronos.core.impl.locks;

import com.ericsson.bss.cassandra.ecchronos.core.utils.LockException;
import com.ericsson.bss.cassandra.ecchronos.utils.exceptions.LockException;
import com.ericsson.bss.cassandra.ecchronos.core.locks.LockFactory.DistributedLock;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Before;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import java.io.Closeable;
import java.util.Map;
import java.util.Optional;

import com.ericsson.bss.cassandra.ecchronos.core.utils.LockException;
import com.ericsson.bss.cassandra.ecchronos.utils.exceptions.LockException;

/**
* Interface for distributed lock factories.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ericsson.bss.cassandra.ecchronos.core.utils;
package com.ericsson.bss.cassandra.ecchronos.utils.exceptions;

/**
* Exception thrown when a lock factory is unable to get a lock.
Expand Down

0 comments on commit 71d8b33

Please sign in to comment.