From: František Dvořák Date: Wed, 4 Dec 2013 08:25:29 +0000 (+0100) Subject: Preparations for pools, public write support from the pool. X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=f29a790392a81cad89e0eecbf6e1f4f1c64989f8;p=dmlite-plugins-vfs.git Preparations for pools, public write support from the pool. --- diff --git a/src/VfsDriver.cpp b/src/VfsDriver.cpp index 25700ba..e562db6 100644 --- a/src/VfsDriver.cpp +++ b/src/VfsDriver.cpp @@ -156,7 +156,7 @@ uint64_t VfsPoolHandler::getFreeSpace(void) throw (DmException) bool VfsPoolHandler::poolIsAvailable(bool write = true) throw (DmException) { - return !write; + return true; } @@ -164,8 +164,10 @@ bool VfsPoolHandler::poolIsAvailable(bool write = true) throw (DmException) bool VfsPoolHandler::replicaIsAvailable(const Replica& replica) throw (DmException) { struct stat fstat; - - return stat(getLocalPath(replica.rfn).c_str(), &fstat) == 0; + Url rloc(replica.rfn); + + debug("replica.rfn='%s'", replica.rfn.c_str()); + return stat(getLocalPath(rloc.path).c_str(), &fstat) == 0; } @@ -174,18 +176,17 @@ Location VfsPoolHandler::whereToRead(const Replica& replica) throw (DmException) { struct stat fstat; std::string path; + Url rloc(replica.rfn); + Chunk single; - if (replica.rfn.empty() || replica.rfn[0] != '/') path = "/" + replica.rfn; - else path = replica.rfn; + if (rloc.path.empty() || rloc.path[0] != '/') path = "/" + rloc.path; + else path = rloc.path; + debug("replica.rfn='%s'", replica.rfn.c_str()); wrapCall(stat(getLocalPath(path).c_str(), &fstat), "could not find '%s'", path.c_str()); - Url rloc(path); - - Chunk single; - - single.url.domain = this->driver_->hostName_; - single.url.path = "/vfs" + rloc.path; + single.url.domain = this->driver_->hostName_; // TODO: from rloc.domain + single.url.path = "/vfs" + path; single.offset = 0; single.size = fstat.st_size; @@ -242,6 +243,7 @@ Location VfsPoolHandler::whereToWrite(const std::string& sfn) throw (DmException void VfsPoolHandler::doneWriting(const Location& loc) throw (DmException) { + debug("%s:%s", loc[0].url.domain.c_str(), loc[0].url.path.c_str()); } diff --git a/src/VfsPool.cpp b/src/VfsPool.cpp index 4682d7f..785f0e0 100644 --- a/src/VfsPool.cpp +++ b/src/VfsPool.cpp @@ -135,6 +135,23 @@ Location VfsPoolManager::whereToRead(const std::string& path) throw (DmException // PoolHandler* handler = this->stack_->getPoolDriver(pool.type)->createPoolHandler(pool.name); // if (handler->replicaIsAvailable(replicas[i])) ... // ... + +#if 0 + std::vector replicas; + Pool pool; + size_t i; + + replicas = this->stack_->getCatalog()->getReplicas(path); + pool = this->getPool("vfs"); + handler = this->stack_->getPoolDriver(pool.type)->createPoolHandler(pool.name); + for (i = 0; i < replicas.size(); i++) { + if (replicas[i].getString("pool") != std::string("vfs")) continue; + if (handler->replicaIsAvailable(replicas[i])) { + location = handler->whereToRead(replicas[i]); + } + } +#endif + // // We create a stub replica instead. //