Commit 1aed45f9 authored by Maiken's avatar Maiken

Merge branch 'dmc_external' into 'master'

Run Xroot DMC in separate process (fixes BUGZ-3830)

See merge request nordugrid/arc!810
parents 9cf886c1 f58ce8ac
......@@ -79,11 +79,13 @@ AC_SUBST([MKDIR_P])
pkgdatadir='${datadir}/arc'
pkgincludedir='${includedir}/arc'
pkglibdir='${libdir}/arc'
extpkglibdir='${libdir}/arc/external'
pkglibexecdir='${libexecdir}/arc'
AC_SUBST(pkgdatadir)
AC_SUBST(pkgincludedir)
AC_SUBST(pkglibdir)
AC_SUBST(extpkglibdir)
AC_SUBST(pkglibexecdir)
ARC_API
......
......@@ -22,6 +22,7 @@ debian/tmp/usr/lib/arc/arc-file-access
debian/tmp/usr/lib/arc/arc-hostname-resolver
debian/tmp/usr/lib/arc/DataStagingDelivery
debian/tmp/usr/lib/arc/arcconfig-parser
debian/tmp/usr/lib/arc/arc-dmc
debian/tmp/usr/lib/python?.?/site-packages/arc/__init__.py*
debian/tmp/usr/lib/python?.?/site-packages/arc/paths.py*
debian/tmp/usr/lib/python?.?/site-packages/arc/paths_dist.py*
......
debian/tmp/usr/lib/libarcglobusutils.so.*
debian/tmp/usr/lib/arc/libaccGRIDFTPJOB.so
debian/tmp/usr/lib/arc/libdmcgridftp.so
debian/tmp/usr/lib/arc/libdmcgridftpdeleg.so
debian/tmp/usr/lib/arc/libaccGRIDFTPJOB.apd
debian/tmp/usr/lib/arc/libdmcgridftp.apd
debian/tmp/usr/lib/arc/libdmcgridftpdeleg.apd
debian/tmp/usr/lib/arc/arc-lcas
debian/tmp/usr/lib/arc/arc-lcmaps
......
#include "../../../src/hed/libs/data/DataExternalComm.h"
#include "../../../src/hed/libs/data/DataExternalHelper.h"
#include "../../../src/hed/libs/data/DataPointDelegate.h"
......@@ -1094,6 +1094,7 @@ service arc-infosys-ldap condrestart > /dev/null 2>&1 || :
%{_libdir}/%{pkgdir}/arc-file-access
%{_libdir}/%{pkgdir}/arc-hostname-resolver
%{_libdir}/%{pkgdir}/DataStagingDelivery
%{_libdir}/%{pkgdir}/arc-dmc
%dir %{_libexecdir}/%{pkgdir}
%{_libexecdir}/%{pkgdir}/arcconfig-parser
%if %{py3default}
......@@ -1451,10 +1452,8 @@ service arc-infosys-ldap condrestart > /dev/null 2>&1 || :
%defattr(-,root,root,-)
%{_libdir}/%{pkgdir}/arc-dmcgridftp
%{_libdir}/%{pkgdir}/libaccGRIDFTPJOB.so
%{_libdir}/%{pkgdir}/libdmcgridftp.so
%{_libdir}/%{pkgdir}/libdmcgridftpdeleg.so
%{_libdir}/%{pkgdir}/libaccGRIDFTPJOB.apd
%{_libdir}/%{pkgdir}/libdmcgridftp.apd
%{_libdir}/%{pkgdir}/libdmcgridftpdeleg.apd
%{_libdir}/libarcglobusutils.so.*
%{_libexecdir}/%{pkgdir}/arc-lcas
......@@ -1463,8 +1462,10 @@ service arc-infosys-ldap condrestart > /dev/null 2>&1 || :
%if %{with_xrootd}
%files plugins-xrootd
%defattr(-,root,root,-)
%{_libdir}/%{pkgdir}/libdmcxrootd.so
%{_libdir}/%{pkgdir}/libdmcxrootd.apd
%{_libdir}/%{pkgdir}/external/libdmcxrootd.so
%{_libdir}/%{pkgdir}/external/libdmcxrootd.apd
%{_libdir}/%{pkgdir}/libdmcxrootddeleg.so
%{_libdir}/%{pkgdir}/libdmcxrootddeleg.apd
%endif
%if %{with_gfal}
......
......@@ -15,8 +15,8 @@ DIST_SUBDIRS = external doc hed libs tests services clients utils doxygen wn
# some autotools experts fix it.
if HED_ENABLED
install-exec-hook:
if test "x$(build_triplet)" = "x$(host_triplet)"; then env LD_LIBRARY_PATH=$(DESTDIR)$(libdir):$(LD_LIBRARY_PATH) $(top_builddir)/src/utils/hed/arcplugin$(EXEEXT) -c $(DESTDIR)$(pkglibdir) -c $(DESTDIR)$(pkglibdir)/test; else echo "No .apd files since we are cross-compiling"; fi
if test "x$(build_triplet)" = "x$(host_triplet)"; then env LD_LIBRARY_PATH=$(DESTDIR)$(libdir):$(LD_LIBRARY_PATH) $(top_builddir)/src/utils/hed/arcplugin$(EXEEXT) -c $(DESTDIR)$(pkglibdir) -c $(DESTDIR)$(pkglibdir)/test -c $(DESTDIR)$(pkglibdir)/external; else echo "No .apd files since we are cross-compiling"; fi
uninstall-local:
test "x$(build_triplet)" = "x$(host_triplet)" && rm -f $(DESTDIR)$(pkglibdir)/*.apd $(DESTDIR)$(pkglibdir)/test/*.apd
test "x$(build_triplet)" = "x$(host_triplet)" && rm -f $(DESTDIR)$(pkglibdir)/*.apd $(DESTDIR)$(pkglibdir)/test/*.apd $(DESTDIR)$(pkglibdir)/external/*.apd
endif
// -*- indent-tabs-mode: nil -*-
#include <arc/Run.h>
#include <arc/data/FileInfo.h>
#include <arc/data/DataStatus.h>
#include <arc/UserConfig.h>
namespace ArcDMCGridFTP {
extern char const ErrorTag;
extern char const DataStatusTag;
extern char const FileInfoTag;
extern char const DataChunkTag;
template<typename T> bool InEntry(std::istream& instream, T& entry) {
try {
instream>>entry;
return true;
} catch(std::exception const&) {
}
return false;
}
template<typename T> void OutEntry(Arc::Run& run, int timeout, T& entry) {
std::ostringstream ostream;
ostream<<entry;
std::string entry_str((std::ostringstream()<<entry).str());
run.WriteStdin(-1, entry_str.c_str(), entry_str.length());
}
char InTag(std::istream& instream);
char InTag(Arc::Run& run, int timeout);
bool OutTag(Arc::Run& run, int timeout, char tag);
bool OutEntry(std::ostream& outstream, Arc::FileInfo const& info);
bool InEntry(Arc::Run& run, int timeout, Arc::FileInfo& info);
bool OutEntry(std::ostream& outstream, Arc::DataStatus const& status);
bool InEntry(Arc::Run& run, int timeout, Arc::DataStatus& status);
bool OutEntry(Arc::Run& run, int timeout, Arc::UserConfig const& data);
bool InEntry(std::istream& instream, Arc::UserConfig& data);
class DataChunkExtBuffer {
public:
DataChunkExtBuffer();
bool complete() const { return (size_left == 0); }
bool write(Arc::Run& run, int timeout, void const* data, unsigned long long int offset, unsigned long long int size) const;
bool read(Arc::Run& run, int timeout, void* data, unsigned long long int& offset, unsigned long long int& size);
private:
DataChunkExtBuffer(DataChunkExtBuffer const&);
DataChunkExtBuffer& operator=(DataChunkExtBuffer const&);
unsigned long long int offset_left;
unsigned long long int size_left;
};
class DataChunkClient {
public:
DataChunkClient(); // empty
DataChunkClient(void* data, unsigned long long int offset, unsigned long long int size);
~DataChunkClient();
bool write(std::ostream& outstream) const;
bool read(std::istream& instream);
bool getEOF() const { return eof; }
void* get() const { return data; }
void* release() { data_allocated = false; return data; }
unsigned long long int getOffset() const { return offset; }
unsigned long long int getSize() const { return size; }
private:
char* data;
bool data_allocated;
unsigned long long int offset;
unsigned long long int size;
bool eof;
};
bool OutEntry(Arc::Run& run, int timeout, DataChunkExtBuffer const& data);
bool InEntry(Arc::Run& run, int timeout, DataChunkExtBuffer& data);
bool OutEntry(std::ostream& outstream, DataChunkClient const& data);
bool InEntry(std::istream& instream, DataChunkClient& data);
} // namespace ArcDMCGridFTP
......@@ -7,18 +7,15 @@
#include <string>
#include <arc/Thread.h>
#include <arc/data/DataPointDirect.h>
#include <arc/URL.h>
#include <arc/Run.h>
#include <arc/Utils.h>
//#include <arc/globusutils/GSSCredential.h>
#include <arc/data/DataPointDelegate.h>
namespace ArcDMCGridFTP {
using namespace Arc;
class Lister;
/**
* GridFTP is essentially the FTP protocol with GSI security. This class
* uses libraries from the Globus Toolkit. It can also be used for regular
......@@ -28,64 +25,15 @@ namespace ArcDMCGridFTP {
* class loads modules at runtime and should be used instead of this.
*/
class DataPointGridFTPDelegate
: public DataPointDirect {
private:
class LogRedirect: public Run::Data {
public:
LogRedirect(): level_(FATAL) { };
virtual ~LogRedirect() { Flush(); };
virtual void Append(char const* data, unsigned int size);
void Flush();
private:
// for sanity checks
static std::string::size_type const level_size_max_;
static std::string::size_type const buffer_size_max_;
LogLevel level_;
std::string buffer_;
};
static Logger logger;
LogRedirect log_redirect;
int ftp_threads;
bool autodir;
SimpleCondition cond;
bool reading;
bool writing;
Arc::CountedPointer<Run> ftp_run;
DataStatus data_status;
bool ftp_eof_flag;
static void ftp_read_thread(void *arg);
static void ftp_write_thread(void *arg);
DataStatus StartCommand(Arc::CountedPointer<Arc::Run>& run, std::list<std::string>& argv, DataBuffer& buf, DataStatus::DataStatusType errCode);
DataStatus StartCommand(Arc::CountedPointer<Arc::Run>& run, std::list<std::string>& argv, DataStatus::DataStatusType errCode);
DataStatus EndCommand(Arc::CountedPointer<Arc::Run>& run, DataStatus::DataStatusType errCode);
DataStatus EndCommand(Arc::CountedPointer<Arc::Run>& run, DataStatus::DataStatusType errCode, char tag);
: public DataPointDelegate {
public:
DataPointGridFTPDelegate(const URL& url, const UserConfig& usercfg, PluginArgument* parg);
virtual ~DataPointGridFTPDelegate();
static Plugin* Instance(PluginArgument *arg);
virtual bool SetURL(const URL& url);
virtual DataStatus StartReading(DataBuffer& buf);
virtual DataStatus StartWriting(DataBuffer& buf,
DataCallback *space_cb = NULL);
virtual DataStatus StopReading();
virtual DataStatus StopWriting();
virtual DataStatus Check(bool check_meta);
virtual DataStatus Remove();
virtual DataStatus CreateDirectory(bool with_parents=false);
virtual DataStatus Stat(FileInfo& file, DataPointInfoType verb = INFO_TYPE_ALL);
virtual DataStatus List(std::list<FileInfo>& files, DataPointInfoType verb = INFO_TYPE_ALL);
virtual DataStatus Rename(const URL& newurl);
virtual bool WriteOutOfOrder();
virtual bool ProvidesMeta() const;
virtual const std::string DefaultCheckSum() const;
virtual bool RequiresCredentials() const;
private:
bool is_secure;
};
} // namespace ArcDMCGridFTP
......
......@@ -18,8 +18,9 @@
#include <arc/globusutils/GlobusWorkarounds.h>
#include <arc/globusutils/GSSCredential.h>
#include <arc/crypto/OpenSSL.h>
#include <arc/data/DataExternalComm.h>
#include <arc/data/DataPointDelegate.h>
#include "Communication.h"
#include "Lister.h"
#include "DataPointGridFTPHelper.h"
......@@ -425,8 +426,8 @@ namespace ArcDMCGridFTP {
logger.msg(DEBUG, "ftp_read_callback: success");
if(length > 0) {
// Report received content
DataChunkClient dataEntry(buffer, offset, length);
dataEntry.write(outstream<<DataChunkTag);
DataExternalComm::DataChunkClient dataEntry(buffer, offset, length);
dataEntry.write(outstream<<DataExternalComm::DataChunkTag);
}
if (eof) it->ftp_eof_flag = true;
if (it->ftp_eof_flag) {
......@@ -447,8 +448,8 @@ namespace ArcDMCGridFTP {
}
}
if(it->data_counter.get() == 0) {
DataChunkClient dataEntry(NULL, offset+length, 0); // using 0 size as eof indication
dataEntry.write(outstream<<DataChunkTag);
DataExternalComm::DataChunkClient dataEntry(NULL, offset+length, 0); // using 0 size as eof indication
dataEntry.write(outstream<<DataExternalComm::DataChunkTag);
if(!it->ftp_eof_flag) {
// Must be case when all buffers are gone due to errors
GlobusResult(globus_ftp_client_abort(&it->ftp_handle));
......@@ -526,13 +527,13 @@ namespace ArcDMCGridFTP {
while(true) {
static globus_byte_t dummy;
logger.msg(VERBOSE, "start_writing_ftp: waiting for data tag");
char c = InTag(instream);
if(c != DataChunkTag) {
char c = DataExternalComm::InTag(instream);
if(c != DataExternalComm::DataChunkTag) {
logger.msg(ERROR, "start_writing_ftp: failed to read data tag");
GlobusResult(globus_ftp_client_abort(&ftp_handle));
break;
}
DataChunkClient dataChunk;
DataExternalComm::DataChunkClient dataChunk;
logger.msg(VERBOSE, "start_writing_ftp: waiting for data chunk");
if(!dataChunk.read(instream)) {
logger.msg(ERROR, "start_writing_ftp: failed to read data chunk");
......@@ -777,7 +778,7 @@ namespace ArcDMCGridFTP {
file.SetCheckSum(lister_info.GetCheckSum());
}
if(result)
OutEntry(outstream<<FileInfoTag, file);
DataExternalComm::OutEntry(outstream<<DataExternalComm::FileInfoTag, file);
return result;
}
......@@ -801,7 +802,7 @@ namespace ArcDMCGridFTP {
result = r;
}
}
OutEntry(outstream<<FileInfoTag, *i);
DataExternalComm::OutEntry(outstream<<DataExternalComm::FileInfoTag, *i);
}
return result;
}
......@@ -1090,6 +1091,7 @@ namespace ArcDMCGridFTP {
} // namespace ArcDMCGridFTP
int main(int argc, char* argv[]) {
using namespace Arc;
// Ignore some signals
signal(SIGTTOU,SIG_IGN);
signal(SIGPIPE,SIG_IGN);
......@@ -1175,7 +1177,7 @@ int main(int argc, char* argv[]) {
try {
Arc::UserConfig usercfg;
if(!ArcDMCGridFTP::InEntry(std::cin, usercfg)) {
if(!DataExternalComm::InEntry(std::cin, usercfg)) {
throw Arc::DataStatus(Arc::DataStatus::GenericError, "Failed to receive configuration");
}
......@@ -1189,7 +1191,7 @@ int main(int argc, char* argv[]) {
handler->SetSecure(secure);
handler->SetPassive(passive);
Arc::DataStatus result(Arc::DataStatus::Success);
if(command == "rename") {
if(command == Arc::DataPointDelegate::RenameCommand) {
if(params.empty()) {
throw Arc::DataStatus(Arc::DataStatus::GenericError, "Expecting new URL among arguments");
}
......@@ -1198,7 +1200,7 @@ int main(int argc, char* argv[]) {
throw Arc::DataStatus(Arc::DataStatus::GenericError, "Unexpected arguments");
}
result = handler->Rename(new_url_str);
} else if(command == "list") {
} else if(command == Arc::DataPointDelegate::ListCommand) {
Arc::DataPoint::DataPointInfoType verb = Arc::DataPoint::INFO_TYPE_ALL;
if(!params.empty()) {
verb = static_cast<Arc::DataPoint::DataPointInfoType>(Arc::stringtoi(params.front()));
......@@ -1208,7 +1210,7 @@ int main(int argc, char* argv[]) {
throw Arc::DataStatus(Arc::DataStatus::GenericError, "Unexpected arguments");
}
result = handler->List(verb);
} else if(command == "stat") {
} else if(command == Arc::DataPointDelegate::StatCommand) {
Arc::DataPoint::DataPointInfoType verb = Arc::DataPoint::INFO_TYPE_ALL;
if(!params.empty()) {
verb = static_cast<Arc::DataPoint::DataPointInfoType>(Arc::stringtoi(params.front()));
......@@ -1222,28 +1224,28 @@ int main(int argc, char* argv[]) {
if(!params.empty()) {
throw Arc::DataStatus(Arc::DataStatus::GenericError, "Unexpected arguments");
}
if(command == "read") {
if(command == Arc::DataPointDelegate::ReadCommand) {
result = handler->Read();
} else if(command == "write") {
} else if(command == Arc::DataPointDelegate::WriteCommand) {
result = handler->Write();
} else if(command == "check") {
} else if(command == Arc::DataPointDelegate::CheckCommand) {
result = handler->Check();
} else if(command == "remove") {
} else if(command == Arc::DataPointDelegate::RemoveCommand) {
result = handler->Remove();
} else if(command == "mkdir") {
} else if(command == Arc::DataPointDelegate::MkdirCommand) {
result = handler->CreateDirectory(false);
} else if(command == "mkdirr") {
} else if(command == Arc::DataPointDelegate::MkdirRecursiveCommand) {
result = handler->CreateDirectory(true);
} else {
throw Arc::DataStatus(Arc::DataStatus::GenericError, "Unknown command "+command);
}
}
ArcDMCGridFTP::OutEntry(std::cout<<ArcDMCGridFTP::DataStatusTag, result);
DataExternalComm::OutEntry(std::cout<<DataExternalComm::DataStatusTag, result);
std::cerr.flush();
std::cout.flush();
_exit(0);
} catch(Arc::DataStatus const& status) {
ArcDMCGridFTP::OutEntry(std::cout<<ArcDMCGridFTP::DataStatusTag, status);
DataExternalComm::OutEntry(std::cout<<DataExternalComm::DataStatusTag, status);
std::cerr.flush();
std::cout.flush();
_exit(0);
......
pkglib_LTLIBRARIES = libdmcgridftp.la libdmcgridftpdeleg.la
pgmpkglibdir = $(pkglibdir)
noinst_LTLIBRARIES = libdmcgridftp.la
pkglib_LTLIBRARIES = libdmcgridftpdeleg.la
pgmpkglib_PROGRAMS = arc-dmcgridftp
libdmcgridftp_la_SOURCES = DataPointGridFTP.cpp Lister.cpp \
......@@ -16,8 +18,8 @@ libdmcgridftp_la_LIBADD = \
$(GLOBUS_FTP_CONTROL_LIBS) $(GLOBUS_COMMON_LIBS) $(GLOBUS_IO_LIBS)
libdmcgridftp_la_LDFLAGS = -no-undefined -avoid-version -module
libdmcgridftpdeleg_la_SOURCES = DataPointGridFTPDelegate.cpp Communication.cpp \
DataPointGridFTPDelegate.h Communication.h
libdmcgridftpdeleg_la_SOURCES = DataPointGridFTPDelegate.cpp \
DataPointGridFTPDelegate.h
libdmcgridftpdeleg_la_CXXFLAGS = -I$(top_srcdir)/include \
$(LIBXML2_CFLAGS) $(GLIBMM_CFLAGS) $(AM_CXXFLAGS)
libdmcgridftpdeleg_la_LIBADD = \
......@@ -25,11 +27,11 @@ libdmcgridftpdeleg_la_LIBADD = \
$(top_builddir)/src/hed/libs/crypto/libarccrypto.la \
$(top_builddir)/src/hed/libs/loader/libarcloader.la \
$(top_builddir)/src/hed/libs/common/libarccommon.la \
$(LIBXML2_LIBS) $(GLIBMM_LIBS) $(GLOBUS_COMMON_LIBS) $(GLOBUS_IO_LIBS)
$(LIBXML2_LIBS) $(GLIBMM_LIBS)
libdmcgridftpdeleg_la_LDFLAGS = -no-undefined -avoid-version -module
arc_dmcgridftp_SOURCES = DataPointGridFTPHelper.cpp Lister.cpp Communication.cpp \
DataPointGridFTPHelper.h Lister.h Communication.h
arc_dmcgridftp_SOURCES = DataPointGridFTPHelper.cpp Lister.cpp \
DataPointGridFTPHelper.h Lister.h
arc_dmcgridftp_CXXFLAGS = -I$(top_srcdir)/include \
$(LIBXML2_CFLAGS) $(GLIBMM_CFLAGS) $(GLOBUS_FTP_CLIENT_CFLAGS) $(AM_CXXFLAGS)
arc_dmcgridftp_LDADD = \
......
// -*- indent-tabs-mode: nil -*-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <openssl/ssl.h>
#include <arc/Logger.h>
#include <arc/StringConv.h>
#include <arc/UserConfig.h>
#include <arc/data/DataBuffer.h>
#include <arc/CheckSum.h>
#include <arc/Run.h>
#include <arc/ArcLocation.h>
#include "DataPointXrootdDelegate.h"
namespace ArcDMCXrootd {
using namespace Arc;
DataPointXrootdDelegate::DataPointXrootdDelegate(const URL& url, const UserConfig& usercfg, PluginArgument* parg)
: DataPointDelegate("dmcxrootd", url, usercfg, parg) {
}
DataPointXrootdDelegate::~DataPointXrootdDelegate() {
}
Plugin* DataPointXrootdDelegate::Instance(PluginArgument *arg) {
DataPointPluginArgument *dmcarg = dynamic_cast<DataPointPluginArgument*>(arg);
if (!dmcarg) return NULL;
if (((const URL&)(*dmcarg)).Protocol() != "root") {
return NULL;
}
return new DataPointXrootdDelegate(*dmcarg, *dmcarg, dmcarg);
}
bool DataPointXrootdDelegate::RequiresCredentials() const {
return true;
}
} // namespace ArcDMCGridFTP
extern Arc::PluginDescriptor const ARC_PLUGINS_TABLE_NAME[] = {
{ "root", "HED:DMC", "XRootd", 0, &ArcDMCXrootd::DataPointXrootdDelegate::Instance },
{ NULL, NULL, NULL, 0, NULL }
};
extern "C" {
void ARC_MODULE_CONSTRUCTOR_NAME(Glib::Module* module, Arc::ModuleManager* manager) {
}
}
// -*- indent-tabs-mode: nil -*-
#ifndef __ARC_DATAPOINTXROOTDDELEGATE_H__
#define __ARC_DATAPOINTXROOTDDELEGATE_H__
#include <list>
#include <string>
#include <arc/Thread.h>
#include <arc/URL.h>
#include <arc/Run.h>
#include <arc/Utils.h>
#include <arc/data/DataPointDelegate.h>
namespace ArcDMCXrootd {
using namespace Arc;
class DataPointXrootdDelegate
: public DataPointDelegate {
public:
DataPointXrootdDelegate(const URL& url, const UserConfig& usercfg, PluginArgument* parg);
virtual ~DataPointXrootdDelegate();
static Plugin* Instance(PluginArgument *arg);
virtual bool RequiresCredentials() const;
};
} // namespace ArcDMCGridFTP
#endif // __ARC_DATAPOINTXROOTDDELEGATE_H__
pkglib_LTLIBRARIES = libdmcxrootd.la
extpkglib_LTLIBRARIES = libdmcxrootd.la
pkglib_LTLIBRARIES = libdmcxrootddeleg.la
libdmcxrootd_la_SOURCES = DataPointXrootd.cpp DataPointXrootd.h
libdmcxrootd_la_CXXFLAGS = -I$(top_srcdir)/include $(XROOTD_CPPFLAGS) \
......@@ -11,3 +12,16 @@ libdmcxrootd_la_LIBADD = \
$(LIBXML2_LIBS) $(GLIBMM_LIBS) \
$(XROOTD_LIBS)
libdmcxrootd_la_LDFLAGS = -no-undefined -avoid-version -module
libdmcxrootddeleg_la_SOURCES = DataPointXrootdDelegate.cpp \
DataPointXrootdDelegate.h
libdmcxrootddeleg_la_CXXFLAGS = -I$(top_srcdir)/include \
$(LIBXML2_CFLAGS) $(GLIBMM_CFLAGS) $(AM_CXXFLAGS)
libdmcxrootddeleg_la_LIBADD = \
$(top_builddir)/src/hed/libs/data/libarcdata.la \
$(top_builddir)/src/hed/libs/crypto/libarccrypto.la \
$(top_builddir)/src/hed/libs/loader/libarcloader.la \
$(top_builddir)/src/hed/libs/common/libarccommon.la \
$(LIBXML2_LIBS) $(GLIBMM_LIBS)
libdmcxrootddeleg_la_LDFLAGS = -no-undefined -avoid-version -module
......@@ -6,16 +6,14 @@
#include <arc/Logger.h>
#include <arc/StringConv.h>
#include "Communication.h"
#include "DataExternalComm.h"
namespace ArcDMCGridFTP {
namespace Arc {
using namespace Arc;
char const ErrorTag = '!';
char const DataStatusTag = 'S';
char const FileInfoTag = 'F';
char const DataChunkTag = 'D';
char const DataExternalComm::ErrorTag = '!';
char const DataExternalComm::DataStatusTag = 'S';
char const DataExternalComm::FileInfoTag = 'F';
char const DataExternalComm::DataChunkTag = 'D';
static char const entrySep = '\n';
static char const itemSep = ',';
......@@ -29,7 +27,7 @@ namespace ArcDMCGridFTP {
EntryFinished() {};
};
char InTag(std::istream& instream) {
char DataExternalComm::InTag(std::istream& instream) {
char tag = ErrorTag;
instream.read(&tag, 1);
if(instream.gcount() != 1) return ErrorTag;
......@@ -37,13 +35,13 @@ namespace ArcDMCGridFTP {
return tag;
}
char InTag(Arc::Run& run, int timeout) {
char DataExternalComm::InTag(Arc::Run& run, int timeout) {
char tag = ErrorTag;
if(run.ReadStdout(timeout, &tag, 1) != 1) return ErrorTag;
return tag;
}
bool OutTag(Arc::Run& run, int timeout, char tag) {
bool DataExternalComm::OutTag(Arc::Run& run, int timeout, char tag) {
if(run.WriteStdin(timeout, &tag, 1) != 1) return false;
return true;
}
......@@ -56,7 +54,7 @@ namespace ArcDMCGridFTP {
return unescape_chars(str, escapeTag, Arc::escape_hex);
}
// std::string itemIn(std::istream& instream, char sep = itemSep) {
// static std::string itemIn(std::istream& instream, char sep = itemSep) {
// std::string str;
// std::getline(instream, str, sep);
// if(instream.fail())
......@@ -64,7 +62,7 @@ namespace ArcDMCGridFTP {
// return decode(str);
// }
std::string itemIn(Run& run, int timeout, char sep = itemSep) {
static std::string itemIn(Run& run, int timeout, char sep = itemSep) {
std::string str;
while(true) {
char c;
......@@ -79,7 +77,7 @@ namespace ArcDMCGridFTP {
return decode(str);
}
void itemOut(Run& run, int timeout, std::string const& item, char sep = itemSep) {
static void itemOut(Run& run, int timeout, std::string const& item, char sep = itemSep) {
std::string str(encode(item));
const char *buf = str.c_str();
int size = str.length();
......@@ -102,7 +100,7 @@ namespace ArcDMCGridFTP {
// return item;
// }
template<typename T> T itemIn(Run& run, int timeout, char sep = itemSep) {
template<typename T> static T itemIn(Run& run, int timeout, char sep = itemSep) {
std::string str(itemIn(run, timeout, sep));
T item;
if(!Arc::stringto<T>(str, item))
......@@ -110,14 +108,14 @@ namespace ArcDMCGridFTP {
return item;
}
void itemOut(std::ostream& outstream, std::string const& item, char sep = itemSep) {
static void itemOut(std::ostream& outstream, std::string const& item, char sep = itemSep) {
std::string str(encode(item));
outstream.write(str.c_str(), str.length());
outstream.write(&sep, 1);
if(outstream.fail()) throw std::exception();
}
std::string itemIn(std::istream& instream, char sep = itemSep) {
static std::string itemIn(std::istream& instream, char sep = itemSep) {
std::string str;
std::getline(instream, str, sep);
if(instream.fail())
......@@ -125,7 +123,7 @@ namespace ArcDMCGridFTP {
return decode(str);
}
template<typename T> T itemIn(std::istream& instream, char sep = itemSep) {
template<typename T> static T itemIn(std::istream& instream, char sep = itemSep) {
std::string str = itemIn(instream, sep);
T item;
if(!Arc::stringto<T>(decode(str), item))
......@@ -139,7 +137,7 @@ namespace ArcDMCGridFTP {
// ------------- control ---------------