Package net.spy.memcached

Examples of net.spy.memcached.MemcachedClient


     */
    ZoneClusteredEVCacheClientImpl(String appName, String zone, int id, int maxQueueSize,
            DynamicIntProperty readTimeout, List<InetSocketAddress> memcachedNodesInZone) throws IOException {
        super(appName, zone, id, maxQueueSize, readTimeout);

        this.client = new MemcachedClient(connectionFactory, memcachedNodesInZone);
    }
View Full Code Here


     */
    EVCacheClientImpl(String appName, String zone, int id, int maxQueueSize, DynamicIntProperty readTimeout,
            List<InetSocketAddress> memcachedNodesInZone) throws IOException {
        super(appName, zone, id, readTimeout, new EVCacheConnectionFactory(appName, zone, id, maxQueueSize));

        this.client = new MemcachedClient(connectionFactory, memcachedNodesInZone);
        this.connectionObserver = new EVCacheConnectionObserver(appName, zone, id);
        this.client.addObserver(connectionObserver);
    }
View Full Code Here

     * @param serviceTicketTimeOut        ST timeout in seconds.
     */
    public MemCacheTicketRegistry(final String[] hostnames, final int ticketGrantingTicketTimeOut,
final int serviceTicketTimeOut) {
        try {
            this.client = new MemcachedClient(AddrUtil.getAddresses(Arrays.asList(hostnames)));
        } catch (final IOException e) {
            throw new IllegalArgumentException("Invalid memcached host specification.", e);
        }
        this.tgtTimeout = ticketGrantingTicketTimeOut;
        this.stTimeout = serviceTicketTimeOut;
View Full Code Here

      CompatibilityCacheFactory.killCacheFactories(cacheFactory);
   }

   public void testLoadingAndStoringEventsMemcached() throws InterruptedException, ExecutionException, TimeoutException {
      Cache<String, String> embedded = cacheFactory.getEmbeddedCache();
      MemcachedClient remote = cacheFactory.getMemcachedClient();

      TestCacheListener l = new TestCacheListener();
      embedded.addListener(l);

      assertTrue(l.created.isEmpty());
      assertTrue(l.removed.isEmpty());
      assertTrue(l.modified.isEmpty());
      assertTrue(l.visited.isEmpty());

      Future<Boolean> future1 = remote.add("k", 0, "v");
      assertTrue(future1.get(60, TimeUnit.SECONDS));

      assertEquals(1, l.createdCounter);
      assertEquals("v", l.created.get("k"));
      assertTrue(l.removed.isEmpty());
      assertEquals(1, l.modifiedCounter);
      assertEquals("v", l.modified.get("k"));
      assertTrue(l.visited.isEmpty());

      Future<Boolean> future2 = remote.set("key", 0, "value");
      assertTrue(future2.get(60, TimeUnit.SECONDS));

      assertEquals(2, l.createdCounter);
      assertTrue(l.removed.isEmpty());
      assertEquals(2, l.modifiedCounter);
      assertTrue(l.visited.isEmpty());

      Future<Boolean> future3 = remote.set("key", 0, "modifiedValue");
      assertTrue(future3.get(60, TimeUnit.SECONDS));

      assertEquals(2, l.createdCounter);
      assertTrue(l.removed.isEmpty());
      assertEquals(3, l.modifiedCounter);
      assertEquals("modifiedValue", l.modified.get("key"));
      assertTrue(l.visited.isEmpty());

      Future<Boolean> future4 = remote.replace("k", 0, "replacedValue");
      assertTrue(future4.get(60, TimeUnit.SECONDS));

      assertEquals(2, l.createdCounter);
      assertTrue(l.removed.isEmpty());
      assertEquals(4, l.modifiedCounter);
      assertEquals("replacedValue", l.modified.get("k"));
      assertTrue(l.visited.isEmpty());

      //resetting so don't have to type "== 2" etc. all over again
      l.reset();

      Future<Boolean> future5 = remote.delete("key");
      assertTrue(future5.get(60, TimeUnit.SECONDS));

      assertTrue(l.created.isEmpty());
      assertEquals(1, l.removedCounter);
      assertEquals("modifiedValue", l.removed.get("key"));
      assertTrue(l.modified.isEmpty());

      l.reset();

      String value = (String) remote.get("k");
      assertTrue(l.created.isEmpty());
      assertTrue(l.removed.isEmpty());
      assertTrue(l.modified.isEmpty());
      assertEquals(1, l.visitedCounter);
      assertEquals("replacedValue", l.visited.get("k"));
View Full Code Here

    int membaseport = Config.getConfig().memcached_port;
    String addr = Config.getConfig().memcached_address;
   
    try {
      InetSocketAddress ia = new InetSocketAddress(InetAddress.getByAddress(ipv4AddressToByte(addr)), membaseport);
      client = new MemcachedClient(ia);
    } catch (UnknownHostException e) {
      e.printStackTrace();
    } catch (IOException e1) {
      e1.printStackTrace();
    }
View Full Code Here

    todelay = Integer.parseInt(getProperties().getProperty(SIMULATE_DELAY, SIMULATE_DELAY_DEFAULT));

    try {
      List<URI> uris = new LinkedList<URI>();
      uris.add(new URI("http://" + address + ":8091/pools"));
      client = new MemcachedClient(uris, bucketName, password);
    } catch (UnknownHostException e) {
      e.printStackTrace();
    } catch (IOException e1) {
      e1.printStackTrace();
    } catch (URISyntaxException e) {
View Full Code Here

     * machine as your application, for example.
     * @param address where the <i>memcached</i> daemon is running
     * @throws IOException in case of an error
     */
    public MemcachedHttpCacheStorage(final InetSocketAddress address) throws IOException {
        this(new MemcachedClient(address));
    }
View Full Code Here

        return new KestrelEndpoint(uri, this, config, queue);
    }

    public MemcachedClient getMemcachedClient(KestrelConfiguration config, String queue) {
        String key = config.getAddressesAsString() + "/" + queue;
        MemcachedClient memcachedClient = memcachedClientCache.get(key);
        if (memcachedClient != null) {
            return memcachedClient;
        }
        synchronized (memcachedClientCache) {
            if ((memcachedClient = memcachedClientCache.get(key)) == null) {
                LOG.info("Creating MemcachedClient for " + key);
                try {
                    memcachedClient = new MemcachedClient(memcachedConnectionFactory, config.getInetSocketAddresses());
                } catch (Exception e) {
                    throw new RuntimeCamelException("Failed to connect to " + key, e);
                }
                memcachedClientCache.put(key, memcachedClient);
            }
View Full Code Here

TOP

Related Classes of net.spy.memcached.MemcachedClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.