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


Java ConnectionFactory类代码示例

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


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

示例1: memcachedClient

import net.spy.memcached.ConnectionFactory; //导入依赖的package包/类
@Bean
public MemcachedClient memcachedClient(ObjectProvider<ConnectionFactory> connection) throws IOException {
    final List<InetSocketAddress> addresses = new ArrayList<>();
    final String servers = environment.getProperty("memcached.servers");
    if (StringUtils.isEmpty(servers)) {
        addresses.add(new InetSocketAddress(LOCALHOST, DEFAULT_PORT));
    } else {
        for (final String server : servers.split(",")) {
            final int colon = server.indexOf(":");
            if (colon == -1) {
                addresses.add(new InetSocketAddress(server, DEFAULT_PORT));
            } else {
                final int port = Integer.parseInt(server.substring(colon + 1));
                addresses.add(new InetSocketAddress(server.substring(0, colon), port));
            }
        }
    }

    ConnectionFactory con = connection.getIfUnique();

    return con == null
            ? new MemcachedClient(addresses)
            : new MemcachedClient(con, addresses);
}
 
开发者ID:bmatthews68,项目名称:memcached-spring-boot-starter,代码行数:25,代码来源:MemcachedAutoConfiguration.java

示例2: FrontCacheMemcachedClient

import net.spy.memcached.ConnectionFactory; //导入依赖的package包/类
/**
 * Create the memcached client and the front cache.
 *
 * @param cf  the connection factory to configure connections for this client
 * @param addrs  the socket addresses for the memcached servers
 * @throws IOException if connections cannot be established
 */
public FrontCacheMemcachedClient(ConnectionFactory cf,
		List<InetSocketAddress> addrs) throws IOException {
	super(cf, addrs);

	if (cf.getMaxFrontCacheElements() > 0) {
		String cacheName = cf.getFrontCacheName();
		int maxElements = cf.getMaxFrontCacheElements();
		int timeToLiveSeconds = cf.getFrontCacheExpireTime();
		boolean copyOnRead = cf.getFrontCacheCopyOnRead();
		boolean copyOnWrite = cf.getFrontCacheCopyOnWrite();
		// TODO add an additional option
		// int timeToIdleSeconds = timeToLiveSeconds;
		
		localCacheManager = new LocalCacheManager(cacheName, maxElements,
				timeToLiveSeconds, copyOnRead, copyOnWrite);
	}
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:25,代码来源:FrontCacheMemcachedClient.java

示例3: EVCacheNodeImpl

import net.spy.memcached.ConnectionFactory; //导入依赖的package包/类
public EVCacheNodeImpl(SocketAddress sa, SocketChannel c, int bufSize, BlockingQueue<Operation> rq,
        BlockingQueue<Operation> wq, BlockingQueue<Operation> iq,
        long opQueueMaxBlockTimeMillis, boolean waitForAuth, long dt, long at, ConnectionFactory fa, String appName,
        int id, ServerGroup serverGroup, long stTime) {
    super(sa, c, bufSize, rq, wq, iq, Long.valueOf(opQueueMaxBlockTimeMillis), waitForAuth, dt, at, fa);

    this.id = id;
    this._appName = appName;
    this._serverGroup = serverGroup;
    setConnectTime(stTime);
    this.readQ = rq;
    this.inputQueue = iq;
    this.sendMetrics = EVCacheConfig.getInstance().getDynamicBooleanProperty("EVCacheNodeImpl." + appName + ".sendMetrics", false);
    this.tags = BasicTagList.of("ServerGroup", _serverGroup.getName(), "APP", appName, "Id", String.valueOf(id), EVCacheMetricsFactory.OWNER.getKey(), EVCacheMetricsFactory.OWNER.getValue());
    this.hostName = ((InetSocketAddress) getSocketAddress()).getHostName();
    this.metricPrefix = "EVCacheNode";
    this.baseConfig = MonitorConfig.builder(metricPrefix).build();
    baseTags = BasicTagList.concat(tags, BasicTagList.of("HOST", hostName));
    setupMonitoring();
}
 
开发者ID:Netflix,项目名称:EVCache,代码行数:21,代码来源:EVCacheNodeImpl.java

示例4: assertMemcachedClient

import net.spy.memcached.ConnectionFactory; //导入依赖的package包/类
private void assertMemcachedClient(MemcachedClient memcachedClient, ClientMode clientMode, InetSocketAddress... servers) {
    List<NodeEndPoint> nodeEndPoints = (List<NodeEndPoint>) memcachedClient.getAllNodeEndPoints();

    assertThat(nodeEndPoints)
            .as("The number of memcached node endpoints should match server list size")
            .hasSize(servers.length);

    ConnectionFactory cf = (ConnectionFactory) ReflectionTestUtils.getField(memcachedClient, "connFactory");

    for (int i = 0; i < nodeEndPoints.size(); i++) {
        NodeEndPoint nodeEndPoint = nodeEndPoints.get(i);
        InetSocketAddress server = servers[i];

        String host = server.getHostString();
        int port = server.getPort();

        assertThat(host.matches("\\w+") ? nodeEndPoint.getHostName() : nodeEndPoint.getIpAddress())
                .as("Memcached node endpoint host is incorrect")
                .isEqualTo(host);
        assertThat(nodeEndPoint.getPort())
                .as("Memcached node endpoint port is incorrect")
                .isEqualTo(port);
    }
    assertThat(cf.getClientMode())
            .as("Memcached node endpoint mode is incorrect")
            .isEqualTo(clientMode);
}
 
开发者ID:sixhours-team,项目名称:memcached-spring-boot,代码行数:28,代码来源:MemcachedAutoConfigurationTest.java

示例5: getCouchBaseConnection

import net.spy.memcached.ConnectionFactory; //导入依赖的package包/类
@Override
   protected CouchbaseClient getCouchBaseConnection(
    CouchbaseConnectionFactoryBuilder connectionFactoryBuilder)
    throws IOException {

ConnectionFactory factory = connectionFactoryBuilder.build();
Assert.assertEquals(factory.getOperationTimeout(), 10223);
assertEquals(factory.getOpQueueMaxBlockTime(), 10223);

return Mockito.mock(CouchbaseClient.class);
   }
 
开发者ID:forcedotcom,项目名称:3levelmemcache,代码行数:12,代码来源:MemcachedClientFactoryBeanUnitTestNG.java

示例6: setupBeforeClass

import net.spy.memcached.ConnectionFactory; //导入依赖的package包/类
@BeforeClass
public static void setupBeforeClass() throws IOException {
  final ConnectionFactory cf = new ConnectionFactoryBuilder()
    .setProtocol(ConnectionFactoryBuilder.Protocol.TEXT)
    .setTranscoder(new WhalinTranscoder())
    .setOpTimeout(1000)
    .build();

  spyClient = new MemcachedClient(cf, Collections.singletonList(new InetSocketAddress("localhost", MEMCACHED_PORT)));
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:11,代码来源:MemcacheClientTest.java

示例7: get

import net.spy.memcached.ConnectionFactory; //导入依赖的package包/类
@Override
public MemcachedClient get() {
  client = throwingSupplier(() -> {
    ConnectionFactory connectionFactory = builder.build();
    this.builder = null;
    return new MemcachedClient(connectionFactory, servers);
  }).get();
  return client;
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:10,代码来源:MemcachedClientProvider.java

示例8: ApiMemcached

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

示例9: convert

import net.spy.memcached.ConnectionFactory; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected ConnectionFactory convert(String property) throws Exception {
  Class<?> clazz = Class.forName(property);
  if (!ConnectionFactory.class.isAssignableFrom(clazz)) {
    throw new IllegalArgumentException(
        "Class '" + clazz.getName() + "' is not a valid '" + ConnectionFactory.class.getName() + "' implementation");
  }
  return (ConnectionFactory) clazz.newInstance();
}
 
开发者ID:mybatis,项目名称:memcached-cache,代码行数:13,代码来源:ConnectionFactorySetter.java

示例10: getConnectionFactory

import net.spy.memcached.ConnectionFactory; //导入依赖的package包/类
public ConnectionFactory getConnectionFactory(String appName, int id, ServerGroup serverGroup, EVCacheClientPoolManager poolManager) {

        final int maxQueueSize = EVCacheConfig.getInstance().getDynamicIntProperty(appName + ".max.queue.length", 16384).get();
        final DynamicIntProperty operationTimeout = EVCacheConfig.getInstance().getDynamicIntProperty(appName + ".operation.timeout", 2500);
        final int opQueueMaxBlockTime = EVCacheConfig.getInstance().getDynamicIntProperty(appName + ".operation.QueueMaxBlockTime", 10).get();

        return new BaseConnectionFactory(appName, maxQueueSize, operationTimeout, opQueueMaxBlockTime, id, serverGroup, poolManager);
    }
 
开发者ID:Netflix,项目名称:EVCache,代码行数:9,代码来源:ConnectionFactoryProvider.java

示例11: connectionFactory

import net.spy.memcached.ConnectionFactory; //导入依赖的package包/类
private ConnectionFactory connectionFactory() {
    ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder();
    builder.setOpTimeout(timeout);
    return builder.build();
}
 
开发者ID:mwarc,项目名称:embedded-memcached-spring,代码行数:6,代码来源:MemcachedConfiguration.java

示例12: MockMemcachedClient

import net.spy.memcached.ConnectionFactory; //导入依赖的package包/类
public MockMemcachedClient(ConnectionFactory cf,
        List<InetSocketAddress> addrs) throws IOException {
    super(cf, addrs);
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:5,代码来源:ApiInterceptorTest.java

示例13: createClient

import net.spy.memcached.ConnectionFactory; //导入依赖的package包/类
static protected void createClient() throws IOException {
    ConnectionFactory connectionFactory = new ConnectionFactoryBuilder().setOpTimeout(TIMEOUT).setProtocol(ConnectionFactoryBuilder.Protocol.BINARY).build();
    client = new MemcachedClient(connectionFactory, Arrays.asList(new InetSocketAddress("localhost", getPort())));
}
 
开发者ID:C2B2,项目名称:memcached-4-coherence,代码行数:5,代码来源:AbstractIntegrationTest.java

示例14: getConnectionFactory

import net.spy.memcached.ConnectionFactory; //导入依赖的package包/类
/**
 * @return the connectionFactory
 */
public ConnectionFactory getConnectionFactory() {
  return connectionFactory;
}
 
开发者ID:mybatis,项目名称:memcached-cache,代码行数:7,代码来源:MemcachedConfiguration.java

示例15: setConnectionFactory

import net.spy.memcached.ConnectionFactory; //导入依赖的package包/类
/**
 * @param connectionFactory the connectionFactory to set
 */
public void setConnectionFactory(ConnectionFactory connectionFactory) {
  this.connectionFactory = connectionFactory;
}
 
开发者ID:mybatis,项目名称:memcached-cache,代码行数:7,代码来源:MemcachedConfiguration.java


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