Preparations for pools, public write support from the pool.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 4 Dec 2013 08:25:29 +0000 (09:25 +0100)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Sun, 23 Feb 2014 00:42:28 +0000 (01:42 +0100)
src/VfsDriver.cpp
src/VfsPool.cpp

index 25700ba..e562db6 100644 (file)
@@ -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());
 }
 
 
index 4682d7f..785f0e0 100644 (file)
@@ -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<Replica> 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.
   //