camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jürgen Kindler <jkind...@talend.com>
Subject Implementing a TCP proxy for Apache Zookeeper using Mina
Date Wed, 22 Jun 2011 10:26:07 GMT
Hi,

I want to simulate a network failure between Zookeeper clients and a
Zookeeper server. 
I try to use Mina to implement a proxy to an Apache Zookeeper process, but
I get strange exceptions.
My route definition looks like this:

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
       

  <camelContext id="camelZookeeperProxyContext"
xmlns="http://camel.apache.org/schema/spring">
    <route id="ZookeeperTCP_1_Proxy">
      <from id="zookeeper1Proxy"
uri="mina:tcp://localhost:2282?sync=true&amp;allowDefaultCodec=false"/>
      <to id="zookeeper1Target"
uri="mina:tcp://localhost:2182?sync=true&amp;allowDefaultCodec=false"/>
    </route>
 </camelContext>
</beans>

So I am trying to forward requests sent to port 2282 to 2182, but it fails:

----%< snip %<------------------- output on proxy ------------------%<
snip %<-----
...
[2011-06-22 10:52:12][TRACE][Camel (camelZookeeperProxyContext) thread #3
- MinaThreadPool][org.apache.camel.management.InstrumentationProcessor] -
route: Recording duration: 60 millis for exchange: Exchange[Message:
DirectBuffer[pos=0 lim=40 cap=1024: 00 00 00 24 00 00 00 00 00 00 75 30 01
30 B6 65 49 10 00 02 00 00 00 10 9C 3A B1 12 E7 04 3B 20 86 CC B8 B8 A1 F0
67 4B]]
[2011-06-22 10:52:12][TRACE][Camel (camelZookeeperProxyContext) thread #3
- MinaThreadPool][org.apache.camel.impl.DefaultUnitOfWork] - UnitOfWork
done for ExchangeId: ID-sopmac11-50678-1308732723240-0-1 with
Exchange[Message: DirectBuffer[pos=0 lim=40 cap=1024: 00 00 00 24 00 00 00
00 00 00 75 30 01 30 B6 65 49 10 00 02 00 00 00 10 9C 3A B1 12 E7 04 3B 20
86 CC B8 B8 A1 F0 67 4B]]
[2011-06-22 10:52:12][TRACE][Camel (camelZookeeperProxyContext) thread #3
- MinaThreadPool][org.apache.camel.impl.DefaultInflightRepository] - Total
0 inflight exchanges. Last removed: ID-sopmac11-50678-1308732723240-0-1
[2011-06-22 10:52:12][TRACE][Camel (camelZookeeperProxyContext) thread #3
- MinaThreadPool][org.apache.camel.util.AsyncProcessorHelper] - Exchange
processed and is continued routed synchronously for exchangeId:
ID-sopmac11-50678-1308732723240-0-1 -> Exchange[Message:
DirectBuffer[pos=0 lim=40 cap=1024: 00 00 00 24 00 00 00 00 00 00 75 30 01
30 B6 65 49 10 00 02 00 00 00 10 9C 3A B1 12 E7 04 3B 20 86 CC B8 B8 A1 F0
67 4B]]
[2011-06-22 10:52:12][DEBUG][Camel (camelZookeeperProxyContext) thread #3
- MinaThreadPool][org.apache.camel.component.mina.MinaConsumer] - Writing
body: DirectBuffer[pos=0 lim=40 cap=1024: 00 00 00 24 00 00 00 00 00 00 75
30 01 30 B6 65 49 10 00 02 00 00 00 10 9C 3A B1 12 E7 04 3B 20 86 CC B8 B8
A1 F0 67 4B]
[2011-06-22 10:52:12][TRACE][Camel (camelZookeeperProxyContext) thread #3
- MinaThreadPool][org.apache.camel.component.mina.MinaHelper] - Waiting
for write to complete
[2011-06-22 10:52:12][DEBUG][Camel (camelZookeeperProxyContext) thread #3
- MinaThreadPool][org.apache.camel.component.mina.MinaConsumer] - Closing
session as an exception was thrown from MINA

[2011-06-22 10:52:12][WARN][Camel (camelZookeeperProxyContext) thread #3 -
MinaThreadPool][org.apache.camel.component.mina.MinaConsumer$ReceiveHandler
] - [/127.0.0.1:50684] Unexpected exception from exceptionCaught handler.
org.apache.camel.CamelException: java.lang.IllegalStateException: Already
released buffer.  You released the buffer too many times.
	at 
org.apache.camel.component.mina.MinaConsumer$ReceiveHandler.exceptionCaught
(MinaConsumer.java:95)
	at 
org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.exceptionCa
ught(AbstractIoFilterChain.java:564)
	at 
org.apache.mina.common.support.AbstractIoFilterChain.callNextExceptionCaugh
t(AbstractIoFilterChain.java:345)
	at 
org.apache.mina.common.support.AbstractIoFilterChain.access$1000(AbstractIo
FilterChain.java:53)
	at 
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.exceptionC
aught(AbstractIoFilterChain.java:643)
	at 
org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.
java:224)
	at 
org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(Ex
ecutorFilter.java:264)
	at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.j
ava:886)
	at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:
908)
	at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.IllegalStateException: Already released buffer.  You
released the buffer too many times.
	at 
