ConnectionFactory cf = new ConnectionFactoryBuilder() .setProtocol(ConnectionFactoryBuilder.Protocol.BINARY) .setAuthDescriptor(ad) .build();
public void setAuthDescriptor(final AuthDescriptor to) { connectionFactoryBuilder.setAuthDescriptor(to); }
public void setAuthDescriptor(final AuthDescriptor to) { connectionFactoryBuilder.setAuthDescriptor(to); }
public void setAuthDescriptor(final AuthDescriptor to) { connectionFactoryBuilder.setAuthDescriptor(to); }
public void setAuthDescriptor(final AuthDescriptor to) { connectionFactoryBuilder.setAuthDescriptor(to); }
connectionFactory = new ConnectionFactoryBuilder() .setProtocol(protocol) .setAuthDescriptor(authDescriptor) .build(); } else {
authDescriptor) : new ConnectionFactoryBuilder().setProtocol(ConnectionFactoryBuilder.Protocol.BINARY) .setAuthDescriptor(authDescriptor) .setOpTimeout(operationTimeout) .setMaxReconnectDelay(maxReconnectDelay)
@Override protected ConnectionFactoryBuilder getConnectionFactoryBuilder() { ConnectionFactoryBuilder factoryBuilder = super.getConnectionFactoryBuilder(); AuthDescriptor ad = new AuthDescriptor(new String[] {"PLAIN"}, new PlainCallbackHandler(_username, _password)); factoryBuilder.setAuthDescriptor(ad); return factoryBuilder; } }
ConnectionFactory cf = new ConnectionFactoryBuilder() .setProtocol(ConnectionFactoryBuilder.Protocol.BINARY) .setAuthDescriptor(ad) .build();
@Override public MemcachedClient call() throws Exception { return new MemcachedClient( new ConnectionFactoryBuilder().setProtocol(ConnectionFactoryBuilder.Protocol.BINARY) .setAuthDescriptor(ad) .build(), AddrUtil.getAddresses(proxy + ":" + port)); } }, 9, 1000L, true);
public void initClient() throws IOException { System.setProperty("net.spy.log.LoggerImpl", "org.osgl.cache.impl.SpyMemcachedLogger"); List<InetSocketAddress> addrs = MemcachedClientConfigurator.getHosts(); if (addrs.isEmpty()) { throw new ConfigurationException("Bad configuration for memcached: missing host(s)"); } String username = MemcachedClientConfigurator.getUsername(); if (S.notBlank(username)) { String password = MemcachedClientConfigurator.getPassword(); if (null == password) { throw new ConfigurationException("Bad configuration for memcached: missing password"); } // Use plain SASL to connect to memcached AuthDescriptor ad = new AuthDescriptor(new String[]{"PLAIN"}, new PlainCallbackHandler(username, password)); ConnectionFactory cf = new ConnectionFactoryBuilder() .setProtocol(ConnectionFactoryBuilder.Protocol.BINARY) .setAuthDescriptor(ad) .build(); client = new MemcachedClient(cf, addrs); } else { client = new MemcachedClient(addrs); } }
/** * 检查ocs服务器网络是否可达 */ private static void hostReachableCheck(Configuration config) { String proxy = config.getString(Key.PROXY); String port = config.getString(Key.PORT); String username = config.getString(Key.USER); String password = config.getString(Key.PASSWORD); AuthDescriptor ad = new AuthDescriptor(new String[] { "PLAIN" }, new PlainCallbackHandler(username, password)); try { MemcachedClient client = new MemcachedClient( new ConnectionFactoryBuilder() .setProtocol( ConnectionFactoryBuilder.Protocol.BINARY) .setAuthDescriptor(ad).build(), AddrUtil.getAddresses(proxy + ":" + port)); client.get("for_check_connectivity"); client.getVersions(); if (client.getAvailableServers().isEmpty()) { throw new RuntimeException( "没有可用的Servers: getAvailableServers() -> is empty"); } client.shutdown(); } catch (Exception e) { throw DataXException.asDataXException( OcsWriterErrorCode.HOST_UNREACHABLE, String.format("OCS[%s]服务不可用", proxy), e); } }
public MemcachedClientWrapper() { configuration = MemcachedConfigurationBuilder.getInstance().parseConfiguration(); try { if (configuration.isUsingSASL()) { AuthDescriptor ad = new AuthDescriptor(new String[] { "PLAIN" }, new PlainCallbackHandler(configuration.getUsername(), configuration.getPassword())); client = new MemcachedClient(new ConnectionFactoryBuilder() .setProtocol(ConnectionFactoryBuilder.Protocol.BINARY).setAuthDescriptor(ad).build(), configuration.getAddresses()); } else { client = new MemcachedClient(configuration.getConnectionFactory(), configuration.getAddresses()); } } catch (IOException e) { String message = "Impossible to instantiate a new memecached client instance, see nested exceptions"; LOG.error(message, e); throw new RuntimeException(message, e); } if (LOG.isDebugEnabled()) { LOG.debug("Running new Memcached client using " + configuration); } }
authDescriptor) : new ConnectionFactoryBuilder().setProtocol(ConnectionFactoryBuilder.Protocol.BINARY) .setAuthDescriptor(authDescriptor) .setOpTimeout(operationTimeout) .setMaxReconnectDelay(maxReconnectDelay)
@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 ) ); }
public ConnectionFactoryBuilder(ConnectionFactory cf) { setAuthDescriptor(cf.getAuthDescriptor()); setDaemon(cf.isDaemon()); setFailureMode(cf.getFailureMode()); setHashAlg(cf.getHashAlg()); setInitialObservers(cf.getInitialObservers()); setMaxReconnectDelay(cf.getMaxReconnectDelay()); setOpQueueMaxBlockTime(cf.getOpQueueMaxBlockTime()); setOpTimeout(cf.getOperationTimeout()); setReadBufferSize(cf.getReadBufSize()); setShouldOptimize(cf.shouldOptimize()); setTimeoutExceptionThreshold(cf.getTimeoutExceptionThreshold()); setTranscoder(cf.getDefaultTranscoder()); setUseNagleAlgorithm(cf.useNagleAlgorithm()); }
public ConnectionFactoryBuilder(ConnectionFactory cf) { setAuthDescriptor(cf.getAuthDescriptor()); setDaemon(cf.isDaemon()); setFailureMode(cf.getFailureMode()); setHashAlg(cf.getHashAlg()); setInitialObservers(cf.getInitialObservers()); setMaxReconnectDelay(cf.getMaxReconnectDelay()); setOpQueueMaxBlockTime(cf.getOpQueueMaxBlockTime()); setOpTimeout(cf.getOperationTimeout()); setReadBufferSize(cf.getReadBufSize()); setShouldOptimize(cf.shouldOptimize()); setTimeoutExceptionThreshold(cf.getTimeoutExceptionThreshold()); setTranscoder(cf.getDefaultTranscoder()); setUseNagleAlgorithm(cf.useNagleAlgorithm()); setEnableMetrics(cf.enableMetrics()); setListenerExecutorService(cf.getListenerExecutorService()); setAuthWaitTime(cf.getAuthWaitTime()); }
public ConnectionFactoryBuilder(ConnectionFactory cf) { setClientMode(cf.getClientMode()); setAuthDescriptor(cf.getAuthDescriptor()); setDaemon(cf.isDaemon()); setFailureMode(cf.getFailureMode()); setHashAlg(cf.getHashAlg()); setInitialObservers(cf.getInitialObservers()); setMaxReconnectDelay(cf.getMaxReconnectDelay()); setOpQueueMaxBlockTime(cf.getOpQueueMaxBlockTime()); setOpTimeout(cf.getOperationTimeout()); setReadBufferSize(cf.getReadBufSize()); setShouldOptimize(cf.shouldOptimize()); setTimeoutExceptionThreshold(cf.getTimeoutExceptionThreshold()); setTranscoder(cf.getDefaultTranscoder()); setUseNagleAlgorithm(cf.useNagleAlgorithm()); setEnableMetrics(cf.enableMetrics()); setListenerExecutorService(cf.getListenerExecutorService()); setAuthWaitTime(cf.getAuthWaitTime()); }
builder.setAuthDescriptor(conf.getAuthDescriptor());
builder.setAuthDescriptor(conf.getAuthDescriptor());