protected ConnectionFactory createConnectionFactory(final MemcachedNodesManager memcachedNodesManager,
final ConnectionType connectionType, final String memcachedProtocol, final String username, final String password, final long operationTimeout,
final long maxReconnectDelay, final Statistics statistics ) {
if (PROTOCOL_BINARY.equals( memcachedProtocol )) {
if (connectionType.isSASL()) {
final AuthDescriptor authDescriptor = new AuthDescriptor(new String[]{"PLAIN"}, new PlainCallbackHandler(username, password));
return memcachedNodesManager.isEncodeNodeIdInSessionId()
? new SuffixLocatorBinaryConnectionFactory( memcachedNodesManager,
memcachedNodesManager.getSessionIdFormat(), statistics, operationTimeout, maxReconnectDelay,
authDescriptor)
: new ConnectionFactoryBuilder().setProtocol(ConnectionFactoryBuilder.Protocol.BINARY)