//////////////////////////////////////////////////////////////////////////////// /// @brief ZeroMQ batch job /// /// @file /// /// DISCLAIMER /// /// Copyright 2012 triAGENS GmbH, Cologne, Germany /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. /// You may obtain a copy of the License at /// /// http://www.apache.org/licenses/LICENSE-2.0 /// /// Unless required by applicable law or agreed to in writing, software /// distributed under the License is distributed on an "AS IS" BASIS, /// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. /// See the License for the specific language governing permissions and /// limitations under the License. /// /// Copyright holder is triAGENS GmbH, Cologne, Germany /// /// @author Dr. Frank Celler /// @author Copyright 2012, triAGENS GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// #ifndef TRIAGENS_ZERO_MQ_ZERO_MQBATCH_JOB_H #define TRIAGENS_ZERO_MQ_ZERO_MQBATCH_JOB_H 1 #include "Dispatcher/Job.h" #include #include "ProtocolBuffers/arangodb.pb.h" #include "Rest/Handler.h" // ----------------------------------------------------------------------------- // --SECTION-- forward declarations // ----------------------------------------------------------------------------- namespace triagens { namespace rest { class HttpHandlerFactory; class HttpHandler; class HttpRequest; // ----------------------------------------------------------------------------- // --SECTION-- class ZeroMQBatchJob // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Dispatcher /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief ZeroMQ batch job //////////////////////////////////////////////////////////////////////////////// class ZeroMQBatchJob : public Job { private: ZeroMQBatchJob (ZeroMQBatchJob const&); ZeroMQBatchJob& operator= (ZeroMQBatchJob const&); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- constructors and destructors // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Dispatcher /// @{ //////////////////////////////////////////////////////////////////////////////// public: //////////////////////////////////////////////////////////////////////////////// /// @brief constructrs a new jobs //////////////////////////////////////////////////////////////////////////////// ZeroMQBatchJob (zframe_t* address, HttpHandlerFactory*, char const* data, size_t length); //////////////////////////////////////////////////////////////////////////////// /// @brief destructors //////////////////////////////////////////////////////////////////////////////// ~ZeroMQBatchJob (); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- public methods // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Dispatcher /// @{ //////////////////////////////////////////////////////////////////////////////// public: //////////////////////////////////////////////////////////////////////////////// /// @brief returns true if all requests are handled //////////////////////////////////////////////////////////////////////////////// bool isDone (); //////////////////////////////////////////////////////////////////////////////// /// @brief returns true if current request is direct //////////////////////////////////////////////////////////////////////////////// bool isDirect (); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- Job methods // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Dispatcher /// @{ //////////////////////////////////////////////////////////////////////////////// public: //////////////////////////////////////////////////////////////////////////////// /// {@inheritDoc} //////////////////////////////////////////////////////////////////////////////// JobType type (); //////////////////////////////////////////////////////////////////////////////// /// {@inheritDoc} //////////////////////////////////////////////////////////////////////////////// string const& queue (); //////////////////////////////////////////////////////////////////////////////// /// {@inheritDoc} //////////////////////////////////////////////////////////////////////////////// void setDispatcherThread (DispatcherThread*); //////////////////////////////////////////////////////////////////////////////// /// {@inheritDoc} //////////////////////////////////////////////////////////////////////////////// status_e work (); //////////////////////////////////////////////////////////////////////////////// /// {@inheritDoc} //////////////////////////////////////////////////////////////////////////////// void cleanup (); //////////////////////////////////////////////////////////////////////////////// /// {@inheritDoc} //////////////////////////////////////////////////////////////////////////////// void finish (void* bridge); //////////////////////////////////////////////////////////////////////////////// /// {@inheritDoc} //////////////////////////////////////////////////////////////////////////////// void handleError (basics::TriagensError const&); //////////////////////////////////////////////////////////////////////////////// /// @brief shuts down the execution and deletes everything //////////////////////////////////////////////////////////////////////////////// bool beginShutdown (); //////////////////////////////////////////////////////////////////////////////// /// @brief extracts the next request and its handler //////////////////////////////////////////////////////////////////////////////// void extractNextRequest (); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- private methods // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Dispatcher /// @{ //////////////////////////////////////////////////////////////////////////////// private: //////////////////////////////////////////////////////////////////////////////// /// @brief executes the current request //////////////////////////////////////////////////////////////////////////////// Handler::status_e executeCurrentRequest (); //////////////////////////////////////////////////////////////////////////////// /// @brief handles a response //////////////////////////////////////////////////////////////////////////////// void handleResponse (); //////////////////////////////////////////////////////////////////////////////// /// @brief handles an not-found error //////////////////////////////////////////////////////////////////////////////// void handleNotFound (); //////////////////////////////////////////////////////////////////////////////// /// @brief handles an internal error //////////////////////////////////////////////////////////////////////////////// void handleInternalError (); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- private variables // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Dispatcher /// @{ //////////////////////////////////////////////////////////////////////////////// private: //////////////////////////////////////////////////////////////////////////////// /// @brief all requests //////////////////////////////////////////////////////////////////////////////// PB_ArangoMessage _requests; //////////////////////////////////////////////////////////////////////////////// /// @brief all responses collected so far //////////////////////////////////////////////////////////////////////////////// PB_ArangoMessage _responses; //////////////////////////////////////////////////////////////////////////////// /// @brief address of the peer //////////////////////////////////////////////////////////////////////////////// zframe_t* _address; //////////////////////////////////////////////////////////////////////////////// /// @brief request handler factory //////////////////////////////////////////////////////////////////////////////// HttpHandlerFactory* _handlerFactory; //////////////////////////////////////////////////////////////////////////////// /// @brief current request handler //////////////////////////////////////////////////////////////////////////////// HttpHandler* _handler; //////////////////////////////////////////////////////////////////////////////// /// @brief number of current request //////////////////////////////////////////////////////////////////////////////// size_t _nrCurrentRequest; }; } } //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// #endif // ----------------------------------------------------------------------------- // --SECTION-- END-OF-FILE // ----------------------------------------------------------------------------- // Local Variables: // mode: outline-minor // outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\)" // End: