本文整理汇总了Java中net.spy.memcached.BinaryConnectionFactory类的典型用法代码示例。如果您正苦于以下问题:Java BinaryConnectionFactory类的具体用法?Java BinaryConnectionFactory怎么用?Java BinaryConnectionFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BinaryConnectionFactory类属于net.spy.memcached包,在下文中一共展示了BinaryConnectionFactory类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initMemcached
import net.spy.memcached.BinaryConnectionFactory; //导入依赖的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();
}
}
示例2: createMemcachedClient
import net.spy.memcached.BinaryConnectionFactory; //导入依赖的package包/类
@Override
protected MemcachedClient createMemcachedClient() throws IOException,
UnknownHostException {
List<InetSocketAddress> addrs = new ArrayList<InetSocketAddress>();
addrs.add(new InetSocketAddress(SocketCreator.getLocalHost(), PORT));
MemcachedClient client = new MemcachedClient(new BinaryConnectionFactory(), addrs);
return client;
}
示例3: startClient
import net.spy.memcached.BinaryConnectionFactory; //导入依赖的package包/类
/**
* @return Memcache client.
* @throws Exception If start failed.
*/
private MemcachedClientIF startClient() throws Exception {
int port = customPort != null ? customPort : IgniteConfiguration.DFLT_TCP_PORT;
return new MemcachedClient(new BinaryConnectionFactory(),
F.asList(new InetSocketAddress(LOC_HOST, port)));
}
示例4: MemcachedClientPool
import net.spy.memcached.BinaryConnectionFactory; //导入依赖的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())));
}
}
示例5: createStore
import net.spy.memcached.BinaryConnectionFactory; //导入依赖的package包/类
@Override
public ResponseStore createStore() {
try {
if (getServers().size() == 0) {
return ResponseStore.NULL_STORE;
} else {
MemcachedClient client = new MemcachedClient(new BinaryConnectionFactory(), getServers());
return new MemcachedResponseStore(client, _keyPrefix, _readOnly);
}
} catch (IOException ex) {
throw Throwables.propagate(ex);
}
}
示例6: BaseConnectionFactory
import net.spy.memcached.BinaryConnectionFactory; //导入依赖的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;
}
示例7: getMemcacheClient
import net.spy.memcached.BinaryConnectionFactory; //导入依赖的package包/类
protected MemcachedClient getMemcacheClient(List<InetSocketAddress> addresses)
throws IOException {
return new MemcachedClient(new BinaryConnectionFactory(), addresses);
}
示例8: createConnectionFactory
import net.spy.memcached.BinaryConnectionFactory; //导入依赖的package包/类
protected DefaultConnectionFactory createConnectionFactory() {
return new BinaryConnectionFactory();
}
示例9: refreshClientConnection
import net.spy.memcached.BinaryConnectionFactory; //导入依赖的package包/类
/**
* Private helper method for ensuring a client connection exists, if not will
* obtain a connection one time, if a failure occurs well remove service provider from component scope so
* it does not hinder the Upstream Components.
*/
private synchronized boolean refreshClientConnection() {
// ************************************
// If our Connection is Null, refresh
//it, but only within a given threshold.
if (this.mc == null) //|| (!this.mc.isAlive()))
{
if (this.timeLastClientStaleOutageOccurred != 0) {
this.numberClientStaleConnections++;
}
this.timeLastClientStaleOutageOccurred = System.currentTimeMillis();
// **************************************************
// Check for a Threshold.
if (this.numberClientStaleConnections > DEFAULT_FINAL_NUMBER_CLIENT_STALE_CONNECTIONS) {
logger.error("*****************************************************************************");
logger.error("Number of Stale Connections:[" + this.numberClientStaleConnections
+ "] has exceed our Default Threshold of:[" + DEFAULT_FINAL_NUMBER_CLIENT_STALE_CONNECTIONS + "]");
logger.error("Potential Memcached Server Latency issue, Please Contact Operations Support!");
logger.error("Memcached Service Provider will be automatically Disabled.");
logger.error("*****************************************************************************");
this.initialized = false;
return this.initialized;
} // End of check for Threshold.
} else {
// **************************
// Good Connection so far...
return this.initialized;
}
// **************************************************
// Attempt a new Connection.
this.initialized = false;
try {
this.mc = new MemcachedClient(new BinaryConnectionFactory(), AddrUtil.getAddresses(memCachedServerList));
if (this.mc == null) {
logger.warn("Unable to obtain MemCached Client, stopping Initialization.");
} else if (this.isMemcachedClusterAlivePrivateMethod()) {
this.initialized = true;
this.mc.addObserver(new MemcachedServiceProviderConnectionObserver());
logger.info("MemCached Application Client Services has been initialized successfully.");
} else {
logger.warn("Unable to Post and Obtain Initial Private Region value from MemCached Cluster, stopping Initialization.");
}
} catch (IOException ioe) {
logger.error("IO Exception occurred during MemCached Client Initialization: " + ioe.getMessage(), ioe);
} catch (Exception e) {
logger.error("Exception occurred during MemCached Client Initialization: " + e.getMessage(), e);
}
// ************************************
// return state.
return this.initialized;
}
示例10: SessionStorageMemcachedImpl
import net.spy.memcached.BinaryConnectionFactory; //导入依赖的package包/类
public SessionStorageMemcachedImpl(String appName, String _connectionUri) throws Exception {
super(appName);
this.uri = _connectionUri;
// Are they using a user/pass
String connectionUri = _connectionUri.substring( _connectionUri.indexOf("//")+2 );
memcache = new MemcachedClient( new BinaryConnectionFactory(), AddrUtil.getAddresses(connectionUri) );
cfEngine.log( "SessionStorageMemcached: Created " + _connectionUri );
}
示例11: MemDataCache
import net.spy.memcached.BinaryConnectionFactory; //导入依赖的package包/类
/**
* Constructor using a default Memcached Client.
*
* @throws IOException if the memcached client fails to start
*/
@Inject
public MemDataCache() throws IOException {
this(new MemcachedClient(new BinaryConnectionFactory(), AddrUtil.getAddresses(SERVER_CONFIG)));
}
示例12: MemcachedCache
import net.spy.memcached.BinaryConnectionFactory; //导入依赖的package包/类
/**
* Construction, with node list, using the binary protocol.
*
* @param nodes
* The node list (space-separated IP addresses or hostnames with port
* specifications after colon)
* @param waitForCompletion
* Whether to wait for all commands to be completed
* @param soleClient
* Whether we are the sole clients of the memcached cluster
* @param tagPrefix
* Prefix to be added to tag keys
* @throws IOException
* In case the memcached client could not be created
* @see AddrUtil#getAddresses(String)
*/
public MemcachedCache( String nodes, boolean waitForCompletion, boolean soleClient, String tagPrefix ) throws IOException
{
this( new MemcachedClient( new BinaryConnectionFactory(), AddrUtil.getAddresses( nodes ) ), waitForCompletion, soleClient, tagPrefix );
}