diff options
Diffstat (limited to 'cpp/test/Freeze')
-rw-r--r-- | cpp/test/Freeze/complex/Client.cpp | 126 | ||||
-rw-r--r-- | cpp/test/Freeze/complex/NodeI.h | 48 | ||||
-rw-r--r-- | cpp/test/Freeze/complex/Parser.cpp | 14 | ||||
-rw-r--r-- | cpp/test/Freeze/dbmap/Client.cpp | 596 | ||||
-rw-r--r-- | cpp/test/Freeze/evictor/Client.cpp | 896 | ||||
-rw-r--r-- | cpp/test/Freeze/evictor/Test.ice | 2 | ||||
-rw-r--r-- | cpp/test/Freeze/evictor/TestI.cpp | 42 | ||||
-rw-r--r-- | cpp/test/Freeze/evictor/TestI.h | 2 | ||||
-rw-r--r-- | cpp/test/Freeze/oldevictor/Client.cpp | 896 | ||||
-rw-r--r-- | cpp/test/Freeze/oldevictor/Test.ice | 2 | ||||
-rw-r--r-- | cpp/test/Freeze/oldevictor/TestI.cpp | 42 | ||||
-rw-r--r-- | cpp/test/Freeze/oldevictor/TestI.h | 2 |
12 files changed, 1334 insertions, 1334 deletions
diff --git a/cpp/test/Freeze/complex/Client.cpp b/cpp/test/Freeze/complex/Client.cpp index 7012c50f038..fdc3850b8a9 100644 --- a/cpp/test/Freeze/complex/Client.cpp +++ b/cpp/test/Freeze/complex/Client.cpp @@ -32,22 +32,22 @@ validate(const Complex::ComplexDict& m) Parser myParser; for(p = m.begin(); p != m.end(); ++p) { - // - // Verify the stored record is correct. - // + // + // Verify the stored record is correct. + // // COMPILERFIX: VC.NET reports an unhandled // exception if the test is written this way: // - //test(p->first.result == p->second->calc()); + //test(p->first.result == p->second->calc()); // Complex::NodePtr n = p->second; - test(p->first.result == n->calc()); + test(p->first.result == n->calc()); - // - // Verify that the expression & result again. - // - Complex::NodePtr root = myParser.parse(p->first.expression); - test(root->calc() == p->first.result); + // + // Verify that the expression & result again. + // + Complex::NodePtr root = myParser.parse(p->first.expression); + test(root->calc() == p->first.result); } cout << "ok" << endl; @@ -71,12 +71,12 @@ populate(Complex::ComplexDict& m) Parser myParser; for(size_t i = 0 ; i < nexpressions; ++i) { - Complex::NodePtr root = myParser.parse(expressions[i]); - assert(root); - Complex::Key k; - k.expression = expressions[i]; - k.result = root->calc(); - m.put(pair<const Complex::Key, const Complex::NodePtr>(k, root)); + Complex::NodePtr root = myParser.parse(expressions[i]); + assert(root); + Complex::Key k; + k.expression = expressions[i]; + k.result = root->calc(); + m.put(pair<const Complex::Key, const Complex::NodePtr>(k, root)); } cout << "ok" << endl; @@ -87,8 +87,8 @@ static void usage(const char* name) { cerr << "Usage: " << name << " [options] validate|populate\n"; - cerr << - "Options:\n" + cerr << + "Options:\n" "--dbdir Location of the database directory.\n"; } @@ -105,11 +105,11 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator, Complex::C if(argc > 1 && strcmp(argv[1], "populate") == 0) { - return populate(m); + return populate(m); } if(argc > 1 && strcmp(argv[1], "validate") == 0) { - return validate(m); + return validate(m); } usage(argv[0]); @@ -126,59 +126,59 @@ main(int argc, char* argv[]) try { - // - // Scan for --dbdir command line argument. - // - int i = 1; - while(i < argc) - { - if(strcmp(argv[i], "--dbdir") == 0) - { - if(i +1 >= argc) - { - usage(argv[0]); - return EXIT_FAILURE; - } - - envName = argv[i+1]; - envName += "/"; - envName += "db"; - - // - // Consume arguments - // - while(i < argc - 2) - { - argv[i] = argv[i+2]; - ++i; - } - argc -= 2; - } - else - { - ++i; - } - } - - communicator = Ice::initialize(argc, argv); - Freeze::ConnectionPtr connection = createConnection(communicator, envName); - Complex::ComplexDict m(connection, "test"); - status = run(argc, argv, communicator, m); + // + // Scan for --dbdir command line argument. + // + int i = 1; + while(i < argc) + { + if(strcmp(argv[i], "--dbdir") == 0) + { + if(i +1 >= argc) + { + usage(argv[0]); + return EXIT_FAILURE; + } + + envName = argv[i+1]; + envName += "/"; + envName += "db"; + + // + // Consume arguments + // + while(i < argc - 2) + { + argv[i] = argv[i+2]; + ++i; + } + argc -= 2; + } + else + { + ++i; + } + } + + communicator = Ice::initialize(argc, argv); + Freeze::ConnectionPtr connection = createConnection(communicator, envName); + Complex::ComplexDict m(connection, "test"); + status = run(argc, argv, communicator, m); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } try { - communicator->destroy(); + communicator->destroy(); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } return status; diff --git a/cpp/test/Freeze/complex/NodeI.h b/cpp/test/Freeze/complex/NodeI.h index 40479c2e2ba..296b3096260 100644 --- a/cpp/test/Freeze/complex/NodeI.h +++ b/cpp/test/Freeze/complex/NodeI.h @@ -26,12 +26,12 @@ public: NumberNodeI(int n) { - number = n; + number = n; } virtual int calc(const Ice::Current&) { - return number; + return number; } }; @@ -45,13 +45,13 @@ public: AddNodeI(const NodePtr& l, const NodePtr& r) { - left = l; - right = r; + left = l; + right = r; } virtual int calc(const Ice::Current&) { - return left->calc() + right->calc(); + return left->calc() + right->calc(); } }; @@ -65,13 +65,13 @@ public: MultiplyNodeI(const NodePtr& l, const NodePtr& r) { - left = l; - right = r; + left = l; + right = r; } virtual int calc(const Ice::Current&) { - return left->calc() * right->calc(); + return left->calc() * right->calc(); } }; @@ -81,26 +81,26 @@ public: virtual Ice::ObjectPtr create(const std::string& type) { - if(type == "::Complex::MultiplyNode") - { - return new MultiplyNodeI(); - } - if(type == "::Complex::AddNode") - { - return new AddNodeI(); - } - if(type == "::Complex::NumberNode") - { - return new NumberNodeI(); - } - std::cout << "create: " << type << std::endl; - assert(false); - return 0; + if(type == "::Complex::MultiplyNode") + { + return new MultiplyNodeI(); + } + if(type == "::Complex::AddNode") + { + return new AddNodeI(); + } + if(type == "::Complex::NumberNode") + { + return new NumberNodeI(); + } + std::cout << "create: " << type << std::endl; + assert(false); + return 0; } virtual void destroy() { - // Nothing to do + // Nothing to do } }; diff --git a/cpp/test/Freeze/complex/Parser.cpp b/cpp/test/Freeze/complex/Parser.cpp index 96616e9daa1..6114668e970 100644 --- a/cpp/test/Freeze/complex/Parser.cpp +++ b/cpp/test/Freeze/complex/Parser.cpp @@ -45,7 +45,7 @@ Parser::parse(const string& commands, bool debug) if(_errors) { - return 0; + return 0; } return _result; @@ -70,17 +70,17 @@ Parser::getInput(char* buf, int& result, int maxSize) if(!_buf.empty()) { #if defined(_MSC_VER) && !defined(_STLP_MSVC) - // COMPILERBUG: Stupid Visual C++ defines min and max as macros - result = _MIN(maxSize, static_cast<int>(_buf.length())); + // COMPILERBUG: Stupid Visual C++ defines min and max as macros + result = _MIN(maxSize, static_cast<int>(_buf.length())); #else - result = min(maxSize, static_cast<int>(_buf.length())); + result = min(maxSize, static_cast<int>(_buf.length())); #endif - strncpy(buf, _buf.c_str(), result); - _buf.erase(0, result); + strncpy(buf, _buf.c_str(), result); + _buf.erase(0, result); } else { - result = 0; + result = 0; } } diff --git a/cpp/test/Freeze/dbmap/Client.cpp b/cpp/test/Freeze/dbmap/Client.cpp index 77f705b8a58..09ab3c7d745 100644 --- a/cpp/test/Freeze/dbmap/Client.cpp +++ b/cpp/test/Freeze/dbmap/Client.cpp @@ -64,27 +64,27 @@ populateDB(const Freeze::ConnectionPtr& connection, ByteIntMap& m) for(;;) { - try - { - TransactionHolder txHolder(connection); - for(size_t j = 0; j < length; ++j) - { - m.put(ByteIntMap::value_type(alphabet[j], static_cast<Int>(j))); - } - txHolder.commit(); - break; - } - catch(const DeadlockException&) - { + try + { + TransactionHolder txHolder(connection); + for(size_t j = 0; j < length; ++j) + { + m.put(ByteIntMap::value_type(alphabet[j], static_cast<Int>(j))); + } + txHolder.commit(); + break; + } + catch(const DeadlockException&) + { #ifdef SHOW_EXCEPTIONS - cerr << "t" << flush; + cerr << "t" << flush; #endif - length = length / 2; - // - // Try again - // - } + length = length / 2; + // + // Try again + // + } } } @@ -93,45 +93,45 @@ class ReadThread : public IceUtil::Thread public: ReadThread(const CommunicatorPtr& communicator, const string& envName, const string& dbName) : - _connection(createConnection(communicator, envName)), - _map(_connection, dbName) + _connection(createConnection(communicator, envName)), + _map(_connection, dbName) { } virtual void run() { - for(int i = 0; i < 10; ++i) - { - for(;;) - { - try - { - for(ByteIntMap::iterator p = _map.begin(); p != _map.end(); ++p) - { - test(p->first == p->second + 'a'); - IceUtil::ThreadControl::yield(); - } - break; // for(;;) - } - catch(const DeadlockException&) - { + for(int i = 0; i < 10; ++i) + { + for(;;) + { + try + { + for(ByteIntMap::iterator p = _map.begin(); p != _map.end(); ++p) + { + test(p->first == p->second + 'a'); + IceUtil::ThreadControl::yield(); + } + break; // for(;;) + } + catch(const DeadlockException&) + { #ifdef SHOW_EXCEPTIONS - cerr << "r" << flush; + cerr << "r" << flush; #endif - // - // Try again - // - } - catch(const InvalidPositionException&) - { + // + // Try again + // + } + catch(const InvalidPositionException&) + { #ifdef SHOW_EXCEPTIONS - cerr << "i" << flush; + cerr << "i" << flush; #endif - break; - } - } - } + break; + } + } + } } private: @@ -146,51 +146,51 @@ class WriteThread : public IceUtil::Thread public: WriteThread(const CommunicatorPtr& communicator, const string& envName, const string& dbName) : - _connection(createConnection(communicator, envName)), - _map(_connection, dbName) + _connection(createConnection(communicator, envName)), + _map(_connection, dbName) { } virtual void run() { - // - // Delete an recreate each object - // - for(int i = 0; i < 4; ++i) - { - for(;;) - { - try - { - TransactionHolder txHolder(_connection); - for(ByteIntMap::iterator p = _map.begin(); p != _map.end(); ++p) - { - p.set(p->second + 1); - _map.erase(p); - } - break; // for(;;) - txHolder.commit(); - } - catch(const DeadlockException&) - { + // + // Delete an recreate each object + // + for(int i = 0; i < 4; ++i) + { + for(;;) + { + try + { + TransactionHolder txHolder(_connection); + for(ByteIntMap::iterator p = _map.begin(); p != _map.end(); ++p) + { + p.set(p->second + 1); + _map.erase(p); + } + break; // for(;;) + txHolder.commit(); + } + catch(const DeadlockException&) + { #ifdef SHOW_EXCEPTIONS - cerr << "w" << flush; + cerr << "w" << flush; #endif - // - // Try again - // - } - catch(const InvalidPositionException&) - { + // + // Try again + // + } + catch(const InvalidPositionException&) + { #ifdef SHOW_EXCEPTIONS - cerr << "I" << flush; + cerr << "I" << flush; #endif - break; - } - } - populateDB(_connection, _map); - } + break; + } + } + populateDB(_connection, _map); + } } private: @@ -222,18 +222,18 @@ run(const CommunicatorPtr& communicator, const string& envName) // for(j = alphabet.begin(); j != alphabet.end(); ++j) { - p = m.find(*j); - test(p != m.end()); - test(p->first == *j && p->second == j - alphabet.begin()); + p = m.find(*j); + test(p != m.end()); + test(p->first == *j && p->second == j - alphabet.begin()); } // // Next try const iterator // for(j = alphabet.begin(); j != alphabet.end(); ++j) { - cp = m.find(*j); - test(cp != m.end()); - test(cp->first == *j && cp->second == j - alphabet.begin()); + cp = m.find(*j); + test(cp != m.end()); + test(cp->first == *j && cp->second == j - alphabet.begin()); } test(!m.empty()); @@ -262,27 +262,27 @@ run(const CommunicatorPtr& communicator, const string& envName) bytes.push_back('c'); for(j = bytes.begin(); j != bytes.end(); ++j) { - p = m.find(*j); - test(p != m.end()); - m.erase(p); - - // - // Release locks to avoid self deadlock - // - p = m.end(); - - p = m.find(*j); - test(p == m.end()); - vector<Byte>::iterator r = find(alphabet.begin(), alphabet.end(), *j); - test(r != alphabet.end()); - alphabet.erase(r); + p = m.find(*j); + test(p != m.end()); + m.erase(p); + + // + // Release locks to avoid self deadlock + // + p = m.end(); + + p = m.find(*j); + test(p == m.end()); + vector<Byte>::iterator r = find(alphabet.begin(), alphabet.end(), *j); + test(r != alphabet.end()); + alphabet.erase(r); } for(j = alphabet.begin(); j != alphabet.end(); ++j) { - cp = m.find(*j); - test(cp != m.end()); - test(cp->first == *j && cp->second == (j - alphabet.begin()) + offset); + cp = m.find(*j); + test(cp != m.end()); + test(cp->first == *j && cp->second == (j - alphabet.begin()) + offset); } cout << "ok" << endl; @@ -486,8 +486,8 @@ run(const CommunicatorPtr& communicator, const string& envName) map<Byte, const Int>::const_iterator pit; for(pit = pairs.begin(); pit != pairs.end(); ++pit) { - p = m.find(pit->first); - test(p != m.end()); + p = m.find(pit->first); + test(p != m.end()); } cout << "ok" << endl; @@ -498,10 +498,10 @@ run(const CommunicatorPtr& communicator, const string& envName) size_t length = alphabet.size(); for(size_t k = 0; k < length; ++k) { - p = m.findByValue(static_cast<Int>(k)); - test(p != m.end()); - test(p->first == alphabet[k]); - test(++p == m.end()); + p = m.findByValue(static_cast<Int>(k)); + test(p != m.end()); + test(p->first == alphabet[k]); + test(++p == m.end()); } // @@ -531,12 +531,12 @@ run(const CommunicatorPtr& communicator, const string& envName) try { - p.set(18); - test(false); + p.set(18); + test(false); } catch(const DatabaseException&) { - // Expected + // Expected } test(p->first == alphabet[17] || p->first == alphabet[21]); test(++p == m.end()); @@ -551,177 +551,177 @@ run(const CommunicatorPtr& communicator, const string& envName) vector<IceUtil::ThreadControl> controls; for(int i = 0; i < 5; ++i) { - IceUtil::ThreadPtr rt = new ReadThread(communicator, envName, dbName); - controls.push_back(rt->start()); - IceUtil::ThreadPtr wt = new WriteThread(communicator, envName, dbName); - controls.push_back(wt->start()); + IceUtil::ThreadPtr rt = new ReadThread(communicator, envName, dbName); + controls.push_back(rt->start()); + IceUtil::ThreadPtr wt = new WriteThread(communicator, envName, dbName); + controls.push_back(wt->start()); } for(vector<IceUtil::ThreadControl>::iterator q = controls.begin(); q != controls.end(); ++q) { - q->join(); + q->join(); } cout << "ok" << endl; cout << "testing index creation... " << flush; { - IntIdentityMap iim(connection, "intIdentity"); - - Ice::Identity odd; - odd.name = "foo"; - odd.category = "odd"; - - Ice::Identity even; - even.name = "bar"; - even.category = "even"; - - TransactionHolder txHolder(connection); - for(int i = 0; i < 1000; i++) - { - if(i % 2 == 0) - { - iim.put(IntIdentityMap::value_type(i, even)); - } - else - { - iim.put(IntIdentityMap::value_type(i, odd)); - } - } - txHolder.commit(); + IntIdentityMap iim(connection, "intIdentity"); + + Ice::Identity odd; + odd.name = "foo"; + odd.category = "odd"; + + Ice::Identity even; + even.name = "bar"; + even.category = "even"; + + TransactionHolder txHolder(connection); + for(int i = 0; i < 1000; i++) + { + if(i % 2 == 0) + { + iim.put(IntIdentityMap::value_type(i, even)); + } + else + { + iim.put(IntIdentityMap::value_type(i, odd)); + } + } + txHolder.commit(); } { - IntIdentityMapWithIndex iim(connection, "intIdentity"); - test(iim.categoryCount("even") == 500); - test(iim.categoryCount("odd") == 500); - - { - int count = 0; - IntIdentityMapWithIndex::iterator p = iim.findByCategory("even"); - while(p != iim.end()) - { - test(p->first % 2 == 0); - ++p; - ++count; - } - test(count == 500); - } - - { - int count = 0; - IntIdentityMapWithIndex::iterator p = iim.findByCategory("odd"); - while(p != iim.end()) - { - test(p->first % 2 == 1); - ++p; - ++count; - } - test(count == 500); - } - iim.clear(); + IntIdentityMapWithIndex iim(connection, "intIdentity"); + test(iim.categoryCount("even") == 500); + test(iim.categoryCount("odd") == 500); + + { + int count = 0; + IntIdentityMapWithIndex::iterator p = iim.findByCategory("even"); + while(p != iim.end()) + { + test(p->first % 2 == 0); + ++p; + ++count; + } + test(count == 500); + } + + { + int count = 0; + IntIdentityMapWithIndex::iterator p = iim.findByCategory("odd"); + while(p != iim.end()) + { + test(p->first % 2 == 1); + ++p; + ++count; + } + test(count == 500); + } + iim.clear(); } cout << "ok" << endl; cout << "testing sorting... " << flush; { - SortedMap sm(connection, "sortedMap"); - - TransactionHolder txHolder(connection); - for(int i = 0; i < 1000; i++) - { - int k = rand() % 1000; - - Ice::Identity id; - id.name = "foo"; - id.category = 'a' + static_cast<char>(k % 26); - - sm.put(SortedMap::value_type(k, id)); - } - txHolder.commit(); + SortedMap sm(connection, "sortedMap"); + + TransactionHolder txHolder(connection); + for(int i = 0; i < 1000; i++) + { + int k = rand() % 1000; + + Ice::Identity id; + id.name = "foo"; + id.category = 'a' + static_cast<char>(k % 26); + + sm.put(SortedMap::value_type(k, id)); + } + txHolder.commit(); } { - SortedMap sm(connection, "sortedMap"); - { - for(int i = 0; i < 100; ++i) - { - int k = rand() % 1000; - SortedMap::iterator p = sm.lower_bound(k); - if(p != sm.end()) - { - test(p->first >= k); - SortedMap::iterator q = sm.upper_bound(k); - if(q == sm.end()) - { - test(p->first == k); - } - else - { - test((p->first == k && q->first > k) || - (p->first > k && q->first == p->first)); - } - } - } - } - - { - for(int i = 0; i < 100; ++i) - { - string category; - category = static_cast<char>('a' + rand() % 26); - - SortedMap::iterator p = sm.findByCategory(category); - if(p != sm.end()) - { - SortedMap::iterator q = sm.lowerBoundForCategory(category); - test(p == q); - do - { - q++; - } while(q != sm.end() && q->second.category == category); - - if(q != sm.end()) - { - test(q == sm.upperBoundForCategory(category)); - } - } - else - { - SortedMap::iterator q = sm.lowerBoundForCategory(category); - if(q != sm.end()) - { - test(p != q); - test(q->second.category < category); - category = q->second.category; - - do - { - q++; - } while(q != sm.end() && q->second.category == category); - - if(q != sm.end()) - { - test(q == sm.upperBoundForCategory(category)); - } - } - } - } - } - - { - string category = "z"; - SortedMap::iterator p = sm.lowerBoundForCategory(category); - - while(p != sm.end()) - { - test(p->second.category <= category); - category = p->second.category; - // cerr << category << ":" << p->first << endl; - ++p; - } - } - - sm.clear(); + SortedMap sm(connection, "sortedMap"); + { + for(int i = 0; i < 100; ++i) + { + int k = rand() % 1000; + SortedMap::iterator p = sm.lower_bound(k); + if(p != sm.end()) + { + test(p->first >= k); + SortedMap::iterator q = sm.upper_bound(k); + if(q == sm.end()) + { + test(p->first == k); + } + else + { + test((p->first == k && q->first > k) || + (p->first > k && q->first == p->first)); + } + } + } + } + + { + for(int i = 0; i < 100; ++i) + { + string category; + category = static_cast<char>('a' + rand() % 26); + + SortedMap::iterator p = sm.findByCategory(category); + if(p != sm.end()) + { + SortedMap::iterator q = sm.lowerBoundForCategory(category); + test(p == q); + do + { + q++; + } while(q != sm.end() && q->second.category == category); + + if(q != sm.end()) + { + test(q == sm.upperBoundForCategory(category)); + } + } + else + { + SortedMap::iterator q = sm.lowerBoundForCategory(category); + if(q != sm.end()) + { + test(p != q); + test(q->second.category < category); + category = q->second.category; + + do + { + q++; + } while(q != sm.end() && q->second.category == category); + + if(q != sm.end()) + { + test(q == sm.upperBoundForCategory(category)); + } + } + } + } + } + + { + string category = "z"; + SortedMap::iterator p = sm.lowerBoundForCategory(category); + + while(p != sm.end()) + { + test(p->second.category <= category); + category = p->second.category; + // cerr << category << ":" << p->first << endl; + ++p; + } + } + + sm.clear(); } cout << "ok" << endl; @@ -729,29 +729,29 @@ run(const CommunicatorPtr& communicator, const string& envName) cout << "testing wstring... " << flush; { - WstringWstringMap wsm(connection, "wstringMap"); - - TransactionHolder txHolder(connection); - wsm.put(WstringWstringMap::value_type(L"AAAAA", L"aaaaa")); - wsm.put(WstringWstringMap::value_type(L"BBBBB", L"bbbbb")); - wsm.put(WstringWstringMap::value_type(L"CCCCC", L"ccccc")); - wsm.put(WstringWstringMap::value_type(L"DDDDD", L"ddddd")); - wsm.put(WstringWstringMap::value_type(L"EEEEE", L"eeeee")); - txHolder.commit(); + WstringWstringMap wsm(connection, "wstringMap"); + + TransactionHolder txHolder(connection); + wsm.put(WstringWstringMap::value_type(L"AAAAA", L"aaaaa")); + wsm.put(WstringWstringMap::value_type(L"BBBBB", L"bbbbb")); + wsm.put(WstringWstringMap::value_type(L"CCCCC", L"ccccc")); + wsm.put(WstringWstringMap::value_type(L"DDDDD", L"ddddd")); + wsm.put(WstringWstringMap::value_type(L"EEEEE", L"eeeee")); + txHolder.commit(); } { - WstringWstringMap wsm(connection, "wstringMap"); - { - WstringWstringMap::iterator p = wsm.find(L"BBBBB"); - test(p != wsm.end()); - test(p->second == L"bbbbb"); - - p = wsm.findByValue(L"ddddd"); - test(p != wsm.end()); - test(p->first == L"DDDDD"); - } - wsm.clear(); + WstringWstringMap wsm(connection, "wstringMap"); + { + WstringWstringMap::iterator p = wsm.find(L"BBBBB"); + test(p != wsm.end()); + test(p->second == L"bbbbb"); + + p = wsm.findByValue(L"ddddd"); + test(p != wsm.end()); + test(p->first == L"DDDDD"); + } + wsm.clear(); } cout << "ok" << endl; @@ -769,30 +769,30 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - if(argc != 1) - { - envName = argv[1]; - envName += "/"; - envName += "db"; - } + communicator = Ice::initialize(argc, argv); + if(argc != 1) + { + envName = argv[1]; + envName += "/"; + envName += "db"; + } - status = run(communicator, envName); + status = run(communicator, envName); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } try { - communicator->destroy(); + communicator->destroy(); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } return status; diff --git a/cpp/test/Freeze/evictor/Client.cpp b/cpp/test/Freeze/evictor/Client.cpp index 41ee315faf2..cfafd704ef7 100644 --- a/cpp/test/Freeze/evictor/Client.cpp +++ b/cpp/test/Freeze/evictor/Client.cpp @@ -29,35 +29,35 @@ class ReadThread : public Thread public: ReadThread(vector<Test::ServantPrx>& servants) : - _servants(servants) + _servants(servants) { } virtual void run() { - int loops = 10; - while(loops-- > 0) - { - try - { - _servants[0]->getValue(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } - catch(...) - { - test(false); - } - - for(int i = 1; i < static_cast<int>(_servants.size()); ++i) - { - test(_servants[i]->getValue() == i); - } - } + int loops = 10; + while(loops-- > 0) + { + try + { + _servants[0]->getValue(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } + catch(...) + { + test(false); + } + + for(int i = 1; i < static_cast<int>(_servants.size()); ++i) + { + test(_servants[i]->getValue() == i); + } + } } private: @@ -71,72 +71,72 @@ public: enum State { StateRunning, StateDeactivating, StateDeactivated }; ReadForeverThread(vector<Test::ServantPrx>& servants) : - _servants(servants), - _state(StateRunning) + _servants(servants), + _state(StateRunning) { } virtual void run() { - for(;;) - { - try - { - for(int i = 0; i < static_cast<int>(_servants.size()); ++i) - { - if(getState() == StateDeactivated) - { - _servants[i]->slowGetValue(); - test(false); - } - else - { - test(_servants[i]->slowGetValue() == i); - } - } - } - catch(const Ice::SocketException&) - { - // - // Expected - // - test(validEx()); - return; - } - catch(const Ice::LocalException& e) - { - cerr << "Caught unexpected : " << e << endl; - test(false); - return; - } - catch(...) - { - test(false); - return; - } - } + for(;;) + { + try + { + for(int i = 0; i < static_cast<int>(_servants.size()); ++i) + { + if(getState() == StateDeactivated) + { + _servants[i]->slowGetValue(); + test(false); + } + else + { + test(_servants[i]->slowGetValue() == i); + } + } + } + catch(const Ice::SocketException&) + { + // + // Expected + // + test(validEx()); + return; + } + catch(const Ice::LocalException& e) + { + cerr << "Caught unexpected : " << e << endl; + test(false); + return; + } + catch(...) + { + test(false); + return; + } + } } State getState() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - return _state; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + return _state; } bool validEx() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - return _state == StateDeactivating || _state == StateDeactivated; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + return _state == StateDeactivating || _state == StateDeactivated; } void setState(State s) { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - _state = s; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + _state = s; } private: @@ -152,99 +152,99 @@ public: enum State { StateRunning, StateDeactivating, StateDeactivated }; AddForeverThread(const Test::RemoteEvictorPrx& evictor, int prefix) : - _evictor(evictor), - _state(StateRunning) + _evictor(evictor), + _state(StateRunning) { - ostringstream ostr; - ostr << prefix; - _prefix = ostr.str(); + ostringstream ostr; + ostr << prefix; + _prefix = ostr.str(); } virtual void run() { - int index = 0; - - for(;;) - { - ostringstream ostr; - ostr << _prefix << "-" << index; - index++; - string id = ostr.str(); - try - { - if(getState() == StateDeactivated) - { - _evictor->createServant(id, 0); - test(false); - } - else - { - _evictor->createServant(id, 0); - } - } - catch(const Test::EvictorDeactivatedException&) - { - test(validEx()); - // - // Expected - // - return; - } - catch(const Ice::ObjectNotExistException&) - { - test(validEx()); - // - // Expected - // - return; - } - catch(const Ice::LocalException& e) - { - cerr << "Caught unexpected : " << e << endl; - test(false); - return; - } - catch(const IceUtil::Exception& e) - { - cerr << "Caught IceUtil::Exception : " << e << endl; - cerr << "Index is " << index << endl; - test(false); - return; - } - catch(const std::exception& e) - { - cerr << "Caught std::exception : " << e.what() << endl; - test(false); - return; - } - catch(...) - { - cerr << "Caught unknown exception" << endl; + int index = 0; + + for(;;) + { + ostringstream ostr; + ostr << _prefix << "-" << index; + index++; + string id = ostr.str(); + try + { + if(getState() == StateDeactivated) + { + _evictor->createServant(id, 0); + test(false); + } + else + { + _evictor->createServant(id, 0); + } + } + catch(const Test::EvictorDeactivatedException&) + { + test(validEx()); + // + // Expected + // + return; + } + catch(const Ice::ObjectNotExistException&) + { + test(validEx()); + // + // Expected + // + return; + } + catch(const Ice::LocalException& e) + { + cerr << "Caught unexpected : " << e << endl; test(false); - return; - } - } + return; + } + catch(const IceUtil::Exception& e) + { + cerr << "Caught IceUtil::Exception : " << e << endl; + cerr << "Index is " << index << endl; + test(false); + return; + } + catch(const std::exception& e) + { + cerr << "Caught std::exception : " << e.what() << endl; + test(false); + return; + } + catch(...) + { + cerr << "Caught unknown exception" << endl; + test(false); + return; + } + } } State getState() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - return _state; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + return _state; } bool validEx() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - return _state == StateDeactivating || _state == StateDeactivated; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + return _state == StateDeactivating || _state == StateDeactivated; } void setState(State s) { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - _state = s; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + _state = s; } private: @@ -259,96 +259,96 @@ class CreateDestroyThread : public Thread public: CreateDestroyThread(const Test::RemoteEvictorPrx& evictor, int id, int size) : - _evictor(evictor), - _size(size) + _evictor(evictor), + _size(size) { - ostringstream ostr; - ostr << id; - _id = ostr.str(); + ostringstream ostr; + ostr << id; + _id = ostr.str(); } virtual void run() { - try - { - int loops = 50; - while(loops-- > 0) - { - for(int i = 0; i < _size; i++) - { - ostringstream ostr; - ostr << i; - string id = ostr.str(); - if(id == _id) - { - // - // Create when odd, destroy when even. - // - - if(loops % 2 == 0) - { - Test::ServantPrx servant = _evictor->getServant(id); - servant->destroy(); - - // - // Twice - // - try - { - servant->destroy(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } - } - else - { - Test::ServantPrx servant = _evictor->createServant(id, i); - - // - // Twice - // - try - { - servant = _evictor->createServant(id, 0); - test(false); - } - catch(const Test::AlreadyRegisteredException&) - { - // Expected - } - } - } - else - { - // - // Just read/write the value - // - Test::ServantPrx servant = _evictor->getServant(id); - try - { - int val = servant->getValue(); - test(val == i || val == -i); - servant->setValue(-val); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected from time to time - } - } - } - } - } - catch(...) - { - // - // Unexpected! - // - test(false); - } + try + { + int loops = 50; + while(loops-- > 0) + { + for(int i = 0; i < _size; i++) + { + ostringstream ostr; + ostr << i; + string id = ostr.str(); + if(id == _id) + { + // + // Create when odd, destroy when even. + // + + if(loops % 2 == 0) + { + Test::ServantPrx servant = _evictor->getServant(id); + servant->destroy(); + + // + // Twice + // + try + { + servant->destroy(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } + } + else + { + Test::ServantPrx servant = _evictor->createServant(id, i); + + // + // Twice + // + try + { + servant = _evictor->createServant(id, 0); + test(false); + } + catch(const Test::AlreadyRegisteredException&) + { + // Expected + } + } + } + else + { + // + // Just read/write the value + // + Test::ServantPrx servant = _evictor->getServant(id); + try + { + int val = servant->getValue(); + test(val == i || val == -i); + servant->setValue(-val); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected from time to time + } + } + } + } + } + catch(...) + { + // + // Unexpected! + // + test(false); + } } private: Test::RemoteEvictorPrx _evictor; @@ -379,32 +379,32 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) vector<Test::ServantPrx> servants; for(i = 0; i < size; i++) { - ostringstream ostr; - ostr << i; - string id = ostr.str(); - servants.push_back(evictor->createServant(id, i)); - servants[i]->ice_ping(); - - Test::FacetPrx facet1 = Test::FacetPrx::uncheckedCast(servants[i], "facet1"); - try - { - facet1->ice_ping(); - test(false); - } - catch(const Ice::FacetNotExistException&) - { - // Expected - } - - servants[i]->addFacet("facet1", "data"); - facet1->ice_ping(); - facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1); - facet1->setValue(10 * i); - facet1->addFacet("facet2", "moreData"); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); - test(facet2); - facet2->setValue(100 * i); + ostringstream ostr; + ostr << i; + string id = ostr.str(); + servants.push_back(evictor->createServant(id, i)); + servants[i]->ice_ping(); + + Test::FacetPrx facet1 = Test::FacetPrx::uncheckedCast(servants[i], "facet1"); + try + { + facet1->ice_ping(); + test(false); + } + catch(const Ice::FacetNotExistException&) + { + // Expected + } + + servants[i]->addFacet("facet1", "data"); + facet1->ice_ping(); + facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1); + facet1->setValue(10 * i); + facet1->addFacet("facet2", "moreData"); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); + test(facet2); + facet2->setValue(100 * i); } // @@ -414,14 +414,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) evictor->setSize(size); for(i = 0; i < size; i++) { - test(servants[i]->getValue() == i); - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1); - test(facet1->getValue() == 10 * i); - test(facet1->getData() == "data"); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); - test(facet2); - test(facet2->getData() == "moreData"); + test(servants[i]->getValue() == i); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1); + test(facet1->getValue() == 10 * i); + test(facet1->getData() == "data"); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); + test(facet2); + test(facet2->getData() == "moreData"); } // @@ -429,13 +429,13 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->setValue(i + 100); - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1); - facet1->setValue(10 * i + 100); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); - test(facet2); - facet2->setValue(100 * i + 100); + servants[i]->setValue(i + 100); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1); + facet1->setValue(10 * i + 100); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); + test(facet2); + facet2->setValue(100 * i + 100); } // @@ -445,13 +445,13 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) evictor->setSize(size); for(i = 0; i < size; i++) { - test(servants[i]->getValue() == i + 100); - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1); - test(facet1->getValue() == 10 * i + 100); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); - test(facet2); - test(facet2->getValue() == 100 * i + 100); + test(servants[i]->getValue() == i + 100); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1); + test(facet1->getValue() == 10 * i + 100); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); + test(facet2); + test(facet2->getValue() == 100 * i + 100); } // // Test saving while busy @@ -459,24 +459,24 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) Test::AMI_Servant_setValueAsyncPtr setCB = new AMI_Servant_setValueAsyncI; for(i = 0; i < size; i++) { - // - // Start a mutating operation so that the object is not idle. - // - servants[i]->setValueAsync_async(setCB, i + 300); - - test(servants[i]->getValue() == i + 100); - // - // This operation modifies the object state but is not saved - // because the setValueAsync operation is still pending. - // - servants[i]->setValue(i + 200); - test(servants[i]->getValue() == i + 200); + // + // Start a mutating operation so that the object is not idle. + // + servants[i]->setValueAsync_async(setCB, i + 300); + + test(servants[i]->getValue() == i + 100); + // + // This operation modifies the object state but is not saved + // because the setValueAsync operation is still pending. + // + servants[i]->setValue(i + 200); + test(servants[i]->getValue() == i + 200); - // - // Force the response to setValueAsync - // - servants[i]->releaseAsync(); - test(servants[i]->getValue() == i + 300); + // + // Force the response to setValueAsync + // + servants[i]->releaseAsync(); + test(servants[i]->getValue() == i + 300); } // @@ -484,14 +484,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - try - { - servants[i]->addFacet("facet1", "foobar"); - test(false); - } - catch(const Test::AlreadyRegisteredException&) - { - } + try + { + servants[i]->addFacet("facet1", "foobar"); + test(false); + } + catch(const Test::AlreadyRegisteredException&) + { + } } // @@ -499,8 +499,8 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // try { - servants[0]->removeFacet("facet3"); - test(false); + servants[0]->removeFacet("facet3"); + test(false); } catch(const Test::NotRegisteredException&) { @@ -512,8 +512,8 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->removeFacet("facet1"); - servants[i]->removeFacet("facet2"); + servants[i]->removeFacet("facet1"); + servants[i]->removeFacet("facet2"); } // @@ -521,10 +521,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1 == 0); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(servants[i], "facet2"); - test(facet2 == 0); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1 == 0); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(servants[i], "facet2"); + test(facet2 == 0); } evictor->setSize(0); @@ -532,10 +532,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) for(i = 0; i < size; i++) { - test(servants[i]->getValue() == i + 300); + test(servants[i]->getValue() == i + 300); - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1 == 0); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1 == 0); } // @@ -543,26 +543,26 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->destroy(); - try - { - servants[i]->getValue(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } - - try - { - servants[i]->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } + servants[i]->destroy(); + try + { + servants[i]->getValue(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } + + try + { + servants[i]->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } } // @@ -571,11 +571,11 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) servants.clear(); for(i = 0; i < size; i++) { - ostringstream ostr; - ostr << i; - string id = ostr.str(); - servants.push_back(evictor->createServant(id, i)); - servants[i]->setTransientValue(i); + ostringstream ostr; + ostr << i; + string id = ostr.str(); + servants.push_back(evictor->createServant(id, i)); + servants[i]->setTransientValue(i); } // @@ -590,7 +590,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - test(servants[i]->getTransientValue() == -1); + test(servants[i]->getTransientValue() == -1); } // @@ -598,9 +598,9 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->keepInCache(); - servants[i]->keepInCache(); - servants[i]->setTransientValue(i); + servants[i]->keepInCache(); + servants[i]->keepInCache(); + servants[i]->setTransientValue(i); } evictor->saveNow(); evictor->setSize(0); @@ -612,7 +612,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - test(servants[i]->getTransientValue() == i); + test(servants[i]->getTransientValue() == i); } // @@ -620,14 +620,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->release(); + servants[i]->release(); } evictor->saveNow(); evictor->setSize(0); evictor->setSize(size); for(i = 0; i < size; i++) { - test(servants[i]->getTransientValue() == i); + test(servants[i]->getTransientValue() == i); } // @@ -635,14 +635,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->release(); + servants[i]->release(); } evictor->saveNow(); evictor->setSize(0); evictor->setSize(size); for(i = 0; i < size; i++) { - test(servants[i]->getTransientValue() == -1); + test(servants[i]->getTransientValue() == -1); } @@ -651,15 +651,15 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - try - { - servants[i]->release(); - test(false); - } - catch(const Test::NotRegisteredException&) - { - // Expected - } + try + { + servants[i]->release(); + test(false); + } + catch(const Test::NotRegisteredException&) + { + // Expected + } } @@ -673,12 +673,12 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) evictor->setSize(size); for(i = 0; i < size; i++) {
- ostringstream ostr;
- ostr << i;
- string id = ostr.str();
+ ostringstream ostr;
+ ostr << i;
+ string id = ostr.str();
- servants[i] = evictor->getServant(id); - test(servants[i]->getValue() == i); + servants[i] = evictor->getServant(id); + test(servants[i]->getValue() == i); } // @@ -689,19 +689,19 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) servants[0]->destroy(); { - const int threadCount = size * 2; - - ThreadPtr threads[threadCount]; - for(i = 0; i < threadCount; i++) - { - threads[i] = new ReadThread(servants); - threads[i]->start(); - } - - for(i = 0; i < threadCount; i++) - { - threads[i]->getThreadControl().join(); - } + const int threadCount = size * 2; + + ThreadPtr threads[threadCount]; + for(i = 0; i < threadCount; i++) + { + threads[i] = new ReadThread(servants); + threads[i]->start(); + } + + for(i = 0; i < threadCount; i++) + { + threads[i]->getThreadControl().join(); + } } // @@ -715,35 +715,35 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // CreateDestroy threads // { - const int threadCount = size;; - - ThreadPtr threads[threadCount]; - for(i = 0; i < threadCount; i++) - { - threads[i] = new CreateDestroyThread(evictor, i, size); - threads[i]->start(); - } - - for(i = 0; i < threadCount; i++) - { - threads[i]->getThreadControl().join(); - } - - // - // Verify all destroyed - // - for(i = 0; i < size; i++) - { - try - { - servants[i]->getValue(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } - } + const int threadCount = size;; + + ThreadPtr threads[threadCount]; + for(i = 0; i < threadCount; i++) + { + threads[i] = new CreateDestroyThread(evictor, i, size); + threads[i]->start(); + } + + for(i = 0; i < threadCount; i++) + { + threads[i]->getThreadControl().join(); + } + + // + // Verify all destroyed + // + for(i = 0; i < size; i++) + { + try + { + servants[i]->getValue(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } + } } // @@ -752,10 +752,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) servants.clear(); for(i = 0; i < size; i++) { - ostringstream ostr; - ostr << i; - string id = ostr.str(); - servants.push_back(evictor->createServant(id, i)); + ostringstream ostr; + ostr << i; + string id = ostr.str(); + servants.push_back(evictor->createServant(id, i)); } // @@ -763,30 +763,30 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // (really testing Ice here) // { - const int threadCount = size; - - ReadForeverThreadPtr threads[threadCount]; - for(i = 0; i < threadCount; i++) - { - threads[i] = new ReadForeverThread(servants); - threads[i]->start(); - } + const int threadCount = size; + + ReadForeverThreadPtr threads[threadCount]; + for(i = 0; i < threadCount; i++) + { + threads[i] = new ReadForeverThread(servants); + threads[i]->start(); + } - ThreadControl::sleep(Time::milliSeconds(500)); - for(i = 0; i < threadCount; i++) - { - threads[i]->setState(ReadForeverThread::StateDeactivating); - } - evictor->deactivate(); - for(i = 0; i < threadCount; i++) - { - threads[i]->setState(ReadForeverThread::StateDeactivated); - } + ThreadControl::sleep(Time::milliSeconds(500)); + for(i = 0; i < threadCount; i++) + { + threads[i]->setState(ReadForeverThread::StateDeactivating); + } + evictor->deactivate(); + for(i = 0; i < threadCount; i++) + { + threads[i]->setState(ReadForeverThread::StateDeactivated); + } - for(i = 0; i < threadCount; i++) - { - threads[i]->getThreadControl().join(); - } + for(i = 0; i < threadCount; i++) + { + threads[i]->getThreadControl().join(); + } } // @@ -799,30 +799,30 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // Deactivate in the middle of adds // { - const int threadCount = size; - - AddForeverThreadPtr threads[threadCount]; - for(i = 0; i < threadCount; i++) - { - threads[i] = new AddForeverThread(evictor, i); - threads[i]->start(); - } - - ThreadControl::sleep(Time::milliSeconds(500)); - for(i = 0; i < threadCount; i++) - { - threads[i]->setState(AddForeverThread::StateDeactivating); - } - evictor->deactivate(); - for(i = 0; i < threadCount; i++) - { - threads[i]->setState(AddForeverThread::StateDeactivated); - } - - for(i = 0; i < threadCount; i++) - { - threads[i]->getThreadControl().join(); - } + const int threadCount = size; + + AddForeverThreadPtr threads[threadCount]; + for(i = 0; i < threadCount; i++) + { + threads[i] = new AddForeverThread(evictor, i); + threads[i]->start(); + } + + ThreadControl::sleep(Time::milliSeconds(500)); + for(i = 0; i < threadCount; i++) + { + threads[i]->setState(AddForeverThread::StateDeactivating); + } + evictor->deactivate(); + for(i = 0; i < threadCount; i++) + { + threads[i]->setState(AddForeverThread::StateDeactivated); + } + + for(i = 0; i < threadCount; i++) + { + threads[i]->getThreadControl().join(); + } } diff --git a/cpp/test/Freeze/evictor/Test.ice b/cpp/test/Freeze/evictor/Test.ice index 4ab855c984c..e51e4b39a18 100644 --- a/cpp/test/Freeze/evictor/Test.ice +++ b/cpp/test/Freeze/evictor/Test.ice @@ -61,7 +61,7 @@ interface RemoteEvictor idempotent void setSize(int size); Servant* createServant(string id, int value) - throws AlreadyRegisteredException, EvictorDeactivatedException; + throws AlreadyRegisteredException, EvictorDeactivatedException; idempotent Servant* getServant(string id); diff --git a/cpp/test/Freeze/evictor/TestI.cpp b/cpp/test/Freeze/evictor/TestI.cpp index 04e94256dcf..490d23083ac 100644 --- a/cpp/test/Freeze/evictor/TestI.cpp +++ b/cpp/test/Freeze/evictor/TestI.cpp @@ -20,16 +20,16 @@ class DelayedResponse : public Thread public: DelayedResponse(const Test::AMD_Servant_slowGetValuePtr& cb, int val) : - _cb(cb), - _val(val) + _cb(cb), + _val(val) { } virtual void run() { - ThreadControl::sleep(Time::milliSeconds(500)); - _cb->ice_response(_val); + ThreadControl::sleep(Time::milliSeconds(500)); + _cb->ice_response(_val); } private: @@ -75,7 +75,7 @@ Test::ServantI::slowGetValue(const Current&) const void Test::ServantI::slowGetValue_async(const AMD_Servant_slowGetValuePtr& cb, - const Current&) const + const Current&) const { IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); Monitor<Mutex>::Lock sync(*this); @@ -123,11 +123,11 @@ Test::ServantI::addFacet(const string& name, const string& data, const Current& try { - _evictor->addFacet(facet, current.id, name); + _evictor->addFacet(facet, current.id, name); } catch(const Ice::AlreadyRegisteredException&) { - throw Test::AlreadyRegisteredException(); + throw Test::AlreadyRegisteredException(); } } @@ -136,11 +136,11 @@ Test::ServantI::removeFacet(const string& name, const Current& current) const { try { - _evictor->removeFacet(current.id, name); + _evictor->removeFacet(current.id, name); } catch(const Ice::NotRegisteredException&) { - throw Test::NotRegisteredException(); + throw Test::NotRegisteredException(); } } @@ -170,11 +170,11 @@ Test::ServantI::release(const Current& current) { try { - _evictor->release(current.id); + _evictor->release(current.id); } catch(const Ice::NotRegisteredException&) { - throw NotRegisteredException(); + throw NotRegisteredException(); } } @@ -183,11 +183,11 @@ Test::ServantI::destroy(const Current& current) { try { - _evictor->remove(current.id); + _evictor->remove(current.id); } catch(const Ice::NotRegisteredException&) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } } @@ -225,7 +225,7 @@ public: void init(const Test::RemoteEvictorIPtr& remoteEvictor, const Freeze::EvictorPtr& evictor) { _remoteEvictor = remoteEvictor; - _evictor = evictor; + _evictor = evictor; } virtual void @@ -243,7 +243,7 @@ private: Test::RemoteEvictorI::RemoteEvictorI(const ObjectAdapterPtr& adapter, const string& envName, - const string& category) : + const string& category) : _adapter(adapter), _category(category) { @@ -275,19 +275,19 @@ Test::RemoteEvictorI::createServant(const string& id, Int value, const Current&) ServantPtr servant = new ServantI(this, _evictor, value); try { - return ServantPrx::uncheckedCast(_evictor->add(servant, ident)); + return ServantPrx::uncheckedCast(_evictor->add(servant, ident)); } catch(const Ice::AlreadyRegisteredException&) { - throw Test::AlreadyRegisteredException(); + throw Test::AlreadyRegisteredException(); } catch(const Ice::ObjectAdapterDeactivatedException&) { - throw EvictorDeactivatedException(); + throw EvictorDeactivatedException(); } catch(const Freeze::EvictorDeactivatedException&) { - throw EvictorDeactivatedException(); + throw EvictorDeactivatedException(); } } @@ -327,7 +327,7 @@ Test::RemoteEvictorI::destroyAllServants(const string& facetName, const Current& Freeze::EvictorIteratorPtr p = _evictor->getIterator(facetName, batchSize); while(p->hasNext()) { - _evictor->remove(p->next()); + _evictor->remove(p->next()); } } @@ -344,7 +344,7 @@ Test::RemoteEvictorFactoryI::createEvictor(const string& name, const Current& cu { RemoteEvictorIPtr remoteEvictor = new RemoteEvictorI(_adapter, _envName, name); return RemoteEvictorPrx::uncheckedCast(_adapter->add(remoteEvictor, - _adapter->getCommunicator()->stringToIdentity(name))); + _adapter->getCommunicator()->stringToIdentity(name))); } void diff --git a/cpp/test/Freeze/evictor/TestI.h b/cpp/test/Freeze/evictor/TestI.h index e886473517c..458cf023702 100644 --- a/cpp/test/Freeze/evictor/TestI.h +++ b/cpp/test/Freeze/evictor/TestI.h @@ -41,7 +41,7 @@ public: virtual void slowGetValue_async(const AMD_Servant_slowGetValuePtr&, - const Ice::Current& = Ice::Current()) const; + const Ice::Current& = Ice::Current()) const; virtual void setValue(::Ice::Int, const Ice::Current& = Ice::Current()); diff --git a/cpp/test/Freeze/oldevictor/Client.cpp b/cpp/test/Freeze/oldevictor/Client.cpp index 41ee315faf2..cfafd704ef7 100644 --- a/cpp/test/Freeze/oldevictor/Client.cpp +++ b/cpp/test/Freeze/oldevictor/Client.cpp @@ -29,35 +29,35 @@ class ReadThread : public Thread public: ReadThread(vector<Test::ServantPrx>& servants) : - _servants(servants) + _servants(servants) { } virtual void run() { - int loops = 10; - while(loops-- > 0) - { - try - { - _servants[0]->getValue(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } - catch(...) - { - test(false); - } - - for(int i = 1; i < static_cast<int>(_servants.size()); ++i) - { - test(_servants[i]->getValue() == i); - } - } + int loops = 10; + while(loops-- > 0) + { + try + { + _servants[0]->getValue(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } + catch(...) + { + test(false); + } + + for(int i = 1; i < static_cast<int>(_servants.size()); ++i) + { + test(_servants[i]->getValue() == i); + } + } } private: @@ -71,72 +71,72 @@ public: enum State { StateRunning, StateDeactivating, StateDeactivated }; ReadForeverThread(vector<Test::ServantPrx>& servants) : - _servants(servants), - _state(StateRunning) + _servants(servants), + _state(StateRunning) { } virtual void run() { - for(;;) - { - try - { - for(int i = 0; i < static_cast<int>(_servants.size()); ++i) - { - if(getState() == StateDeactivated) - { - _servants[i]->slowGetValue(); - test(false); - } - else - { - test(_servants[i]->slowGetValue() == i); - } - } - } - catch(const Ice::SocketException&) - { - // - // Expected - // - test(validEx()); - return; - } - catch(const Ice::LocalException& e) - { - cerr << "Caught unexpected : " << e << endl; - test(false); - return; - } - catch(...) - { - test(false); - return; - } - } + for(;;) + { + try + { + for(int i = 0; i < static_cast<int>(_servants.size()); ++i) + { + if(getState() == StateDeactivated) + { + _servants[i]->slowGetValue(); + test(false); + } + else + { + test(_servants[i]->slowGetValue() == i); + } + } + } + catch(const Ice::SocketException&) + { + // + // Expected + // + test(validEx()); + return; + } + catch(const Ice::LocalException& e) + { + cerr << "Caught unexpected : " << e << endl; + test(false); + return; + } + catch(...) + { + test(false); + return; + } + } } State getState() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - return _state; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + return _state; } bool validEx() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - return _state == StateDeactivating || _state == StateDeactivated; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + return _state == StateDeactivating || _state == StateDeactivated; } void setState(State s) { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - _state = s; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + _state = s; } private: @@ -152,99 +152,99 @@ public: enum State { StateRunning, StateDeactivating, StateDeactivated }; AddForeverThread(const Test::RemoteEvictorPrx& evictor, int prefix) : - _evictor(evictor), - _state(StateRunning) + _evictor(evictor), + _state(StateRunning) { - ostringstream ostr; - ostr << prefix; - _prefix = ostr.str(); + ostringstream ostr; + ostr << prefix; + _prefix = ostr.str(); } virtual void run() { - int index = 0; - - for(;;) - { - ostringstream ostr; - ostr << _prefix << "-" << index; - index++; - string id = ostr.str(); - try - { - if(getState() == StateDeactivated) - { - _evictor->createServant(id, 0); - test(false); - } - else - { - _evictor->createServant(id, 0); - } - } - catch(const Test::EvictorDeactivatedException&) - { - test(validEx()); - // - // Expected - // - return; - } - catch(const Ice::ObjectNotExistException&) - { - test(validEx()); - // - // Expected - // - return; - } - catch(const Ice::LocalException& e) - { - cerr << "Caught unexpected : " << e << endl; - test(false); - return; - } - catch(const IceUtil::Exception& e) - { - cerr << "Caught IceUtil::Exception : " << e << endl; - cerr << "Index is " << index << endl; - test(false); - return; - } - catch(const std::exception& e) - { - cerr << "Caught std::exception : " << e.what() << endl; - test(false); - return; - } - catch(...) - { - cerr << "Caught unknown exception" << endl; + int index = 0; + + for(;;) + { + ostringstream ostr; + ostr << _prefix << "-" << index; + index++; + string id = ostr.str(); + try + { + if(getState() == StateDeactivated) + { + _evictor->createServant(id, 0); + test(false); + } + else + { + _evictor->createServant(id, 0); + } + } + catch(const Test::EvictorDeactivatedException&) + { + test(validEx()); + // + // Expected + // + return; + } + catch(const Ice::ObjectNotExistException&) + { + test(validEx()); + // + // Expected + // + return; + } + catch(const Ice::LocalException& e) + { + cerr << "Caught unexpected : " << e << endl; test(false); - return; - } - } + return; + } + catch(const IceUtil::Exception& e) + { + cerr << "Caught IceUtil::Exception : " << e << endl; + cerr << "Index is " << index << endl; + test(false); + return; + } + catch(const std::exception& e) + { + cerr << "Caught std::exception : " << e.what() << endl; + test(false); + return; + } + catch(...) + { + cerr << "Caught unknown exception" << endl; + test(false); + return; + } + } } State getState() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - return _state; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + return _state; } bool validEx() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - return _state == StateDeactivating || _state == StateDeactivated; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + return _state == StateDeactivating || _state == StateDeactivated; } void setState(State s) { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - _state = s; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + _state = s; } private: @@ -259,96 +259,96 @@ class CreateDestroyThread : public Thread public: CreateDestroyThread(const Test::RemoteEvictorPrx& evictor, int id, int size) : - _evictor(evictor), - _size(size) + _evictor(evictor), + _size(size) { - ostringstream ostr; - ostr << id; - _id = ostr.str(); + ostringstream ostr; + ostr << id; + _id = ostr.str(); } virtual void run() { - try - { - int loops = 50; - while(loops-- > 0) - { - for(int i = 0; i < _size; i++) - { - ostringstream ostr; - ostr << i; - string id = ostr.str(); - if(id == _id) - { - // - // Create when odd, destroy when even. - // - - if(loops % 2 == 0) - { - Test::ServantPrx servant = _evictor->getServant(id); - servant->destroy(); - - // - // Twice - // - try - { - servant->destroy(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } - } - else - { - Test::ServantPrx servant = _evictor->createServant(id, i); - - // - // Twice - // - try - { - servant = _evictor->createServant(id, 0); - test(false); - } - catch(const Test::AlreadyRegisteredException&) - { - // Expected - } - } - } - else - { - // - // Just read/write the value - // - Test::ServantPrx servant = _evictor->getServant(id); - try - { - int val = servant->getValue(); - test(val == i || val == -i); - servant->setValue(-val); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected from time to time - } - } - } - } - } - catch(...) - { - // - // Unexpected! - // - test(false); - } + try + { + int loops = 50; + while(loops-- > 0) + { + for(int i = 0; i < _size; i++) + { + ostringstream ostr; + ostr << i; + string id = ostr.str(); + if(id == _id) + { + // + // Create when odd, destroy when even. + // + + if(loops % 2 == 0) + { + Test::ServantPrx servant = _evictor->getServant(id); + servant->destroy(); + + // + // Twice + // + try + { + servant->destroy(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } + } + else + { + Test::ServantPrx servant = _evictor->createServant(id, i); + + // + // Twice + // + try + { + servant = _evictor->createServant(id, 0); + test(false); + } + catch(const Test::AlreadyRegisteredException&) + { + // Expected + } + } + } + else + { + // + // Just read/write the value + // + Test::ServantPrx servant = _evictor->getServant(id); + try + { + int val = servant->getValue(); + test(val == i || val == -i); + servant->setValue(-val); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected from time to time + } + } + } + } + } + catch(...) + { + // + // Unexpected! + // + test(false); + } } private: Test::RemoteEvictorPrx _evictor; @@ -379,32 +379,32 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) vector<Test::ServantPrx> servants; for(i = 0; i < size; i++) { - ostringstream ostr; - ostr << i; - string id = ostr.str(); - servants.push_back(evictor->createServant(id, i)); - servants[i]->ice_ping(); - - Test::FacetPrx facet1 = Test::FacetPrx::uncheckedCast(servants[i], "facet1"); - try - { - facet1->ice_ping(); - test(false); - } - catch(const Ice::FacetNotExistException&) - { - // Expected - } - - servants[i]->addFacet("facet1", "data"); - facet1->ice_ping(); - facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1); - facet1->setValue(10 * i); - facet1->addFacet("facet2", "moreData"); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); - test(facet2); - facet2->setValue(100 * i); + ostringstream ostr; + ostr << i; + string id = ostr.str(); + servants.push_back(evictor->createServant(id, i)); + servants[i]->ice_ping(); + + Test::FacetPrx facet1 = Test::FacetPrx::uncheckedCast(servants[i], "facet1"); + try + { + facet1->ice_ping(); + test(false); + } + catch(const Ice::FacetNotExistException&) + { + // Expected + } + + servants[i]->addFacet("facet1", "data"); + facet1->ice_ping(); + facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1); + facet1->setValue(10 * i); + facet1->addFacet("facet2", "moreData"); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); + test(facet2); + facet2->setValue(100 * i); } // @@ -414,14 +414,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) evictor->setSize(size); for(i = 0; i < size; i++) { - test(servants[i]->getValue() == i); - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1); - test(facet1->getValue() == 10 * i); - test(facet1->getData() == "data"); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); - test(facet2); - test(facet2->getData() == "moreData"); + test(servants[i]->getValue() == i); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1); + test(facet1->getValue() == 10 * i); + test(facet1->getData() == "data"); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); + test(facet2); + test(facet2->getData() == "moreData"); } // @@ -429,13 +429,13 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->setValue(i + 100); - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1); - facet1->setValue(10 * i + 100); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); - test(facet2); - facet2->setValue(100 * i + 100); + servants[i]->setValue(i + 100); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1); + facet1->setValue(10 * i + 100); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); + test(facet2); + facet2->setValue(100 * i + 100); } // @@ -445,13 +445,13 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) evictor->setSize(size); for(i = 0; i < size; i++) { - test(servants[i]->getValue() == i + 100); - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1); - test(facet1->getValue() == 10 * i + 100); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); - test(facet2); - test(facet2->getValue() == 100 * i + 100); + test(servants[i]->getValue() == i + 100); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1); + test(facet1->getValue() == 10 * i + 100); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); + test(facet2); + test(facet2->getValue() == 100 * i + 100); } // // Test saving while busy @@ -459,24 +459,24 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) Test::AMI_Servant_setValueAsyncPtr setCB = new AMI_Servant_setValueAsyncI; for(i = 0; i < size; i++) { - // - // Start a mutating operation so that the object is not idle. - // - servants[i]->setValueAsync_async(setCB, i + 300); - - test(servants[i]->getValue() == i + 100); - // - // This operation modifies the object state but is not saved - // because the setValueAsync operation is still pending. - // - servants[i]->setValue(i + 200); - test(servants[i]->getValue() == i + 200); + // + // Start a mutating operation so that the object is not idle. + // + servants[i]->setValueAsync_async(setCB, i + 300); + + test(servants[i]->getValue() == i + 100); + // + // This operation modifies the object state but is not saved + // because the setValueAsync operation is still pending. + // + servants[i]->setValue(i + 200); + test(servants[i]->getValue() == i + 200); - // - // Force the response to setValueAsync - // - servants[i]->releaseAsync(); - test(servants[i]->getValue() == i + 300); + // + // Force the response to setValueAsync + // + servants[i]->releaseAsync(); + test(servants[i]->getValue() == i + 300); } // @@ -484,14 +484,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - try - { - servants[i]->addFacet("facet1", "foobar"); - test(false); - } - catch(const Test::AlreadyRegisteredException&) - { - } + try + { + servants[i]->addFacet("facet1", "foobar"); + test(false); + } + catch(const Test::AlreadyRegisteredException&) + { + } } // @@ -499,8 +499,8 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // try { - servants[0]->removeFacet("facet3"); - test(false); + servants[0]->removeFacet("facet3"); + test(false); } catch(const Test::NotRegisteredException&) { @@ -512,8 +512,8 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->removeFacet("facet1"); - servants[i]->removeFacet("facet2"); + servants[i]->removeFacet("facet1"); + servants[i]->removeFacet("facet2"); } // @@ -521,10 +521,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1 == 0); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(servants[i], "facet2"); - test(facet2 == 0); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1 == 0); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(servants[i], "facet2"); + test(facet2 == 0); } evictor->setSize(0); @@ -532,10 +532,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) for(i = 0; i < size; i++) { - test(servants[i]->getValue() == i + 300); + test(servants[i]->getValue() == i + 300); - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1 == 0); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1 == 0); } // @@ -543,26 +543,26 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->destroy(); - try - { - servants[i]->getValue(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } - - try - { - servants[i]->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } + servants[i]->destroy(); + try + { + servants[i]->getValue(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } + + try + { + servants[i]->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } } // @@ -571,11 +571,11 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) servants.clear(); for(i = 0; i < size; i++) { - ostringstream ostr; - ostr << i; - string id = ostr.str(); - servants.push_back(evictor->createServant(id, i)); - servants[i]->setTransientValue(i); + ostringstream ostr; + ostr << i; + string id = ostr.str(); + servants.push_back(evictor->createServant(id, i)); + servants[i]->setTransientValue(i); } // @@ -590,7 +590,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - test(servants[i]->getTransientValue() == -1); + test(servants[i]->getTransientValue() == -1); } // @@ -598,9 +598,9 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->keepInCache(); - servants[i]->keepInCache(); - servants[i]->setTransientValue(i); + servants[i]->keepInCache(); + servants[i]->keepInCache(); + servants[i]->setTransientValue(i); } evictor->saveNow(); evictor->setSize(0); @@ -612,7 +612,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - test(servants[i]->getTransientValue() == i); + test(servants[i]->getTransientValue() == i); } // @@ -620,14 +620,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->release(); + servants[i]->release(); } evictor->saveNow(); evictor->setSize(0); evictor->setSize(size); for(i = 0; i < size; i++) { - test(servants[i]->getTransientValue() == i); + test(servants[i]->getTransientValue() == i); } // @@ -635,14 +635,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->release(); + servants[i]->release(); } evictor->saveNow(); evictor->setSize(0); evictor->setSize(size); for(i = 0; i < size; i++) { - test(servants[i]->getTransientValue() == -1); + test(servants[i]->getTransientValue() == -1); } @@ -651,15 +651,15 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - try - { - servants[i]->release(); - test(false); - } - catch(const Test::NotRegisteredException&) - { - // Expected - } + try + { + servants[i]->release(); + test(false); + } + catch(const Test::NotRegisteredException&) + { + // Expected + } } @@ -673,12 +673,12 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) evictor->setSize(size); for(i = 0; i < size; i++) {
- ostringstream ostr;
- ostr << i;
- string id = ostr.str();
+ ostringstream ostr;
+ ostr << i;
+ string id = ostr.str();
- servants[i] = evictor->getServant(id); - test(servants[i]->getValue() == i); + servants[i] = evictor->getServant(id); + test(servants[i]->getValue() == i); } // @@ -689,19 +689,19 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) servants[0]->destroy(); { - const int threadCount = size * 2; - - ThreadPtr threads[threadCount]; - for(i = 0; i < threadCount; i++) - { - threads[i] = new ReadThread(servants); - threads[i]->start(); - } - - for(i = 0; i < threadCount; i++) - { - threads[i]->getThreadControl().join(); - } + const int threadCount = size * 2; + + ThreadPtr threads[threadCount]; + for(i = 0; i < threadCount; i++) + { + threads[i] = new ReadThread(servants); + threads[i]->start(); + } + + for(i = 0; i < threadCount; i++) + { + threads[i]->getThreadControl().join(); + } } // @@ -715,35 +715,35 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // CreateDestroy threads // { - const int threadCount = size;; - - ThreadPtr threads[threadCount]; - for(i = 0; i < threadCount; i++) - { - threads[i] = new CreateDestroyThread(evictor, i, size); - threads[i]->start(); - } - - for(i = 0; i < threadCount; i++) - { - threads[i]->getThreadControl().join(); - } - - // - // Verify all destroyed - // - for(i = 0; i < size; i++) - { - try - { - servants[i]->getValue(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } - } + const int threadCount = size;; + + ThreadPtr threads[threadCount]; + for(i = 0; i < threadCount; i++) + { + threads[i] = new CreateDestroyThread(evictor, i, size); + threads[i]->start(); + } + + for(i = 0; i < threadCount; i++) + { + threads[i]->getThreadControl().join(); + } + + // + // Verify all destroyed + // + for(i = 0; i < size; i++) + { + try + { + servants[i]->getValue(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } + } } // @@ -752,10 +752,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) servants.clear(); for(i = 0; i < size; i++) { - ostringstream ostr; - ostr << i; - string id = ostr.str(); - servants.push_back(evictor->createServant(id, i)); + ostringstream ostr; + ostr << i; + string id = ostr.str(); + servants.push_back(evictor->createServant(id, i)); } // @@ -763,30 +763,30 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // (really testing Ice here) // { - const int threadCount = size; - - ReadForeverThreadPtr threads[threadCount]; - for(i = 0; i < threadCount; i++) - { - threads[i] = new ReadForeverThread(servants); - threads[i]->start(); - } + const int threadCount = size; + + ReadForeverThreadPtr threads[threadCount]; + for(i = 0; i < threadCount; i++) + { + threads[i] = new ReadForeverThread(servants); + threads[i]->start(); + } - ThreadControl::sleep(Time::milliSeconds(500)); - for(i = 0; i < threadCount; i++) - { - threads[i]->setState(ReadForeverThread::StateDeactivating); - } - evictor->deactivate(); - for(i = 0; i < threadCount; i++) - { - threads[i]->setState(ReadForeverThread::StateDeactivated); - } + ThreadControl::sleep(Time::milliSeconds(500)); + for(i = 0; i < threadCount; i++) + { + threads[i]->setState(ReadForeverThread::StateDeactivating); + } + evictor->deactivate(); + for(i = 0; i < threadCount; i++) + { + threads[i]->setState(ReadForeverThread::StateDeactivated); + } - for(i = 0; i < threadCount; i++) - { - threads[i]->getThreadControl().join(); - } + for(i = 0; i < threadCount; i++) + { + threads[i]->getThreadControl().join(); + } } // @@ -799,30 +799,30 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // Deactivate in the middle of adds // { - const int threadCount = size; - - AddForeverThreadPtr threads[threadCount]; - for(i = 0; i < threadCount; i++) - { - threads[i] = new AddForeverThread(evictor, i); - threads[i]->start(); - } - - ThreadControl::sleep(Time::milliSeconds(500)); - for(i = 0; i < threadCount; i++) - { - threads[i]->setState(AddForeverThread::StateDeactivating); - } - evictor->deactivate(); - for(i = 0; i < threadCount; i++) - { - threads[i]->setState(AddForeverThread::StateDeactivated); - } - - for(i = 0; i < threadCount; i++) - { - threads[i]->getThreadControl().join(); - } + const int threadCount = size; + + AddForeverThreadPtr threads[threadCount]; + for(i = 0; i < threadCount; i++) + { + threads[i] = new AddForeverThread(evictor, i); + threads[i]->start(); + } + + ThreadControl::sleep(Time::milliSeconds(500)); + for(i = 0; i < threadCount; i++) + { + threads[i]->setState(AddForeverThread::StateDeactivating); + } + evictor->deactivate(); + for(i = 0; i < threadCount; i++) + { + threads[i]->setState(AddForeverThread::StateDeactivated); + } + + for(i = 0; i < threadCount; i++) + { + threads[i]->getThreadControl().join(); + } } diff --git a/cpp/test/Freeze/oldevictor/Test.ice b/cpp/test/Freeze/oldevictor/Test.ice index f1ee08793eb..61610763814 100644 --- a/cpp/test/Freeze/oldevictor/Test.ice +++ b/cpp/test/Freeze/oldevictor/Test.ice @@ -61,7 +61,7 @@ interface RemoteEvictor void setSize(int size); Servant* createServant(string id, int value) - throws AlreadyRegisteredException, EvictorDeactivatedException; + throws AlreadyRegisteredException, EvictorDeactivatedException; Servant* getServant(string id); diff --git a/cpp/test/Freeze/oldevictor/TestI.cpp b/cpp/test/Freeze/oldevictor/TestI.cpp index 9b2850c9397..2e88f875e28 100644 --- a/cpp/test/Freeze/oldevictor/TestI.cpp +++ b/cpp/test/Freeze/oldevictor/TestI.cpp @@ -20,16 +20,16 @@ class DelayedResponse : public Thread public: DelayedResponse(const Test::AMD_Servant_slowGetValuePtr& cb, int val) : - _cb(cb), - _val(val) + _cb(cb), + _val(val) { } virtual void run() { - ThreadControl::sleep(Time::milliSeconds(500)); - _cb->ice_response(_val); + ThreadControl::sleep(Time::milliSeconds(500)); + _cb->ice_response(_val); } private: @@ -75,7 +75,7 @@ Test::ServantI::slowGetValue(const Current&) const void Test::ServantI::slowGetValue_async(const AMD_Servant_slowGetValuePtr& cb, - const Current&) const + const Current&) const { IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); Monitor<Mutex>::Lock sync(*this); @@ -122,11 +122,11 @@ Test::ServantI::addFacet(const string& name, const string& data, const Current& try { - _evictor->addFacet(facet, current.id, name); + _evictor->addFacet(facet, current.id, name); } catch(const Ice::AlreadyRegisteredException&) { - throw Test::AlreadyRegisteredException(); + throw Test::AlreadyRegisteredException(); } } @@ -135,11 +135,11 @@ Test::ServantI::removeFacet(const string& name, const Current& current) const { try { - _evictor->removeFacet(current.id, name); + _evictor->removeFacet(current.id, name); } catch(const Ice::NotRegisteredException&) { - throw Test::NotRegisteredException(); + throw Test::NotRegisteredException(); } } @@ -169,11 +169,11 @@ Test::ServantI::release(const Current& current) { try { - _evictor->release(current.id); + _evictor->release(current.id); } catch(const Ice::NotRegisteredException&) { - throw NotRegisteredException(); + throw NotRegisteredException(); } } @@ -182,11 +182,11 @@ Test::ServantI::destroy(const Current& current) { try { - _evictor->remove(current.id); + _evictor->remove(current.id); } catch(const Ice::NotRegisteredException&) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } } @@ -224,7 +224,7 @@ public: void init(const Test::RemoteEvictorIPtr& remoteEvictor, const Freeze::EvictorPtr& evictor) { _remoteEvictor = remoteEvictor; - _evictor = evictor; + _evictor = evictor; } virtual void @@ -242,7 +242,7 @@ private: Test::RemoteEvictorI::RemoteEvictorI(const ObjectAdapterPtr& adapter, const string& envName, - const string& category) : + const string& category) : _adapter(adapter), _category(category) { @@ -274,19 +274,19 @@ Test::RemoteEvictorI::createServant(const string& id, Int value, const Current&) ServantPtr servant = new ServantI(this, _evictor, value); try { - return ServantPrx::uncheckedCast(_evictor->add(servant, ident)); + return ServantPrx::uncheckedCast(_evictor->add(servant, ident)); } catch(const Ice::AlreadyRegisteredException&) { - throw Test::AlreadyRegisteredException(); + throw Test::AlreadyRegisteredException(); } catch(const Ice::ObjectAdapterDeactivatedException&) { - throw EvictorDeactivatedException(); + throw EvictorDeactivatedException(); } catch(const Freeze::EvictorDeactivatedException&) { - throw EvictorDeactivatedException(); + throw EvictorDeactivatedException(); } } @@ -326,7 +326,7 @@ Test::RemoteEvictorI::destroyAllServants(const string& facetName, const Current& Freeze::EvictorIteratorPtr p = _evictor->getIterator(facetName, batchSize); while(p->hasNext()) { - _evictor->remove(p->next()); + _evictor->remove(p->next()); } } @@ -343,7 +343,7 @@ Test::RemoteEvictorFactoryI::createEvictor(const string& name, const Current& cu { RemoteEvictorIPtr remoteEvictor = new RemoteEvictorI(_adapter, _envName, name); return RemoteEvictorPrx::uncheckedCast(_adapter->add(remoteEvictor, - _adapter->getCommunicator()->stringToIdentity(name))); + _adapter->getCommunicator()->stringToIdentity(name))); } void diff --git a/cpp/test/Freeze/oldevictor/TestI.h b/cpp/test/Freeze/oldevictor/TestI.h index 3f7ac3af396..cef09c3d6ad 100644 --- a/cpp/test/Freeze/oldevictor/TestI.h +++ b/cpp/test/Freeze/oldevictor/TestI.h @@ -41,7 +41,7 @@ public: virtual void slowGetValue_async(const AMD_Servant_slowGetValuePtr&, - const Ice::Current& = Ice::Current()) const; + const Ice::Current& = Ice::Current()) const; virtual void setValue(::Ice::Int, const Ice::Current& = Ice::Current()); |