• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FailureMode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createWithSpecificConf

import net.spy.memcached.FailureMode; //导入依赖的package包/类
@Test
public void createWithSpecificConf() throws IOException {
    SpymemcachedConfiguration conf = new SpymemcachedConfiguration();
    conf.setConsistentHashing(true);
    conf.setOperationTimeout(1000);
    conf.setUseBinaryProtocol(false);
    conf.setFailureMode(FailureMode.Cancel);
    conf.setShouldOptimize(true);
    conf.setMaxReconnectDelay(1000L);
    conf.setTimeoutExceptionThreshold(100);
    conf.setUseNagleAlgorithm(false);
    conf.setMetricCollector(new NoopMetricCollector());
    conf.setMetricType(MetricType.PERFORMANCE);
    CacheClient client = factory.create(addrs, conf);
    assertNotNull(client);
    client.shutdown();
}
 
开发者ID:ragnor,项目名称:simple-spring-memcached,代码行数:18,代码来源:MemcacheClientFactoryImplTest.java


示例2: createWithSpecificConf

import net.spy.memcached.FailureMode; //导入依赖的package包/类
@Test
public void createWithSpecificConf() throws IOException {
    ElastiCacheConfiguration conf = new ElastiCacheConfiguration();
    conf.setConsistentHashing(true);
    conf.setOperationTimeout(100);
    conf.setUseBinaryProtocol(false);
    conf.setFailureMode(FailureMode.Retry);
    conf.setShouldOptimize(true);
    conf.setMaxReconnectDelay(1000L);
    conf.setTimeoutExceptionThreshold(100);
    conf.setUseNagleAlgorithm(false);

    CacheClient client = factory.create(addrs, conf);

    assertNotNull(client);
    client.shutdown();
}
 
开发者ID:ragnor,项目名称:simple-spring-memcached,代码行数:18,代码来源:MemcacheClientFactoryImplTest.java


示例3: getObject

import net.spy.memcached.FailureMode; //导入依赖的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.FailureMode; //导入依赖的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: MemcachedBlockCache

import net.spy.memcached.FailureMode; //导入依赖的package包/类
public MemcachedBlockCache(Configuration c) throws IOException {
  LOG.info("Creating MemcachedBlockCache");

  long opTimeout = c.getLong(MEMCACHED_OPTIMEOUT_KEY, MEMCACHED_DEFAULT_TIMEOUT);
  long queueTimeout = c.getLong(MEMCACHED_TIMEOUT_KEY, opTimeout + MEMCACHED_DEFAULT_TIMEOUT);
  boolean optimize = c.getBoolean(MEMCACHED_OPTIMIZE_KEY, MEMCACHED_OPTIMIZE_DEFAULT);

  ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder()
      .setOpTimeout(opTimeout)
      .setOpQueueMaxBlockTime(queueTimeout) // Cap the max time before anything times out
      .setFailureMode(FailureMode.Redistribute)
      .setShouldOptimize(optimize)
      .setDaemon(true)                      // Don't keep threads around past the end of days.
      .setUseNagleAlgorithm(false)          // Ain't nobody got time for that
      .setReadBufferSize(HConstants.DEFAULT_BLOCKSIZE * 4 * 1024); // Much larger just in case

  // Assume only the localhost is serving memecached.
  // A la mcrouter or co-locating memcached with split regionservers.
  //
  // If this config is a pool of memecached servers they will all be used according to the
  // default hashing scheme defined by the memcache client. Spy Memecache client in this
  // case.
  String serverListString = c.get(MEMCACHED_CONFIG_KEY,"localhost:11211");
  String[] servers = serverListString.split(",");
  List<InetSocketAddress> serverAddresses = new ArrayList<InetSocketAddress>(servers.length);
  for (String s:servers) {
    serverAddresses.add(Addressing.createInetSocketAddressFromHostAndPortStr(s));
  }

  client = new MemcachedClient(builder.build(), serverAddresses);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:32,代码来源:MemcachedBlockCache.java


示例6: doStart

import net.spy.memcached.FailureMode; //导入依赖的package包/类
@Override
protected void doStart() throws Exception {
    super.doStart();

    ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder();
    // VERY IMPORTANT! Otherwise, spymemcached optimizes away concurrent gets
    builder.setShouldOptimize(false);
    // We never want spymemcached to time out
    builder.setOpTimeout(9999999);
    // Retry upon failure
    builder.setFailureMode(FailureMode.Retry);
    memcachedConnectionFactory = builder.build();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:KestrelComponent.java


示例7: MemcacheConnect

import net.spy.memcached.FailureMode; //导入依赖的package包/类
public MemcacheConnect(String ip, int port) {
    super(ip, port);
    try {
        client = new MemcachedClient(new ConnectionFactoryBuilder().setDaemon(true).setFailureMode(FailureMode.Retry).build(),AddrUtil.getAddresses(ip + ":" + port));
    } catch (IOException ex) {
        Logger.getLogger(MemcacheConnect.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:eternalthinker,项目名称:finagle-java-example-master-slave,代码行数:9,代码来源:MemcacheConnect.java


示例8: create

import net.spy.memcached.FailureMode; //导入依赖的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


示例9: MemcachedBlockCache

import net.spy.memcached.FailureMode; //导入依赖的package包/类
public MemcachedBlockCache(Configuration c) throws IOException {
  LOG.info("Creating MemcachedBlockCache");

  long opTimeout = c.getLong(MEMCACHED_OPTIMEOUT_KEY, MEMCACHED_DEFAULT_TIMEOUT);
  long queueTimeout = c.getLong(MEMCACHED_TIMEOUT_KEY, opTimeout + MEMCACHED_DEFAULT_TIMEOUT);
  boolean optimize = c.getBoolean(MEMCACHED_OPTIMIZE_KEY, MEMCACHED_OPTIMIZE_DEFAULT);

  ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder()
      .setOpTimeout(opTimeout)
      .setOpQueueMaxBlockTime(queueTimeout) // Cap the max time before anything times out
      .setFailureMode(FailureMode.Redistribute)
      .setShouldOptimize(optimize)
      .setDaemon(true)                      // Don't keep threads around past the end of days.
      .setUseNagleAlgorithm(false)          // Ain't nobody got time for that
      .setReadBufferSize(HConstants.DEFAULT_BLOCKSIZE * 4 * 1024); // Much larger just in case

  // Assume only the localhost is serving memecached.
  // A la mcrouter or co-locating memcached with split regionservers.
  //
  // If this config is a pool of memecached servers they will all be used according to the
  // default hashing scheme defined by the memcache client. Spy Memecache client in this
  // case.
  String serverListString = c.get(MEMCACHED_CONFIG_KEY,"localhost:11211");
  String[] servers = serverListString.split(",");
  List<InetSocketAddress> serverAddresses = new ArrayList<>(servers.length);
  for (String s:servers) {
    serverAddresses.add(Addressing.createInetSocketAddressFromHostAndPortStr(s));
  }

  client = new MemcachedClient(builder.build(), serverAddresses);
}
 
开发者ID:apache,项目名称:hbase,代码行数:32,代码来源:MemcachedBlockCache.java


示例10: newConnectionFactoryBuilder

import net.spy.memcached.FailureMode; //导入依赖的package包/类
private ConnectionFactoryBuilder newConnectionFactoryBuilder(final Config conf) {
  ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder();

  ifset(conf, "authWaitTime", path -> builder
      .setAuthWaitTime(conf.getDuration(path, TimeUnit.MILLISECONDS)));
  ifset(conf, "daemon", path -> builder.setDaemon(conf.getBoolean(path)));
  ifset(conf, "enableMetrics", path -> builder
      .setEnableMetrics(enumFor(conf.getString(path), MetricType.values())));
  ifset(conf, "failureMode", path -> builder
      .setFailureMode(enumFor(conf.getString(path), FailureMode.values())));
  ifset(conf, "locator", path -> builder
      .setLocatorType(enumFor(conf.getString(path), Locator.values())));
  ifset(conf, "maxReconnectDelay", path -> builder
      .setMaxReconnectDelay(conf.getDuration(path, TimeUnit.SECONDS)));
  ifset(conf, "opQueueMaxBlockTime", path -> builder
      .setOpQueueMaxBlockTime(conf.getDuration(path, TimeUnit.MILLISECONDS)));
  ifset(conf, "opTimeout", path -> builder
      .setOpTimeout(conf.getDuration(path, TimeUnit.MILLISECONDS)));
  ifset(conf, "protocol", path -> builder
      .setProtocol(enumFor(conf.getString(path), Protocol.values())));
  ifset(conf, "readBufferSize", path -> builder
      .setReadBufferSize(conf.getInt(path)));
  ifset(conf, "shouldOptimize", path -> builder
      .setShouldOptimize(conf.getBoolean(path)));
  ifset(conf, "timeoutExceptionThreshold", path -> builder
      .setTimeoutExceptionThreshold(conf.getInt(path)));
  ifset(conf, "useNagleAlgorithm", path -> builder
      .setUseNagleAlgorithm(conf.getBoolean(path)));
  return builder;
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:31,代码来源:SpyMemcached.java


示例11: ApiMemcached

import net.spy.memcached.FailureMode; //导入依赖的package包/类
public ApiMemcached() {
	AppConstants ac = AppConstants.getInstance();
	String address = ac.getProperty("etag.cache.server", "localhost:11211");
	String username = ac.getProperty("etag.cache.username", "");
	String password = ac.getProperty("etag.cache.password", "");
	int timeout = ac.getInt("etag.cache.timeout", 10);

	List<InetSocketAddress> addresses = AddrUtil.getAddresses(address);

	ConnectionFactoryBuilder connectionFactoryBuilder = new ConnectionFactoryBuilder()
		.setProtocol(Protocol.BINARY)
		.setOpTimeout(timeout)
		.setInitialObservers(Collections.singleton(obs));

	if(addresses.size()  > 1)
		connectionFactoryBuilder.setFailureMode(FailureMode.Redistribute);
	else
		connectionFactoryBuilder.setFailureMode(FailureMode.Retry);

	if(!username.isEmpty())
		connectionFactoryBuilder.setAuthDescriptor(AuthDescriptor.typical(username, password));

	ConnectionFactory cf = connectionFactoryBuilder.build();

	try {
		client = new MemcachedClient(cf, addresses);
		//Fetching a none-existing key to test the connection
		Future<Object> future = client.asyncGet("test-connection");
		future.get(timeout, TimeUnit.MILLISECONDS);
	} catch (Exception e) {
		ConfigurationWarnings.getInstance().add(log, "Unable to connect to one or more memcached servers.", null, true);
	}
}
 
开发者ID:ibissource,项目名称:iaf,代码行数:34,代码来源:ApiMemcached.java


示例12: getFailureMode

import net.spy.memcached.FailureMode; //导入依赖的package包/类
public FailureMode getFailureMode() {
    try {
        return FailureMode.valueOf(failureMode.get());
    } catch (IllegalArgumentException ex) {
        return FailureMode.Cancel;
    }
}
 
开发者ID:Netflix,项目名称:EVCache,代码行数:8,代码来源:BaseConnectionFactory.java


示例13: init

import net.spy.memcached.FailureMode; //导入依赖的package包/类
protected void init() throws Exception {

        if (BucketConfig.instance == null){
            new BucketConfig().afterPropertiesSet();
        }
        this.config = BucketConfig.instance;

		initMetrics();
		
		this.buckets = new HashMap<String, CouchbaseClient>();
		this.entityBuckets = new HashMap<String, String>();
		
		List<Map> items = (List<Map>) this.config.getBuckets();

		CouchbaseConnectionFactoryBuilder builder = new CouchbaseConnectionFactoryBuilder();
		builder.setDaemon(true);
		builder.setEnableMetrics(MetricType.PERFORMANCE);
		builder.setFailureMode(FailureMode.Redistribute);
		
		for (Map item : items) {
			String name = Objects.toString(item.get("bucket"), "").trim();
			String user = Objects.toString(item.get("user"), "");
			String pwd = Objects.toString(item.get("pwd"), "");
			String urls = Objects.toString(item.get("urls"), "");
			String[] ents = Objects.toString(item.get("ents"), "").split(",");
            logger.info("@Couchbase connecting to bucket: {}, urls: {}", name, urls);
			CouchbaseConnectionFactory ccf = null;
            if(StringUtils.isNotBlank(user)){
                ccf = builder.buildCouchbaseConnection(this.wrapBaseList(urls), name, user, pwd);
            }else{
                ccf = builder.buildCouchbaseConnection(this.wrapBaseList(urls), name, pwd);
            }
			this.buckets.put(name, new CouchbaseClient(ccf));
			this.defaultBucket = name;
			for(String str : ents){
				this.entityBuckets.put(str.toLowerCase().trim(), name);
			}
			logger.info("@Couchbase init, bucket:{}, urls:{}", name, urls);
		}
	}
 
开发者ID:yamingd,项目名称:argo,代码行数:41,代码来源:BucketManager.java


示例14: setFailureMode

import net.spy.memcached.FailureMode; //导入依赖的package包/类
public void setFailureMode(final FailureMode fm) {
  connectionFactoryBuilder.setFailureMode(fm);
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:4,代码来源:MemcachedClientFactoryBean.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CannotGetJdbcConnectionException类代码示例发布时间:2022-05-21
下一篇:
Java ObjectCursor类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap