Giter Club home page Giter Club logo

java-gearman-service's Issues

The server displays an error message when using perl worker/client

What steps will reproduce the problem?
1. Run the server
java -server -jar java-gearman-service-0.4.jar --port=7003

2. Run a perl worker using the Gearman distribution.
use Gearman::Worker;
my $worker = Gearman::Worker->new;
$worker->job_servers('127.0.0.1:7003');
$worker->register_function('echo' => sub { return $_[0]->arg } );
$worker->work while 1;

3. Run a perl client using the Gearman distribution.
use Gearman::Worker;
my $worker = Gearman::Worker->new;
$worker->job_servers('127.0.0.1:7003');
$worker->register_function('echo' => sub { return $_[0]->arg } );
$worker->work while 1;

What is the expected output? What do you see instead?
The worker does the job and the client displays the result.
However in the server console I this error message :

Exception in thread "pool-1-thread-18" java.lang.NullPointerException
        at java.util.concurrent.ConcurrentHashMap.remove(Unknown Source)
        at org.gearman.util.ConcurrentHashSet.remove(ConcurrentHashSet.java:58)
        at org.gearman.ServerImpl.onDisconnect(ServerImpl.java:115)
        at org.gearman.core.GearmanConnectionManager$SocketHandlerImpl.onDisconnect(GearmanConnectionManager.java:129)
        at org.gearman.reactor.SocketImpl.closeConnection(SocketImpl.java:209)
        at org.gearman.reactor.SocketImpl.completed(SocketImpl.java:170)
        at org.gearman.reactor.SocketImpl.completed(SocketImpl.java:1)
        at sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
        at sun.nio.ch.Invoker$2.run(Unknown Source)
        at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

What version of the product are you using? On what operating system?
java-gearman-service-0.4.jar under win7 x64

Please provide any additional information below.
Perl version: Strawberry 5.12.1
Gearman perl distribution version: 1.11

Original issue reported on code.google.com by [email protected] on 5 Jul 2011 at 7:57

GearmanJobReturnImpl.java poll(timeout,timeunit) function fail,

What steps will reproduce the problem?

@Override
    public synchronized GearmanJobEvent poll(long timeout, TimeUnit unit) throws InterruptedException {
        if(timeout==0) return poll();

        timeout = TimeUnit.MILLISECONDS.convert(timeout, unit);
        while(eventList.isEmpty() && !this.isEOF && timeout>0) {
            long startTime = System.currentTimeMillis();

            this.wait(timeout);
            timeout = timeout - (startTime - System.currentTimeMillis());//this line has bug
        }

        if(this.isEOF())
            return GearmanJobEventImmutable.GEARMAN_EOF;

        return eventList.pollFirst();
    }

What is the expected output? What do you see instead?

timeout = timeout - (startTime - System.currentTimeMillis()); 

should change to

timeout = timeout - ( System.currentTimeMillis() -startTime );


What version of the product are you using? On what operating system?
version is 0.6.6

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 9 Jan 2013 at 5:40

Logger

Implement a logger with at least four levels
  * OFF - no logging
  * EXCEPTION - log only exceptions or system errors
  * WARNING - log warnings that might cause problems (also logs EXCEPTION data)
  * DEBUG - log all actions to aid in debugging (also logs WARNING, and EXCEPTION data)


Original issue reported on code.google.com by [email protected] on 12 Mar 2011 at 10:26

Gearman shutdown issue

Hey i created a job and submitted to gearmand, if the job is taking too long to 
finish i try client shutdown. Even thought i am calling shutdown and setting 
the object to null, i am getting success event after that.

Original issue reported on code.google.com by [email protected] on 7 Jan 2013 at 1:48

After timeout on GRAB_JOB no futher jobs are processed and connection is dropped every 20 seconds

What steps will reproduce the problem?
1. Start the attached Main.java
2. killall -STOP gearmand
3. Wait until next GRAB_JOB gets a timeout and the connection is disconnected
4. killall -CONT gearmand
5. Observe that new connections are dropped after 20 seconds and no jobs are 
processed.


What is the expected output? What do you see instead?

New connections should start grabbing jobs right after establishing the 
connection. Instead, new connections only send CAN_DO, but don't grab any jobs 
anymore.


What version of the product are you using? On what operating system?

Reproducible on 0.6.6 and latest svn.


It appears that on read timeout the org.gearman.impl.worker.Dispatcher#count is 
never decreased and so on new connections the condition "count < maxCount" is 
always false in grabNext(). This causes the grab to be never issued and the 
connection times out due to GRAB_TIMEOUT.

This is especially notable on workers with 1 thread, although with more workers 
1 thread is also lost on every timeout.

I've attached a suggested patch for this issue, but I'm not 100% sure this is 
the correct way to solve this.  Feedback welcome.

Original issue reported on code.google.com by [email protected] on 4 Apr 2013 at 9:50

Attachments:

client deadlocks on shutown if server is down in 0.5.2

