Unusual exception

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Unusual exception

Avinash Lakshman
I started seeing a bunch of these exceptions. What do these mean?

2010-10-13 14:01:33,426 - WARN [NIOServerCxn.Factory:
0.0.0.0/0.0.0.0:5001:NIOServerCnxn@606] - EndOfStreamException: Unable to
read additional data from client sessionid 0x0, likely client has closed
socket
2010-10-13 14:01:33,426 - INFO [NIOServerCxn.Factory:
0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1286] - Closed socket connection for
client /10.138.34.195:55738 (no session established for client)
2010-10-13 14:01:33,426 - DEBUG [CommitProcessor:1:FinalRequestProcessor@78]
- Processing request:: sessionid:0x12b9d1f8b907a44 type:closeSession
cxid:0x0 zxid:0x600193996 txntype:-11 reqpath:n/a
2010-10-13 14:01:33,427 - WARN [NIOServerCxn.Factory:
0.0.0.0/0.0.0.0:5001:NIOServerCnxn@606] - EndOfStreamException: Unable to
read additional data from client sessionid 0x12b9d1f8b907a5d, likely client
has closed socket
2010-10-13 14:01:33,427 - INFO [NIOServerCxn.Factory:
0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1286] - Closed socket connection for
client /10.138.34.195:55979 which had sessionid 0x12b9d1f8b907a5d
2010-10-13 14:01:33,427 - DEBUG [QuorumPeer:/0.0.0.0:5001
:CommitProcessor@159] - Committing request:: sessionid:0x52b90ab45bd51af
type:createSession cxid:0x0 zxid:0x600193cf9 txntype:-10 reqpath:n/a
2010-10-13 14:01:33,427 - DEBUG [NIOServerCxn.Factory:
0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1302] - ignoring exception during output
shutdown
java.net.SocketException: Transport endpoint is not connected
at sun.nio.ch.SocketChannelImpl.shutdown(Native Method)
at sun.nio.ch.SocketChannelImpl.shutdownOutput(SocketChannelImpl.java:651)
at sun.nio.ch.SocketAdaptor.shutdownOutput(SocketAdaptor.java:368)
at
org.apache.zookeeper.server.NIOServerCnxn.closeSock(NIOServerCnxn.java:1298)
at org.apache.zookeeper.server.NIOServerCnxn.close(NIOServerCnxn.java:1263)
at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:609)
at
org.apache.zookeeper.server.NIOServerCnxn$Factory.run(NIOServerCnxn.java:262)
2010-10-13 14:01:33,428 - DEBUG [NIOServerCxn.Factory:
0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1310] - ignoring exception during input
shutdown
java.net.SocketException: Transport endpoint is not connected
at sun.nio.ch.SocketChannelImpl.shutdown(Native Method)
at sun.nio.ch.SocketChannelImpl.shutdownInput(SocketChannelImpl.java:640)
at sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:360)
at
org.apache.zookeeper.server.NIOServerCnxn.closeSock(NIOServerCnxn.java:1306)
at org.apache.zookeeper.server.NIOServerCnxn.close(NIOServerCnxn.java:1263)
at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:609)
at
org.apache.zookeeper.server.NIOServerCnxn$Factory.run(NIOServerCnxn.java:262)
2010-10-13 14:01:33,428 - WARN [NIOServerCxn.Factory:
0.0.0.0/0.0.0.0:5001:NIOServerCnxn@606] - EndOfStreamException: Unable to
read additional data from client sessionid 0x0, likely client has closed
socket
2010-10-13 14:01:33,428 - INFO [NIOServerCxn.Factory:
0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1286] - Closed socket connection for
client /10.138.34.195:55731 (no session established for client)
Reply | Threaded
Open this post in threaded view
|

Re: Unusual exception

Patrick Hunt
EOS means that the client closed the connection (from the point of view of
the server). The server then tries to cleanup by closing the socket
explicitly, in some cases that results in debug messages you see subsequent.

EndOfStreamException: Unable to
read additional data from client sessionid 0x0, likely client has closed
socket

Notice that the session id is 0 - so either this is a zk client that failed
before establishing a session, or more likely it's a monitoring/4letterword
command (which never est sessions).

Patrick

On Wed, Oct 13, 2010 at 2:49 PM, Avinash Lakshman <
[hidden email]> wrote:

