本文整理汇总了Java中net.spy.memcached.DefaultHashAlgorithm类的典型用法代码示例。如果您正苦于以下问题:Java DefaultHashAlgorithm类的具体用法?Java DefaultHashAlgorithm怎么用?Java DefaultHashAlgorithm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultHashAlgorithm类属于net.spy.memcached包,在下文中一共展示了DefaultHashAlgorithm类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: create
import net.spy.memcached.DefaultHashAlgorithm; //导入依赖的package包/类
@Override
public CacheClient create(final List<InetSocketAddress> addrs, final CacheConfiguration conf) throws IOException {
// currently its works because this factory creates clients with the same connection settings, only memcached
// addresses can be changed
if (connectionFactory == null) {
ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder();
if (conf.isConsistentHashing()) {
builder.setHashAlg(DefaultHashAlgorithm.KETAMA_HASH);
builder.setLocatorType(Locator.CONSISTENT);
}
builder.setProtocol(conf.isUseBinaryProtocol() ? Protocol.BINARY : Protocol.TEXT);
if (conf.getOperationTimeout() != null) {
builder.setOpTimeout(conf.getOperationTimeout());
}
if (conf instanceof SpymemcachedConfiguration) {
setProviderSpecificSettings(builder, (SpymemcachedConfiguration) conf);
}
connectionFactory = builder.build();
}
return new MemcacheClientWrapper(new MemcachedClient(connectionFactory, addrs));
}
开发者ID:ragnor,项目名称:simple-spring-memcached,代码行数:27,代码来源:MemcacheClientFactoryImpl.java
示例2: init
import net.spy.memcached.DefaultHashAlgorithm; //导入依赖的package包/类
public static void init() {
Map<String, Object> props = new HashMap<String, Object>();
props.put(AvailableSettings.USE_SECOND_LEVEL_CACHE, true);
props.put(AvailableSettings.USE_QUERY_CACHE, true);
props.put(AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY, CacheConcurrencyStrategy.NONSTRICT_READ_WRITE);
props.put(AvailableSettings.CACHE_REGION_FACTORY, Hibernate4MemcachedRegionFactory.class.getName());
props.put(AvailableSettings.CACHE_REGION_PREFIX, "cachetest");
props.put(AvailableSettings.CACHE_PROVIDER_CONFIG, "META-INF/h4m-properties.xml");
props.put(AvailableSettings.HBM2DDL_AUTO, "create");
props.put(AvailableSettings.USE_STRUCTURED_CACHE, "false");
props.put(Hibernate4MemcachedRegionFactory.MEMCACHED_ADAPTER_CLASS_PROPERTY_KEY,
SpyMemcachedAdapter.class.getName());
props.put(SpyMemcachedAdapter.HOST_PROPERTY_KEY, "localhost:11211");
props.put(SpyMemcachedAdapter.HASH_ALGORITHM_PROPERTY_KEY, DefaultHashAlgorithm.KETAMA_HASH.name());
props.put(SpyMemcachedAdapter.OPERATION_TIMEOUT_MILLIS_PROPERTY_KEY, "5000");
props.put(SpyMemcachedAdapter.TRANSCODER_PROPERTY_KEY, KryoTranscoder.class.getName());
props.put(SpyMemcachedAdapter.CACHE_KEY_PREFIX_PROPERTY_KEY, "h4m");
props.put(KryoTranscoder.COMPRESSION_THREASHOLD_PROPERTY_KEY, "20000");
emf = Persistence.createEntityManagerFactory("cachetest", props);
}
开发者ID:kwon37xi,项目名称:hibernate4-memcached,代码行数:22,代码来源:EntityTestUtils.java
示例3: getObject
import net.spy.memcached.DefaultHashAlgorithm; //导入依赖的package包/类
@Override
public Object getObject() throws IOException {
List<URI> addresses = getAddresses(connectionURI);
long timeout = Math.max(readTimeout, writeTimeout);
//TODO make all the below properties configurable via properties file
ConnectionFactoryBuilder builder = new CouchbaseConnectionFactoryBuilder()
.setOpTimeout(timeout) // wait up to timeout seconds for an operation to succeed
.setOpQueueMaxBlockTime(enqueueTimeout) // wait up to 'enqueueTimeout' seconds when trying to enqueue an operation
.setDaemon(true)
.setProtocol(Protocol.BINARY)
.setHashAlg(DefaultHashAlgorithm.KETAMA_HASH)
.setFailureMode(FailureMode.Redistribute)
.setInitialObservers(Collections.singleton((ConnectionObserver) new CouchbaseAlerter()));
if(transcoder!=null) {
builder.setTranscoder(transcoder);
}
//assuming there isn't any password set for Couchbase
CouchbaseConnectionFactory connectionFactory
= ((CouchbaseConnectionFactoryBuilder)builder).buildCouchbaseConnection(addresses, "default", "", "");
return new CouchbaseClient(connectionFactory);
}
开发者ID:parekhparth,项目名称:SimpleJavaWS,代码行数:24,代码来源:CouchbaseFactory.java
示例4: memcachedClient
import net.spy.memcached.DefaultHashAlgorithm; //导入依赖的package包/类
@Lazy
@Bean
public MemcachedClientFactoryBean memcachedClient() {
try {
final MemcachedClientFactoryBean bean = new MemcachedClientFactoryBean();
bean.setServers(casProperties.getTicket().getRegistry().getMemcached().getServers());
bean.setLocatorType(ConnectionFactoryBuilder.Locator.valueOf(casProperties.getTicket().getRegistry().getMemcached().getLocatorType()));
bean.setTranscoder(kryoTranscoder());
bean.setFailureMode(FailureMode.valueOf(casProperties.getTicket().getRegistry().getMemcached().getFailureMode()));
bean.setHashAlg(DefaultHashAlgorithm.valueOf(casProperties.getTicket().getRegistry().getMemcached().getHashAlgorithm()));
return bean;
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:16,代码来源:MemcachedTicketRegistryConfiguration.java
示例5: create
import net.spy.memcached.DefaultHashAlgorithm; //导入依赖的package包/类
public static MemcachedCache create(final MemcachedCacheConfig config) {
if (INSTANCE == null) {
try {
LZ4Transcoder transcoder = new LZ4Transcoder(config.getMaxObjectSize());
// always use compression
transcoder.setCompressionThreshold(0);
OperationQueueFactory opQueueFactory;
long maxQueueBytes = config.getMaxOperationQueueSize();
if (maxQueueBytes > 0) {
opQueueFactory = new MemcachedOperationQueueFactory(maxQueueBytes);
} else {
opQueueFactory = new LinkedOperationQueueFactory();
}
String hosts2Str = config.getHosts().toString();
String hostsList = hosts2Str.substring(1, hosts2Str.length() - 1);
synchronized (MemcachedCache.class) {
if (INSTANCE == null) {
INSTANCE = new MemcachedCache(new MemcachedClient(new ConnectionFactoryBuilder().setProtocol(ConnectionFactoryBuilder.Protocol.BINARY).setHashAlg(DefaultHashAlgorithm.FNV1A_64_HASH).setLocatorType(ConnectionFactoryBuilder.Locator.CONSISTENT).setDaemon(true).setFailureMode(FailureMode.Cancel).setTranscoder(transcoder).setShouldOptimize(true).setOpQueueMaxBlockTime(config.getTimeout()).setOpTimeout(config.getTimeout()).setReadBufferSize(config.getReadBufferSize())
.setOpQueueFactory(opQueueFactory).build(), AddrUtil.getAddresses(hostsList)), config);
}
}
} catch (IOException e) {
logger.error("Unable to create MemcachedCache instance: " + e.getMessage());
throw Throwables.propagate(e);
}
}
return INSTANCE;
}
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:32,代码来源:MemcachedCache.java
示例6: testAllPropertiesSet
import net.spy.memcached.DefaultHashAlgorithm; //导入依赖的package包/类
@Test
public void testAllPropertiesSet() throws Exception {
properties.setProperty("hibernate.memcached.servers", "localhost:11211 localhost:11212");
properties.setProperty("hibernate.memcached.hashAlgorithm", DefaultHashAlgorithm.CRC_HASH.name());
properties.setProperty("hibernate.memcached.operationQueueLength", "8192");
properties.setProperty("hibernate.memcached.readBufferLength", "8192");
properties.setProperty("hibernate.memcached.operationTimeout", "5000");
properties.setProperty("hibernate.memcached.daemonMode", "true");
client = factory.createMemcacheClient();
Assert.assertNotNull(client);
}
开发者ID:mihaicostin,项目名称:hibernate-l2-memcached,代码行数:14,代码来源:SpyMemcacheClientFactoryIT.java
示例7: create
import net.spy.memcached.DefaultHashAlgorithm; //导入依赖的package包/类
@Override
public CacheClient create(final List<InetSocketAddress> addrs, final CacheConfiguration conf) throws IOException {
// currently its works because this factory creates clients with the same connection settings, only memcached
// addresses can be changed
if (connectionFactory == null) {
ElastiCacheConfiguration elasticacheConf = null;
if (conf instanceof ElastiCacheConfiguration) {
elasticacheConf = (ElastiCacheConfiguration) conf;
}
if (elasticacheConf != null && Boolean.TRUE.equals(elasticacheConf.getUseAutoDiscovery())) {
// there is no way to use custom client settings and auto discovery together
LOGGER.info("All cache settings will be ignored because useAutoDiscovery is true");
return new MemcacheClientWrapper(new MemcachedClient(addrs));
}
ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder();
if (conf.isConsistentHashing()) {
builder.setHashAlg(DefaultHashAlgorithm.KETAMA_HASH);
builder.setLocatorType(Locator.CONSISTENT);
}
builder.setProtocol(conf.isUseBinaryProtocol() ? Protocol.BINARY : Protocol.TEXT);
if (conf.getOperationTimeout() != null) {
builder.setOpTimeout(conf.getOperationTimeout());
}
if (elasticacheConf != null) {
setProviderSpecificSettings(builder, elasticacheConf);
}
connectionFactory = builder.build();
}
return new MemcacheClientWrapper(new MemcachedClient(connectionFactory, addrs));
}
开发者ID:ragnor,项目名称:simple-spring-memcached,代码行数:39,代码来源:MemcacheClientFactoryImpl.java
示例8: setKetamaNodes
import net.spy.memcached.DefaultHashAlgorithm; //导入依赖的package包/类
/**
* Setup the KetamaNodeLocator with the list of nodes it should use.
*
* @param nodes
* a List of MemcachedNodes for this KetamaNodeLocator to use in
* its continuum
*/
protected final void setKetamaNodes(List<MemcachedNode> nodes) {
TreeMap<Long, MemcachedNode> newNodeMap = new TreeMap<Long, MemcachedNode>();
final int numReps = config.getNodeRepetitions();
for (MemcachedNode node : nodes) {
// Ketama does some special work with md5 where it reuses chunks.
if (hashingAlgorithm == DefaultHashAlgorithm.KETAMA_HASH) {
for (int i = 0; i < numReps / 4; i++) {
final String hashString = config.getKeyForNode(node, i);
byte[] digest = DefaultHashAlgorithm.computeMd5(hashString);
if (log.isDebugEnabled()) log.debug("digest : " + digest);
for (int h = 0; h < 4; h++) {
long k = ((long) (digest[3 + h * 4] & 0xFF) << 24)
| ((long) (digest[2 + h * 4] & 0xFF) << 16)
| ((long) (digest[1 + h * 4] & 0xFF) << 8)
| (digest[h * 4] & 0xFF);
newNodeMap.put(Long.valueOf(k), node);
if (log.isDebugEnabled()) log.debug("Key : " + hashString + " ; hash : " + k + "; node " + node );
}
}
} else {
for (int i = 0; i < numReps; i++) {
final Long hashL = Long.valueOf(hashingAlgorithm.hash(config.getKeyForNode(node, i)));
newNodeMap.put(hashL, node);
}
}
}
if (log.isDebugEnabled()) log.debug("NewNodeMapSize : " + newNodeMap.size() + "; MapSize : " + (numReps * nodes.size()));
if (log.isTraceEnabled()) {
for (Long key : newNodeMap.keySet()) {
log.trace("Hash : " + key + "; Node : " + newNodeMap.get(key));
}
}
ketamaNodes = newNodeMap;
}
开发者ID:Netflix,项目名称:EVCache,代码行数:42,代码来源:EVCacheNodeLocator.java
示例9: BaseConnectionFactory
import net.spy.memcached.DefaultHashAlgorithm; //导入依赖的package包/类
BaseConnectionFactory(String appName, int len, DynamicIntProperty _operationTimeout, long opMaxBlockTime, int id,
ServerGroup serverGroup, EVCacheClientPoolManager poolManager) {
super(len, BinaryConnectionFactory.DEFAULT_READ_BUFFER_SIZE, DefaultHashAlgorithm.KETAMA_HASH);
this.appName = appName;
this.operationTimeout = _operationTimeout;
this.opMaxBlockTime = opMaxBlockTime;
this.id = id;
this.serverGroup = serverGroup;
this.poolManager = poolManager;
this.startTime = System.currentTimeMillis();
this.failureMode = EVCacheConfig.getInstance().getChainedStringProperty(this.serverGroup.getName() + ".failure.mode", appName + ".failure.mode", "Retry", null);
this.name = appName + "-" + serverGroup.getName() + "-" + id;
}
开发者ID:Netflix,项目名称:EVCache,代码行数:14,代码来源:BaseConnectionFactory.java
示例10: createLocator
import net.spy.memcached.DefaultHashAlgorithm; //导入依赖的package包/类
public NodeLocator createLocator(List<MemcachedNode> list) {
this.locator = new EVCacheNodeLocator(appName, serverGroup, list, DefaultHashAlgorithm.KETAMA_HASH,
new EVCacheKetamaNodeLocatorConfiguration(appName, serverGroup, poolManager));
return locator;
}
开发者ID:Netflix,项目名称:EVCache,代码行数:6,代码来源:BaseConnectionFactory.java
注:本文中的net.spy.memcached.DefaultHashAlgorithm类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论