From 472d9552de83c5e8b96030f47ed222de77556417 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Tue, 21 Aug 2012 17:01:15 -0400 Subject: Much better fix for ICE-2097: whether or not to keep the stats is no longer determined by the encoding but by the Catalog data for the evictor. With the new default, the catalog data key and value are set, in particular the value is set to "Object". With old evictors, the catalog data value was set to "", which means ::Freeze::ObjectRecord (with stats). --- cpp/src/FreezeScript/DumpDB.cpp | 54 ++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 31 deletions(-) (limited to 'cpp/src/FreezeScript/DumpDB.cpp') diff --git a/cpp/src/FreezeScript/DumpDB.cpp b/cpp/src/FreezeScript/DumpDB.cpp index 955cbcf66af..b2da041ec3d 100755 --- a/cpp/src/FreezeScript/DumpDB.cpp +++ b/cpp/src/FreezeScript/DumpDB.cpp @@ -106,7 +106,6 @@ usage(const string& n) "--select EXPR Dump a record only if EXPR is true.\n" "-c, --catalog Display information about the databases in an\n" " environment, or about a particular database.\n" - "--encoding VERSION Sets the encoding version for the database environment.\n" ; } @@ -159,7 +158,6 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator opts.addOpt("", "value", IceUtilInternal::Options::NeedArg); opts.addOpt("", "select", IceUtilInternal::Options::NeedArg); opts.addOpt("c", "catalog"); - opts.addOpt("", "encoding", IceUtilInternal::Options::NeedArg); vector args; try @@ -173,8 +171,6 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator return EXIT_FAILURE; } - Ice::EncodingVersion encoding = Ice::currentEncoding; - // // Freeze creates a lock file by default to prevent multiple processes from opening // the same database environment simultaneously. In the case of a read-only program @@ -193,9 +189,6 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator { props->setProperty(prefix + ".LockFile", "0"); } - - encoding = Ice::stringToEncodingVersion( - props->getPropertyWithDefault(prefix + ".Encoding", Ice::encodingVersionToString(encoding))); } if(opts.isSet("h")) @@ -321,17 +314,7 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator { selectExpr = opts.optArg("select"); } - if(opts.isSet("encoding")) - { - encoding = Ice::stringToEncodingVersion(opts.optArg("encoding")); - } - - if(!IceInternal::isSupported(encoding, Ice::currentEncoding)) - { - cerr << appName << ": " << "unsupported encoding" << endl; - return EXIT_FAILURE; - } - + if(outputFile.empty() && args.size() != 2) { usage(appName); @@ -374,15 +357,16 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator if(inputFile.empty()) { const string evictorKeyTypeName = "::Ice::Identity"; - const string evictorValueTypeName = (encoding == Ice::Encoding_1_0) ? "::Freeze::ObjectRecord" : "Object"; + const string oldEvictorValueTypeName = "::Freeze::ObjectRecord"; + const string newEvictorValueTypeName = "Object"; - if((!keyTypeName.empty() && valueTypeName.empty()) || (keyTypeName.empty() && !valueTypeName.empty())) + if((!keyTypeName.empty() && valueTypeName.empty()) || (keyTypeName.empty() && !valueTypeName.empty() && !evictor)) { cerr << appName << ": a key type and a value type must be specified" << endl; usage(appName); return EXIT_FAILURE; } - else if(!evictor && keyTypeName.empty() && valueTypeName.empty()) + else if(valueTypeName.empty()) { try { @@ -404,24 +388,32 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator { evictor = true; } - else - { - keyTypeName = p->second.key; - valueTypeName = p->second.value; - } + keyTypeName = p->second.key; + valueTypeName = p->second.value; + + if(evictor && valueTypeName.empty()) + { + valueTypeName = oldEvictorValueTypeName; + } } } catch(const FreezeScript::FailureException& ex) { - cerr << appName << ": " << ex.reason() << endl; - return EXIT_FAILURE; + cerr << appName << ": " << ex.reason() << endl; + return EXIT_FAILURE; } } if(evictor) { - keyTypeName = evictorKeyTypeName; - valueTypeName = evictorValueTypeName; + if(keyTypeName.empty()) + { + keyTypeName = evictorKeyTypeName; + } + if(valueTypeName.empty()) + { + valueTypeName = newEvictorValueTypeName; + } } Slice::TypePtr keyType, valueType; @@ -553,7 +545,7 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL); Dbc* dbc = 0; - db.cursor(0, &dbc, 0); + db.cursor(txn, &dbc, 0); while(dbc->get(&dbKey, &dbValue, DB_NEXT) == 0) { -- cgit v1.2.3