2012-06-15 2 views
1
내 자바 코드는 IOException가 및 memcache 서버를주고있다

가 다시 연결 ..IOException이 자바에서 memcached와의 설정 작업에

코드 :

public class Memcache implements Serializable { 

    MemcachedClient client; 

    public static final int EXP_TIME = 10; 
    public static final String KEY = "spoon"; 

    public static void main(String[] args)throws IOException{ 
     Memcache temp=new Memcache(); 
     Dummy dummy= new Dummy("Hello World"); 

     try { 
      temp.client = new MemcachedClient(new InetSocketAddress("localhost", 11211)); 
     } catch (IOException e) { 
      e.printStackTrace(); 
      System.err.println("connection problem"); 
     } 
     temp.obj=temp.client.getAvailableServers(); 
     System.out.println(temp.obj); 
     temp.obj1=temp.client.getUnavailableServers(); 
     System.out.println(temp.obj1); 
     temp.client.add(KEY, EXP_TIME, dummy); 
     Object myObject=temp.client.get(KEY); 
     System.out.println(myObject); 
     temp.client.delete(KEY); 
    } 
} 

코드를 디버깅했지만 설정 작업에 도달했을 때 IOException n disconnected가 발생했습니다. 더미에 대한

코드는 다음과 같습니다

import java.io.Serializable; 

public class Dummy implements Serializable { 
    String one; 

    public Dummy(String one){ 
     this.one=one; 
    } 
} 

스택 트레이스는 다음과 같습니다

 
2012-06-15 14:30:19.259 INFO net.spy.memcached.MemcachedConnection: Added {QA sa=/10.2.200.104:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue 
2012-06-15 14:30:19.274 INFO net.spy.memcached.MemcachedConnection: Connection state changed for [email protected] 
[/10.2.200.104:11211] 
[] 
2012-06-15 14:30:22.852 INFO net.spy.memcached.MemcachedConnection: Reconnecting due to exception on {QA sa=/10.2.200.104:11211, #Rops=1, #Wops=0, #iq=0, topRop=Cmd: set Key: spoon Flags: 1 Exp: 10 Data Length: 76, topWop=null, toWrite=0, interested=1} 
java.io.IOException: Disconnected unexpected, will reconnect. 
    at net.spy.memcached.MemcachedConnection.handleReads(MemcachedConnection.java:452) 
    at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:380) 
    at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:242) 
    at net.spy.memcached.MemcachedConnection.run(MemcachedConnection.java:833) 
2012-06-15 14:30:22.852 WARN net.spy.memcached.MemcachedConnection: Closing, and reopening {QA sa=/10.2.200.104:11211, #Rops=1, #Wops=0, #iq=0, topRop=Cmd: set Key: spoon Flags: 1 Exp: 10 Data Length: 76, topWop=null, toWrite=0, interested=1}, attempt 0. 
2012-06-15 14:30:22.852 WARN net.spy.memcached.protocol.ascii.AsciiMemcachedNodeImpl: Discarding partially completed op: Cmd: set Key: spoon Flags: 1 Exp: 10 Data Length: 76 
2012-06-15 14:30:24.868 INFO net.spy.memcached.MemcachedConnection: Reconnecting {QA sa=/10.2.200.104:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} 
2012-06-15 14:30:24.868 INFO net.spy.memcached.MemcachedConnection: Connection state changed for [email protected] 
2012-06-15 14:30:31.665 INFO net.spy.memcached.MemcachedConnection: Reconnecting due to exception on {QA sa=/10.2.200.104:11211, #Rops=1, #Wops=0, #iq=0, topRop=Cmd: get Keys: spoon Exp: 0, topWop=null, toWrite=0, interested=1} 
java.io.IOException: Disconnected unexpected, will reconnect. 
    at net.spy.memcached.MemcachedConnection.handleReads(MemcachedConnection.java:452) 
    at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:380) 
    at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:242) 
    at net.spy.memcached.MemcachedConnection.run(MemcachedConnection.java:833) 
2012-06-15 14:30:31.665 WARN net.spy.memcached.MemcachedConnection: Closing, and reopening {QA sa=/10.2.200.104:11211, #Rops=1, #Wops=0, #iq=0, topRop=Cmd: get Keys: spoon Exp: 0, topWop=null, toWrite=0, interested=1}, attempt 0. 
2012-06-15 14:30:31.665 WARN net.spy.memcached.protocol.ascii.AsciiMemcachedNodeImpl: Discarding partially completed op: Cmd: get Keys: spoon Exp: 0 
2012-06-15 14:30:33.680 INFO net.spy.memcached.MemcachedConnection: Reconnecting {QA sa=/10.2.200.104:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} 
2012-06-15 14:30:33.680 INFO net.spy.memcached.MemcachedConnection: Connection state changed for [email protected] 
Exception in thread "main" java.lang.RuntimeException: Exception waiting for value 
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1001) 
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1018) 
    at ballydev.Memcache.main(Memcache.java:39) 
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Cancelled 
    at net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:103) 
    at net.spy.memcached.internal.GetFuture.get(GetFuture.java:62) 
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:997) 
    ... 2 more 
Caused by: java.lang.RuntimeException: Cancelled 
    ... 5 more 
+0

여분의 스택 트레이스가 있습니까? – adarshr

+0

질문 업데이트 –

+0

방화벽/바이러스 백신 문제처럼 보입니다. 비활성화하십시오. – adarshr

답변

1

문제를 디버깅하려면, 요청이 시작된 서버에서 memcached를 텔넷을 시도하시기 바랍니다. memcached가 명시 적으로 IP 주소를 언급하기 시작하면 다른 호스트에 대한 연결을 거부 할 수 있습니다.

+0

i telnet localhost 11211 명령을 시도했지만 명령 프롬프트에 빈 화면이 표시됩니다 ... 입력 할 때 커서가 공백으로 이동합니다 ... –

+0

텔넷에서 통계와 같은 명령을 설정하거나 실행할 수 있습니까? –

+0

cmd에 문자를 입력 할 때 아무런 문제가 없습니다. Enter 키를 누르면 정상으로 돌아갑니다 ... –