当前位置: 首页>>代码示例>>Java>>正文


Java OperationTimeoutException类代码示例

本文整理汇总了Java中net.spy.memcached.OperationTimeoutException的典型用法代码示例。如果您正苦于以下问题:Java OperationTimeoutException类的具体用法?Java OperationTimeoutException怎么用?Java OperationTimeoutException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


OperationTimeoutException类属于net.spy.memcached包,在下文中一共展示了OperationTimeoutException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEntry

import net.spy.memcached.OperationTimeoutException; //导入依赖的package包/类
@Override
public HttpCacheEntry getEntry(final String url) throws IOException {
    final String key = getCacheKey(url);
    if (key == null) {
        return null;
    }
    try {
        final MemcachedCacheEntry mce = reconstituteEntry(client.get(key));
        if (mce == null || !url.equals(mce.getStorageKey())) {
            return null;
        }
        return mce.getHttpCacheEntry();
    } catch (final OperationTimeoutException ex) {
        throw new MemcachedOperationTimeoutException(ex);
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:17,代码来源:MemcachedHttpCacheStorage.java

示例2: testThrowsIOExceptionWhenMemcachedPutTimesOut

import net.spy.memcached.OperationTimeoutException; //导入依赖的package包/类
public void testThrowsIOExceptionWhenMemcachedPutTimesOut() {
    final String url = "foo";
    final String key = "key";
    final HttpCacheEntry value = HttpTestUtils.makeCacheEntry();
    final byte[] serialized = HttpTestUtils.getRandomBytes(128);

    when(mockMemcachedCacheEntryFactory.getMemcachedCacheEntry(url, value))
        .thenReturn(mockMemcachedCacheEntry);
    when(mockMemcachedCacheEntry.toByteArray())
        .thenReturn(serialized);
    when(mockKeyHashingScheme.hash(url))
        .thenReturn(key);
    when(mockMemcachedClient.set(key, 0, serialized))
        .thenThrow(new OperationTimeoutException("timed out"));

    try {
        impl.putEntry(url, value);
        fail("should have thrown exception");
    } catch (final IOException expected) {
    }

    verify(mockMemcachedCacheEntryFactory).getMemcachedCacheEntry(url, value);
    verify(mockMemcachedCacheEntry).toByteArray();
    verify(mockKeyHashingScheme).hash(url);
    verify(mockMemcachedClient).set(key, 0, serialized);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:27,代码来源:TestMemcachedHttpCacheStorage.java

示例3: testThrowsIOExceptionIfMemcachedTimesOutOnGet

import net.spy.memcached.OperationTimeoutException; //导入依赖的package包/类
@Test
public void testThrowsIOExceptionIfMemcachedTimesOutOnGet() {
    final String url = "foo";
    final String key = "key";
    when(mockKeyHashingScheme.hash(url)).thenReturn(key);
    when(mockMemcachedClient.get(key))
        .thenThrow(new OperationTimeoutException(""));

    try {
        impl.getEntry(url);
        fail("should have thrown exception");
    } catch (final IOException expected) {
    }
    verify(mockKeyHashingScheme).hash(url);
    verify(mockMemcachedClient).get(key);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:17,代码来源:TestMemcachedHttpCacheStorage.java

示例4: testCacheRemoveThrowsIOExceptionOnMemcachedTimeout

import net.spy.memcached.OperationTimeoutException; //导入依赖的package包/类
@Test
public void testCacheRemoveThrowsIOExceptionOnMemcachedTimeout() {
    final String url = "foo";
    final String key = "key";
    when(mockKeyHashingScheme.hash(url)).thenReturn(key);
    when(mockMemcachedClient.delete(key))
        .thenThrow(new OperationTimeoutException(""));

    try {
        impl.removeEntry(url);
        fail("should have thrown exception");
    } catch (final IOException expected) {
    }

    verify(mockKeyHashingScheme).hash(url);
    verify(mockMemcachedClient).delete(key);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestMemcachedHttpCacheStorage.java

示例5: putEntry

import net.spy.memcached.OperationTimeoutException; //导入依赖的package包/类
@Override
public void putEntry(final String url, final HttpCacheEntry entry) throws IOException  {
    final byte[] bytes = serializeEntry(url, entry);
    final String key = getCacheKey(url);
    if (key == null) {
        return;
    }
    try {
        client.set(key, 0, bytes);
    } catch (final OperationTimeoutException ex) {
        throw new MemcachedOperationTimeoutException(ex);
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:14,代码来源:MemcachedHttpCacheStorage.java

示例6: removeEntry

import net.spy.memcached.OperationTimeoutException; //导入依赖的package包/类
@Override
public void removeEntry(final String url) throws IOException {
    final String key = getCacheKey(url);
    if (key == null) {
        return;
    }
    try {
        client.delete(key);
    } catch (final OperationTimeoutException ex) {
        throw new MemcachedOperationTimeoutException(ex);
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:13,代码来源:MemcachedHttpCacheStorage.java

示例7: testUpdateThrowsIOExceptionIfMemcachedTimesOut

import net.spy.memcached.OperationTimeoutException; //导入依赖的package包/类
@Test
public void testUpdateThrowsIOExceptionIfMemcachedTimesOut() throws HttpCacheUpdateException {
    final String url = "foo";
    final String key = "key";
    final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();

    final HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() {
        @Override
        public HttpCacheEntry update(final HttpCacheEntry old) {
            assertNull(old);
            return updatedValue;
        }
    };

    // get empty old entry
    when(mockKeyHashingScheme.hash(url)).thenReturn(key);
    when(mockMemcachedClient.gets(key))
        .thenThrow(new OperationTimeoutException(""));

    try {
        impl.updateEntry(url, callback);
        fail("should have thrown exception");
    } catch (final IOException expected) {
    }

    verify(mockKeyHashingScheme).hash(url);
    verify(mockMemcachedClient).gets(key);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:29,代码来源:TestMemcachedHttpCacheStorage.java

示例8: increment

import net.spy.memcached.OperationTimeoutException; //导入依赖的package包/类
/**
 * Increments the object count
 *
 * @param key  
 * @param value  
 * @param defaultValue  this value is set if the object doesn't exists
 * @param timeoutMiliSec  not used
 * @return new count value of the object
 */
public long increment(String key, int delta, long defaultValue, long timeoutMiliSec) 
		throws TimeoutException, com.quickserverlab.quickcached.client.MemcachedException {	
	long newval = -1;
	try{
		newval = getCache().incr(key, delta, defaultValue);
	}catch(OperationTimeoutException ote){
		throw new TimeoutException("Timeout "+ ote);
	}catch(IllegalStateException ise){
		throw new com.quickserverlab.quickcached.client.MemcachedException("IllegalStateException "+ ise);
	}
	return newval;
}
 
开发者ID:QuickServerLab,项目名称:QuickCached,代码行数:22,代码来源:SpyMemcachedImpl.java

示例9: decrement

import net.spy.memcached.OperationTimeoutException; //导入依赖的package包/类
public long decrement(String key, int delta, long defaultValue, long timeoutMiliSec) 
		throws TimeoutException, com.quickserverlab.quickcached.client.MemcachedException {	
	long newval = -1;
	try{
		newval = getCache().decr(key, delta, defaultValue);
	}catch(OperationTimeoutException ote){
		throw new TimeoutException("Timeout "+ ote);
	}catch(IllegalStateException ise){
		throw new com.quickserverlab.quickcached.client.MemcachedException("IllegalStateException "+ ise);
	}
	return newval;
}
 
开发者ID:QuickServerLab,项目名称:QuickCached,代码行数:13,代码来源:SpyMemcachedImpl.java

示例10: updateEntry

import net.spy.memcached.OperationTimeoutException; //导入依赖的package包/类
@Override
public void updateEntry(final String url, final HttpCacheUpdateCallback callback)
        throws HttpCacheUpdateException, IOException {
    int numRetries = 0;
    final String key = getCacheKey(url);
    if (key == null) {
        throw new HttpCacheUpdateException("couldn't generate cache key");
    }
    do {
        try {
            final CASValue<Object> v = client.gets(key);
            MemcachedCacheEntry mce = (v == null) ? null
                    : reconstituteEntry(v.getValue());
            if (mce != null && (!url.equals(mce.getStorageKey()))) {
                mce = null;
            }
            final HttpCacheEntry existingEntry = (mce == null) ? null
                    : mce.getHttpCacheEntry();
            final HttpCacheEntry updatedEntry = callback.update(existingEntry);

            if (existingEntry == null) {
                putEntry(url, updatedEntry);
                return;

            } else {
                final byte[] updatedBytes = serializeEntry(url, updatedEntry);
                final CASResponse casResult = client.cas(key, v.getCas(),
                        updatedBytes);
                if (casResult != CASResponse.OK) {
                    numRetries++;
                } else {
                    return;
                }
            }
        } catch (final OperationTimeoutException ex) {
            throw new MemcachedOperationTimeoutException(ex);
        }
    } while (numRetries <= maxUpdateRetries);

    throw new HttpCacheUpdateException("Failed to update");
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:42,代码来源:MemcachedHttpCacheStorage.java

示例11: cas

import net.spy.memcached.OperationTimeoutException; //导入依赖的package包/类
@Override
   public CASResponse cas(String key, long casId, Object value)
    throws OperationTimeoutException {
return null;
   }
 
开发者ID:forcedotcom,项目名称:3levelmemcache,代码行数:6,代码来源:EmptyMemcachedConnection.java

示例12: gets

import net.spy.memcached.OperationTimeoutException; //导入依赖的package包/类
@Override
   public <T> CASValue<T> gets(String key, Transcoder<T> tc)
    throws OperationTimeoutException {

return null;
   }
 
开发者ID:forcedotcom,项目名称:3levelmemcache,代码行数:7,代码来源:EmptyMemcachedConnection.java

示例13: get

import net.spy.memcached.OperationTimeoutException; //导入依赖的package包/类
@Override
   public <T> T get(String key, Transcoder<T> tc)
    throws OperationTimeoutException {
return null;
   }
 
开发者ID:forcedotcom,项目名称:3levelmemcache,代码行数:6,代码来源:EmptyMemcachedConnection.java

示例14: getBulk

import net.spy.memcached.OperationTimeoutException; //导入依赖的package包/类
@Override
   public <T> Map<String, T> getBulk(Collection<String> keys, Transcoder<T> tc)
    throws OperationTimeoutException {
return Collections.emptyMap();
   }
 
开发者ID:forcedotcom,项目名称:3levelmemcache,代码行数:6,代码来源:EmptyMemcachedConnection.java

示例15: incr

import net.spy.memcached.OperationTimeoutException; //导入依赖的package包/类
@Override
   public long incr(String key, int by) throws OperationTimeoutException {
return 0;
   }
 
开发者ID:forcedotcom,项目名称:3levelmemcache,代码行数:5,代码来源:EmptyMemcachedConnection.java


注:本文中的net.spy.memcached.OperationTimeoutException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。