Search in sources :

Example 1 with DCAwareRoundRobinPolicy

use of com.datastax.driver.core.policies.DCAwareRoundRobinPolicy in project zipkin by openzipkin.

the class SessionFactoryTest method loadBalancing_settingLocalDcIgnoresOtherDatacenters.

@Test
public void loadBalancing_settingLocalDcIgnoresOtherDatacenters() {
    DCAwareRoundRobinPolicy policy = toDCAwareRoundRobinPolicy(CassandraStorage.builder().localDc("bar").build());
    Host foo = mock(Host.class);
    when(foo.getDatacenter()).thenReturn("foo");
    Host bar = mock(Host.class);
    when(bar.getDatacenter()).thenReturn("bar");
    policy.init(mock(Cluster.class), asList(foo, bar));
    assertThat(policy.distance(foo)).isEqualTo(HostDistance.IGNORED);
    assertThat(policy.distance(bar)).isEqualTo(HostDistance.LOCAL);
}
Also used : DCAwareRoundRobinPolicy(com.datastax.driver.core.policies.DCAwareRoundRobinPolicy) Default.buildCluster(zipkin.storage.cassandra.SessionFactory.Default.buildCluster) Cluster(com.datastax.driver.core.Cluster) Host(com.datastax.driver.core.Host) Test(org.junit.Test)

Example 2 with DCAwareRoundRobinPolicy

use of com.datastax.driver.core.policies.DCAwareRoundRobinPolicy in project zipkin by openzipkin.

the class SessionFactoryTest method loadBalancing_settingLocalDcIgnoresOtherDatacenters.

@Test
public void loadBalancing_settingLocalDcIgnoresOtherDatacenters() {
    DCAwareRoundRobinPolicy policy = toDCAwareRoundRobinPolicy(Cassandra3Storage.builder().localDc("bar").build());
    Host foo = mock(Host.class);
    when(foo.getDatacenter()).thenReturn("foo");
    Host bar = mock(Host.class);
    when(bar.getDatacenter()).thenReturn("bar");
    policy.init(mock(Cluster.class), asList(foo, bar));
    assertThat(policy.distance(foo)).isEqualTo(HostDistance.IGNORED);
    assertThat(policy.distance(bar)).isEqualTo(HostDistance.LOCAL);
}
Also used : DCAwareRoundRobinPolicy(com.datastax.driver.core.policies.DCAwareRoundRobinPolicy) DefaultSessionFactory.buildCluster(zipkin.storage.cassandra3.DefaultSessionFactory.buildCluster) Cluster(com.datastax.driver.core.Cluster) Host(com.datastax.driver.core.Host) Test(org.junit.Test)

Aggregations

Cluster (com.datastax.driver.core.Cluster)2 Host (com.datastax.driver.core.Host)2 DCAwareRoundRobinPolicy (com.datastax.driver.core.policies.DCAwareRoundRobinPolicy)2 Test (org.junit.Test)2 Default.buildCluster (zipkin.storage.cassandra.SessionFactory.Default.buildCluster)1 DefaultSessionFactory.buildCluster (zipkin.storage.cassandra3.DefaultSessionFactory.buildCluster)1