void PopulateLifos( Session & session, vector<myLifo> & l ) { int i, j; string data; char s[4]; psoObjectDefinition queueDef = { PSO_LIFO, 0, 0, 0 }; for ( i = 0; i < NUM_LIFOS; ++i ) { session.CreateQueue( l[i].name, queueDef, "Default" ); l[i].queue.Open( session, l[i].name ); for ( j = 0; j < 20; ++j ) { sprintf(s, "%d", j); data = string("Inserted data item = ") + s; sprintf(s, "%d", i); data += string(" in queue = ") + s; l[i].queue.Push( data.c_str(), data.length() ); } } session.Commit(); }
void CleanupPreviousRun( Session & session ) { Folder folder; psoFolderEntry entry; int ok; string s; try { folder.Open( session, foldername ); ok = folder.GetFirst( entry ); while ( ok == 0 ) { s = foldername + "/" + entry.name; session.DestroyObject( s ); ok = folder.GetNext( entry ); } session.Commit(); } catch ( pso::Exception exc ) { cerr << "Cleanup of previous session failed, error = " << exc.Message() << endl; exit(1); } }
void PopulateQueues( Session & session, vector<myQueue> & q ) { int i, j; string data; char s[4]; psoObjectDefinition queueDef = { PSO_QUEUE, 0, 0, 0 }; for ( i = 0; i < NUM_QUEUES; ++i ) { cout << " i = " << i << ", " << q[i].name << ", " << &session << endl; session.CreateQueue( q[i].name, queueDef, "Default" ); q[i].queue.Open( session, q[i].name ); for ( j = 0; j < 20; ++j ) { sprintf(s, "%d", j); data = string("Inserted data item = ") + s; sprintf(s, "%d", i); data += string(" in queue = ") + s; q[i].queue.Push( data.c_str(), data.length() ); } } session.Commit(); }
void PopulateHashMaps( Session & session, vector<myMap> & h ) { int i, j; string data, key; char s[4]; psoObjectDefinition mapDef = { PSO_HASH_MAP, 0, 0, 0 }; for ( i = 0; i < NUM_MAPS; ++i ) { session.CreateMap( h[i].name, mapDef, "Default", "Default" ); h[i].map.Open( session, h[i].name ); for ( j = 0; j < 20; ++j ) { sprintf(s, "%d", j); key = string("Key ") + s; data = string("Inserted data item = ") + s; sprintf(s, "%d", i); data += string(" in hashMap = ") + s; h[i].map.Insert( key.c_str(), key.length(), data.c_str(), data.length() ); } } session.Commit(); }