From 43ef04d7070afc7fb44216b7d664dd61a5fe6697 Mon Sep 17 00:00:00 2001 From: JesusMtnez Date: Thu, 9 Mar 2017 11:48:06 +0100 Subject: [PATCH] Move locks to global directory 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. --- .../impl/ZookeeperRepositoryWithTransactionsComponent.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/stratio/common/utils/components/transaction_manager/impl/ZookeeperRepositoryWithTransactionsComponent.scala b/src/main/scala/com/stratio/common/utils/components/transaction_manager/impl/ZookeeperRepositoryWithTransactionsComponent.scala index 20a974b..c8d5e53 100644 --- a/src/main/scala/com/stratio/common/utils/components/transaction_manager/impl/ZookeeperRepositoryWithTransactionsComponent.scala +++ b/src/main/scala/com/stratio/common/utils/components/transaction_manager/impl/ZookeeperRepositoryWithTransactionsComponent.scala @@ -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 { @@ -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](