/** * Returns a list of couchbase REST interface uris if the current configuration is * a couchbase bucket configuration. * @see #isCouchbaseBucketConfig() */ public List<URI> getCouchbaseBucketURIs() { if(!isCouchbaseBucketConfig()) throw new IllegalStateException("This is not a couchbase bucket configuration."); final List<URI> result = new ArrayList<URI>(_address2Ids.size()); final Matcher matcher = COUCHBASE_BUCKET_NODE_PATTERN.matcher(_memcachedNodes); while (matcher.find()) { try { result.add(new URI(matcher.group())); } catch (final URISyntaxException e) { throw new RuntimeException(e); } } return result; }
@Test public void testIsCouchbaseBucketConfig() { assertTrue(createFor("http://10.10.0.1:8091/pools", null, null, _mcc ).isCouchbaseBucketConfig()); assertTrue(createFor("http://10.10.0.1:8091/pools,http://10.10.0.2:8091/pools", null, null, _mcc ).isCouchbaseBucketConfig()); }
private void initNonStickyLockingMode( @Nonnull final MemcachedNodesManager config ) { if ( _sticky ) { setLockingMode( null, null, false ); return; } if ( _sessionAttributeFilter != null ) { _log.warn( "There's a sessionAttributesFilter configured ('" + _sessionAttributeFilter + "')," + " all other session attributes will be lost after the request due to non-sticky configuration!" ); } Pattern uriPattern = null; LockingMode lockingMode = null; if ( _lockingMode != null ) { if ( _lockingMode.startsWith( "uriPattern:" ) ) { lockingMode = LockingMode.URI_PATTERN; uriPattern = Pattern.compile( _lockingMode.substring( "uriPattern:".length() ) ); } else { lockingMode = LockingMode.valueOf( _lockingMode.toUpperCase() ); } } if ( lockingMode == null ) { lockingMode = LockingMode.NONE; } final boolean storeSecondaryBackup = config.getCountNodes() > 1 && !config.isCouchbaseBucketConfig(); setLockingMode( lockingMode, uriPattern, storeSecondaryBackup ); }
protected StorageClient createStorageClient(final MemcachedNodesManager memcachedNodesManager, final String memcachedProtocol, final String username, final String password, final long operationTimeout, final long maxReconnectDelay, final Statistics statistics ) { try { if (memcachedNodesManager.isRedisConfig()) { return new RedisStorageClient(memcachedNodesManager.getMemcachedNodes(), operationTimeout); } final ConnectionType connectionType = ConnectionType.valueOf(memcachedNodesManager.isCouchbaseBucketConfig(), username, password); if (connectionType.isCouchbaseBucketConfig()) { return new MemcachedStorageClient(MemcachedHelper.createCouchbaseClient(memcachedNodesManager, memcachedProtocol, username, password, operationTimeout, maxReconnectDelay, statistics)); } final ConnectionFactory connectionFactory = MemcachedHelper.createConnectionFactory(memcachedNodesManager, connectionType, memcachedProtocol, username, password, operationTimeout, maxReconnectDelay, statistics); return new MemcachedStorageClient(new MemcachedClient(connectionFactory, memcachedNodesManager.getAllMemcachedAddresses())); } catch (final Exception e) { throw new RuntimeException("Could not create memcached client", e); } }
/** * Returns a list of couchbase REST interface uris if the current configuration is * a couchbase bucket configuration. * @see #isCouchbaseBucketConfig() */ public List<URI> getCouchbaseBucketURIs() { if(!isCouchbaseBucketConfig()) throw new IllegalStateException("This is not a couchbase bucket configuration."); final List<URI> result = new ArrayList<URI>(_address2Ids.size()); final Matcher matcher = COUCHBASE_BUCKET_NODE_PATTERN.matcher(_memcachedNodes); while (matcher.find()) { try { result.add(new URI(matcher.group())); } catch (final URISyntaxException e) { throw new RuntimeException(e); } } return result; }
private void initNonStickyLockingMode( @Nonnull final MemcachedNodesManager config ) { if ( _sticky ) { setLockingMode( null, null, false ); return; } if ( _sessionAttributeFilter != null ) { _log.warn( "There's a sessionAttributesFilter configured ('" + _sessionAttributeFilter + "')," + " all other session attributes will be lost after the request due to non-sticky configuration!" ); } Pattern uriPattern = null; LockingMode lockingMode = null; if ( _lockingMode != null ) { if ( _lockingMode.startsWith( "uriPattern:" ) ) { lockingMode = LockingMode.URI_PATTERN; uriPattern = Pattern.compile( _lockingMode.substring( "uriPattern:".length() ) ); } else { lockingMode = LockingMode.valueOf( _lockingMode.toUpperCase() ); } } if ( lockingMode == null ) { lockingMode = LockingMode.NONE; } final boolean storeSecondaryBackup = config.getCountNodes() > 1 && !config.isCouchbaseBucketConfig(); setLockingMode( lockingMode, uriPattern, storeSecondaryBackup ); }
protected StorageClient createStorageClient(final MemcachedNodesManager memcachedNodesManager, final String memcachedProtocol, final String username, final String password, final long operationTimeout, final long maxReconnectDelay, final Statistics statistics ) { try { if (memcachedNodesManager.isRedisConfig()) { return new RedisStorageClient(memcachedNodesManager.getMemcachedNodes(), operationTimeout); } final ConnectionType connectionType = ConnectionType.valueOf(memcachedNodesManager.isCouchbaseBucketConfig(), username, password); if (connectionType.isCouchbaseBucketConfig()) { return new MemcachedStorageClient(MemcachedHelper.createCouchbaseClient(memcachedNodesManager, memcachedProtocol, username, password, operationTimeout, maxReconnectDelay, statistics)); } final ConnectionFactory connectionFactory = MemcachedHelper.createConnectionFactory(memcachedNodesManager, connectionType, memcachedProtocol, username, password, operationTimeout, maxReconnectDelay, statistics); return new MemcachedStorageClient(new MemcachedClient(connectionFactory, memcachedNodesManager.getAllMemcachedAddresses())); } catch (final Exception e) { throw new RuntimeException("Could not create memcached client", e); } }