Hi Isaiah,
I bumped into the following problem with gearman java client, wonder if you 
fixed this already (I`m still on my own branch) :

The problem is as follows:
1. I send a request to the server.
2. I kill the server.
3. I shut down the gearman client

shutdown does not complete:
Thread [main] (Suspended)   
    ClientImpl$RemoteConnectionController(JobServerPoolAbstract$ConnectionController<K,C>).dropServer() line: not available   
    ClientImpl(JobServerPoolAbstract<X>).removeAllServers() line: not available   
    ClientImpl(JobServerPoolAbstract<X>).shutdown() line: not available   
    ClientImpl.shutdown() line: not available   


how you seen this?

Original issue reported on code.google.com by [email protected] on 2 May 2012 at 8:49

Possible Memory Leak

Look into this issue:

Ref: https://groups.google.com/forum/?fromgroups=#!topic/gearman/l5aDALZ0JMo

--------------------------------------------------------

I've had an application running for over a week that is suffering from
a connection leak.  While looking at the number of connections to
gearman coming from it I saw it was at 93, when it should at max be
5.  I'm using a pool of GearmanClients that, using apache commons pool
library with a max pool size of 5.  To further debug I was able to get
a jmap heap dump of the running application to see the leak up close.
I'll summarize below:

I have a wrapper class around GearmanClient, I'm using the library
from scala so I made simple wrappers around all the gearman java
objects.  So, I'm actually pooling my own GearmanClient class, which
has org.gearman.GearmanClient objects referenced in it.  The number of
instances of my own class is 5, which is the max you would expect for
the pool.  But, there are 88 ClientImpl gearman objects still around
in the app, which shouldn't be the case but is the obvious cause of
the leak.  By looking at the references to those objects I was able to
see that 5 of them are indeed referenced by my own GearmanClient, with
a shutdown state of false, these are fine.  But the rest aren't
referenced by my client or any of my code and they have a shutdown
state of true, which if functioning properly should have closed the
socket connection and the object should be destroyed/cleaned up.  If
you look at the isShutdown variable in those ClientImpl's you'll see
that it is set to true, which means the shutdown method was called.

Looking at the references to the ClientImpl classes they are still
held by a ClientImpl$InnerConnectionController, which is an inner
class of ClientImpl.  If you look at what is referencing this you see
that it's referenced by both a GearmanServerRemote
$InnerGearmanConnectionHandler and is in a LinkedBlockingQueue.
Following the GearmanServerRemote$InnerGearmanConnectionHandler
reference I see that that object is referenced by an NioReactor$1 and
a GearmanConnectionManager$SocketHandlerImpl object.

At this stage I really don't know enough about the internals to fix
the issue, but it's clear that these ClientImpl's are still being
referenced by other objects that are suppose to manage them while
they're active but are still keeping references to them after they are
shutdown.  Aside from just keeping those reference it doesn't seem
like the shutdown is even closing the socket connections, which is
what manifested this problem in the first place bc the memory leak by
itself isn't big enough to be noticed.

I would give the heap dump to help debug, but there is sensitive
information (credentials, etc) in there.  I'll send a few screen shots
of the analysis to help out, and see if I can get a test case example
made:

http://i.imgur.com/LGSCT.png - my GearmanClient instances (5)
http://i.imgur.com/cCLUK.png - org.gearman.impl.client.ClientImpl's
(88)
http://i.imgur.com/uUqOT.png - one of the ClientImpl's that is
referenced by my GearmanClient and is not shutdown, these are the only
one's I expected to exist
http://i.imgur.com/bVLQ3.png - ClientImpl that has no reference in my
code and isShutdown == true
http://i.imgur.com/3dOFT.png - ClientImpl$InnerClientController
referencing the ClientImpl
http://i.imgur.com/JzT3O.png - the GearmanServerRemote
$InnerGearmanConnection handler referencing the ClientImpl
$InnerConnectionController

Let me know if there is any other info needed that would be helpful. 

Original issue reported on code.google.com by [email protected] on 20 Sep 2012 at 4:54

creation of ServerClients

Instanciation of a ServerClient is currently private.
Will it be possible to add a createServerClient method to the Gearman class ?

Thanks.

Original issue reported on code.google.com by [email protected] on 14 Feb 2012 at 1:06

Deadlock issue with the GearmanClient.

What steps will reproduce the problem?
1. Submit a job to a GearmanClient.

This issue can happen when the GearmanClient attempts connect to a job server 
while job is being submitted.

Original issue reported on code.google.com by [email protected] on 22 May 2011 at 1:17

Gearman worker stopped connecting to server

What steps will reproduce the problem?

Don't know how to reproduce the problem, occurred after worker had been running 
for many days.

What is the expected output? What do you see instead?

I expect when the worker has a problem connecting to the server it will handle 
the error gracefully and reopen the connection.  Instead it never reconnected, 
requiring a restart of the service.

What version of the product are you using? On what operating system?
a build from source, revision 170.

Please provide any additional information below.

Basically the worker started printing out these errors in the warning:

[2012-11-14 06:43:40,543] 187793395 WARN  [gearman-3148] 
gearman.closeConnection[-1] - Failed to close connection
java.nio.channels.ClosedChannelException: null
    at sun.nio.ch.AsynchronousSocketChannelImpl.begin(AsynchronousSocketChannelImpl.java:114) ~[na:1.7.0_06]
    at sun.nio.ch.AsynchronousSocketChannelImpl.shutdownOutput(AsynchronousSocketChannelImpl.java:528) ~[na:1.7.0_06]
    at org.gearman.impl.reactor.SocketImpl.closeConnection(Unknown Source) [java-gearman-service-0.6.6.jar:na]
    at org.gearman.impl.reactor.SocketImpl.completed(Unknown Source) [java-gearman-service-0.6.6.jar:na]
    at org.gearman.impl.reactor.SocketImpl.completed(Unknown Source) [java-gearman-service-0.6.6.jar:na]
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126) [na:1.7.0_06]
    at sun.nio.ch.Invoker$2.run(Invoker.java:206) [na:1.7.0_06]
    at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112) [na:1.7.0_06]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [na:1.7.0_06]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [na:1.7.0_06]
    at java.lang.Thread.run(Thread.java:722) [na:1.7.0_06]

it printed this out a total of 5 or so times in a time span of 6 hours or so 
before the error was discovered and the worker restarted.  It reconnected to 
the gearman server fine, but it should really be able to recover from this and 
properly connect to the server.  I'm sorry I can't give more info on the issue, 
I'm not entirely sure what it is either.


Original issue reported on code.google.com by [email protected] on 14 Nov 2012 at 4:17

Handling of conditions where server is down

Hi,
I am trying to determine if I want to switch to this library from the other 
older java lib (https://launchpad.net/gearman-java)

my biggest problem with the other lib is that it does not handle error properly.
for example, existing workers becomes "bad" if the gearman server restarts - 
and does not reconnect.

during my tests, I attempted to send a request to a server which is down.
my GearmanSubmitHandler initially received FAILED_TO_CONNECT.
a second attempt to submit a request using the same client object resulted in 
FAILED_TO_NO_SERVER. I keep getting those errors even after I restart the 
server.

this makes me thing that the client have decided that the server is bad, and 
does no longer attempt to re-establish connection to it.
it would be better in my opinion to remember the server and try it again if 
another request is sent through the client.

btw: I am using the standard C server, but it should not make any difference in 
my opinion.

Original issue reported on code.google.com by [email protected] on 7 Mar 2012 at 4:45

java.lang.NoClassDefFoundError: java/net/StandardSocketOption

What steps will reproduce the problem?
1. Install java 1.7.0-ea-b145 for Linux (Ubuntu 11.04)
2. Create a GearmanWorker instance

You get: 

java.lang.NoClassDefFoundError: java/net/StandardSocketOption
    at org.gearman.reactor.SocketImpl.setTcpNoDelay(SocketImpl.java:126)
    at org.gearman.core.GearmanConnectionManager$SocketHandlerImpl.onAccept(GearmanConnectionManager.java:106)
    at org.gearman.reactor.NioReactor$1.completed(NioReactor.java:99)
    at org.gearman.reactor.NioReactor$1.completed(NioReactor.java:1)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker$2.run(Invoker.java:206)
    at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: java.net.StandardSocketOption
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 10 more


It looks like the class StandardSocketOption has been renamed to 
StandardSocketOptions.

Thanks!

Original issue reported on code.google.com by [email protected] on 13 Jun 2011 at 9:08

Client tasks

Have you considered implementing client side tasks similar to those available 
in the C library?
a task is a set of calls, where the user receives a callback for each one 
separately - but can also wait on the success/failure of the entire set.
this is useful for jobs that are split into multiple jobs internally, and then 
the results are to be combined and processed (map reduce style).

Original issue reported on code.google.com by [email protected] on 8 Mar 2012 at 9:22

Text instructions make the server hang

What steps will reproduce the problem?
1. Start the EchoWorkerServer from examples (from 0.3)
2. Open a connection with telnet to the gearman server
3. Type any supported text command (version, status, etc.)

The server hangs with no exception nor answer to the telnet connection. I 
dumped the stack and it seems that it hangs reading on the connection:

Full thread dump Java HotSpot(TM) 64-Bit Server VM (21.0-b15 mixed mode):

"pool-1-thread-5" prio=10 tid=0x0000000000b88000 nid=0x3f4 waiting on condition 
[0x00007f694eab9000]
   java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000f078c7d8> (a java.util.concurrent.SynchronousQueue$TransferStack)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
    at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
    at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:359)
    at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:942)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1043)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1103)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

"pool-1-thread-4" prio=10 tid=0x00007f6940034800 nid=0x3f0 waiting on condition 
[0x00007f694ebba000]
   java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000f078c7d8> (a java.util.concurrent.SynchronousQueue$TransferStack)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
    at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
    at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:359)
    at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:942)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1043)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1103)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

"pool-1-thread-3" prio=10 tid=0x0000000000ba4000 nid=0x3ef runnable 
[0x00007f694ecba000]
   java.lang.Thread.State: RUNNABLE
    at sun.nio.ch.AsynchronousChannelGroupImpl.bindToGroup(AsynchronousChannelGroupImpl.java:109)
    at sun.nio.ch.AsynchronousChannelGroupImpl.executeOnPooledThread(AsynchronousChannelGroupImpl.java:188)
    at sun.nio.ch.Invoker.invokeIndirectly(Invoker.java:200)
    at sun.nio.ch.Invoker.invoke(Invoker.java:176)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:268)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
    at sun.nio.ch.Invoker.invoke(Invoker.java:173)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:268)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
    at sun.nio.ch.Invoker.invoke(Invoker.java:173)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:268)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
    at sun.nio.ch.Invoker.invoke(Invoker.java:173)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:268)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
    at sun.nio.ch.Invoker.invoke(Invoker.java:173)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:268)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
    at sun.nio.ch.Invoker.invoke(Invoker.java:173)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:268)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
    at sun.nio.ch.Invoker.invoke(Invoker.java:173)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:268)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
    at sun.nio.ch.Invoker.invoke(Invoker.java:173)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:268)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
    at sun.nio.ch.Invoker.invoke(Invoker.java:173)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:268)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
    at sun.nio.ch.Invoker.invoke(Invoker.java:173)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:268)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
    at sun.nio.ch.Invoker.invoke(Invoker.java:173)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:268)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
    at sun.nio.ch.Invoker.invoke(Invoker.java:173)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:268)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
    at sun.nio.ch.Invoker.invoke(Invoker.java:173)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:268)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
    at sun.nio.ch.Invoker.invoke(Invoker.java:173)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:268)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
    at sun.nio.ch.Invoker.invoke(Invoker.java:173)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:268)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
    at sun.nio.ch.Invoker.invoke(Invoker.java:173)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:268)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker$2.run(Invoker.java:206)
    at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

"pool-1-thread-2" prio=10 tid=0x0000000000ba2800 nid=0x3ee waiting on condition 
[0x00007f694edbc000]
   java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000f078c7d8> (a java.util.concurrent.SynchronousQueue$TransferStack)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
    at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
    at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:359)
    at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:942)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1043)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1103)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

"DestroyJavaVM" prio=10 tid=0x00007f694019d000 nid=0x3e1 waiting on condition 
[0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"pool-1-thread-1" prio=10 tid=0x00007f694019b800 nid=0x3ec waiting on condition 
[0x00007f694eebd000]
   java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000f078c7d8> (a java.util.concurrent.SynchronousQueue$TransferStack)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
    at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
    at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:359)
    at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:942)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1043)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1103)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

"Thread-0" daemon prio=10 tid=0x00007f694017d800 nid=0x3eb runnable 
[0x00007f694efbe000]
   java.lang.Thread.State: RUNNABLE
    at sun.nio.ch.EPoll.epollWait(Native Method)
    at sun.nio.ch.EPollPort$EventHandlerTask.poll(EPollPort.java:194)
    at sun.nio.ch.EPollPort$EventHandlerTask.run(EPollPort.java:268)
    at java.lang.Thread.run(Thread.java:722)

"pool-2-thread-1" prio=10 tid=0x00007f6940080000 nid=0x3ea waiting on condition 
[0x00007f694f69a000]
   java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000f078ce20> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2082)
    at java.util.concurrent.DelayQueue.take(DelayQueue.java:220)
    at org.gearman.util.Scheduler$Driver.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:722)

"Service Thread" daemon prio=10 tid=0x00007f6948052000 nid=0x3e8 runnable 
[0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" daemon prio=10 tid=0x00007f694804f800 nid=0x3e7 waiting on 
condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" daemon prio=10 tid=0x00007f694804d800 nid=0x3e6 waiting on 
condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x00007f694804b000 nid=0x3e5 runnable 
[0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=10 tid=0x00007f6948001000 nid=0x3e4 in Object.wait() 
[0x00007f694ff49000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000f078d0c8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked <0x00000000f078d0c8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:177)

"Reference Handler" daemon prio=10 tid=0x0000000000af5000 nid=0x3e3 in 
Object.wait() [0x00007f695004a000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000f078cb70> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
    - locked <0x00000000f078cb70> (a java.lang.ref.Reference$Lock)

"VM Thread" prio=10 tid=0x0000000000aed800 nid=0x3e2 runnable 

"VM Periodic Task Thread" prio=10 tid=0x00007f694805d800 nid=0x3e9 waiting on 
condition 

JNI global references: 188

Heap
 def new generation   total 4800K, used 231K [0x00000000eb400000, 0x00000000eb930000, 0x00000000f0750000)
  eden space 4288K,   5% used [0x00000000eb400000, 0x00000000eb439978, 0x00000000eb830000)
  from space 512K,   0% used [0x00000000eb830000, 0x00000000eb830588, 0x00000000eb8b0000)
  to   space 512K,   0% used [0x00000000eb8b0000, 0x00000000eb8b0000, 0x00000000eb930000)
 tenured generation   total 10688K, used 702K [0x00000000f0750000, 0x00000000f11c0000, 0x00000000fae00000)
   the space 10688K,   6% used [0x00000000f0750000, 0x00000000f07ffb50, 0x00000000f07ffc00, 0x00000000f11c0000)
 compacting perm gen  total 21248K, used 3848K [0x00000000fae00000, 0x00000000fc2c0000, 0x0000000100000000)
   the space 21248K,  18% used [0x00000000fae00000, 0x00000000fb1c21e8, 0x00000000fb1c2200, 0x00000000fc2c0000)
No shared spaces configured.



Thanks!

Original issue reported on code.google.com by [email protected] on 17 Jun 2011 at 12:53

Connection lost, fail to reconnect

What steps will reproduce the problem?
1. Use java-gearman-service 0.6.5
2. Create one Gearman instance with workers for different functions (maybe set 
maximum concurrency)
3. Use a remote (not local) Gearman Server

What is the expected output? What do you see instead?

Expected would be, that it will stay connected to the job server, but loses 
connection after some time.

What version of the product are you using? On what operating system?

java-gearman-service 0.6.5
gearmand 0.35
Debian Squeeze

Please provide any additional information below.

Example source:

package gearmantest;

import org.gearman.Gearman;
import org.gearman.GearmanFunction;
import org.gearman.GearmanFunctionCallback;
import org.gearman.GearmanWorker;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class Bug {
    public static void main(String[] args) throws Exception {
        Gearman gearman = Gearman.createGearman();

        ExecutorService executor = Executors.newFixedThreadPool(3);
        WorkerThread thread1 = new WorkerThread("function1", gearman, new WorkerObject());
        executor.execute(thread1);
        WorkerThread thread2 = new WorkerThread("function2", gearman, new WorkerObject());
        executor.execute(thread2);
        WorkerThread thread3 = new WorkerThread("function3", gearman, new WorkerObject());
        executor.execute(thread3);

    }


}

final class WorkerObject implements GearmanFunction {
    @Override
    public byte[] work(String s, byte[] bytes, GearmanFunctionCallback gearmanFunctionCallback) throws Exception {
        // do some stuff.   for example sleep 10 seconds.
        System.out.println("New Job: sleep for 10 sec.");
        Thread.sleep(10000);
        return new byte[0];
    }
}

final class WorkerThread implements Runnable {
    private GearmanWorker worker;
    public WorkerThread(String functionName, Gearman gearman, WorkerObject workerObject) {
        worker = gearman.createGearmanWorker();
        worker.addServer(gearman.createGearmanServer("ip",1234));
        worker.addFunction(functionName, workerObject);
        worker.setMaximumConcurrency(5);
        worker.setReconnectPeriod(5, TimeUnit.MINUTES);
    }

    @Override
    public void run() {
        while(true);
    }
}

this should not take any new actions after some time (couple of hours)

Original issue reported on code.google.com by [email protected] on 13 Aug 2012 at 7:32

the server stops without errors

What steps will reproduce the problem?
1. java -jar java-gearman-service-0.x.jar
2.
3.

What is the expected output? What do you see instead?
The server should run until I want to stop it.
However it stops without errors after 1 minute.

What version of the product are you using? On what operating system?
Tried versions : 0.1, 0.2 and 0.3

Please provide any additional information below.
System: Windows 7 SP1 x64
JDK: jdk-7-fcs-bin-b146-windows-x64-20_jun_2011
JRE: jre-7-fcs-bin-b146-windows-x64-20_jun_2011

During the minute the server is up I can't make working any worker/client 
(using the Perl API).
The server goes off even if I don't start a worker.

Original issue reported on code.google.com by [email protected] on 27 Jun 2011 at 7:37

python & java-gearman-service communication issue

What steps will reproduce the problem?

Run the following code.

1. worker.py
#!/usr/bin/python
import gearman

gm_worker = gearman.GearmanWorker(['localhost:4730'])

def task_listener_reverse(gearman_worker, gearman_job):
    return gearman_job.data

# gm_worker.set_client_id is optional
gm_worker.set_client_id('your_worker_client_id_name')
gm_worker.register_task('echo', task_listener_reverse)

# Enter our work loop and call gm_worker.after_poll() after each time we 
timeout/see socket activity
gm_worker.work()

2. client.py
#!/usr/bin/python
import gearman

def check_request_status(job_request):
    if job_request.complete:
        print "Job %s finished!  Result: %s - %s" % (job_request.job.unique, job_request.state, job_request.result)
    elif job_request.timed_out:
        print "Job %s timed out!" % job_request.unique
    elif job_request.state == JOB_UNKNOWN:
        print "Job %s connection failed!" % job_request.unique

gm_client = gearman.GearmanClient(['localhost:4730'])
list_of_jobs = [dict(task='echo', data='hello'), dict(task='echo',\
data='hi')]
submitted_requests = gm_client.submit_multiple_jobs(list_of_jobs, 
background=False, wait_until_complete=False)

# Wait at most 5 seconds before timing out incomplete requests
completed_requests = gm_client.wait_until_jobs_completed(submitted_requests, 
poll_timeout=5.0)
for completed_job_request in completed_requests:
    check_request_status(completed_job_request)


What is the expected output? What do you see instead?

The python client should echo a string, as it does on with the C server.

Original issue reported on code.google.com by [email protected] on 19 Aug 2011 at 4:45

Exception with job return is over 1024 bytes

What steps will reproduce the problem?
1. Modify "EchoClient" from examples.
2. Replace the "Hello world" (line 62) by an over 1024 bytes string
3. Start the EchoWorkerServer and then the EchoClient

Results on the EchoWorkerServer:

Exception in thread "pool-1-thread-1" java.lang.IllegalArgumentException
    at java.nio.Buffer.limit(Buffer.java:267)
    at org.gearman.core.StandardCodec.header(Unknown Source)
    at org.gearman.core.StandardCodec.decode(Unknown Source)
    at org.gearman.core.GearmanConnectionManager$SocketHandlerImpl.onRead(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
    at sun.nio.ch.UnixAsynchronousSocketChannelImpl.implRead(UnixAsynchronousSocketChannelImpl.java:553)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:272)
    at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
    at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at org.gearman.reactor.SocketImpl.completed(Unknown Source)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker$2.run(Invoker.java:206)
    at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

A quick workaround was to increase the buffer in StandardCodec, but it's taking 
more memory and could still run over. Perhaps it should read the size (in the 
header method) and make sure it gets the rest of the message if the buffer is 
not big enough?

Thanks!

Original issue reported on code.google.com by [email protected] on 15 Jun 2011 at 2:22

Persistent Queues

The C server offers persistence for background job. I'd like to do the same 
using standard SQL and JDBC.

Original issue reported on code.google.com by [email protected] on 12 Mar 2011 at 10:31

Null pointer exception when trying to unregister a function

What steps will reproduce the problem?
1. start the gearman server
2. register a function remotely
3. unregister a function remotely

What is the expected output? What do you see instead?
The function should be unregistered but I have a NPE.

Here is the stack trace :
3439 [gearman-4] ERROR gearman - failed to execute packet: CANT_DO
java.lang.NullPointerException
        at org.gearman.impl.server.local.ClientImpl.cant_do(Unknown Source)
        at org.gearman.impl.server.local.Interpreter.cant_do(Unknown Source)
        at org.gearman.impl.server.local.Interpreter.execute(Unknown Source)
        at org.gearman.impl.server.local.GearmanServerLocal.onPacketReceived(Unknown Source)
        at org.gearman.impl.core.GearmanConnectionManager$SocketHandlerImpl$Connection.onDecode(Unknown Source)
        at org.gearman.impl.core.StandardCodec.body(Unknown Source)
        at org.gearman.impl.core.StandardCodec.decode(Unknown Source)
        at org.gearman.impl.core.GearmanConnectionManager$SocketHandlerImpl.onRead(Unknown Source)
        at org.gearman.impl.reactor.SocketImpl.completed(Unknown Source)
        at org.gearman.impl.reactor.SocketImpl.completed(Unknown Source)
        at sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
        at sun.nio.ch.Invoker$2.run(Unknown Source)
        at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

What version of the product are you using? On what operating system?
JGS version 0.6.6
Java(TM) SE Runtime Environment (build 1.7.0_04-ea-b14)
Java HotSpot(TM) 64-Bit Server VM (build 23.0-b16, mixed mode)
Windows 2008 R2 server x64

Please provide any additional information below.
I'm using a Perl client to send the CANT_DO request.

Here is the code snippet :

use AnyEvent::Gearman::Worker;

# create gearman worker
my $worker = AnyEvent::Gearman::Worker->new( job_servers => ['127.0.0.1:4730'] 
);

# add worker function
$worker->register_function( 'echo' => sub {
  my $job = shift;
  $job->complete($job->workload); 
});

# unregister the function
$worker->unregister_function( 'echo' );

AE::cv->recv;

Original issue reported on code.google.com by [email protected] on 19 Jun 2013 at 8:00

Suspected memory leak

What steps will reproduce the problem?
1. Started 0.6.2 version as follows nohup java -Xms4096m -Xmx8192m 
-Dconfig.properties.path=/home/gearman/jobServer/config1.properties -jar 
jobServer.jar -p 4801 -s com.test.gearman.MySQLGearmanPersistence &
2. Started gearman-manager on same machine
3. After some time I see

java.lang.OutOfMemoryError: Direct buffer memory
    at java.nio.Bits.reserveMemory(Bits.java:658)
    at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:123)
    at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:306)
    at org.gearman.impl.core.StandardCodec.createByteBuffer(StandardCodec.java:53)
    at org.gearman.impl.core.GearmanConnectionManager$SocketHandlerImpl.createSocketBuffer(GearmanConnectionManager.java:126)
    at org.gearman.impl.reactor.SocketImpl.<init>(SocketImpl.java:66)
    at org.gearman.impl.reactor.NioReactor$2.completed(NioReactor.java:230)
    at org.gearman.impl.reactor.NioReactor$2.completed(NioReactor.java:1)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker$2.run(Invoker.java:206)
    at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

Even doing a telnet to the port and running status does not return.
Need to restart the geaman (jobServer)

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?
0.6.2, Centos 5.8

Please provide any additional information below.

Original issue reported on code.google.com by floyd.lewis on 16 Jul 2012 at 3:51

fake workers on gearman server

I'm using gearman with java client based on Java Gearman Service (just using 
the client part) for about two years now. Everything seemed fine until this 
strange thing started happening. 
Its that every now and then I figure out that there are more than one (two 
specifically) workers registered with the job on gearman server. But there is 
just one instance of the worker up. and it seems that gearman is submitting 
jobs to the fake one too, so the real worker misses some of the jobs. 
I just can't find out why it is happening. Monitoring the services shows no 
abnormal behaviour. Nothing is restarted. Everything is up and running doing 
their normal jobs.

Original issue reported on code.google.com by [email protected] on 15 Mar 2014 at 10:51

SocketImpl has error class StandardSocketOptions

What steps will reproduce the problem?

1.
the SocketImpl class :
java.lang.NoClassDefFoundError: java/net/StandardSocketOptions
Jdk1.7 it has not StandardSocketOptions class!


What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 11 Aug 2011 at 10:38

  • Merged into: #6

Worker disconnects 30 sec after PRE_SLEEP

What steps will reproduce the problem?
1. Have a server and a bunch of remote workers running without job in the 
server's queue
2. Some workers periodically disconnect after every PRE_SLEEP state

What is the expected output? What do you see instead?
Workers shouldn't disconnect. Some of them do periodically instead, see the 
attached log for the worker. (I'm using similar lostConnectionPolicy as in 
http://code.google.com/p/java-gearman-service/issues/detail?id=36#c15). The 
server doesn't have anything special in its log, however it has the 
corresponding "Disconnected" log entries.

What version of the product are you using? On what operating system?
0.6.6 and latest 0.7 snapshot.

Please provide any additional information below.
The tricky thing is the "some workers" part. I have several worker machines: 
physical and virtual, with winXP and win7, but couldn't find a pattern. All 
workers have a single working thread because they do GUI testing. If a machine 
has this problem it's doing it all the time.

Please help me - what should I do to be able to narrow down the cause of the 
problem?

Original issue reported on code.google.com by [email protected] on 12 Apr 2013 at 10:19

Attachments:

Client connection pool

Below is a generic client connection pool I have implemented.
I have not tested it throughly yet, but it appears to work.
currently it supports min/max connections.
in the future I might add idle timeout (where an idle connection will be closed 
after an inactivity time, down to minimum active connections).

Feel free to take as is/implement something similar in the core library.

import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.apache.log4j.Logger;
import org.gearman.Gearman;
import org.gearman.GearmanClient;
import org.gearman.GearmanJob;
import org.gearman.GearmanLostConnectionPolicy;
import org.gearman.GearmanServer;

public class ConnectionPool
{
    static Logger logger = Logger.getLogger(ConnectionPool.class);

    private final int m_min;
    private final int m_max;
    private Gearman m_gearman;

    private List<GearmanClient> m_busyConnections;
    private List<GearmanClient> m_idleConnections;

    private final List<InetSocketAddress> m_servers;

    public ConnectionPool(int min, int max, List<InetSocketAddress> servers) throws IOException
    {
        m_servers = servers;
        if (servers.isEmpty()) throw new IllegalStateException("empty hosts list");
        m_gearman = new Gearman();
        m_min = min;
        m_max = max;
        if (min < 0) throw new IllegalArgumentException("Negative min clients");
        if (max < min) throw new IllegalArgumentException("max < min");

        m_busyConnections = new ArrayList<GearmanClient>();
        m_idleConnections = new ArrayList<GearmanClient>();
        for (int i=0;i<m_min;i++)
        {
            m_idleConnections.add(createClient());
        }
    }

    public synchronized GearmanClient getClient()
    {
        if (m_idleConnections.isEmpty())
        {
            if (m_busyConnections.size() < m_max)
            {
                m_idleConnections.add(createClient());
            }
            else
            {
                // max capacity reached
                logger.warn("Maximum capacity reached, waiting for clients to become available");
                while(m_busyConnections.size() == m_max)
                {
                    try
                    {
                        wait(100);
                    }
                    catch (InterruptedException e){}
                }
            }
        }

        GearmanClient client = m_idleConnections.remove(0);
        m_busyConnections.add(client);
        return client;
    }

    public synchronized void releaseClient(GearmanClient client)
    {
        boolean removed = m_busyConnections.remove(client);
        if (removed)
        {
            logger.debug("Client idle : " + client);
            m_idleConnections.add(client);
            notifyAll();
        }
        else
            logger.warn("releaseClient called on a client which was not in the busy list");
    }

    private GearmanClient createClient()
    {
        GearmanClient gc = m_gearman.createGearmanClient();
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<m_servers.size();i++)
        {
            InetSocketAddress server = m_servers.get(i);
            gc.addServer(server);
            if (i != 0) sb.append(',');
            sb.append(server.getHostName()).append(':').append(server.getPort());
        }
        PooledGearmanClient pc = new PooledGearmanClient(gc);
        logger.debug("Created " + pc + " to " + sb.toString());
        return pc;
    }

    public void shutDown()
    {
        m_gearman.shutdown();
    }


    static int s_clientCounter = 0;

    // delegate to the real client, that returns to the pool instead of actually shutting down when its shutdown method is called
    private class PooledGearmanClient implements GearmanClient
    {
        private final GearmanClient m_client;
        private String m_desc;

        public PooledGearmanClient(GearmanClient client)
        {
            m_desc = "PooledClient-" + (s_clientCounter++);
            m_client = client;
        }

        @Override
        public String toString()
        {
            return m_desc;
        }

        public boolean isShutdown()
        {
            return m_client.isShutdown();
        }

        public void shutdown()
        {
            releaseClient(this);
        }

        public Gearman getGearman()
        {
            return m_client.getGearman();
        }

        public void setLoggerID(String loggerId)
        {
            m_client.setLoggerID(loggerId);
        }

        public boolean addServer(GearmanServer srvr)
        {
            return m_client.addServer(srvr);
        }

        public String getLoggerID()
        {
            return m_client.getLoggerID();
        }

        public boolean addServer(InetSocketAddress adrs)
        {
            return m_client.addServer(adrs);
        }

        public String getClientID()
        {
            return m_client.getClientID();
        }

        public long getReconnectPeriod(TimeUnit unit)
        {
            return m_client.getReconnectPeriod(unit);
        }

        public int getServerCount()
        {
            return m_client.getServerCount();
        }

        public void removeAllServers()
        {
            m_client.removeAllServers();
        }

        public boolean removeServer(GearmanServer srvr)
        {
            return m_client.removeServer(srvr);
        }

        public boolean removeServer(InetSocketAddress adrs)
        {
            return m_client.removeServer(adrs);
        }

        public void setClientID(String id)
        {
            m_client.setClientID(id);
        }

        public void setLostConnectionPolicy(GearmanLostConnectionPolicy policy)
        {
            m_client.setLostConnectionPolicy(policy);
        }

        public void setReconnectPeriod(long time, TimeUnit unit)
        {
            m_client.setReconnectPeriod(time, unit);
        }

        public boolean hasServer(InetSocketAddress address)
        {
            return m_client.hasServer(address);
        }

        public boolean hasServer(GearmanServer srvr)
        {
            return m_client.hasServer(srvr);
        }

        public void submitJob(GearmanJob job, GearmanSubmitHandler callback)
        {
            m_client.submitJob(job, callback);
        }
    }
}

Original issue reported on code.google.com by [email protected] on 8 Mar 2012 at 5:06

exported .jar with 'echo' example produces errors

What steps will reproduce the problem?
1. download the whole project into some local dir from the java-gearman-service 
svn
2.import the downloaded source into eclipse as a new maven project.
3. import the four 'echo' example files into the same eclipse project and put 
it in a package that matches what is in the source for those files (in this 
case it is 'package org.gearman.examples.echo')
4. run the 'echoWorkerServer.java' file by right clicking on it and choosing 
run as -> 'java application' 
5. let it run, then stop it.
6. export 'echoworkerserver.java' as a .jar by right clicking on the java file 
-> export -> select 'runnable JAR file' (click 'next') -> select 'package 
required libraries into generated JAR' (make sure that the 'echoWorkerServer' 
run configuration is selected)->   click on 'finish'
7. go to where the jar is saved and run it with the following command (in 
Ubuntu Linux 12.10) 'java -jar <theJARfileName>.jar'
8. see below error

What is the expected output? What do you see instead?
I would expect to see no output, or maybe just some output from log4j, and have 
the program continue to run. instead I get an error with the program 
terminating immediately after.  Here is the error that is being experienced:
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.ExceptionInInitializerError
        at org.gearman.Gearman.createGearman(Gearman.java:53)
        at org.gearman.examples.echo.EchoWorkerServer.main(EchoWorkerServer.java:22)
        ... 5 more
Caused by: java.lang.NullPointerException
        at java.util.Properties$LineReader.readLine(Properties.java:434)
        at java.util.Properties.load0(Properties.java:353)
        at java.util.Properties.load(Properties.java:341)
        at org.gearman.context.GearmanContext.loadProperties(GearmanContext.java:176)
        at org.gearman.context.GearmanContext.loadProperties(GearmanContext.java:159)
        at org.gearman.context.GearmanContext.loadProperties(GearmanContext.java:144)
        at org.gearman.context.GearmanContext.initProperties(GearmanContext.java:74)
        at org.gearman.context.GearmanContext.<clinit>(GearmanContext.java:66)
        ... 7 more


What version of the product are you using? On what operating system?

Java-gearman-service version: 0.7.0-SNAPSHOT

Operating system: Ubuntu 12.04 LTS. 

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 7 May 2013 at 10:56

Attachments:

When multiple perl clients perform the same task only the first client is processed

When multiple perl clients perform the same task only the first client seems to 
be added to the queue.

All Perl clients return the same value even if sent parameters are different.

Here are the source of the perl scripts used.

init_worker.pl
###
use 5.12.0;

use Gearman::Worker;
my $worker = Gearman::Worker->new;
$worker->job_servers('127.0.0.1:4730');
$worker->register_function('echo' => sub {
                                          my $req = shift;
                                          my $arg = $req->arg;
                                          print "received: ".$arg."\n";
                                          return $arg
                                          }
                           );
$worker->work while 1;
####

init_client.pl
###
use strict;
use 5.12.0;
use Gearman::Client;
use JSON;

my $client = Gearman::Client->new;
$client->job_servers('127.0.0.1:4730');

my $tasks = $client->new_task_set;
my $handle = $tasks->add_task(echo => "test_at_".time, {
    on_complete => sub {
      my $result_ref = $_[0];
      say $$result_ref if defined $result_ref;
    }
});
$tasks->wait;
###

Original issue reported on code.google.com by [email protected] on 15 Feb 2012 at 4:24

The java-gearman-service-0.6.jar is not working as a standalone job server

This is because there is no Class-Path is defined in the jar, and the 
java-gearman-service now requires the slf4j logging faced. Moreover, when 
running an executable jar, the classpath cannot be set externally. This implies 
that setting the jvm's classpath option or the CLASSPATH environment variable 
has no effect on the application's actual classpath

I'll need to support setting the classpath from within the application though a 
ClassLoader. This will allow the user to set the classpath to include the 
desired slf4j implementation. And even better, it will allow the user to add to 
the classpath a gearman persistence implementation and any dependencies it may 
have.

This should not take to long to implement and will be available in version 0.6.1

thanks,
isaiah.v

Original issue reported on code.google.com by [email protected] on 13 May 2012 at 6:15

some typos in constants

SubmitCallbackResult.FAILED_TO_NO_SERVER
should probably be
SubmitCallbackResult.FAILED_NO_SERVER

RESPONCE_TIMEOUT should be RESPONSE_TIMEOUT

other RESPONCEs should be RESPONSEs :)

Original issue reported on code.google.com by [email protected] on 7 Mar 2012 at 3:33

java-gearman-service job server exit after thread timeout

Hi,

I'm testing java-gearman-service as a Job server and found a bug that make the 
server exit after a worker thread timeout. The following steps always end up as 
the job server exit unexpectedly, without any exception and error code = 0:

 - start the job server with 1 worker thread
 - start a worker (e.g., gearman -w -f wc -- wc)
 - submit a job (e.g., echo 'foo' | gearman -f wc)
 - wait until the job server exit ;)

When the job arrived at job server, it create a new thread (gearman-x) to 
handle it. Then that thread went idle and timeout, but the server also exited 
at the same time. 

Original issue reported on code.google.com by [email protected] on 8 Jun 2012 at 3:32

Net_Gearman_Manager sends text commands with \r\n, resulting in errors when more than one text-command is sent

The PEAR Net_Gearman implementation sends administrative text commands like 
this:
version\r\n

This results in errors when another text command is sent afterwars, I guess 
because the Java server only cuts the \r of and leaves the \n which is then 
prepended to the next command.

gearmand 0.28 has no problems with \r\n

Original issue reported on code.google.com by [email protected] on 16 Feb 2012 at 5:48

Internal onDisconnect not called

An internal onDisconnect method is not always called. The extent of this issue 
is not completely known. Some of the services depend on this method to release 
system resources. Therefore it may cause a memory leak.

Original issue reported on code.google.com by [email protected] on 19 Jun 2011 at 6:16

Get the job handle from the GearmanFunction

when a java-gearman-service worker grab a job and execute the GearmanFunction, 
I wish to get the job handler, so that I can know the job unique id and also 
other information

Original issue reported on code.google.com by [email protected] on 18 Aug 2012 at 3:38

java.util.ConcurrentModificationException on the server side

What steps will reproduce the problem?
1. There's no exact scenario, it's not happening all the time. But sometimes it 
does and I'm afraid that it might cause side-effects as well.

What version of the product are you using? On what operating system?
0.7.0-SNAPTSHOT

Please provide any additional information below.
So the exception is this:
java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
    at java.util.HashMap$KeyIterator.next(Unknown Source)
    at org.gearman.impl.server.local.Interpreter.text_workers(Interpreter.java:247)
    at org.gearman.impl.server.local.Interpreter.text_packet(Interpreter.java:227)
    at org.gearman.impl.server.local.Interpreter.execute(Interpreter.java:109)
    at org.gearman.impl.server.local.GearmanServerLocal.onPacketReceived(GearmanServerLocal.java:317)
    at org.gearman.impl.core.GearmanConnectionManager$SocketHandlerImpl$Connection.onDecode(GearmanConnectionManager.java:215)
    at org.gearman.impl.core.StandardCodec.text(StandardCodec.java:197)
    at org.gearman.impl.core.StandardCodec.decode(StandardCodec.java:74)
    at org.gearman.impl.core.GearmanConnectionManager$SocketHandlerImpl.onRead(GearmanConnectionManager.java:161)
    at org.gearman.impl.reactor.SocketImpl.completed(SocketImpl.java:205)
    at org.gearman.impl.reactor.SocketImpl.completed(SocketImpl.java:43)
    at sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
    at sun.nio.ch.Invoker$2.run(Unknown Source)
    at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

As I can see the collection we're iterating over is defined in
org.gearman.impl.server.local.GearmanServerLocal#L59
which is a nice synchronized wrapper, however in
http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronized
Set%28java.util.Set%29
they say iteration should be done inside a synchronized block and the for-loop 
at
org.gearman.impl.server.local.Interpreter#L247
is not in any.

So it seems it would be really just a quick fix.
Thanks

Original issue reported on code.google.com by [email protected] on 4 Oct 2013 at 9:52

Worker is not closing connections on shutdown.

A user has encountered the following issue. This behavior is a result of the 
worker not properly closing connections.

*Reported Behavior:*

I have a test case hosted in this github repository:

https://github.com/efuquen/java-gearman-fail-to-shutdown

that shows java-gearman-service fails to stop when shutdown is called
if both a client and worker are created from the same gearman
instance.  This is with 0.6.5 and running on Ubuntu 12.04.

I've tried other combinations, such as making a new instance of
Gearman for the client and then another for the worker (which
shouldn't be necessary), but I still get weird errors on shutdown.
Sometimes I get assertion errors, sometimes I get an concurrency
modification error, etc.  I know that's vague, but the errors aren't
100% reproducible as sometimes it works fine when I shutdown both
Gearman instances.  Looking at the code, i feel like there might be an
issue with the Gearman instances sharing listeners and not properly
handling the concurreny issues involved.

So, I've decided to add the simplest test case above, as I believe the
above functionality should work and not require me to have to make
multiple Gearman instances to do a proper shutdown.  I also am hopeful
that fixing the above issue might also take care of the same problem
causing the issues with multiple Gearman instances.  Any feedback
would be welcome, as the above problem makes it difficult to have
proper test cases that clean up after themselves and any code I write
that does the above won't shutdown gracefully w/o a System.exit. 

Original issue reported on code.google.com by [email protected] on 15 Sep 2012 at 8:32

Java 7 dependency

Java 7 is still not wildly available (especially on older operating systems 
that you are likely to find on servers.

is the dependency real, or should it be relatively easy to make this work on 
1.6 as well?

Original issue reported on code.google.com by [email protected] on 7 Mar 2012 at 11:17

can a gearman client be coded to act as a listener?

What steps will reproduce the problem?

A gearman client can be created from gearman.createGearmanClient method call. 
This creates a Gearman instance that can later be attached to a server and 
submit jobs. If we do not explicitly call gearman.shutdown the client does not 
die, thus it may act as a listener accepting new requests.

Can this really be done?

Can a gearman client act as listener accepting new requests and dispatching 
them to the server, or is it better to use a fire and forget strategy, like:

-create gearman instance -> new gearman();
-create a gearman client -> gearman.createGearmanClient(); 
-submit a job client.submit(job, handler);
-shutdown gearman instance -> gearman.shutdown();


Original issue reported on code.google.com by [email protected] on 11 Jan 2012 at 4:54

The gearman worker behaves incorectly when a function is removed and added from within the worker

Calling the removeFunction and the addFunction from within a function may 
causes strange behavior.

If after the function is removed and no remaining functions exist, the worker 
disconnects from the server. Adding it back in causes it to reconnect. When the 
worker completes, submitting the job result is successful, but the worker is in 
an unpredictable state and does not seem to attempt to call the next job.

Original issue reported on code.google.com by [email protected] on 5 Aug 2012 at 2:28

java.lang.NullPointerException

What steps will reproduce the problem?
1. Have 2 gearman-managers pointing to 2 gearman servers. Using 0.6.3v on 
centos 5.8
2. After sometime I see the exception.
76825 [gearman-6] INFO gearman - [192.168.37.13:34771] : Disconnected
Exception in thread "gearman-5" java.lang.NullPointerException
    at org.gearman.impl.util.GearmanUtils.toString(GearmanUtils.java:52)
    at org.gearman.impl.server.local.GearmanServerLocal.onDisconnect(GearmanServerLocal.java:324)
    at org.gearman.impl.core.GearmanConnectionManager$SocketHandlerImpl.onDisconnect(GearmanConnectionManager.java:156)
    at org.gearman.impl.reactor.SocketImpl.closeConnection(SocketImpl.java:238)
    at org.gearman.impl.reactor.SocketImpl.writeNext(SocketImpl.java:182)
    at org.gearman.impl.reactor.SocketImpl.access$100(SocketImpl.java:43)
    at org.gearman.impl.reactor.SocketImpl$Writter.write(SocketImpl.java:257)
    at org.gearman.impl.reactor.SocketImpl$Writter.completed(SocketImpl.java:270)
    at org.gearman.impl.reactor.SocketImpl$Writter.completed(SocketImpl.java:242)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker$2.run(Invoker.java:206)
    at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
76827 [gearman-1] INFO gearman - [192.168.37.13:34777] : OUT : NOOP
Exception in thread "gearman-4" 76827 [gearman-1] INFO gearman - 
[192.168.37.14:48225] : OUT : NOOP
java.lang.NullPointerException
    at org.gearman.impl.util.GearmanUtils.toString(GearmanUtils.java:52)
    at org.gearman.impl.server.local.GearmanServerLocal.onDisconnect(GearmanServerLocal.java:324)
    at org.gearman.impl.core.GearmanConnectionManager$SocketHandlerImpl.onDisconnect(GearmanConnectionManager.java:156)
    at org.gearman.impl.reactor.SocketImpl.closeConnection(SocketImpl.java:238)
    at org.gearman.impl.reactor.SocketImpl.writeNext(SocketImpl.java:182)
    at org.gearman.impl.reactor.SocketImpl.access$100(SocketImpl.java:43)
    at org.gearman.impl.reactor.SocketImpl$Writter.write(SocketImpl.java:257)

 Beyond this I keep geting this exceptions now and then. Is this someting to be concerned 


Original issue reported on code.google.com by floyd.lewis on 26 Jul 2012 at 4:10

new Gearman() fails with NoClassDefFoundError

What steps will reproduce the problem?
1. I created SampleWorker, Sample Client based on the Echo examples with 
similar functionality.
2. When I try to run the worker class, it fails at he first line where a new 
Geaman object is getting created.

What is the expected output? What do you see instead?
It should create the object without any error. I see the following error -
java.lang.NoClassDefFoundError: java/nio/channels/CompletionHandler
    at org.gearman.core.GearmanConnectionManager.<init>(GearmanConnectionManager.java:37)
    at org.gearman.Gearman.<init>(Gearman.java:51)
    at org.gearman.Gearman.<init>(Gearman.java:35)
    at com.deem.content.items.worker.ItemsWorker.main(ItemsWorker.java:23)
Caused by: java.lang.ClassNotFoundException: java.nio.channels.CompletionHandler
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 4 more

What version of the product are you using? On what operating system?
java-gearman-service-0.5.jar

Please provide any additional information below.
Please provide details about how to fix the issue.

Thanks,
Pinaki

Original issue reported on code.google.com by [email protected] on 17 Feb 2012 at 6:52

EchoWorkerServer translateErrorToIOException

What steps will reproduce the problem?
EchoWorkerServer class run.....
Echo: Hello World
java.io.IOException: 由于线程退出或应用程序请求,已放弃 I/O 
操作。

    at sun.nio.ch.Iocp.translateErrorToIOException(Iocp.java:309)
    at sun.nio.ch.Iocp.access$700(Iocp.java:46)
    at sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:399)
    at java.lang.Thread.run(Thread.java:722)

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 11 Aug 2011 at 10:52

out of order data

The client receives data in the callback channels concurrently. Depending on 
how the processing threads are scheduled, it's possible some GearmanPackets 
will be processed out of order.

Original issue reported on code.google.com by [email protected] on 12 Mar 2011 at 4:43

Logging using slf4j

Hi,
I noticed that you are using java.util.Logging.
it would be better to use slf4j (http://www.slf4j.org/), as it will allow users 
to hook their own logging framework.
personally I use log4j across the board, and I would much rather be able to get 
the gearman logs into it, than into java logging.

Original issue reported on code.google.com by [email protected] on 8 Mar 2012 at 10:01

patch to zip source in build file

below is an svn patch to add zip source archive.

Index: build.xml
===================================================================
--- build.xml   (revision 93)
+++ build.xml   (working copy)
@@ -30,7 +30,7 @@
        <property name="project" value="java-gearman-service" />

        <!-- current version number -->
-       <property name="version" value="0.5.1" />
+       <property name="version" value="0.5.2" />

        <!-- source directory -->
        <property name="src" location="src" />
@@ -44,9 +44,21 @@
     <!-- Builds the executable jar, creates javadocs, and zips source -->
        <target name="build-all">
        <antcall target="jar" />
-       <antcall target="javadoc" />
+               <antcall target="zip-source" />
+               <antcall target="javadoc" />
     </target>

+       <!-- ================================= 
+          target: zip-source              
+         ================================= -->
+    <target name="zip-source" depends="" description="Zips the source code">
+        <zip destfile="${basedir}/${project}-${version}-src.zip" 
+            basedir="${src}"
+            includes="**/*"
+        />
+    </target>
+
+
        <!-- Builds the project's executable jar -->
        <target name="jar" depends="build" description="Builds the project's executable jar">
                <jar destfile="${basedir}/${project}-${version}.jar" >

Original issue reported on code.google.com by [email protected] on 8 Mar 2012 at 11:39

NullPointerException

Look into why this NullPointerException is occurring:

Ref: https://groups.google.com/forum/?fromgroups=#!topic/gearman/ZfkIYis_FbI

----------------------------------------------------

Hello everybody,

I'm new to gearman and try to implement a simple client perl. The worker will 
also be written in Perl. Because compiling the gearmand unter Red Hat 5.6 is a 
real pain, I want to use the Java-Implementation.
The java-service runs. I can connect a client, I can see the announced function 
of the worker, but when the client should start a task, I get the following 
NullPointerException:

 ERROR gearman - failed to execute packet: SUBMIT_JOB
java.lang.NullPointerException
        at org.gearman.impl.server.local.JobAbstract.getNextJobHandle(Unknown Source)
        at org.gearman.impl.server.local.JobAbstract.<init>(Unknown Source)
        at org.gearman.impl.server.local.Function$InnerJob.<init>(Unknown Source)
        at org.gearman.impl.server.local.Function.createJob(Unknown Source)
        at org.gearman.impl.server.local.Interpreter.submit_job(Unknown Source)
        at org.gearman.impl.server.local.Interpreter.execute(Unknown Source)
        at org.gearman.impl.server.local.GearmanServerLocal.onPacketReceived(Unknown Source)
        at org.gearman.impl.core.GearmanConnectionManager$SocketHandlerImpl$Connection.onDecode(Unknown Source)
        at org.gearman.impl.core.StandardCodec.body(Unknown Source)
        at org.gearman.impl.core.StandardCodec.decode(Unknown Source)
        at org.gearman.impl.core.GearmanConnectionManager$SocketHandlerImpl.onRead(Unknown Source)
        at org.gearman.impl.reactor.SocketImpl.completed(Unknown Source)
        at org.gearman.impl.reactor.SocketImpl.completed(Unknown Source)
        at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
        at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
        at sun.nio.ch.UnixAsynchronousSocketChannelImpl.implRead(UnixAsynchronousSocketChannelImpl.java:553)
        at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:272)
        at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
        at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
        at org.gearman.impl.reactor.SocketImpl.completed(Unknown Source)
        at org.gearman.impl.reactor.SocketImpl.completed(Unknown Source)
        at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
        at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
        at sun.nio.ch.UnixAsynchronousSocketChannelImpl.implRead(UnixAsynchronousSocketChannelImpl.java:553)
        at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:272)
        at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
        at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
        at org.gearman.impl.reactor.SocketImpl.completed(Unknown Source)
        at org.gearman.impl.reactor.SocketImpl.completed(Unknown Source)
        at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
        at sun.nio.ch.Invoker$2.run(Invoker.java:206)
        at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)


My client-code looks like this (original sample from CPAN for testing):

use strict;
use lib "/opt/gearman/lib";
use Gearman::Client;
use Storable qw( freeze );

my $client = Gearman::Client->new;
$client->job_servers('xxx.xxx.xxx.xxx:4730');
#my $result_ref = $client->do_task("mer_v13_u1", "BLAA");
#print $$result_ref."\n";

  my $tasks = $client->new_task_set;
    my $handle = $tasks->add_task(sum => freeze([ 3, 5 ]), {
        on_complete => sub { print ${ $_[0] }, "\n" }
});
$tasks->wait;


And here is my worker:

use strict;
use Cwd;
use lib "/opt/gearman/lib";
use Gearman::Worker;
use Config::INI::Simple;

my $path_separator = "/";
my $ini_file = "/opt/gearman/config.ini";

my $conf = new Config::INI::Simple;
$conf->read($ini_file);

print "JOB_SERVERS: ".$$conf{'GENERAL'}{'JOB_SERVERS'}."\n";
print "CSI_DIR: ".$$conf{'GENERAL'}{'CSI_DIR'}."\n";
print "ENV_COUNT: ".$$conf{'GENERAL'}{'ENV_COUNT'}."\n\n\n";

for(my $i=1;$i <= $$conf{'GENERAL'}{'ENV_COUNT'};$i++){
        print "Umgebung Nr. ".$i."\n";
        print "Mandant: ".$$conf{'ENV'.$i}{'CUSTOMER'}."\n";
        print "Basis-Verzeichnis: ".$$conf{'ENV'.$i}{'BASE_DIR'}."\n";
        print "Cef-File: ".$$conf{'ENV'.$i}{'CEF_FILE'}."\n\n";
}

my $worker = Gearman::Worker->new;
$worker->job_servers($$conf{'GENERAL'}{'JOB_SERVERS'});
$worker->register_function(mer_v13_u1 => sub { print "YEAAAHH!!!";});
$worker->work while 1;


I tried both, sending the task to the worker and calling the job on the worker. 
Everything I try leads to the Exception above.

Here my versions:
JAVA: JDK 1.7u7
Java-Gearman-Service 0.6.5
Perl-Libraries for Client and Worker: 1.11

Does someone have a clue, what goes wrong?

Original issue reported on code.google.com by [email protected] on 20 Sep 2012 at 4:52

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.