Commit 2f746d5d authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Implementing creation of base path for mock name server

parent c2a83282
......@@ -381,6 +381,20 @@ Create the \texttt{/eos} directory within the EOS namespace, map it to the EOS
sudo eos attr -r set sys.forced.nstripes="1" /eos
\end{verbatim}
\section{Create the mock nameserver base directory}
We can do this by running the executable:
\begin{verbatim}
$ <cta_build_dir>/nameserver/makeMockNameServerBasePath
\end{verbatim}
This command will return the newly created path to the mock nameserver base directory. Now we give it full permissions:
\begin{verbatim}
$ chmod -R 0777 <result_dir_of_previous_cmd>
\end{verbatim}
Now we need to add it as a configuration parameter in the \texttt{castor.conf}, as in the following example:
\begin{verbatim}
TapeServer MockNameServerPath /tmp/CTAMockNS9r236q
\end{verbatim}
\section{Set up the objectstore VFS backend}
First we create the new objectstore VFS backend using a simple executable:
\begin{verbatim}
......
......@@ -23,3 +23,6 @@ add_library (ctanameserverunittests SHARED
target_link_libraries(ctanameserverunittests
ctanameserver)
add_executable(makeMockNameServerBasePath mockNS/makeMockNameServerBasePath.cpp)
target_link_libraries(makeMockNameServerBasePath ctacommon)
\ No newline at end of file
......@@ -304,6 +304,15 @@ cta::MockNameServer::MockNameServer(): m_fileIdCounter(0) {
setOwner(initialRequester, "/", initialOwner);
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::MockNameServer::MockNameServer(const std::string &path): m_fileIdCounter(0) {
Utils::assertAbsolutePathSyntax(path);
assertFsDirExists(path);
m_fsDir = path;
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
......
......@@ -41,6 +41,13 @@ public:
* Constructor.
*/
MockNameServer();
/**
* Constructor for an already existing mock name server temporary directory
*
* @param path The already existing mock name server temporary directory
*/
MockNameServer(const std::string &path);
/**
* Destructor.
......
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* This program will create a new directory for the mock name server
*/
#include <iostream>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <attr/xattr.h>
#include "common/exception/Errnum.hpp"
#include "common/exception/Exception.hpp"
#include "common/Utils.hpp"
//------------------------------------------------------------------------------
// setXattr
//------------------------------------------------------------------------------
void setXattr(const std::string &path, const std::string &name, const std::string &value) {
if(setxattr(path.c_str(), name.c_str(), value.c_str(), value.length(), 0)) {
const int savedErrno = errno;
std::ostringstream msg;
msg << "Call to setxattr() failed: path=" << path << " name=" << name << " value=" << value << ": " << cta::Utils::errnoToString(savedErrno);
throw cta::exception::Exception(msg.str());
}
}
//------------------------------------------------------------------------------
// main
//------------------------------------------------------------------------------
int main(void) {
try {
umask(0);
char path[100];
strncpy(path, "/tmp/CTAMockNSXXXXXX", 100);
cta::exception::Errnum::throwOnNull(mkdtemp(path), "MockNameServer() - Failed to create temporary directory");
std::string pathString(path);
pathString+="/";
setXattr(pathString.c_str(), "user.CTAStorageClass", "");
setXattr(pathString.c_str(), "user.uid", "0");
setXattr(pathString.c_str(), "user.gid", "0");
std::cout << "New mock name server path: " << pathString << std::endl;
} catch (cta::exception::Exception & e) {
std::cerr << "Failed to create a new directory for the mock name server. CTA Exception: " << e.getMessageValue() << std::endl;
} catch (std::exception & e) {
std::cerr << "Failed to create a new directory for the mock name server. STD Exception: " << e.what() << std::endl;
} catch (...) {
std::cerr << "Failed to create a new directory for the mock name server. Unknown Exception!" << std::endl;
}
}
......@@ -651,6 +651,12 @@
# directory recursively readable and writable by stage:st.
#TapeServer ObjectStoreBackendPath /tmp/jobStoreVFS9r236q
# This is the location of the mock name server base path. If you want to create
# a local empty mock name server base dir you may use the
# makeMockNameServerBasePath binary (takes no argument), which returns the newly
# created path.
#TapeServer MockNameServerPath /tmp/CTAMockNS9r236q
## Tape Bridge Clients: dumptp, readtp and writetp #############################
# The inclusive low port of the tapebridge client callback port number range.
......
......@@ -255,6 +255,7 @@ void XrdProFilesystem::EnvInfo(XrdOucEnv *envP)
// constructor
//------------------------------------------------------------------------------
XrdProFilesystem::XrdProFilesystem():
m_ns(castor::common::CastorConfiguration::getConfig().getConfEntString("TapeServer", "MockNameServerPath")),
m_remoteStorage("localhost:1094"),
m_backend(castor::common::CastorConfiguration::getConfig().getConfEntString("TapeServer", "ObjectStoreBackendPath")),
m_backendPopulator(m_backend),
......
......@@ -62,7 +62,7 @@ protected:
/**
* The CTA nameserver
*/
cta::CastorNameServer m_ns;
cta::MockNameServer m_ns;
/**
* The remote file storage system (typically EOS)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment