예제 #1
0
    void testLostConnection() {
        class Listener : public StatusListener {
        public:
            bool reported;
           Listener() : reported(false) {}
            virtual bool uncaughtException(
                    std::exception exception,
                    boost::shared_ptr<voltdb::ProcedureCallback> callback,
                    InvocationResponse response) {
                CPPUNIT_ASSERT(false);
                return false;
            }
            virtual bool connectionLost(std::string hostname, int32_t connectionsLeft) {
                reported = true;
                CPPUNIT_ASSERT(connectionsLeft == 0);
                return false;
            }
            virtual bool backpressure(bool hasBackpressure) {
                CPPUNIT_ASSERT(false);
                return false;
            }
        }  listener;
        (*m_dlistener)->m_listener = &listener;
        (m_client)->createConnection("localhost");

        std::vector<Parameter> signature;
        Procedure proc("Insert", signature);
        proc.params();

        SyncCallback *cb = new SyncCallback();
        boost::shared_ptr<ProcedureCallback> callback(cb);
        (m_client)->invoke(proc, callback);
        m_voltdb->hangupOnRequestCount(1);

        proc.params();
        InvocationResponse syncResponse = (m_client)->invoke(proc);
        CPPUNIT_ASSERT(syncResponse.failure());
        CPPUNIT_ASSERT(syncResponse.statusCode() == voltdb::STATUS_CODE_CONNECTION_LOST);
        CPPUNIT_ASSERT(syncResponse.results().size() == 0);

        InvocationResponse response = cb->m_response;
        CPPUNIT_ASSERT(response.failure());
        CPPUNIT_ASSERT(response.statusCode() == voltdb::STATUS_CODE_CONNECTION_LOST);
        CPPUNIT_ASSERT(response.results().size() == 0);
        CPPUNIT_ASSERT(listener.reported);
        (m_client)->runOnce();
    }
예제 #2
0
 bool callback(InvocationResponse response) throw (voltdb::Exception)
 {
     if (response.failure()){
         //TODO:log
         return false;
     }
     m_dist->updateProcedurePartitioning(response.results());
     return true;
 }
예제 #3
0
 bool callback(InvocationResponse response) throw (voltdb::Exception)
 {
     if (response.failure()){
         //TODO:log
         return false;
     }
     m_dist->updateAffinityTopology(response.results());
     return true;
 }
예제 #4
0
 bool callback(InvocationResponse response) throw (voltdb::Exception)
 {
     if (response.failure()){
         //TODO:log
         std::cout << "subscribeToTopoNotifications FAILED" << std::endl;
         return false;
     }
     return true;
 }