gearman with http,get,how with workload?

Asked by jiaofuyou

curl --get "http://172.16.18.114:8080/reverse?hello"

it is error

how with workload?

Question information

Language:
English Edit question
Status:
Answered
For:
Gearman Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was reopened

Revision history for this message
chjgcn (chjgcn) said :
#1

You can send the content below(not contain first and last empty line) to server via socket write:

POST reverse HTTP/1.1
Content-Length: 5
X-Gearman-Unique: 63ee68c3c51343c93f88afb9343fcfe7
X-Gearman-Priority: high

hello

and then read response from server via socket read.

Revision history for this message
jiaofuyou (jiaofuyou) said :
#2

only POST method, GET method?

Revision history for this message
chjgcn (chjgcn) said :
#3

Maybe it does not support at this time. You can modify the code of protocol "HTTP" to support appendding workload behind function name and "?" like a url.

Revision history for this message
jiaofuyou (jiaofuyou) said :
#4

OK,thanks

Revision history for this message
chjgcn (chjgcn) said :
#5

I have submit a patch file in
    https://bugs.launchpad.net/gearmand/+bug/1348865
After patching, you can use GET method like:
    curl --get --header 'X-Gearman-Unique: 111111' 'http://172.16.18.114:8080/reverse?hello'
But I do not know why there is no output after execution of this command.

Revision history for this message
jiaofuyou (jiaofuyou) said :
#6

"But I do not know why there is no output after execution of this command."

Yes, your gearmand-1.1.12.patch have some problem

Now, gearman http POST reture is also NULL

gearman log:

  DEBUG 2014-08-11 04:49:21.416779 [ 2 ] Sending HTTP response: Content-length:0 data_size:8 gearmand_command_t:WORK_COMPLETE response:OK -> libgearman-server/plugins/protocol/http/protocol.cc:172

data_size:8 //it is OK
Content-length:0 //it is Error

Revision history for this message
chjgcn (chjgcn) said :
#7

What is the version of gearmand you use with my patch file?
My patch file is based on version 1.1.12 .

Revision history for this message
jiaofuyou (jiaofuyou) said :
#8

YES,I use is 1.1.12

is my wrong, youe patch no problem

but gearmand1.1.12 self is have problem

      else if (method() == gearmand::protocol::httpd::POST)
      {
        pack_size= (size_t)snprintf((char *)send_buffer, send_buffer_size,
                                    "HTTP/1.0 200 OK\r\n"
                                    "X-Gearman-Job-Handle: %.*s\r\n"
                                    "X-Gearman-Command: %s\r\n"
// "Content-Length: %d\r\n"
                                    "Server: Gearman/" PACKAGE_VERSION "\r\n"
                                    "\r\n%.*s",
                                    packet->command == GEARMAN_COMMAND_JOB_CREATED ? int(packet->arg_size[0]) : int(packet->arg_size[0] - 1),
                                    (const char *)packet->arg[0], // Job handle
                                    gearman_strcommand(packet->command),
// int(content.size()), //<email address hidden>,2014.08.11 because return is 0, so Comment
                                    int(content.size()), &content[0]);
      }

here :
header: Content-Length , result is 0
so, "why there is no output after execution of this command."

Revision history for this message
chjgcn (chjgcn) said :
#9

I find out the reason of no output after execution. In my patch file, when the job is created, the message of 'JOB_CREATED' is sent out from server to client with header 'Content-Length: 0' ; but before patching, this kind of messages are ignored, and server waits for those kinds of messages of 'WORK_DATA' or 'WORK_COMPLETE' from worker.
So my patch will make the response from server to client into more than one part, first one is 'JOB_CREATED', later ones are 'WORK_DATA' if worker sends something back to server while job is running, last one is 'WORK_COMPLETE' if worker returns something back to server when job is completed.
I do not know this change is right or wrong, as I writed in
    https://bugs.launchpad.net/gearmand/+bug/1352411/comments/3

Revision history for this message
jiaofuyou (jiaofuyou) said :
#10

specialty reply, thanks

Revision history for this message
chjgcn (chjgcn) said :
#11

I have posted a newer patch file in
    https://bugs.launchpad.net/gearmand/+bug/1352411/comments/4
and the protocol 'HTTP' will work perfectly,

Can you help with this problem?

Provide an answer of your own, or ask jiaofuyou for more information if necessary.

To post a message you must log in.