{"action":"created","comment":{"url":"https://api.github.com/repos/lsst/qserv/pulls/comments/39796206","id":39796206,"diff_hunk":"@@ -0,0 +1,132 @@\n+/*\n+ * LSST Data Management System\n+ * Copyright 2015 LSST Corporation.\n+ *\n+ * This product includes software developed by the\n+ * LSST Project (http://www.lsst.org/).\n+ *\n+ * This program is free software: you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation, either version 3 of the License, or\n+ * (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the LSST License Statement and\n+ * the GNU General Public License along with this program.  If not,\n+ * see <http://www.lsstcorp.org/LegalNotices/>.\n+ *\n+ *  Created on: Sep 3, 2015\n+ *      Author: jgates\n+ */\n+\n+#ifndef LSST_QSERV_QDISP_JOBQUERY_H_\n+#define LSST_QSERV_QDISP_JOBQUERY_H_\n+\n+// System headers\n+#include <atomic>\n+#include <memory>\n+#include <mutex>\n+\n+// LSST headers\n+#include \"lsst/log/Log.h\"\n+\n+// Qserv headers\n+#include \"qdisp/Executive.h\"\n+#include \"qdisp/ResponseRequester.h\"\n+\n+namespace lsst {\n+namespace qserv {\n+namespace qdisp {\n+\n+class QueryRequest;\n+\n+/** This class is used to describe, monitor, and control a single query to a worker.\n+ *\n+ */\n+class JobQuery : public std::enable_shared_from_this<JobQuery> {\n+public:\n+    typedef std::shared_ptr<JobQuery> Ptr;\n+\n+    /// Make a copy of the job description. JobQuery::setup() must be called after creation.\n+    JobQuery(Executive* executive, JobDescription const& jobDescription,\n+        JobStatus::Ptr const& jobStatus, std::shared_ptr<MarkCompleteFunc> const& markCompleteFunc) :\n+        _executive(executive), _jobDescription(jobDescription),\n+        _markCompleteFunc(markCompleteFunc), _jobStatus(jobStatus) {}\n+    void setup() {\n+        _jobDescription.respHandler()->setJobQuery(shared_from_this());\n+    }\n+\n+    virtual ~JobQuery() {\n+        LOGF_DEBUG(\"~JobQuery _jobId=%1%\" % getId());\n+    }\n+    int getAttemptsToRun() const {\n+        std::lock_guard<std::recursive_mutex> lock(_rmutex);\n+        return _attemptsToRun;\n+    }\n+    int getMaxRetries() const { return 5; }\n+    bool shouldRetry() const { return getAttemptsToRun() < getMaxRetries(); }\n+    virtual bool runJob();\n+\n+    int getId() const { return _jobDescription.id(); }\n+    JobDescription& getDescription() { return _jobDescription; }\n+    JobStatus::Ptr getStatus() { return _jobStatus; }\n+\n+    void provisioningFailed(std::string const& msg, int code);\n+    std::shared_ptr<QueryResource> getQueryResource() {\n+        std::lock_guard<std::recursive_mutex> lock(_rmutex);\n+        return _queryResourcePtr;\n+    }\n+    void freeQueryResource() {\n+        std::lock_guard<std::recursive_mutex> lock(_rmutex);\n+        _queryResourcePtr.reset();\n+    }\n+\n+    void setQueryRequest(std::shared_ptr<QueryRequest> const& qr) {\n+        std::lock_guard<std::recursive_mutex> lock(_rmutex);\n+        _queryRequestPtr = qr;\n+    }\n+    std::shared_ptr<QueryRequest> getQueryRequest() {\n+        std::lock_guard<std::recursive_mutex> lock(_rmutex);\n+        return _queryRequestPtr; }","path":"core/modules/qdisp/JobQuery.h","position":94,"original_position":94,"commit_id":"befad6ef005b10d4866b3a6852323c39d0d7434f","original_commit_id":"befad6ef005b10d4866b3a6852323c39d0d7434f","user":{"login":"fritzm","id":1530638,"avatar_url":"https://avatars.githubusercontent.com/u/1530638?v=3","gravatar_id":"","url":"https://api.github.com/users/fritzm","html_url":"https://github.com/fritzm","followers_url":"https://api.github.com/users/fritzm/followers","following_url":"https://api.github.com/users/fritzm/following{/other_user}","gists_url":"https://api.github.com/users/fritzm/gists{/gist_id}","starred_url":"https://api.github.com/users/fritzm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fritzm/subscriptions","organizations_url":"https://api.github.com/users/fritzm/orgs","repos_url":"https://api.github.com/users/fritzm/repos","events_url":"https://api.github.com/users/fritzm/events{/privacy}","received_events_url":"https://api.github.com/users/fritzm/received_events","type":"User","site_admin":false},"body":"formatting?","created_at":"2015-09-17T20:42:00Z","updated_at":"2015-09-17T20:42:00Z","html_url":"https://github.com/lsst/qserv/pull/130#discussion_r39796206","pull_request_url":"https://api.github.com/repos/lsst/qserv/pulls/130","_links":{"self":{"href":"https://api.github.com/repos/lsst/qserv/pulls/comments/39796206"},"html":{"href":"https://github.com/lsst/qserv/pull/130#discussion_r39796206"},"pull_request":{"href":"https://api.github.com/repos/lsst/qserv/pulls/130"}}},"pull_request":{"url":"https://api.github.com/repos/lsst/qserv/pulls/130","id":44958551,"html_url":"https://github.com/lsst/qserv/pull/130","diff_url":"https://github.com/lsst/qserv/pull/130.diff","patch_url":"https://github.com/lsst/qserv/pull/130.patch","issue_url":"https://api.github.com/repos/lsst/qserv/issues/130","number":130,"state":"open","locked":false,"title":"Tickets/dm 3562","user":{"login":"jgates108","id":6558057,"avatar_url":"https://avatars.githubusercontent.com/u/6558057?v=3","gravatar_id":"","url":"https://api.github.com/users/jgates108","html_url":"https://github.com/jgates108","followers_url":"https://api.github.com/users/jgates108/followers","following_url":"https://api.github.com/users/jgates108/following{/other_user}","gists_url":"https://api.github.com/users/jgates108/gists{/gist_id}","starred_url":"https://api.github.com/users/jgates108/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgates108/subscriptions","organizations_url":"https://api.github.com/users/jgates108/orgs","repos_url":"https://api.github.com/users/jgates108/repos","events_url":"https://api.github.com/users/jgates108/events{/privacy}","received_events_url":"https://api.github.com/users/jgates108/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-14T17:40:08Z","updated_at":"2015-09-17T20:42:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1a9c1ef21d65e3e85a0bee68ad3ee55428d5e01e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lsst/qserv/pulls/130/commits","review_comments_url":"https://api.github.com/repos/lsst/qserv/pulls/130/comments","review_comment_url":"https://api.github.com/repos/lsst/qserv/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lsst/qserv/issues/130/comments","statuses_url":"https://api.github.com/repos/lsst/qserv/statuses/befad6ef005b10d4866b3a6852323c39d0d7434f","head":{"label":"lsst:tickets/DM-3562","ref":"tickets/DM-3562","sha":"befad6ef005b10d4866b3a6852323c39d0d7434f","user":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"repo":{"id":23013460,"name":"qserv","full_name":"lsst/qserv","owner":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lsst/qserv","description":"LSST Query Services","fork":false,"url":"https://api.github.com/repos/lsst/qserv","forks_url":"https://api.github.com/repos/lsst/qserv/forks","keys_url":"https://api.github.com/repos/lsst/qserv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsst/qserv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsst/qserv/teams","hooks_url":"https://api.github.com/repos/lsst/qserv/hooks","issue_events_url":"https://api.github.com/repos/lsst/qserv/issues/events{/number}","events_url":"https://api.github.com/repos/lsst/qserv/events","assignees_url":"https://api.github.com/repos/lsst/qserv/assignees{/user}","branches_url":"https://api.github.com/repos/lsst/qserv/branches{/branch}","tags_url":"https://api.github.com/repos/lsst/qserv/tags","blobs_url":"https://api.github.com/repos/lsst/qserv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsst/qserv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsst/qserv/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsst/qserv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsst/qserv/statuses/{sha}","languages_url":"https://api.github.com/repos/lsst/qserv/languages","stargazers_url":"https://api.github.com/repos/lsst/qserv/stargazers","contributors_url":"https://api.github.com/repos/lsst/qserv/contributors","subscribers_url":"https://api.github.com/repos/lsst/qserv/subscribers","subscription_url":"https://api.github.com/repos/lsst/qserv/subscription","commits_url":"https://api.github.com/repos/lsst/qserv/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsst/qserv/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsst/qserv/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsst/qserv/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsst/qserv/contents/{+path}","compare_url":"https://api.github.com/repos/lsst/qserv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsst/qserv/merges","archive_url":"https://api.github.com/repos/lsst/qserv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsst/qserv/downloads","issues_url":"https://api.github.com/repos/lsst/qserv/issues{/number}","pulls_url":"https://api.github.com/repos/lsst/qserv/pulls{/number}","milestones_url":"https://api.github.com/repos/lsst/qserv/milestones{/number}","notifications_url":"https://api.github.com/repos/lsst/qserv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsst/qserv/labels{/name}","releases_url":"https://api.github.com/repos/lsst/qserv/releases{/id}","created_at":"2014-08-16T07:50:36Z","updated_at":"2015-05-08T02:01:15Z","pushed_at":"2015-09-17T15:01:58Z","git_url":"git://github.com/lsst/qserv.git","ssh_url":"git@github.com:lsst/qserv.git","clone_url":"https://github.com/lsst/qserv.git","svn_url":"https://github.com/lsst/qserv","homepage":"http://dm.lsst.org/","size":21438,"stargazers_count":4,"watchers_count":4,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":15,"forks":5,"open_issues":15,"watchers":4,"default_branch":"master"}},"base":{"label":"lsst:master","ref":"master","sha":"df63221ff74164ef0b91c0d08c2f1960bb4ea906","user":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"repo":{"id":23013460,"name":"qserv","full_name":"lsst/qserv","owner":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lsst/qserv","description":"LSST Query Services","fork":false,"url":"https://api.github.com/repos/lsst/qserv","forks_url":"https://api.github.com/repos/lsst/qserv/forks","keys_url":"https://api.github.com/repos/lsst/qserv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsst/qserv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsst/qserv/teams","hooks_url":"https://api.github.com/repos/lsst/qserv/hooks","issue_events_url":"https://api.github.com/repos/lsst/qserv/issues/events{/number}","events_url":"https://api.github.com/repos/lsst/qserv/events","assignees_url":"https://api.github.com/repos/lsst/qserv/assignees{/user}","branches_url":"https://api.github.com/repos/lsst/qserv/branches{/branch}","tags_url":"https://api.github.com/repos/lsst/qserv/tags","blobs_url":"https://api.github.com/repos/lsst/qserv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsst/qserv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsst/qserv/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsst/qserv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsst/qserv/statuses/{sha}","languages_url":"https://api.github.com/repos/lsst/qserv/languages","stargazers_url":"https://api.github.com/repos/lsst/qserv/stargazers","contributors_url":"https://api.github.com/repos/lsst/qserv/contributors","subscribers_url":"https://api.github.com/repos/lsst/qserv/subscribers","subscription_url":"https://api.github.com/repos/lsst/qserv/subscription","commits_url":"https://api.github.com/repos/lsst/qserv/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsst/qserv/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsst/qserv/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsst/qserv/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsst/qserv/contents/{+path}","compare_url":"https://api.github.com/repos/lsst/qserv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsst/qserv/merges","archive_url":"https://api.github.com/repos/lsst/qserv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsst/qserv/downloads","issues_url":"https://api.github.com/repos/lsst/qserv/issues{/number}","pulls_url":"https://api.github.com/repos/lsst/qserv/pulls{/number}","milestones_url":"https://api.github.com/repos/lsst/qserv/milestones{/number}","notifications_url":"https://api.github.com/repos/lsst/qserv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsst/qserv/labels{/name}","releases_url":"https://api.github.com/repos/lsst/qserv/releases{/id}","created_at":"2014-08-16T07:50:36Z","updated_at":"2015-05-08T02:01:15Z","pushed_at":"2015-09-17T15:01:58Z","git_url":"git://github.com/lsst/qserv.git","ssh_url":"git@github.com:lsst/qserv.git","clone_url":"https://github.com/lsst/qserv.git","svn_url":"https://github.com/lsst/qserv","homepage":"http://dm.lsst.org/","size":21438,"stargazers_count":4,"watchers_count":4,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":15,"forks":5,"open_issues":15,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lsst/qserv/pulls/130"},"html":{"href":"https://github.com/lsst/qserv/pull/130"},"issue":{"href":"https://api.github.com/repos/lsst/qserv/issues/130"},"comments":{"href":"https://api.github.com/repos/lsst/qserv/issues/130/comments"},"review_comments":{"href":"https://api.github.com/repos/lsst/qserv/pulls/130/comments"},"review_comment":{"href":"https://api.github.com/repos/lsst/qserv/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lsst/qserv/pulls/130/commits"},"statuses":{"href":"https://api.github.com/repos/lsst/qserv/statuses/befad6ef005b10d4866b3a6852323c39d0d7434f"}}}}