> I started seeing a bunch of these exceptions. What do these mean?
>
> 2010-10-13 14:01:33,426 - WARN [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@606] - EndOfStreamException: Unable to
> read additional data from client sessionid 0x0, likely client has closed
> socket
> 2010-10-13 14:01:33,426 - INFO [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1286] - Closed socket connection for
> client /10.138.34.195:55738 (no session established for client)
> 2010-10-13 14:01:33,426 - DEBUG [CommitProcessor:1:FinalRequestProcessor@78
> ]
> - Processing request:: sessionid:0x12b9d1f8b907a44 type:closeSession
> cxid:0x0 zxid:0x600193996 txntype:-11 reqpath:n/a
> 2010-10-13 14:01:33,427 - WARN [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@606] - EndOfStreamException: Unable to
> read additional data from client sessionid 0x12b9d1f8b907a5d, likely client
> has closed socket
> 2010-10-13 14:01:33,427 - INFO [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1286] - Closed socket connection for
> client /10.138.34.195:55979 which had sessionid 0x12b9d1f8b907a5d
> 2010-10-13 14:01:33,427 - DEBUG [QuorumPeer:/0.0.0.0:5001
> :CommitProcessor@159] - Committing request:: sessionid:0x52b90ab45bd51af
> type:createSession cxid:0x0 zxid:0x600193cf9 txntype:-10 reqpath:n/a
> 2010-10-13 14:01:33,427 - DEBUG [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1302] - ignoring exception during
> output
> shutdown
> java.net.SocketException: Transport endpoint is not connected
> at sun.nio.ch.SocketChannelImpl.shutdown(Native Method)
> at sun.nio.ch.SocketChannelImpl.shutdownOutput(SocketChannelImpl.java:651)
> at sun.nio.ch.SocketAdaptor.shutdownOutput(SocketAdaptor.java:368)
> at
>
> org.apache.zookeeper.server.NIOServerCnxn.closeSock(NIOServerCnxn.java:1298)
> at org.apache.zookeeper.server.NIOServerCnxn.close(NIOServerCnxn.java:1263)
> at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:609)
> at
>
> org.apache.zookeeper.server.NIOServerCnxn$Factory.run(NIOServerCnxn.java:262)
> 2010-10-13 14:01:33,428 - DEBUG [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1310] - ignoring exception during input
> shutdown
> java.net.SocketException: Transport endpoint is not connected
> at sun.nio.ch.SocketChannelImpl.shutdown(Native Method)
> at sun.nio.ch.SocketChannelImpl.shutdownInput(SocketChannelImpl.java:640)
> at sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:360)
> at
>
> org.apache.zookeeper.server.NIOServerCnxn.closeSock(NIOServerCnxn.java:1306)
> at org.apache.zookeeper.server.NIOServerCnxn.close(NIOServerCnxn.java:1263)
> at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:609)
> at
>
> org.apache.zookeeper.server.NIOServerCnxn$Factory.run(NIOServerCnxn.java:262)
> 2010-10-13 14:01:33,428 - WARN [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@606] - EndOfStreamException: Unable to
> read additional data from client sessionid 0x0, likely client has closed
> socket
> 2010-10-13 14:01:33,428 - INFO [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1286] - Closed socket connection for
> client /10.138.34.195:55731 (no session established for client)
>
Reply | Threaded
Open this post in threaded view
|

Re: Unusual exception

Mahadev Konar
In reply to this post by Avinash Lakshman
Hi Avinash,
 Not sure if you got a response for your email.
  The exception that you mention mostly means that the client already closed
the socket or shutdown.
 Looks like a client is trying to connect but disconnects before the server
can respond.

Do you have any such clients? Is this causing any issues with your zookeeper
set up?

Thanks
mahadev


On 10/13/10 2:49 PM, "Avinash Lakshman" <[hidden email]> wrote:

