summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceGrid/AdminSessionI.cpp15
-rw-r--r--cpp/src/IceGrid/AdminSessionI.h11
-rw-r--r--cpp/src/IceGrid/FileCache.cpp21
-rw-r--r--cpp/src/IceGrid/FileCache.h9
-rw-r--r--cpp/src/IceGrid/Internal.ice3
-rw-r--r--cpp/src/IceGrid/InternalRegistryI.cpp8
-rw-r--r--cpp/src/IceGrid/InternalRegistryI.h2
-rw-r--r--cpp/src/IceGrid/NodeI.cpp6
-rw-r--r--cpp/src/IceGrid/NodeI.h2
-rw-r--r--cpp/src/IceGrid/Parser.cpp8
-rw-r--r--cpp/src/IceGrid/ServerI.cpp6
-rw-r--r--cpp/src/IceGrid/ServerI.h2
12 files changed, 56 insertions, 37 deletions
diff --git a/cpp/src/IceGrid/AdminSessionI.cpp b/cpp/src/IceGrid/AdminSessionI.cpp
index 6b9ac62d31b..6785fedf70c 100644
--- a/cpp/src/IceGrid/AdminSessionI.cpp
+++ b/cpp/src/IceGrid/AdminSessionI.cpp
@@ -22,20 +22,22 @@ using namespace IceGrid;
FileIteratorI::FileIteratorI(const AdminSessionIPtr& session,
const FileReaderPrx& reader,
const string& filename,
- Ice::Long offset) :
+ Ice::Long offset,
+ int messageSizeMax) :
_session(session),
_reader(reader),
_filename(filename),
- _offset(offset)
+ _offset(offset),
+ _messageSizeMax(messageSizeMax)
{
}
bool
-FileIteratorI::read(int nlines, int size, Ice::StringSeq& lines, const Ice::Current& current)
+FileIteratorI::read(int size, Ice::StringSeq& lines, const Ice::Current& current)
{
try
{
- return _reader->read(_filename, _offset, nlines, size, _offset, lines);
+ return _reader->read(_filename, _offset, size > _messageSizeMax ? _messageSizeMax : size, _offset, lines);
}
catch(const Ice::LocalException& ex)
{
@@ -321,8 +323,11 @@ AdminSessionI::addFileIterator(const FileReaderPrx& reader,
}
}
+ Ice::PropertiesPtr properties = reader->ice_getCommunicator()->getProperties();
+ int messageSizeMax = properties->getPropertyAsIntWithDefault("Ice.MessageSizeMax", 1024) * 1024;
+
Ice::ObjectPrx obj;
- Ice::ObjectPtr servant = new FileIteratorI(this, reader, filename, offset);
+ Ice::ObjectPtr servant = new FileIteratorI(this, reader, filename, offset, messageSizeMax);
if(_servantLocator)
{
obj = _servantLocator->add(servant, current.con);
diff --git a/cpp/src/IceGrid/AdminSessionI.h b/cpp/src/IceGrid/AdminSessionI.h
index f9e379f9b68..ec9c29c55ec 100644
--- a/cpp/src/IceGrid/AdminSessionI.h
+++ b/cpp/src/IceGrid/AdminSessionI.h
@@ -131,17 +131,18 @@ class FileIteratorI : public FileIterator
{
public:
- FileIteratorI(const AdminSessionIPtr&, const FileReaderPrx&, const std::string&, Ice::Long);
+ FileIteratorI(const AdminSessionIPtr&, const FileReaderPrx&, const std::string&, Ice::Long, int);
- virtual bool read(int, int, Ice::StringSeq&, const Ice::Current&);
+ virtual bool read(int, Ice::StringSeq&, const Ice::Current&);
virtual void destroy(const Ice::Current&);
private:
- AdminSessionIPtr _session;
- FileReaderPrx _reader;
- std::string _filename;
+ const AdminSessionIPtr _session;
+ const FileReaderPrx _reader;
+ const std::string _filename;
Ice::Long _offset;
+ const int _messageSizeMax;
};
};
diff --git a/cpp/src/IceGrid/FileCache.cpp b/cpp/src/IceGrid/FileCache.cpp
index 9dd062ce66f..f6cbce81264 100644
--- a/cpp/src/IceGrid/FileCache.cpp
+++ b/cpp/src/IceGrid/FileCache.cpp
@@ -7,6 +7,9 @@
//
// **********************************************************************
+#include <Ice/Communicator.h>
+#include <Ice/Properties.h>
+
#include <IceGrid/FileCache.h>
#include <IceGrid/Exception.h>
@@ -16,7 +19,8 @@
using namespace std;
using namespace IceGrid;
-FileCache::FileCache()
+FileCache::FileCache(const Ice::CommunicatorPtr& communicator) :
+ _messageSizeMax(communicator->getProperties()->getPropertyAsIntWithDefault("Ice.MessageSizeMax", 1024) * 1024)
{
}
@@ -106,9 +110,14 @@ FileCache::getOffsetFromEnd(const string& file, int originalCount)
}
bool
-FileCache::read(const string& file, Ice::Long offset, int count, int size, Ice::Long& newOffset, Ice::StringSeq& lines)
+FileCache::read(const string& file, Ice::Long offset, int size, Ice::Long& newOffset, Ice::StringSeq& lines)
{
- assert(size > 0 && count > 0);
+ assert(size > 0);
+
+ if(size > _messageSizeMax)
+ {
+ size = _messageSizeMax;
+ }
ifstream is(file.c_str());
if(is.fail())
@@ -139,12 +148,12 @@ FileCache::read(const string& file, Ice::Long offset, int count, int size, Ice::
#else
is.seekg(static_cast<streampos>(offset));
#endif
- int totalSize = 0;
+ int totalSize = 1024; // Some room for the message header.
string line;
- for(int i = 0; i < count && is.good() && totalSize < size; ++i)
+ for(int i = 0; is.good() && totalSize < size; ++i)
{
getline(is, line);
- totalSize += line.size() + (is.eof() ? 0 : 1);
+ totalSize += line.size() + 5; // 5 bytes for the encoding of the string size (worst case scenario)
if(!is.fail())
{
newOffset = is.tellg();
diff --git a/cpp/src/IceGrid/FileCache.h b/cpp/src/IceGrid/FileCache.h
index 4a827c6581d..51939521f87 100644
--- a/cpp/src/IceGrid/FileCache.h
+++ b/cpp/src/IceGrid/FileCache.h
@@ -12,6 +12,7 @@
#include <IceUtil/Shared.h>
#include <Ice/BuiltinSequences.h>
+#include <Ice/CommunicatorF.h>
namespace IceGrid
{
@@ -20,10 +21,14 @@ class FileCache : public IceUtil::Shared
{
public:
- FileCache();
+ FileCache(const Ice::CommunicatorPtr&);
Ice::Long getOffsetFromEnd(const std::string&, int);
- bool read(const std::string&, Ice::Long, int, int, Ice::Long&, Ice::StringSeq&);
+ bool read(const std::string&, Ice::Long, int, Ice::Long&, Ice::StringSeq&);
+
+private:
+
+ const int _messageSizeMax;
};
typedef IceUtil::Handle<FileCache> FileCachePtr;
diff --git a/cpp/src/IceGrid/Internal.ice b/cpp/src/IceGrid/Internal.ice
index 53ffa5b02bd..361f8a817c0 100644
--- a/cpp/src/IceGrid/Internal.ice
+++ b/cpp/src/IceGrid/Internal.ice
@@ -113,8 +113,7 @@ interface FileReader
* Read and return up to count lines (or size bytes) at the specified position.
*
**/
- ["cpp:const"] idempotent bool read(string filename, long pos, int count, int size, out long newPos,
- out Ice::StringSeq lines)
+ ["cpp:const"] idempotent bool read(string filename, long pos, int size, out long newPos, out Ice::StringSeq lines)
throws FileNotAvailableException;
};
diff --git a/cpp/src/IceGrid/InternalRegistryI.cpp b/cpp/src/IceGrid/InternalRegistryI.cpp
index 2d45bbf129f..2425fe0f177 100644
--- a/cpp/src/IceGrid/InternalRegistryI.cpp
+++ b/cpp/src/IceGrid/InternalRegistryI.cpp
@@ -32,7 +32,7 @@ InternalRegistryI::InternalRegistryI(const RegistryIPtr& registry,
_database(database),
_reaper(reaper),
_wellKnownObjects(wellKnownObjects),
- _fileCache(new FileCache()),
+ _fileCache(new FileCache(database->getCommunicator())),
_session(session)
{
Ice::PropertiesPtr properties = database->getCommunicator()->getProperties();
@@ -121,10 +121,10 @@ InternalRegistryI::getOffsetFromEnd(const string& filename, int count, const Ice
}
bool
-InternalRegistryI::read(const string& filename, Ice::Long pos, int count, int size, Ice::Long& newPos,
- Ice::StringSeq& lines, const Ice::Current&) const
+InternalRegistryI::read(const string& filename, Ice::Long pos, int size, Ice::Long& newPos, Ice::StringSeq& lines,
+ const Ice::Current&) const
{
- return _fileCache->read(getFilePath(filename), pos, count, size, newPos, lines);
+ return _fileCache->read(getFilePath(filename), pos, size, newPos, lines);
}
string
diff --git a/cpp/src/IceGrid/InternalRegistryI.h b/cpp/src/IceGrid/InternalRegistryI.h
index b8355817292..8200bf0d21f 100644
--- a/cpp/src/IceGrid/InternalRegistryI.h
+++ b/cpp/src/IceGrid/InternalRegistryI.h
@@ -52,7 +52,7 @@ public:
virtual void shutdown(const Ice::Current&) const;
virtual Ice::Long getOffsetFromEnd(const std::string&, int, const Ice::Current&) const;
- virtual bool read(const std::string&, Ice::Long, int, int, Ice::Long&, Ice::StringSeq&, const Ice::Current&) const;
+ virtual bool read(const std::string&, Ice::Long, int, Ice::Long&, Ice::StringSeq&, const Ice::Current&) const;
private:
diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp
index 11c218a23b3..35bfd9d9013 100644
--- a/cpp/src/IceGrid/NodeI.cpp
+++ b/cpp/src/IceGrid/NodeI.cpp
@@ -209,7 +209,7 @@ NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter,
_waitTime(0),
_userAccountMapper(mapper),
_platform("IceGrid.Node", _communicator, _traceLevels),
- _fileCache(new FileCache()),
+ _fileCache(new FileCache(_communicator)),
_serial(1)
{
Ice::PropertiesPtr properties = _communicator->getProperties();
@@ -558,10 +558,10 @@ NodeI::getOffsetFromEnd(const string& filename, int count, const Ice::Current&)
}
bool
-NodeI::read(const string& filename, Ice::Long pos, int count, int size, Ice::Long& newPos, Ice::StringSeq& lines,
+NodeI::read(const string& filename, Ice::Long pos, int size, Ice::Long& newPos, Ice::StringSeq& lines,
const Ice::Current&) const
{
- return _fileCache->read(getFilePath(filename), pos, count, size, newPos, lines);
+ return _fileCache->read(getFilePath(filename), pos, size, newPos, lines);
}
void
diff --git a/cpp/src/IceGrid/NodeI.h b/cpp/src/IceGrid/NodeI.h
index ccef9a8c8a4..40609d74015 100644
--- a/cpp/src/IceGrid/NodeI.h
+++ b/cpp/src/IceGrid/NodeI.h
@@ -58,7 +58,7 @@ public:
virtual void shutdown(const Ice::Current&) const;
virtual Ice::Long getOffsetFromEnd(const std::string&, int, const Ice::Current&) const;
- virtual bool read(const std::string&, Ice::Long, int, int, Ice::Long&, Ice::StringSeq&, const Ice::Current&) const;
+ virtual bool read(const std::string&, Ice::Long, int, Ice::Long&, Ice::StringSeq&, const Ice::Current&) const;
void destroy();
diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp
index 74b4b9b292e..f34341aba1e 100644
--- a/cpp/src/IceGrid/Parser.cpp
+++ b/cpp/src/IceGrid/Parser.cpp
@@ -1336,7 +1336,7 @@ Parser::dumpFile(const string& reader, const string& filename, const list<string
return;
}
int lineCount = 20;
- const int maxBytes = 512 * 1024;
+ int maxBytes = _communicator->getProperties()->getPropertyAsIntWithDefault("Ice.MessageSizeMax", 1024) * 1024;
if(head || tail)
{
istringstream is(head ? opts.optArg("head") : opts.optArg("tail"));
@@ -1397,7 +1397,7 @@ Parser::dumpFile(const string& reader, const string& filename, const list<string
bool eof = false;
while(!interrupted() && !eof && i < lineCount)
{
- eof = it->read(20, maxBytes, lines);
+ eof = it->read(maxBytes, lines);
for(Ice::StringSeq::const_iterator p = lines.begin(); i < lineCount && p != lines.end(); ++p, ++i)
{
cout << endl << *p << flush;
@@ -1409,7 +1409,7 @@ Parser::dumpFile(const string& reader, const string& filename, const list<string
bool eof = false;
while(!interrupted() && !eof)
{
- eof = it->read(20, maxBytes, lines);
+ eof = it->read(maxBytes, lines);
for(Ice::StringSeq::const_iterator p = lines.begin(); p != lines.end(); ++p)
{
cout << endl << *p << flush;
@@ -1421,7 +1421,7 @@ Parser::dumpFile(const string& reader, const string& filename, const list<string
{
while(!interrupted())
{
- bool eof = it->read(20, maxBytes, lines);
+ bool eof = it->read(maxBytes, lines);
for(Ice::StringSeq::const_iterator p = lines.begin(); p != lines.end(); ++p)
{
cout << *p;
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index daeef08ca53..d1906372d2b 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -777,10 +777,10 @@ ServerI::getOffsetFromEnd(const string& filename, int count, const Ice::Current&
}
bool
-ServerI::read(const string& filename, Ice::Long pos, int count, int size, Ice::Long& newPos, Ice::StringSeq& lines,
- const Ice::Current&) const
+ServerI::read(const string& filename, Ice::Long pos, int size, Ice::Long& newPos, Ice::StringSeq& lines,
+ const Ice::Current&) const
{
- return _node->getFileCache()->read(getFilePath(filename), pos, count, size, newPos, lines);
+ return _node->getFileCache()->read(getFilePath(filename), pos, size, newPos, lines);
}
bool
diff --git a/cpp/src/IceGrid/ServerI.h b/cpp/src/IceGrid/ServerI.h
index 56f023e3afd..e7e7db2d11c 100644
--- a/cpp/src/IceGrid/ServerI.h
+++ b/cpp/src/IceGrid/ServerI.h
@@ -84,7 +84,7 @@ public:
virtual void setProcess_async(const AMD_Server_setProcessPtr&, const ::Ice::ProcessPrx&, const ::Ice::Current&);
virtual Ice::Long getOffsetFromEnd(const std::string&, int, const Ice::Current&) const;
- virtual bool read(const std::string&, Ice::Long, int, int, Ice::Long&, Ice::StringSeq&, const Ice::Current&) const;
+ virtual bool read(const std::string&, Ice::Long, int, Ice::Long&, Ice::StringSeq&, const Ice::Current&) const;
bool isAdapterActivatable(const std::string&, int&) const;
const std::string& getId() const;