Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,40 +58,40 @@ public void afterPropertiesSet() throws Exception {

poolingOptions = new PoolingOptions();

if (localMinSimultaneousRequests != null) {
poolingOptions.setMinSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, localMinSimultaneousRequests);
if (localMaxConnections != null) {
poolingOptions.setMaxConnectionsPerHost(HostDistance.LOCAL, localMaxConnections);
}


if (localCoreConnections != null) {
poolingOptions.setCoreConnectionsPerHost(HostDistance.LOCAL, localCoreConnections);
}

if (localMaxSimultaneousRequests != null) {
poolingOptions.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, localMaxSimultaneousRequests);
}

if (localCoreConnections != null) {
poolingOptions.setCoreConnectionsPerHost(HostDistance.LOCAL, localCoreConnections);
if (localMinSimultaneousRequests != null) {
poolingOptions.setMinSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, localMinSimultaneousRequests);
}

if (localMaxConnections != null) {
poolingOptions.setMaxConnectionsPerHost(HostDistance.LOCAL, localMaxConnections);
if (remoteMaxConnections != null) {
poolingOptions.setMaxConnectionsPerHost(HostDistance.REMOTE, remoteMaxConnections);
}

if (remoteMinSimultaneousRequests != null) {
poolingOptions.setMinSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE,
remoteMinSimultaneousRequests);

if (remoteCoreConnections != null) {
poolingOptions.setCoreConnectionsPerHost(HostDistance.REMOTE, remoteCoreConnections);
}

if (remoteMaxSimultaneousRequests != null) {
poolingOptions.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE,
remoteMaxSimultaneousRequests);
}

if (remoteCoreConnections != null) {
poolingOptions.setCoreConnectionsPerHost(HostDistance.REMOTE, remoteCoreConnections);
}

if (remoteMaxConnections != null) {
poolingOptions.setMaxConnectionsPerHost(HostDistance.REMOTE, remoteMaxConnections);

if (remoteMinSimultaneousRequests != null) {
poolingOptions.setMinSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE,
remoteMinSimultaneousRequests);
}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2013-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cassandra.test.unit.config;

import junit.framework.Assert;
import org.junit.Test;
import org.springframework.cassandra.config.PoolingOptionsFactoryBean;

/**
* Pooling Options Factory Bean Test.
* https://jira.spring.io/browse/DATACASS-176
*
* @author Sumit Kumar
*/
public class PollingOptionsFactoryBeanTest {

/**
* The max values should be set before setting core values.
* Otherwise the core values will be compared with the default max values which is 8.
* Same for other min-max properties pairs. This test checks the same.
*/
@Test
public void testAfterPropertiesSet() {
boolean gotException = false;
PoolingOptionsFactoryBean factoryBean = new PoolingOptionsFactoryBean();
factoryBean.setLocalMaxConnections(200);
factoryBean.setLocalCoreConnections(100);
factoryBean.setLocalMaxSimultaneousRequests(128);
factoryBean.setLocalMinSimultaneousRequests(101);
factoryBean.setRemoteMaxConnections(200);
factoryBean.setRemoteCoreConnections(100);
factoryBean.setRemoteMaxSimultaneousRequests(128);
factoryBean.setRemoteMinSimultaneousRequests(101);
try {
factoryBean.afterPropertiesSet();
} catch (Exception e) {
e.printStackTrace();
gotException = true;
}
Assert.assertFalse(gotException);
}

}