How do i get the uinque id from the client?

Asked by Khai Do on 2013-01-10

I see that the gearman protocol contains 'JOB_ASSIGN_UNIQ' and 'GRAB_JOB_UNIQ' packets. I also see that the DigestClient example sends a unique id when it submits a job (it was set to null, but i changed it to 'id99'). When i run the worker & client I see this in the gearman server log..

Received submission, org.gearman.example.DigestFunction/id99 with 2 arguments -> libgearman-server/server.c:213

This tells me that the client sent 'id99' however I don't see whether it made it thru to the worker.

Is this unique id available to the worker? if so how can i get this info when executing the worker (in executeFunction)?

Question information

Language:
English Edit question
Status:
Solved
For:
Gearman Java Edit question
Assignee:
No assignee Edit question
Solved by:
Khai Do
Solved:
2013-04-01
Last query:
2013-04-01
Last reply:
2013-01-12
Eric Lambert (elambert) said : #1

No, the UNIQ value is not made available to the function ... and for the most part the worker ignores it too. Nor does the worker ever perform a GRAB_JOB_UNIQ so in theory it will never receive a JOB_ASSIGN_UNIQ. Perhaps it should be capable of making these requests.

Is this causing a specific issue for you or was this more of a general question?

Eric

Khai Do (zaro0508) said : #2

No, I wanted to use the UNIQ value. Is there a reason for ignoring it? I noticed that it's available when I run the python gearman worker.

I had planned to use the uuid to keep track of tasks that are run in the worker. Then additional gearman clients could use the uuid to get status or cancel those tasks.

Eric Lambert (elambert) said : #3

I think it was just an oversight on my part when I implemented the worker.The worker as implemented never performs a GRAB_JOB_UNIQ and while it can accept a JOB_ASSIGN_UNIQ, it does nothing with the UNIQ id field in the JOB_ASSIGN_UNIQ packet.

But I am still not sure i understand your use case here. Maybe you can give me a more detailed description of what you want to happen?

Eric

PS, feel free to file bug/RFE on this.

Khai Do (zaro0508) said : #4

I am trying to integrate gearman with jenkins. I was planning to use gearman workers to start jenkins builds (also known as jobs). I wanted to pass the UUID to the jenkins jobs so I can keep track of them. The jenkins jobs might take a long time to complete so I was going to use the UUID to lookup the jenkins job so that I can abort them.

So here is the workflow..

Initially..
Start a gearman server
Start a gearman ExectuionWorker to start jenkins jobs. The function name(s) is "build_"+$projectName
Start a separate gearman ManagementWorker to abort jenkins jobs. The function name is "stop_build"

Then..
   1. a gearman client sends a request, submitJob("build_projectA", $build_params, uuid="123")
   2. a gearman worker creates a jenkins build job and assigns it the UUID from client.
            -- jenkins build "123" is now running..

   Now I want to abort the jenkins build job with UUID of "123".
   3. a gearman client sends a separate request, submitJob("stop_build", uuid="123"). The ManagementWorker will lookup the jenkins job "123" and abort that job.

Eric Lambert (elambert) said : #5

OK, makes sense. I've filed a bug and will try to address this pretty quickly

Khai Do (zaro0508) said : #6

I've tested and verified that the fix is working.