Skip to content

Commit

Permalink
Move locks to global directory
Browse files Browse the repository at this point in the history
Leaving the locks in a directory under entity's directory caused an
error when retrieving all directories for an entity, because locks
appeared as an empty entity.

TODO: Improve locks directory under stratio directory, not globally.
  • Loading branch information
JesusMtnez authored and pfcoperez committed Mar 10, 2017
1 parent c922f2e commit 43ef04d
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ trait ZookeeperRepositoryWithTransactionsComponent extends ZookeeperRepositoryCo

override val repository: ZookeeperRepositoryWithTransactions = new ZookeeperRepositoryWithTransactions(None)

//TODO Improve paths and locksPath behaviour
class ZookeeperRepositoryWithTransactions(path: Option[String] = None) extends ZookeeperRepository(path)
with TransactionalRepository {

//TODO: Improve path option usage
private def acquisitionResource: String = "/" + path.map(_ + "/").getOrElse("") + "locks"
private def acquisitionResource: String = "/locks" + path.map("/" + _).getOrElse("")

private object AcquiredLocks {

Expand Down Expand Up @@ -72,7 +73,7 @@ trait ZookeeperRepositoryWithTransactionsComponent extends ZookeeperRepositoryCo
}

private def lockPath(entity: String)(resource: TransactionResource): String = {
s"/$entity/locks/${resource.id}"
s"/locks/$entity/${resource.id}"
}

override def atomically[T](
Expand Down

0 comments on commit 43ef04d

Please sign in to comment.