7

Non sono stato in grado di trovare un buon tutorial su Memcached su Amazon Cloud e sono molto nuovo a questa cosa del caching. Sto provando ad usare memcached tramite il servizio ElastiCache di Amazon e con un client spymemcache per effettuare effettivamente le chiamate memcached.Impostazione Amazon ElastiCache w/spymemcache in Java

Ecco quello che sto facendo in Java in questo momento:

try { 
     ConnectionFactoryBuilder connectionFactoryBuilder = new ConnectionFactoryBuilder(); 
     MemcachedClient memcachedClient = new MemcachedClient(
       connectionFactoryBuilder.build(), 
       AddrUtil.getAddresses("<beginning of cache node end point grabbed from AWS Console>.cache.amazonaws.com:11211")); 
     memcachedClient.set("test", 12, new Integer(12)); 
     System.out.println(memcachedClient.get("test")); 
    } catch (IOException ioException) { 
     ioException.printStackTrace(); 
    } 

L'errore che ottengo quando provo questo è:

java.net.ConnectException: Connection refused 
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:567) 
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:414) 
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:278) 
at net.spy.memcached.MemcachedClient.run(MemcachedClient.java:1981) 
2012-02-01 19:25:35.415 WARN net.spy.memcached.MemcachedConnection: Closing, and  reopening {QA sa=<node endpoint>.cache.amazonaws.com/184.73.64.56:11211, #Rops=0, #Wops=2, #iq=0, topRop=null, [email protected]e, toWrite=0, interested=0}, attempt 1. 
net.spy.memcached.OperationTimeoutException: Timeout waiting for value 
at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1142) 
at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1157) 
at com.amazon.imaging.demo.SQSQueueManager.requeue(SQSQueueManager.java:117) 
at com.amazon.imaging.demo.SQSQueueManager.requeue(SQSQueueManager.java:88) 
at com.amazon.imaging.demo.DemoUI$4.run(DemoUI.java:368) 
at com.amazon.imaging.demo.DemoUI.main(DemoUI.java:391) 
Caused by: net.spy.memcached.internal.CheckedOperationTimeoutException: Timed out waiting for operation - failing node: <node endpoint>.cache.amazonaws.com/184.73.64.56:11211 
at net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:65) 
at net.spy.memcached.internal.GetFuture.get(GetFuture.java:37) 
at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1135) 
... 5 more 

Chiunque ha ottenuto tutte le idee o esperienza con questo? Grazie!

risposta

2

Dove stai eseguendo questo? Da con in un'istanza EC2 o da una rete esterna. Ricordare che i server ElastiCache sono vincolati dal gruppo di sicurezza che limita l'accesso alle istanze di ElastiCAche. Quindi controlla il gruppo di sicurezza e altre configurazioni che ti permettono di collegarti al server Memcached. per quanto ne so, non è possibile accedere a ElastiCache dall'esterno del limite AWS

Il resto del codice sembra corretto e cConsiderare l'utilizzo di un framework come Spring per gestire l'istanza dell'oggetto client memcache e la relativa configurazione.

Problemi correlati