org.apache.mina.common.PooledByteBufferAllocator$PooledByteBuffer.release(P
ooledByteBufferAllocator.java:310)
	at 
org.apache.mina.util.ByteBufferUtil.releaseIfPossible(ByteBufferUtil.java:3
9)
	at 
org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messageRece
ived(AbstractIoFilterChain.java:572)
	at 
org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceive
d(AbstractIoFilterChain.java:299)
	at 
org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIo
FilterChain.java:53)
	at 
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageRec
eived(AbstractIoFilterChain.java:648)
	at 
org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.
java:220)
	... 4 more
[2011-06-22 10:52:12][DEBUG][Camel (camelZookeeperProxyContext) thread #3
- MinaThreadPool][org.apache.camel.component.mina.MinaConsumer] - Closing
session as an exception was thrown from MINA

[2011-06-22 10:52:12][WARN][Camel (camelZookeeperProxyContext) thread #3 -
MinaThreadPool][org.apache.camel.component.mina.MinaConsumer$ReceiveHandler
] - [/127.0.0.1:50684] Unexpected exception from exceptionCaught handler.
org.apache.camel.CamelException: java.lang.IllegalStateException: Already
released buffer.  You released the buffer too many times.
	at 
org.apache.camel.component.mina.MinaConsumer$ReceiveHandler.exceptionCaught
(MinaConsumer.java:95)
	at 
org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.exceptionCa
ught(AbstractIoFilterChain.java:564)
	at 
org.apache.mina.common.support.AbstractIoFilterChain.callNextExceptionCaugh
t(AbstractIoFilterChain.java:345)
	at 
org.apache.mina.common.support.AbstractIoFilterChain.access$1000(AbstractIo
FilterChain.java:53)
	at 
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.exceptionC
aught(AbstractIoFilterChain.java:643)
	at 
org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.
java:224)
	at 
org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(Ex
ecutorFilter.java:264)
	at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.j
ava:886)
	at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:
908)
	at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.IllegalStateException: Already released buffer.  You
released the buffer too many times.
	at 
org.apache.mina.common.PooledByteBufferAllocator$PooledByteBuffer.release(P
ooledByteBufferAllocator.java:310)
	at 
org.apache.mina.util.ByteBufferUtil.releaseIfPossible(ByteBufferUtil.java:3
9)
	at 
org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messageSent
(AbstractIoFilterChain.java:581)
	at 
org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageSent(Ab
stractIoFilterChain.java:320)
	at 
org.apache.mina.common.support.AbstractIoFilterChain.access$1200(AbstractIo
FilterChain.java:53)
	at 
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageSen
t(AbstractIoFilterChain.java:653)
	at 
org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.
java:222)
	... 4 more
[2011-06-22 10:52:12][DEBUG][Camel (camelZookeeperProxyContext) thread #3
- MinaThreadPool][org.apache.mina.filter.executor.ExecutorFilter] -
Exiting since queue is empty for /127.0.0.1:50684
[2011-06-22 
10:52:14][TRACE][SocketAcceptor-0][org.apache.camel.util.concurrent.Executo
rServiceHelper] - Created thread[MinaSocketAcceptor]: Thread[Camel
(camelZookeeperProxyContext) thread #8 - MinaSocketAcceptor,5,main]
[2011-06-22 
10:52:14][DEBUG][SocketAcceptorIoProcessor-0.1][org.apache.mina.filter.exec
utor.ExecutorFilter] - Launching thread for /127.0.0.1:50688
[2011-06-22 
10:52:14][TRACE][SocketAcceptorIoProcessor-0.1][org.apache.camel.util.concu
rrent.ExecutorServiceHelper] - Created thread[MinaThreadPool]:
Thread[Camel (camelZookeeperProxyContext) thread #9 -
MinaThreadPool,5,main]
[2011-06-22 10:52:14][DEBUG][Camel (camelZookeeperProxyContext) thread #9
- MinaThreadPool][org.apache.camel.component.mina.MinaConsumer] - Received
body: DirectBuffer[pos=0 lim=48 cap=1024: 00 00 00 2C 00 00 00 00 00 00 00
00 00 00 00 00 00 00 75 30 01 30 B6 65 49 10 00 02 00 00 00 10 9C 3A B1 12
E7 04 3B 20 86 CC B8 B8 A1 F0 67 4B]
[2011-06-22 10:52:14][TRACE][Camel (camelZookeeperProxyContext) thread #9
- MinaThreadPool][org.apache.camel.impl.DefaultUnitOfWork] - UnitOfWork
created for ExchangeId: ID-sopmac11-50678-1308732723240-0-3 with
Exchange[Message: DirectBuffer[pos=0 lim=48 cap=1024: 00 00 00 2C 00 00 00
00 00 00 00 00 00 00 00 00 00 00 75 30 01 30 B6 65 49 10 00 02 00 00 00 10
9C 3A B1 12 E7 04 3B 20 86 CC B8 B8 A1 F0 67 4B]]
...
---->% snap >%----------------- end output on proxy ---------------->%
snap >%-----

Is there anything obvious I am missing?
Do I need a Java Implementation?

Would this be easier using Netty instead of Mina?


Thanks in advance
  Jürgen
-- 
Jürgen Kindler


Mime
View raw message