> I started seeing a bunch of these exceptions. What do these mean?
>
> 2010-10-13 14:01:33,426 - WARN [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@606] - EndOfStreamException: Unable to
> read additional data from client sessionid 0x0, likely client has closed
> socket
> 2010-10-13 14:01:33,426 - INFO [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1286] - Closed socket connection for
> client /10.138.34.195:55738 (no session established for client)
> 2010-10-13 14:01:33,426 - DEBUG [CommitProcessor:1:FinalRequestProcessor@78]
> - Processing request:: sessionid:0x12b9d1f8b907a44 type:closeSession
> cxid:0x0 zxid:0x600193996 txntype:-11 reqpath:n/a
> 2010-10-13 14:01:33,427 - WARN [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@606] - EndOfStreamException: Unable to
> read additional data from client sessionid 0x12b9d1f8b907a5d, likely client
> has closed socket
> 2010-10-13 14:01:33,427 - INFO [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1286] - Closed socket connection for
> client /10.138.34.195:55979 which had sessionid 0x12b9d1f8b907a5d
> 2010-10-13 14:01:33,427 - DEBUG [QuorumPeer:/0.0.0.0:5001
> :CommitProcessor@159] - Committing request:: sessionid:0x52b90ab45bd51af
> type:createSession cxid:0x0 zxid:0x600193cf9 txntype:-10 reqpath:n/a
> 2010-10-13 14:01:33,427 - DEBUG [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1302] - ignoring exception during output
> shutdown
> java.net.SocketException: Transport endpoint is not connected
> at sun.nio.ch.SocketChannelImpl.shutdown(Native Method)
> at sun.nio.ch.SocketChannelImpl.shutdownOutput(SocketChannelImpl.java:651)
> at sun.nio.ch.SocketAdaptor.shutdownOutput(SocketAdaptor.java:368)
> at
> org.apache.zookeeper.server.NIOServerCnxn.closeSock(NIOServerCnxn.java:1298)
> at org.apache.zookeeper.server.NIOServerCnxn.close(NIOServerCnxn.java:1263)
> at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:609)
> at
> org.apache.zookeeper.server.NIOServerCnxn$Factory.run(NIOServerCnxn.java:262)
> 2010-10-13 14:01:33,428 - DEBUG [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1310] - ignoring exception during input
> shutdown
> java.net.SocketException: Transport endpoint is not connected
> at sun.nio.ch.SocketChannelImpl.shutdown(Native Method)
> at sun.nio.ch.SocketChannelImpl.shutdownInput(SocketChannelImpl.java:640)
> at sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:360)
> at
> org.apache.zookeeper.server.NIOServerCnxn.closeSock(NIOServerCnxn.java:1306)
> at org.apache.zookeeper.server.NIOServerCnxn.close(NIOServerCnxn.java:1263)
> at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:609)
> at
> org.apache.zookeeper.server.NIOServerCnxn$Factory.run(NIOServerCnxn.java:262)
> 2010-10-13 14:01:33,428 - WARN [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@606] - EndOfStreamException: Unable to
> read additional data from client sessionid 0x0, likely client has closed
> socket
> 2010-10-13 14:01:33,428 - INFO [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1286] - Closed socket connection for
> client /10.138.34.195:55731 (no session established for client)
>

Reply | Threaded
Open this post in threaded view
|

Re: Unusual exception

Avinash Lakshman
Hi Mahadev

I did and it turned out to be some screw up on our end. Thanks

Avinash

On Tue, Oct 26, 2010 at 3:39 PM, Mahadev Konar <[hidden email]>wrote:

