TEST(ConnectionPoolTest, Limit) { log4cpp::Priority::PriorityLevel level = log4cpp::Priority::ERROR; log4cpp::Category& log = logging_init(level); ConnectionPool *pool = new ConnectionPool(&log, 200); ASSERT_EQ(pool->GetLimit(), 200); }
int run( const std::string& connectionString ){ try{ //************* std::cout <<"> Connecting with db in "<<connectionString<<std::endl; ConnectionPool connPool; connPool.setMessageVerbosity( coral::Debug ); Session session = connPool.createSession( connectionString, true ); session.transaction().start( false ); IOVEditor editor; if( !session.existsDatabase() || !session.existsIov( "BasicPayload_v0" ) ){ editor = session.createIov<cond::BasicPayload>( "BasicPayload_v0", cond::runnumber ); editor.setDescription("Test for timestamp selection"); } for( int i=0;i<10;i++ ){ cond::BasicPayload p( i*10.1, i+1. ); auto pid = session.storePayload( p ); editor.insert( i*100+1, pid ); } editor.flush(); std::cout <<"> iov changes flushed..."<<std::endl; session.transaction().commit(); } catch (const std::exception& e){ std::cout << "ERROR: " << e.what() << std::endl; return -1; } catch (...){ std::cout << "UNEXPECTED FAILURE." << std::endl; return -1; } std::cout <<"## Run successfully completed."<<std::endl; return 0; }
int main (int argc, char** argv) { edmplugin::PluginManager::Config config; edmplugin::PluginManager::configure(edmplugin::standard::config()); std::vector<edm::ParameterSet> psets; edm::ParameterSet pSet; pSet.addParameter("@service_type",std::string("SiteLocalConfigService")); psets.push_back(pSet); static const edm::ServiceToken services(edm::ServiceRegistry::createSet(psets)); static const edm::ServiceRegistry::Operate operate(services); std::string connectionString("frontier://FrontierProd/CMS_CONDITIONS"); std::cout <<"# Connecting with db in "<<connectionString<<std::endl; try{ //************* ConnectionPool connPool; connPool.setMessageVerbosity( coral::Debug ); Session session = connPool.createSession( connectionString ); session.transaction().start(); IOVProxy iov = session.readIov( "runinfo_31X_hlt", true ); std::cout << "Loaded size="<<iov.loadedSize()<<std::endl; session.transaction().commit(); } catch (const std::exception& e){ std::cout << "ERROR: " << e.what() << std::endl; return -1; } catch (...){ std::cout << "UNEXPECTED FAILURE." << std::endl; return -1; } }
/** * The testing logic of the test case. */ dvoid select () { cout << "occipool - Selecting records using ConnectionPool interface" << endl; const string poolUserName = "******"; const string poolPassword = "******"; const string connectString = ""; const string username = "******"; const string passWord = "******"; unsigned int maxConn = 5; unsigned int minConn = 3; unsigned int incrConn = 2; ConnectionPool *connPool; try{ connPool = env->createConnectionPool (poolUserName, poolPassword, connectString, minConn, maxConn, incrConn); if (connPool) cout << "SUCCESS - createConnectionPool" << endl; else cout << "FAILURE - createConnectionPool" << endl; con = connPool->createConnection (username, passWord); if (con) cout << "SUCCESS - createConnection" << endl; else cout << "FAILURE - createConnection" << endl; }catch(SQLException ex) { cout<<"Exception thrown for createConnectionPool"<<endl; cout<<"Error number: "<< ex.getErrorCode() << endl; cout<<ex.getMessage() << endl; return; } cout << "retrieving the data" << endl; try{ stmt = con->createStatement ("SELECT author_id, author_name FROM author_tab"); ResultSet *rset = stmt->executeQuery(); while (rset->next()) { cout << "author_id:" << rset->getInt (1) << endl; cout << "author_name:" << rset->getString (2) << endl; } stmt->closeResultSet (rset); con->terminateStatement (stmt); connPool->terminateConnection (con); env->terminateConnectionPool (connPool); }catch(SQLException ex) { cout<<"Exception thrown for retrieving data"<<endl; cout<<"Error number: "<< ex.getErrorCode() << endl; cout<<ex.getMessage() << endl; } cout << "occipool - done" << endl; } // end of test (Connection *)
void setUp() { for (int i = 0; i < connectionPool.size(); i++) { Connection& connection = connectionPool.getConnection(i); connection.accept(8080, "127.0.0.1"); cout << "Connected" << i << endl; } }
void Connection::handle_auth(CryptoIdentity& ci, ConnectionHandler& ch, const std::string& packet, TransportSocket ts, ConnectionPool& cp, NetworkMap& nm) { // This may be the auth packet to start a connection, with contents: // pkttype, routeid, pktid, cookie, [[A'](A<>B'),bcard_A](A'<>B') if (packet.size() < 1+8+8+COOKIE_SIZE) return; std::string nonce = packet.substr(1,8+8); nonce.resize(crypto_box_NONCEBYTES,'\0'); std::string their_connection_pk; std::string connection_sk; { // open the cookie we gave them before std::string c; std::string cookie = packet.substr(1+8+8, COOKIE_SIZE); if ( ! ci.cookies.open(cookie, c) ) return; their_connection_pk = c.substr(0,crypto_box_PUBLICKEYBYTES); if ( ! ci.cookies.allowed(their_connection_pk)) return; ci.cookies.blacklist(their_connection_pk); /// \FIXME don't accept connections from connection enc keys that may /// have been used with the current cookies to avoid session replays connection_sk = c.substr(crypto_box_PUBLICKEYBYTES); assert(connection_sk.size() == crypto_box_SECRETKEYBYTES); } std::string remaining = packet.substr(1+8+8+COOKIE_SIZE); // decrypt the message body std::string message; nacl25519_nm naclsession(their_connection_pk, connection_sk); if ( ! naclsession.decrypt(remaining, nonce, message) ) return; // their main enc key should vouch for the connection enc key std::size_t vouchlen = crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES; if (message.size() < vouchlen) return; std::string their_main_pk; Device dev; if ( ! dev.parseFrom( message.substr(vouchlen) ) ) return; // verify the vouching std::string vouch = message.substr(0, vouchlen); std::string vkey; /// \FIXME get from device if ( ! dev.open( vouch, nonce, connection_sk , PkencAlgo::CURVE25519XSALSA20POLY1305, vkey ) || vkey != their_connection_pk) return; // all ok, save the connection std::string their_id = dev.id(); std::string route_id = packet.substr(1,8); auto conn = std::make_shared <Connection>(std::move(naclsession), their_id, route_id, cp, ch); auto rfwd = std::make_shared <SimpleForwarding>(nm, conn->id()); Forwarding::pair(conn, rfwd); auto it = cp.find(their_id); if (it != cp.end()) WARNING() << "Already connected" << (it->second->_authenticated? " and authenticated": ""); cp.insert( std::make_pair(their_id, conn) ); nm.device(ts)->addForwarding(rfwd); }
int doWrite( const std::string& connectionString ){ try{ //************* std::cout <<"> Connecting for writing with db in "<<connectionString<<std::endl; ConnectionPool connPool; connPool.setMessageVerbosity( coral::Debug ); Session session = connPool.createSession( connectionString, true ); session.transaction().start( false ); MyTestData d0( iVal0 ); MyTestData d1( iVal1 ); std::cout <<"> Storing payload ptr=" << &d0 << std::endl; cond::Hash p0 = session.storePayload( d0, boost::posix_time::microsec_clock::universal_time() ); cond::Hash p1 = session.storePayload( d1, boost::posix_time::microsec_clock::universal_time() ); std::string d(sVal); cond::Hash p3 = session.storePayload( d, boost::posix_time::microsec_clock::universal_time() ); IOVEditor editor; if( !session.existsIov( "MyNewIOV" ) ){ editor = session.createIov<MyTestData>( "MyNewIOV", cond::runnumber ); editor.setDescription("Test with MyTestData class"); editor.insert( 1, p0 ); editor.insert( 100, p1 ); std::cout <<"> inserted 2 iovs..."<<std::endl; editor.flush(); std::cout <<"> iov changes flushed..."<<std::endl; } if( !session.existsIov( "StringData" ) ){ editor = session.createIov<std::string>( "StringData", cond::timestamp ); editor.setDescription("Test with std::string class"); editor.insert( 1000000, p3 ); editor.insert( 2000000, p3 ); editor.flush(); } session.transaction().commit(); std::cout <<"> iov changes committed!..."<<std::endl; session.transaction().commit(); } catch (const std::exception& e){ std::cout << "ERROR: " << e.what() << std::endl; return -1; } catch (...){ std::cout << "UNEXPECTED FAILURE." << std::endl; return -1; } std::cout <<"## Run successfully completed."<<std::endl; return 0; }
void task() { for (int i = 0; i < connectionPool.size(); i++) { Connection& connection = connectionPool.getConnection(i); string text = ""; text = connection.getData(); if (text != "") { cout << text << endl; } } }
void run() { std::mt19937 generator(randomSeed()); std::uniform_int_distribution<size_t> distribution(0, queries.size() - 1); for (size_t i = 0; i < concurrency; ++i) pool.schedule(std::bind(&Benchmark::thread, this, connections.get())); InterruptListener interrupt_listener; info_per_interval.watch.restart(); delay_watch.restart(); /// Push queries into queue for (size_t i = 0; !max_iterations || i < max_iterations; ++i) { size_t query_index = randomize ? distribution(generator) : i % queries.size(); if (!tryPushQueryInteractively(queries[query_index], interrupt_listener)) break; } shutdown = true; pool.wait(); info_total.watch.stop(); if (!json_path.empty()) reportJSON(info_total, json_path); printNumberOfQueriesExecuted(info_total.queries); report(info_total); }
TEST(ConnectionPoolTest, Available) { log4cpp::Priority::PriorityLevel level = log4cpp::Priority::ERROR; log4cpp::Category& log = logging_init(level); ConnectionPool *pool = new ConnectionPool(&log); ASSERT_EQ(pool->GetLimit(), 100); ASSERT_EQ(pool->GetAvailable(), 0); int fd = open("/dev/null", O_APPEND); if (fd == -1) { log.error("Open failed: %s", strerror(errno)); ASSERT_NE(fd, -1); } connection *conn = pool->Checkout(fd); ASSERT_EQ(pool->GetAvailable(), 0); int result = pool->Return(conn); ASSERT_EQ(result, 0); int available = pool->GetAvailable(); log.warn("asfasfdasf"); ASSERT_EQ(available, 1); };
int main() { ReceiverThread receiver; receiver.startLooping(1); ConnectionPool connectionPool; connectionPool.maxConnections = size; connectionPool.add(connectionPool.maxConnections); cout << "Connecting" << endl; for (int i = 0; i < connectionPool.size(); i++) { Connection& connection = connectionPool.getConnection(i); if (!connection.connect("127.0.0.1", 8080, 1)) { cout << "Failed to connect " << i << endl; cin.get(); exit(0); return 0; } } sleep(3000); while (true) { for (int i = 0; i < connectionPool.size(); i++) { Connection& connection = connectionPool.getConnection(i); connection.sendData("This is a test. " + toString(i)); } } }
int run( const std::string& connectionString ){ try{ //************* std::cout <<"> Connecting with db in "<<connectionString<<std::endl; ConnectionPool connPool; connPool.setMessageVerbosity( coral::Debug ); Session session = connPool.createSession( connectionString, true ); session.transaction().start( false ); std::string pay0("Payload #0"); std::string pay1("Payload #1"); auto p0 = session.storePayload( pay0); auto p1 = session.storePayload( pay1); IOVEditor editor; if( !session.existsIov( "MyTag" ) ){ editor = session.createIov<std::string>( "MyTag", cond::runnumber ); editor.setDescription("Test for timestamp selection"); editor.insert( 100, p0 ); editor.insert( 200, p1 ); editor.insert( 1001, p0 ); editor.insert( 1500, p1 ); editor.insert( 2100, p0 ); editor.insert( 2500, p1 ); editor.insert( 10000, p0 ); std::cout <<"> inserted 7 iovs..."<<std::endl; editor.flush(); std::cout <<"> iov changes flushed..."<<std::endl; } if( !session.existsIov( "MyTag2" ) ){ editor = session.createIov<std::string>( "MyTag2", cond::runnumber ); editor.setDescription("Test for timestamp selection"); editor.insert( 100, p0 ); std::cout <<"> inserted 1 iovs..."<<std::endl; editor.flush(); std::cout <<"> iov changes flushed..."<<std::endl; } session.transaction().commit(); std::cout <<"> iov changes committed!..."<<std::endl; ::sleep(2); session.transaction().start(); IOVProxy proxy = session.readIov( "MyTag" ); readIov( proxy, 1, false ); readIov( proxy, 100, true ); readIov( proxy, 1499, true ); readIov( proxy, 1500, true ); readIov( proxy, 20000, true ); proxy.find( 101 ); for( const auto i : proxy ){ std::cout <<"# iov since "<<i.since<<" - till "<<i.till<<std::endl; } proxy = session.readIov( "MyTag2" ); readIov( proxy, 1, false ); readIov( proxy, 100, true ); session.transaction().commit(); } catch (const std::exception& e){ std::cout << "ERROR: " << e.what() << std::endl; return -1; } catch (...){ std::cout << "UNEXPECTED FAILURE." << std::endl; return -1; } std::cout <<"## Run successfully completed."<<std::endl; return 0; }
int cond::MigrateGTUtilities::execute(){ std::string gtag = getOptionValue<std::string>("globaltag"); std::string release = getOptionValue<std::string>("release"); bool debug = hasDebug(); std::string destConnect = getOptionValue<std::string>("destConnect" ); std::string sourceConnect = getOptionValue<std::string>("sourceConnect"); bool verbose = hasOptionValue("verbose"); bool dryRun = hasOptionValue("dryRun"); bool onlineMode = hasOptionValue("online"); std::vector<std::tuple<std::string,std::string,std::string,std::string,std::string> > gtlist; if(! getGTList( gtag, gtlist ) ) throw std::runtime_error( std::string("Source GT ")+gtag+" has not been found." ); ConnectionPool connPool; if( hasDebug() ) connPool.setMessageVerbosity( coral::Debug ); Session session = connPool.createSession( destConnect, !dryRun ); session.transaction().start( dryRun ); if( session.existsGlobalTag( gtag ) ){ std::cout <<"GT "<<gtag<<" already exists in the destination database."<<std::endl; return 1; } GTEditor newGT; if( !dryRun ){ newGT = session.createGlobalTag( gtag ); newGT.setDescription( "GT "+gtag+" migrated from account "+sourceConnect ); newGT.setRelease( release ); newGT.setSnapshotTime( boost::posix_time::time_from_string(std::string(cond::time::MAX_TIMESTAMP) ) ); } std::cout <<"Processing "<<gtlist.size()<<" tags."<<std::endl; size_t nerr = 0; for(auto gtitem : gtlist ){ std::string tag = std::get<0>( gtitem ); std::string payloadTypeName = std::get<1>( gtitem ); std::string recordName = std::get<2>( gtitem ); std::string recordLabel = std::get<3>( gtitem ); std::string connectionString = std::get<4>( gtitem ); std::cout <<"--> Processing tag "<<tag<<" (objectType: "<<payloadTypeName<<") on account "<<connectionString<<std::endl; std::string sourceConn = convert( connectionString, onlineMode ); // "oracle://cms_orcon_adg/"+account; std::string destTag(""); cond::MigrationStatus status; bool exists = session.checkMigrationLog( sourceConn, tag, destTag, status ); if(!exists || status==cond::ERROR){ std::cout <<" ERROR: Tag "<<tag<<" from "<<sourceConn<<" has not been migrated to the destination database."<<std::endl; if( !dryRun ){ return 1; } else { nerr++; } } else { std::cout <<" Inserting tag "<<destTag<<std::endl; } if( !dryRun ) newGT.insert( recordName, recordLabel, destTag ); } if( !dryRun )newGT.flush(); session.transaction().commit(); std::cout << std::endl; if( !dryRun ) { std::cout <<"Global Tag \""<<gtag<<"\" imported."<<std::endl; } else { std::cout <<"Importing Global Tag \""<<gtag<<"\" will run with "<<nerr<<" error(s)"<<std::endl; } return 0; }
int doRead( const std::string& connectionString ){ int nFail = 0; try{ //************* std::cout <<"> Connecting for reading with db in "<<connectionString<<std::endl; ConnectionPool connPool; connPool.setMessageVerbosity( coral::Debug ); Session session = connPool.createSession( connectionString, true ); session.transaction().start( false ); session.transaction().start(); IOVProxy proxy = session.readIov( "MyNewIOV" ); std::cout <<"> iov loaded size="<<proxy.loadedSize()<<std::endl; std::cout <<"> iov sequence size="<<proxy.sequenceSize()<<std::endl; IOVProxy::Iterator iovIt = proxy.find( 57 ); if( iovIt == proxy.end() ){ std::cout <<">[0] not found!"<<std::endl; } else { cond::Iov_t val = *iovIt; std::cout <<"#[0] iov since="<<val.since<<" till="<<val.till<<" pid="<<val.payloadId<<std::endl; std::shared_ptr<MyTestData> pay0 = session.fetchPayload<MyTestData>( val.payloadId ); pay0->print(); if ( *pay0 != MyTestData(iVal0) ){ nFail++; std::cout << "ERROR, pay0 found to be wrong, expected : " << iVal0 << " IOV: " << val.since << std::endl; } iovIt++; } if(iovIt == proxy.end() ){ std::cout<<"#[1] not found!"<<std::endl; } else { cond::Iov_t val =*iovIt; std::cout <<"#[1] iov since="<<val.since<<" till="<<val.till<<" pid="<<val.payloadId<<std::endl; std::shared_ptr<MyTestData> pay1 = session.fetchPayload<MyTestData>( val.payloadId ); pay1->print(); if ( *pay1 != MyTestData(iVal1) ){ nFail++; std::cout << "ERROR, pay1 found to be wrong, expected : " << iVal1 << " IOV: " << val.since << std::endl; } } iovIt = proxy.find( 176 ); if( iovIt == proxy.end() ){ std::cout <<"#[2] not found!"<<std::endl; } else { cond::Iov_t val = *iovIt; std::cout <<"#[2] iov since="<<val.since<<" till="<<val.till<<" pid="<<val.payloadId<<std::endl; std::shared_ptr<MyTestData> pay2 = session.fetchPayload<MyTestData>( val.payloadId ); pay2->print(); if ( *pay2 != MyTestData(iVal1) ){ nFail++; std::cout << "ERROR, pay2 found to be wrong, expected : " << iVal1 << " IOV: " << val.since << std::endl; } iovIt++; } if(iovIt == proxy.end() ){ std::cout<<"#[3] not found!"<<std::endl; } else { cond::Iov_t val =*iovIt; std::cout <<"#[3] iov since="<<val.since<<" till="<<val.till<<" pid="<<val.payloadId<<std::endl; std::shared_ptr<MyTestData> pay3 = session.fetchPayload<MyTestData>( val.payloadId ); pay3->print(); if ( *pay3 != MyTestData(iVal1) ){ nFail++; std::cout << "ERROR, pay3 found to be wrong, expected : " << iVal1 << " IOV: " << val.since << std::endl; } } proxy = session.readIov( "StringData" ); auto iov2It = proxy.find( 1000022 ); if(iov2It == proxy.end() ){ std::cout<<"#[4] not found!"<<std::endl; } else { cond::Iov_t val =*iov2It; std::cout <<"#[4] iov since="<<val.since<<" till="<<val.till<<" pid="<<val.payloadId<<std::endl; std::shared_ptr<std::string> pay4 = session.fetchPayload<std::string>( val.payloadId ); std::cout <<"#pay4="<<*pay4<<std::endl; if ( *pay4 != sVal ){ nFail++; std::cout << "ERROR, pay4 found to be " << *pay4 << " expected : " << sVal << " IOV: " << val.since << std::endl; } } session.transaction().commit(); } catch (const std::exception& e){ std::cout << "ERROR: " << e.what() << std::endl; return -1; } catch (...){ std::cout << "UNEXPECTED FAILURE." << std::endl; return -1; } if (nFail == 0) { std::cout << "## Run successfully completed." << std::endl; } else { std::cout << "## Run completed with ERRORS. nFail = " << nFail << std::endl; } return nFail; }
ReceiverThread() { connectionPool.maxConnections = size; connectionPool.add(connectionPool.maxConnections); }
int run( const std::string& connectionString ){ try{ //************* std::cout <<"> Connecting with db in "<<connectionString<<std::endl; ConnectionPool connPool; connPool.setMessageVerbosity( coral::Debug ); Session session = connPool.createSession( connectionString, true, cond::COND_DB ); session.transaction().start( false ); std::string pay0("Payload #0"); std::string pay1("Payload #1"); std::string pay2("Payload #2"); std::string pay3("Payload #3"); std::string pay4("Payload #4"); std::string pay5("Payload #5"); auto p0 = session.storePayload( pay0 ); auto p1 = session.storePayload( pay1 ); auto p2 = session.storePayload( pay2 ); IOVEditor editor; if( !session.existsIov( "MyTag" ) ){ editor = session.createIov<std::string>( "MyTag", cond::runnumber ); editor.setDescription("Test for timestamp selection"); editor.insert( 1, p0 ); editor.insert( 101, p1 ); editor.insert( 201, p2 ); std::cout <<"> inserted 3 iovs..."<<std::endl; editor.flush(); std::cout <<"> iov changes flushed..."<<std::endl; } session.transaction().commit(); boost::posix_time::ptime snap0 = boost::posix_time::microsec_clock::universal_time(); std::cout <<"> iov changes committed!..."<<std::endl; ::sleep(2); boost::posix_time::ptime notime; session.transaction().start(); readTag( "MyTag", session, notime ); session.transaction().commit(); session.transaction().start( false ); auto p3 = session.storePayload( pay3 ); auto p4 = session.storePayload( pay4 ); auto p5 = session.storePayload( pay5 ); editor = session.editIov( "MyTag" ); editor.insert( 101, p3 ); editor.insert( 222, p4 ); editor.flush(); session.transaction().commit(); boost::posix_time::ptime snap1 = boost::posix_time::microsec_clock::universal_time(); ::sleep(2); session.transaction().start(); readTag( "MyTag", session, notime ); session.transaction().commit(); session.transaction().start( false ); editor = session.editIov( "MyTag" ); editor.insert( 102, p5 ); editor.flush(); session.transaction().commit(); session.transaction().start(); readTag( "MyTag", session, notime ); session.transaction().commit(); session.transaction().start(); readTag( "MyTag", session, snap0 ); session.transaction().commit(); session.transaction().start(); readTag( "MyTag", session, snap1 ); session.transaction().commit(); } catch (const std::exception& e){ std::cout << "ERROR: " << e.what() << std::endl; return -1; } catch (...){ std::cout << "UNEXPECTED FAILURE." << std::endl; return -1; } std::cout <<"## Run successfully completed."<<std::endl; return 0; }
int run( const std::string& connectionString ){ try{ //************* std::cout <<"> Connecting with db in "<<connectionString<<std::endl; ConnectionPool connPool; connPool.setMessageVerbosity( coral::Debug ); Session session = connPool.createSession( connectionString, true ); session.transaction().start( false ); MyTestData d0( 17 ); MyTestData d1( 999 ); std::cout <<"> Storing payload ptr="<<&d0<<std::endl; cond::Hash p0 = session.storePayload( d0, boost::posix_time::microsec_clock::universal_time() ); cond::Hash p1 = session.storePayload( d1, boost::posix_time::microsec_clock::universal_time() ); std::string d("abcd1234"); cond::Hash p3 = session.storePayload( d, boost::posix_time::microsec_clock::universal_time() ); IOVEditor editor; if( !session.existsIov( "MyNewIOV" ) ){ editor = session.createIov<MyTestData>( "MyNewIOV", cond::runnumber, cond::SYNCH_OFFLINE ); editor.setDescription("Test with MyTestData class"); editor.insert( 1, p0 ); editor.insert( 100, p1 ); std::cout <<"> inserted 2 iovs..."<<std::endl; editor.flush(); std::cout <<"> iov changes flushed..."<<std::endl; } if( !session.existsIov( "StringData" ) ){ editor = session.createIov<std::string>( "StringData", cond::timestamp ); editor.setDescription("Test with std::string class"); editor.insert( 1000000, p3 ); editor.insert( 2000000, p3 ); editor.flush(); } session.transaction().commit(); std::cout <<"> iov changes committed!..."<<std::endl; session.transaction().start( false ); std::cout <<"## now trying to insert in the past..."<<std::endl; try{ editor = session.editIov( "MyNewIOV" ); editor.insert( 200, p1 ); editor.insert( 300, p1 ); editor.insert( 50, p1 ); editor.flush(); std::cout <<"ERROR: forbidden insertion."<<std::endl; session.transaction().commit(); } catch ( const cond::persistency::Exception& e ){ std::cout <<"Expected error: "<<e.what()<<std::endl; session.transaction().rollback(); } session.transaction().start( false ); editor = session.editIov( "StringData" ); editor.insert( 3000000, p3 ); editor.insert( 4000000, p3 ); editor.insert( 1500000, p3); editor.flush(); std::cout <<"Insertion in the past completed."<<std::endl; session.transaction().commit(); ::sleep(2); session.transaction().start(); IOVProxy proxy = session.readIov( "MyNewIOV" ); std::cout <<"> iov loaded size="<<proxy.loadedSize()<<std::endl; std::cout <<"> iov sequence size="<<proxy.sequenceSize()<<std::endl; IOVProxy::Iterator iovIt = proxy.find( 57 ); if( iovIt == proxy.end() ){ std::cout <<">[0] not found!"<<std::endl; } else { cond::Iov_t val = *iovIt; std::cout <<"#[0] iov since="<<val.since<<" till="<<val.till<<" pid="<<val.payloadId<<std::endl; std::shared_ptr<MyTestData> pay0 = session.fetchPayload<MyTestData>( val.payloadId ); pay0->print(); iovIt++; } if(iovIt == proxy.end() ){ std::cout<<"#[1] not found!"<<std::endl; } else { cond::Iov_t val =*iovIt; std::cout <<"#[1] iov since="<<val.since<<" till="<<val.till<<" pid="<<val.payloadId<<std::endl; std::shared_ptr<MyTestData> pay1 = session.fetchPayload<MyTestData>( val.payloadId ); pay1->print(); } iovIt = proxy.find( 176 ); if( iovIt == proxy.end() ){ std::cout <<"#[2] not found!"<<std::endl; } else { cond::Iov_t val = *iovIt; std::cout <<"#[2] iov since="<<val.since<<" till="<<val.till<<" pid="<<val.payloadId<<std::endl; std::shared_ptr<MyTestData> pay2 = session.fetchPayload<MyTestData>( val.payloadId ); pay2->print(); iovIt++; } if(iovIt == proxy.end() ){ std::cout<<"#[3] not found!"<<std::endl; } else { cond::Iov_t val =*iovIt; std::cout <<"#[3] iov since="<<val.since<<" till="<<val.till<<" pid="<<val.payloadId<<std::endl; std::shared_ptr<MyTestData> pay3 = session.fetchPayload<MyTestData>( val.payloadId ); pay3->print(); } proxy = session.readIov( "StringData" ); auto iov2It = proxy.find( 1000022 ); if(iov2It == proxy.end() ){ std::cout<<"#[4] not found!"<<std::endl; } else { cond::Iov_t val =*iov2It; std::cout <<"#[4] iov since="<<val.since<<" till="<<val.till<<" pid="<<val.payloadId<<std::endl; std::shared_ptr<std::string> pay4 = session.fetchPayload<std::string>( val.payloadId ); std::cout <<"#pay4="<<*pay4<<std::endl; } session.transaction().commit(); } catch (const std::exception& e){ std::cout << "ERROR: " << e.what() << std::endl; return -1; } catch (...){ std::cout << "UNEXPECTED FAILURE." << std::endl; return -1; } std::cout <<"## Run successfully completed."<<std::endl; return 0; }