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


Java AddrUtil类代码示例

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


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

示例1: initMemcached

import net.spy.memcached.AddrUtil; //导入依赖的package包/类
public void initMemcached(String addresses) // addresses: space sep. like 'localhost:11211 10.10.10.10:1234'
{
    if (memcachedClient.get() != null)
        throw new IllegalStateException("memcached already initialized");
    try
    {
        final MemcachedClient _memcachedClient = new MemcachedClient(
                new BinaryConnectionFactory(),
                AddrUtil.getAddresses(addresses));
        _memcachedClient.addObserver(this);
        memcachedClient.set(_memcachedClient);
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:18,代码来源:CacheHelper.java

示例2: MemCacheTicketRegistry

import net.spy.memcached.AddrUtil; //导入依赖的package包/类
/**
 * Creates a new instance that stores tickets in the given memcached hosts.
 *
 * @param hostnames                   Array of memcached hosts where each element is of the form host:port.
 * @param ticketGrantingTicketTimeOut TGT timeout in seconds.
 * @param serviceTicketTimeOut        ST timeout in seconds.
 */
@Autowired
public MemCacheTicketRegistry(@Value("${memcached.servers:}")
                              final String[] hostnames,
                              @Value("${tgt.maxTimeToLiveInSeconds:28800}")
                              final int ticketGrantingTicketTimeOut,
                              @Value("${st.timeToKillInSeconds:10}")
                              final int serviceTicketTimeOut) {

    try {
        final List<String> hostNamesArray = Arrays.asList(hostnames);
        if (hostNamesArray.isEmpty()) {
            logger.debug("No memcached hosts are define. Client shall not be configured");
        } else {
            logger.info("Setting up Memcached Ticket Registry...");
            this.tgtTimeout = ticketGrantingTicketTimeOut;
            this.stTimeout = serviceTicketTimeOut;

            this.client = new MemcachedClient(AddrUtil.getAddresses(hostNamesArray));
        }
    } catch (final IOException e) {
        throw new IllegalArgumentException("Invalid memcached host specification.", e);
    }

}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:32,代码来源:MemCacheTicketRegistry.java

示例3: MemcachedDistributedGroup

import net.spy.memcached.AddrUtil; //导入依赖的package包/类
/**
 * 构造memcached组
 * 
 * @param groupServerUrl
 *            -- 组中Memcached服务器连接字符串
 */
MemcachedDistributedGroup(String groupServerUrl) {
	this.groupServerUrl = groupServerUrl;
	String items = groupServerUrl.replaceAll(";", " ");
	try {
		mcc = new MemcachedClient(new DefaultConnectionFactory() {
			@Override
			public long getOperationTimeout() {
				return connectTimeout;
			}
		}, AddrUtil.getAddresses(items));

		initMemCachedHealthMBean(groupServerUrl);
	} catch (Exception ex) {
		throw new FwRuntimeException("初始化MemcachedClient对象失败", ex);
	}

}
 
开发者ID:bignippleboy,项目名称:ipaas,代码行数:24,代码来源:FwSpyDirectMemcachedService.java

示例4: ExceptionSwallowingMemcachedClient

import net.spy.memcached.AddrUtil; //导入依赖的package包/类
@Autowired
public ExceptionSwallowingMemcachedClient(GlobalConfigHandler globalConfigHandler, ZkCuratorHandler zkCuratorHandler) throws Exception {
    logger.info("Initializing...");
    Stat stat = zkCuratorHandler.getCurator().checkExists().forPath(ZK_CONFIG_KEY_MEMCACHED_SERVERS_FPATH);
    if (stat != null) 
    {
        ObjectMapper mapper = new ObjectMapper();
        byte[] bytes = zkCuratorHandler.getCurator().getData().forPath(ZK_CONFIG_KEY_MEMCACHED_SERVERS_FPATH);
        MemcacheConfig config = mapper.readValue(bytes,MemcacheConfig.class);
        logger.info(config.toString());
        memcachedClient = new MemcachedClient(new ConnectionFactoryBuilder(new DefaultConnectionFactory()).setOpTimeout(MEMCACHE_OP_TIMEOUT).build(),
                AddrUtil.getAddresses(config.servers));
        logger.info(String.format("MemcachedClient initialized using %s[%s]", ZK_CONFIG_KEY_MEMCACHED_SERVERS, config.servers));
        
        MemCachePeer.initialise(config.servers,config.numClients);
    }

    if (memcachedClient == null) {
        throw new Exception("*Warning* Memcached NOT initialized!");
    }
    globalConfigHandler.addSubscriber(ZK_CONFIG_KEY_MEMCACHED_SERVERS, this);
}
 
开发者ID:SeldonIO,项目名称:seldon-server,代码行数:23,代码来源:ExceptionSwallowingMemcachedClient.java

示例5: SASLConnectReconnect

import net.spy.memcached.AddrUtil; //导入依赖的package包/类
SASLConnectReconnect(String username, String password, String host) {

		AuthDescriptor ad = new AuthDescriptor(new String[] { "PLAIN" },
				new PlainCallbackHandler(username, password));
		try {
			List<InetSocketAddress> addresses = AddrUtil.getAddresses(host);
			mc = new MemcachedClient(
					new ConnectionFactoryBuilder().setProtocol(Protocol.BINARY)
							.setAuthDescriptor(ad).build(), addresses);
		} catch (IOException ex) {
			System.err
					.println("Couldn't create a connection, bailing out: \nIOException "
							+ ex.getMessage());
			if (mc != null) {
				mc.shutdown();
			}
		}

	}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:20,代码来源:SASLConnectReconnect.java

示例6: MemCacheTicketRegistry

import net.spy.memcached.AddrUtil; //导入依赖的package包/类
/**
 * Creates a new instance that stores tickets in the given memcached hosts.
 *
 * @param hostnames                   Array of memcached hosts where each element is of the form host:port.
 * @param ticketGrantingTicketTimeOut TGT timeout in seconds.
 * @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;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:MemCacheTicketRegistry.java

示例7: MemCacheTicketRegistry

import net.spy.memcached.AddrUtil; //导入依赖的package包/类
/**
     * Creates a new instance that stores tickets in the given memcached hosts.
     *
     * @param hostnames                   Array of memcached hosts where each element is of the form host:port.
     * @param ticketGrantingTicketTimeOut TGT timeout in seconds.
     * @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;
    }
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:18,代码来源:MemCacheTicketRegistry.java

示例8: setServers

import net.spy.memcached.AddrUtil; //导入依赖的package包/类
/**
 * Populate server list from comma-separated list of hostname:port strings.
 *
 * @param value Comma-separated list
 */
public void setServers(String value) {
    if (StringUtils.isEmpty(value)) {
        throw new IllegalArgumentException("Server list is empty");
    }
    this.servers = AddrUtil.getAddresses(Arrays.asList(value.split(",")));
}
 
开发者ID:sixhours-team,项目名称:memcached-spring-boot,代码行数:12,代码来源:MemcachedCacheProperties.java

示例9: activateService

import net.spy.memcached.AddrUtil; //导入依赖的package包/类
@Override
public void activateService()
    throws Exception
{
    MemcacheConfiguration config = configuration.get();
    expiration = ( config.expiration().get() == null )
                 ? 3600
                 : config.expiration().get();
    String addresses = ( config.addresses().get() == null )
                       ? "localhost:11211"
                       : config.addresses().get();
    Protocol protocol = ( config.protocol().get() == null )
                        ? Protocol.TEXT
                        : Protocol.valueOf( config.protocol().get().toUpperCase() );
    String username = config.username().get();
    String password = config.password().get();
    String authMech = config.authMechanism().get() == null
                      ? "PLAIN"
                      : config.authMechanism().get();

    ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder();
    builder.setProtocol( protocol );
    if( username != null && !username.isEmpty() )
    {
        String[] authType = { authMech };
        AuthDescriptor to = new AuthDescriptor( authType, new PlainCallbackHandler( username, password ) );
        builder.setAuthDescriptor( to );
    }

    client = new MemcachedClient( builder.build(), AddrUtil.getAddresses( addresses ) );
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:32,代码来源:MemcachePoolMixin.java

示例10: setup

import net.spy.memcached.AddrUtil; //导入依赖的package包/类
@Before
public void setup()
{
  MemcacheStore operatorStore = new MemcacheStore();
  operatorStore.setServerAddresses( AddrUtil.getAddresses("localhost:11211") );
  MemcacheStore testStore = new MemcacheStore();
  testStore.setServerAddresses( AddrUtil.getAddresses("localhost:11211") );
  testFramework = new KeyValueStoreOperatorTest<MemcacheStore>( operatorStore, testStore );
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:10,代码来源:MemcacheOperatorTest.java

示例11: MemcacheConnect

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

示例12: create

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

示例13: MemcachedClientPool

import net.spy.memcached.AddrUtil; //导入依赖的package包/类
public MemcachedClientPool(int poolSize, String server) throws IOException {
  this.index = 0;
  this.clients = new ArrayList<>();
  for (int i = 0; i < poolSize; i++) {
    this.clients.add(new MemcachedClient(new BinaryConnectionFactory(),
        AddrUtil.getAddresses(server.trim())));
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:9,代码来源:MemcachedClientPool.java

示例14: setUp

import net.spy.memcached.AddrUtil; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
    client = new MemcachedClient(AddrUtil.getAddresses("localhost:11211"));
    Properties properties = new Properties();
    PropertiesHelper props = new PropertiesHelper(properties);
    Config config = new Config(props);
    cache = new MemcachedCache("MemcachedCacheTest", new SpyMemcache(client), config);
}
 
开发者ID:mihaicostin,项目名称:hibernate-l2-memcached,代码行数:9,代码来源:SpyMemcacheIT.java

示例15: ServerAddress

import net.spy.memcached.AddrUtil; //导入依赖的package包/类
public static MongoClient	newClient(String server, String user, String pass, String db) throws UnknownHostException{

	MongoClientOptions options = MongoClientOptions
			.builder()
			.readPreference( ReadPreference.secondaryPreferred() )
			.build();

	List<InetSocketAddress> serverList = AddrUtil.getAddresses(server);
	List<ServerAddress> addrs = new ArrayList<ServerAddress>();
		
	Iterator<InetSocketAddress>	it	= serverList.iterator();
	while ( it.hasNext() ){
		InetSocketAddress	isa	= it.next();
		addrs.add( new ServerAddress( isa.getAddress(), isa.getPort() ) );
	}
	
	
	if ( user != null ) {
		MongoCredential cred = MongoCredential.createCredential( user, db, pass.toCharArray() );
		List<MongoCredential> creds = new ArrayList<MongoCredential>();
		creds.add( cred );

		return new MongoClient( addrs, creds, options );
	} else {
		return new MongoClient( addrs, options );
	}

	
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:30,代码来源:MongoDSN.java


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