> Hi Avinash,
>  Not sure if you got a response for your email.
>  The exception that you mention mostly means that the client already closed
> the socket or shutdown.
>  Looks like a client is trying to connect but disconnects before the server
> can respond.
>
> Do you have any such clients? Is this causing any issues with your
> zookeeper
> set up?
>
> Thanks
> mahadev
>
>
> On 10/13/10 2:49 PM, "Avinash Lakshman" <[hidden email]>
> wrote:
>
> > I started seeing a bunch of these exceptions. What do these mean?
> >
> > 2010-10-13 14:01:33,426 - WARN [NIOServerCxn.Factory:
> > 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@606] - EndOfStreamException: Unable
> to
> > read additional data from client sessionid 0x0, likely client has closed
> > socket
> > 2010-10-13 14:01:33,426 - INFO [NIOServerCxn.Factory:
> > 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1286] - Closed socket connection for
> > client /10.138.34.195:55738 (no session established for client)
> > 2010-10-13 14:01:33,426 - DEBUG
> [CommitProcessor:1:FinalRequestProcessor@78]
> > - Processing request:: sessionid:0x12b9d1f8b907a44 type:closeSession
> > cxid:0x0 zxid:0x600193996 txntype:-11 reqpath:n/a
> > 2010-10-13 14:01:33,427 - WARN [NIOServerCxn.Factory:
> > 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@606] - EndOfStreamException: Unable
> to
> > read additional data from client sessionid 0x12b9d1f8b907a5d, likely
> client
> > has closed socket
> > 2010-10-13 14:01:33,427 - INFO [NIOServerCxn.Factory:
> > 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1286] - Closed socket connection for
> > client /10.138.34.195:55979 which had sessionid 0x12b9d1f8b907a5d
> > 2010-10-13 14:01:33,427 - DEBUG [QuorumPeer:/0.0.0.0:5001
> > :CommitProcessor@159] - Committing request:: sessionid:0x52b90ab45bd51af
> > type:createSession cxid:0x0 zxid:0x600193cf9 txntype:-10 reqpath:n/a
> > 2010-10-13 14:01:33,427 - DEBUG [NIOServerCxn.Factory:
> > 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1302] - ignoring exception during
> output
> > shutdown
> > java.net.SocketException: Transport endpoint is not connected
> > at sun.nio.ch.SocketChannelImpl.shutdown(Native Method)
> > at
> sun.nio.ch.SocketChannelImpl.shutdownOutput(SocketChannelImpl.java:651)
> > at sun.nio.ch.SocketAdaptor.shutdownOutput(SocketAdaptor.java:368)
> > at
> >
> org.apache.zookeeper.server.NIOServerCnxn.closeSock(NIOServerCnxn.java:1298)
> > at
> org.apache.zookeeper.server.NIOServerCnxn.close(NIOServerCnxn.java:1263)
> > at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:609)
> > at
> >
> org.apache.zookeeper.server.NIOServerCnxn$Factory.run(NIOServerCnxn.java:262)
> > 2010-10-13 14:01:33,428 - DEBUG [NIOServerCxn.Factory:
> > 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1310] - ignoring exception during
> input
> > shutdown
> > java.net.SocketException: Transport endpoint is not connected
> > at sun.nio.ch.SocketChannelImpl.shutdown(Native Method)
> > at sun.nio.ch.SocketChannelImpl.shutdownInput(SocketChannelImpl.java:640)
> > at sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:360)
> > at
> >
> org.apache.zookeeper.server.NIOServerCnxn.closeSock(NIOServerCnxn.java:1306)
> > at
> org.apache.zookeeper.server.NIOServerCnxn.close(NIOServerCnxn.java:1263)
> > at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:609)
> > at
> >
> org.apache.zookeeper.server.NIOServerCnxn$Factory.run(NIOServerCnxn.java:262)
> > 2010-10-13 14:01:33,428 - WARN [NIOServerCxn.Factory:
> > 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@606] - EndOfStreamException: Unable
> to
> > read additional data from client sessionid 0x0, likely client has closed
> > socket
> > 2010-10-13 14:01:33,428 - INFO [NIOServerCxn.Factory:
> > 0.0.0.0/0.0.0.0:5001:NIOServerCnxn@1286] - Closed socket connection for
> > client /10.138.34.195:55731 (no session established for client)
> >
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Unusual exception

devsri
Hi,

I am naive to hbase. I am getting the following warning and info in the log file

2011-07-26 14:04:55,055 WARN org.apache.zookeeper.server.NIOServerCnxn: EndOfStreamException: Unable to read additional data from client sessionid 0x131659420650004, likely client has closed socket
2011-07-26 14:04:55,056 INFO org.apache.zookeeper.server.NIOServerCnxn: Closed socket connection for client /0:0:0:0:0:0:0:1:58125 which had sessionid 0x131659420650004

I am not abe to figure out the way to solve this as this is closing the connection.

Thanks in advance for any help or suggestion

regards
devsri
Reply | Threaded
Open this post in threaded view
|

Re: Unusual exception

Patrick Hunt
This is saying that the client (hbase in this case) is no longer
connected to the server (tcp connection down) for some reason. This
can happen for a number of reasons - typically the client process was
killed, host restarted or partitioned from the server, etc.... There's
nothing really to "solve" here, once the issue is resolved, ie client
process is restarted or network healed etc..., the client will
re-connect and start participating again.

Patrick

On Tue, Jul 26, 2011 at 2:03 AM, devsri <[hidden email]> wrote:

> Hi,
>
> I am naive to hbase. I am getting the following warning and info in the log
> file
>
> 2011-07-26 14:04:55,055 WARN org.apache.zookeeper.server.NIOServerCnxn:
> EndOfStreamException: Unable to read additional data from client sessionid
> 0x131659420650004, likely client has closed socket
> 2011-07-26 14:04:55,056 INFO org.apache.zookeeper.server.NIOServerCnxn:
> Closed socket connection for client /0:0:0:0:0:0:0:1:58125 which had
> sessionid 0x131659420650004
>
> I am not abe to figure out the way to solve this as this is closing the
> connection.
>
> Thanks in advance for any help or suggestion
>
> regards
> devsri
>
>
> --
> View this message in context: http://zookeeper-user.578899.n2.nabble.com/Unusual-exception-tp5632833p6621467.html
> Sent from the zookeeper-user mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: Unusual exception

adje
I'm new to Zookeeper. The first tests all worked but now I'm getting the same exception as the previous posters. Unfortunately I don't see the answer.
My situation is that I have the zookeeper server running on my PC and am in a cluster with two other servers. I'm on Windows and just run the ZkCli.cmd script multiple times on my PC. The first two start fine, but the third gives this error message:

zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181
zookeeper.ClientCnxn: Socket connection established to localhost/127.0.0.1:2181, initiating session
zookeeper.ClientCnxn: Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect

Is there a limit somewhere on number of client connections? Or is it a problem on my Windows PC with sockets?

Any help would be appreciated.

Adje
Reply | Threaded
Open this post in threaded view
|

Re: Unusual exception

Patrick Hunt
What do the server logs indicate?

On Thu, Dec 1, 2011 at 11:49 PM, adje <[hidden email]> wrote:

> I'm new to Zookeeper. The first tests all worked but now I'm getting the same
> exception as the previous posters. Unfortunately I don't see the answer.
> My situation is that I have the zookeeper server running on my PC and am in
> a cluster with two other servers. I'm on Windows and just run the ZkCli.cmd
> script multiple times on my PC. The first two start fine, but the third
> gives this error message:
>
> zookeeper.ClientCnxn: Opening socket connection to server
> localhost/127.0.0.1:2181
> zookeeper.ClientCnxn: Socket connection established to
> localhost/127.0.0.1:2181, initiating session
> zookeeper.ClientCnxn: Unable to read additional data from server sessionid
> 0x0, likely server has closed socket, closing socket connection and
> attempting reconnect
>
> Is there a limit somewhere on number of client connections? Or is it a
> problem on my Windows PC with sockets?
>
> Any help would be appreciated.
>
> Adje
>
> --
> View this message in context: http://zookeeper-user.578899.n2.nabble.com/Unusual-exception-tp5632833p7053818.html
> Sent from the zookeeper-user mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Unusual exception

vineet.salian
In reply to this post by Avinash Lakshman
Hi Avinash,
I am facing the same problem.
I am unable to detect the source of the problem as the producer program is
working but consumer is not.
Can you please help me out.

import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import kafka.consumer.Consumer;
import kafka.consumer.ConsumerConfig;
import kafka.consumer.ConsumerIterator;
import kafka.consumer.KafkaStream;
import kafka.javaapi.consumer.ConsumerConnector;
import kafka.javaapi.message.ByteBufferMessageSet;
import kafka.message.MessageAndOffset;
public class HelloKafkaConsumer extends  Thread {
    final static String clientId = "SimpleConsumerDemoClient";
    final static String TOPIC = "test";
    ConsumerConnector consumerConnector;


    public static void main(String[] argv) throws
UnsupportedEncodingException {
        HelloKafkaConsumer helloKafkaConsumer = new HelloKafkaConsumer();
        helloKafkaConsumer.start();
    }

    public HelloKafkaConsumer(){
    try{
        Properties properties = new Properties();
        properties.put("zookeeper.connect","localhost:2181");
        System.out.println("Hi"+properties);
        properties.put("group.id","test-group");
        System.out.println("Hi1"+properties);
        ConsumerConfig consumerConfig = new ConsumerConfig(properties);
        System.out.println("hi2"+consumerConfig);
        consumerConnector =
Consumer.createJavaConsumerConnector(consumerConfig);
    System.out.println("hi3"+consumerConnector);
        }catch(Exception e){}
    }

    @Override
    public void run() {
    try{
        Map<String, Integer> topicCountMap = new HashMap<String, Integer>();
System.out.println("topic count map "+topicCountMap);
        topicCountMap.put(TOPIC, new Integer(1));
        Map<String, List&lt;KafkaStream&lt;byte[], byte[]>>> consumerMap =
consumerConnector.createMessageStreams(topicCountMap);
        System.out.println("------------------------->");
        KafkaStream<byte[], byte[]> stream =  consumerMap.get(TOPIC).get(0);
        ConsumerIterator<byte[], byte[]> it = stream.iterator();
        while(it.hasNext())
            System.out.println(new String(it.next().message()));
    }catch(Exception e){ System.out.print("Inside run"+e);
e.printStackTrace(); }
    }

    private static void printMessages(ByteBufferMessageSet messageSet)
throws UnsupportedEncodingException {
        for(MessageAndOffset messageAndOffset: messageSet)
        {
        try{
        ByteBuffer payload = messageAndOffset.message().payload();
        byte[] bytes = new byte[payload.limit()];
        payload.get(bytes);
        System.out.println(new String(bytes, "UTF-8"));
        }catch(Exception e){}
        }
    }
}

This is the consumer program.

Regards,
Vineet



--
View this message in context: http://zookeeper-user.578899.n2.nabble.com/Unusual-exception-tp5632833p7582198.html
Sent from the zookeeper-user mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Unusual exception

Flavio Junqueira-3
Hi Vineet,

You probably meant to send this message to the Kafka list, no?

-Flavio

> On 23 Mar 2016, at 06:33, vineet.salian <[hidden email]> wrote:
>
> Hi Avinash,
> I am facing the same problem.
> I am unable to detect the source of the problem as the producer program is
> working but consumer is not.
> Can you please help me out.
>
> import java.io.UnsupportedEncodingException;
> import java.nio.ByteBuffer;
> import java.util.HashMap;
> import java.util.List;
> import java.util.Map;
> import java.util.Properties;
>
> import kafka.consumer.Consumer;
> import kafka.consumer.ConsumerConfig;
> import kafka.consumer.ConsumerIterator;
> import kafka.consumer.KafkaStream;
> import kafka.javaapi.consumer.ConsumerConnector;
> import kafka.javaapi.message.ByteBufferMessageSet;
> import kafka.message.MessageAndOffset;
> public class HelloKafkaConsumer extends  Thread {
>    final static String clientId = "SimpleConsumerDemoClient";
>    final static String TOPIC = "test";
>    ConsumerConnector consumerConnector;
>
>
>    public static void main(String[] argv) throws
> UnsupportedEncodingException {
>        HelloKafkaConsumer helloKafkaConsumer = new HelloKafkaConsumer();
>        helloKafkaConsumer.start();
>    }
>
>    public HelloKafkaConsumer(){
>     try{
>        Properties properties = new Properties();
>        properties.put("zookeeper.connect","localhost:2181");
>        System.out.println("Hi"+properties);
>        properties.put("group.id","test-group");
>        System.out.println("Hi1"+properties);
>        ConsumerConfig consumerConfig = new ConsumerConfig(properties);
>        System.out.println("hi2"+consumerConfig);
>        consumerConnector =
> Consumer.createJavaConsumerConnector(consumerConfig);
>     System.out.println("hi3"+consumerConnector);
>        }catch(Exception e){}
>    }
>
>    @Override
>    public void run() {
>     try{
>        Map<String, Integer> topicCountMap = new HashMap<String, Integer>();
> System.out.println("topic count map "+topicCountMap);
>        topicCountMap.put(TOPIC, new Integer(1));
>        Map<String, List&lt;KafkaStream&lt;byte[], byte[]>>> consumerMap =
> consumerConnector.createMessageStreams(topicCountMap);
>        System.out.println("------------------------->");
>        KafkaStream<byte[], byte[]> stream =  consumerMap.get(TOPIC).get(0);
>        ConsumerIterator<byte[], byte[]> it = stream.iterator();
>        while(it.hasNext())
>            System.out.println(new String(it.next().message()));
>     }catch(Exception e){ System.out.print("Inside run"+e);
> e.printStackTrace(); }
>    }
>
>    private static void printMessages(ByteBufferMessageSet messageSet)
> throws UnsupportedEncodingException {
>         for(MessageAndOffset messageAndOffset: messageSet)
>         {
>         try{
>         ByteBuffer payload = messageAndOffset.message().payload();
>         byte[] bytes = new byte[payload.limit()];
>         payload.get(bytes);
>         System.out.println(new String(bytes, "UTF-8"));
>         }catch(Exception e){}
>         }
>    }
> }
>
> This is the consumer program.
>
> Regards,
> Vineet
>
>
>
> --
> View this message in context: http://zookeeper-user.578899.n2.nabble.com/Unusual-exception-tp5632833p7582198.html
> Sent from the zookeeper-user mailing list archive at Nabble.com.