AmarokUrlHandler::AmarokUrlHandler() : QObject() , m_navigationRunner( 0 ) , m_playRunner ( 0 ) , m_timecodeObserver( 0 ) { DEBUG_BLOCK //init the bookmark model to make sure that db tables are created/updated if needed. BookmarkModel::instance(); //we init some of the default runners here. m_navigationRunner = new NavigationUrlRunner(); m_playlistViewRunner = new Playlist::ViewUrlRunner(); m_playRunner = new PlayUrlRunner(); m_timecodeObserver = new TimecodeObserver( this ); registerRunner( m_navigationRunner, m_navigationRunner->command() ); registerRunner( m_playRunner, m_playRunner->command() ); registerRunner( m_playlistViewRunner, m_playlistViewRunner->command() ); registerGenerator( ContextUrlGenerator::instance() ); registerGenerator( NavigationUrlGenerator::instance() ); registerGenerator( Playlist::ViewUrlGenerator::instance() ); registerGenerator( PlayUrlGenerator::instance() ); }
void run() { auto_ptr<Runner> run(getCollscan()); BSONObj obj; _client.ensureIndex(ns(), BSON("foo" << 1)); // Read some of it. for (int i = 0; i < 10; ++i) { ASSERT_EQUALS(Runner::RUNNER_ADVANCED, run->getNext(&obj, NULL)); ASSERT_EQUALS(i, obj["foo"].numberInt()); } // Save state and register. run->saveState(); registerRunner(run.get()); // Drop a specific index. _client.dropIndex(ns(), BSON("foo" << 1)); // Unregister and restore state. deregisterRunner(run.get()); run->restoreState(); // Runner was killed. ASSERT_EQUALS(Runner::RUNNER_DEAD, run->getNext(&obj, NULL)); }
void run() { auto_ptr<Runner> run(getCollscan()); BSONObj obj; // Read some of it. for (int i = 0; i < 10; ++i) { ASSERT_EQUALS(Runner::RUNNER_ADVANCED, run->getNext(&obj, NULL)); ASSERT_EQUALS(i, obj["foo"].numberInt()); } // Save state and register. run->saveState(); registerRunner(run.get()); // Drop a DB that's not ours. We can't have a lock at all to do this as dropping a DB // requires a "global write lock." _ctx.reset(); _client.dropDatabase("somesillydb"); _ctx.reset(new Client::WriteContext(ns())); // Unregister and restore state. deregisterRunner(run.get()); run->restoreState(); ASSERT_EQUALS(Runner::RUNNER_ADVANCED, run->getNext(&obj, NULL)); ASSERT_EQUALS(10, obj["foo"].numberInt()); // Save state and register. run->saveState(); registerRunner(run.get()); // Drop our DB. Once again, must give up the lock. _ctx.reset(); _client.dropDatabase("unittests"); _ctx.reset(new Client::WriteContext(ns())); // Unregister and restore state. deregisterRunner(run.get()); run->restoreState(); // Runner was killed. ASSERT_EQUALS(Runner::RUNNER_DEAD, run->getNext(&obj, NULL)); }
void run() { auto_ptr<Runner> run(getCollscan()); BSONObj obj; // Read some of it. for (int i = 0; i < 10; ++i) { ASSERT_EQUALS(Runner::RUNNER_ADVANCED, run->getNext(&obj, NULL)); ASSERT_EQUALS(i, obj["foo"].numberInt()); } // Save state and register. run->saveState(); registerRunner(run.get()); // Drop a collection that's not ours. _client.dropCollection("unittests.someboguscollection"); // Unregister and restore state. deregisterRunner(run.get()); run->restoreState(); ASSERT_EQUALS(Runner::RUNNER_ADVANCED, run->getNext(&obj, NULL)); ASSERT_EQUALS(10, obj["foo"].numberInt()); // Save state and register. run->saveState(); registerRunner(run.get()); // Drop our collection. _client.dropCollection(ns()); // Unregister and restore state. deregisterRunner(run.get()); run->restoreState(); // Runner was killed. ASSERT_EQUALS(Runner::RUNNER_DEAD, run->getNext(&obj, NULL)); }
void run() { Client::WriteContext ctx(&_txn, ns()); insert(BSON("_id" << 1)); insert(BSON("_id" << 2)); BSONObj filterObj = fromjson("{_id: {$gt: 0}}"); scoped_ptr<SingleSolutionRunner> ssr(makeCollScanRunner(ctx.ctx(),filterObj)); registerRunner(ssr.get()); BSONObj objOut; ASSERT_EQUALS(Runner::RUNNER_ADVANCED, ssr->getNext(&objOut, NULL)); ASSERT_EQUALS(1, objOut["_id"].numberInt()); // After dropping the collection, the runner // should be dead. dropCollection(); ASSERT_EQUALS(Runner::RUNNER_DEAD, ssr->getNext(&objOut, NULL)); deregisterRunner(ssr.get()); }
void run() { Client::WriteContext ctx(&_txn, ns()); insert(BSON("_id" << 1 << "a" << 6)); insert(BSON("_id" << 2 << "a" << 7)); insert(BSON("_id" << 3 << "a" << 8)); BSONObj indexSpec = BSON("a" << 1); addIndex(indexSpec); scoped_ptr<SingleSolutionRunner> ssr(makeIndexScanRunner(ctx.ctx(), indexSpec, 7, 10)); registerRunner(ssr.get()); BSONObj objOut; ASSERT_EQUALS(Runner::RUNNER_ADVANCED, ssr->getNext(&objOut, NULL)); ASSERT_EQUALS(7, objOut["a"].numberInt()); // After dropping the collection, the runner // should be dead. dropCollection(); ASSERT_EQUALS(Runner::RUNNER_DEAD, ssr->getNext(&objOut, NULL)); deregisterRunner(ssr.get()); }
void run() { auto_ptr<Runner> run(getCollscan()); BSONObj obj; // Read some of it. for (int i = 0; i < 10; ++i) { ASSERT_EQUALS(Runner::RUNNER_ADVANCED, run->getNext(&obj, NULL)); ASSERT_EQUALS(i, obj["foo"].numberInt()); } // Register it. run->saveState(); registerRunner(run.get()); // At this point it's safe to yield. forceYield would do that. Let's now simulate some // stuff going on in the yield. // Delete some data, namely the next 2 things we'd expect. _client.remove(ns(), BSON("foo" << 10)); _client.remove(ns(), BSON("foo" << 11)); // At this point, we're done yielding. We recover our lock. // Unregister the runner. deregisterRunner(run.get()); // And clean up anything that happened before. run->restoreState(); // Make sure that the runner moved forward over the deleted data. We don't see foo==10 // or foo==11. for (int i = 12; i < N(); ++i) { ASSERT_EQUALS(Runner::RUNNER_ADVANCED, run->getNext(&obj, NULL)); ASSERT_EQUALS(i, obj["foo"].numberInt()); } ASSERT_EQUALS(Runner::RUNNER_EOF, run->getNext(&obj, NULL)); }