当前位置: 首页>>代码示例>>Java>>正文


Java Configuration类代码示例

本文整理汇总了Java中com.datastax.driver.core.Configuration的典型用法代码示例。如果您正苦于以下问题:Java Configuration类的具体用法?Java Configuration怎么用?Java Configuration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Configuration类属于com.datastax.driver.core包,在下文中一共展示了Configuration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: connectViaConnectionString

import com.datastax.driver.core.Configuration; //导入依赖的package包/类
@Test
public void connectViaConnectionString() throws Exception {
  new MockUnit(Env.class, Config.class, Binder.class, Cluster.class, Cluster.Builder.class,
      Configuration.class, Session.class)
      .expect(clusterBuilder)
      .expect(serviceKey(new Env.ServiceKey()))
      .expect(contactPoints("localhost"))
      .expect(port(9042))
      .expect(codecRegistry)
      .expect(bind("beers", Cluster.class))
      .expect(bind(null, Cluster.class))
      .expect(bind("beers", Session.class))
      .expect(bind(null, Session.class))
      .expect(connect("beers"))
      .expect(mapper)
      .expect(bind("beers", MappingManager.class))
      .expect(bind(null, MappingManager.class))
      .expect(datastore)
      .expect(bind("beers", Datastore.class))
      .expect(bind(null, Datastore.class))
      .expect(routeMapper).expect(onStop)
      .run(unit -> {
        new Cassandra("cassandra://localhost/beers")
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:27,代码来源:CassandraTest.java

示例2: connectViaConnectionStringSupplier

import com.datastax.driver.core.Configuration; //导入依赖的package包/类
@Test
public void connectViaConnectionStringSupplier() throws Exception {
  new MockUnit(Env.class, Config.class, Binder.class, Cluster.class, Cluster.Builder.class,
      Configuration.class, Session.class)
      .expect(clusterBuilderProvider)
      .expect(serviceKey(new Env.ServiceKey()))
      .expect(contactPoints("localhost"))
      .expect(port(9042))
      .expect(codecRegistry)
      .expect(bind("beers", Cluster.class))
      .expect(bind(null, Cluster.class))
      .expect(bind("beers", Session.class))
      .expect(bind(null, Session.class))
      .expect(connect("beers"))
      .expect(mapper)
      .expect(bind("beers", MappingManager.class))
      .expect(bind(null, MappingManager.class))
      .expect(datastore)
      .expect(bind("beers", Datastore.class))
      .expect(bind(null, Datastore.class))
      .expect(routeMapper).expect(onStop)
      .run(unit -> {
        new Cassandra("cassandra://localhost/beers", () -> unit.get(Cluster.Builder.class))
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:27,代码来源:CassandraTest.java

示例3: testCassandraProtocolVersion

import com.datastax.driver.core.Configuration; //导入依赖的package包/类
@Test
public void testCassandraProtocolVersion()
{
  TestOutputOperator outputOperator = setupForOutputOperatorTest();
  outputOperator.getStore().setProtocolVersion("v2");

  outputOperator.setup(context);

  Configuration config = outputOperator.getStore().getCluster().getConfiguration();
  Assert.assertEquals("Procotol version was not set to V2.", ProtocolVersion.V2, config.getProtocolOptions().getProtocolVersion());
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:12,代码来源:CassandraOperatorTest.java

示例4: createMaxLoad

import com.datastax.driver.core.Configuration; //导入依赖的package包/类
private Gauge<Integer> createMaxLoad(String hostname) {
    return () -> {
        Session.State state = session.getState();
        return getHost(state, hostname).map((host) -> {
            Configuration configuration = session.getCluster().getConfiguration();
            PoolingOptions poolingOptions = configuration.getPoolingOptions();
            HostDistance distance = configuration.getPolicies().getLoadBalancingPolicy().distance(host);
            int connections = state.getOpenConnections(host);
            return connections * poolingOptions.getMaxRequestsPerConnection(distance);
        }).orElse(0);
    };
}
 
开发者ID:hawkular,项目名称:hawkular-metrics,代码行数:13,代码来源:CassandraDriverMetrics.java

示例5: connectViaProperty

import com.datastax.driver.core.Configuration; //导入依赖的package包/类
@Test
public void connectViaProperty() throws Exception {
  new MockUnit(Env.class, Config.class, Binder.class, Cluster.class, Cluster.Builder.class,
      Configuration.class, Session.class)
      .expect(unit -> {
        Config conf = unit.get(Config.class);
        expect(conf.getString("db")).andReturn("cassandra://localhost/beers");
      })
      .expect(serviceKey(new Env.ServiceKey()))
      .expect(clusterBuilder)
      .expect(contactPoints("localhost"))
      .expect(port(9042))
      .expect(codecRegistry)
      .expect(bind("beers", Cluster.class))
      .expect(bind(null, Cluster.class))
      .expect(bind("beers", Session.class))
      .expect(bind(null, Session.class))
      .expect(connect("beers"))
      .expect(mapper)
      .expect(bind("beers", MappingManager.class))
      .expect(bind(null, MappingManager.class))
      .expect(datastore)
      .expect(bind("beers", Datastore.class))
      .expect(bind(null, Datastore.class))
      .expect(routeMapper).expect(onStop)
      .run(unit -> {
        new Cassandra()
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:31,代码来源:CassandraTest.java

示例6: connectViaPropertySupplier

import com.datastax.driver.core.Configuration; //导入依赖的package包/类
@Test
public void connectViaPropertySupplier() throws Exception {
  new MockUnit(Env.class, Config.class, Binder.class, Cluster.class, Cluster.Builder.class,
      Configuration.class, Session.class)
      .expect(unit -> {
        Config conf = unit.get(Config.class);
        expect(conf.getString("db")).andReturn("cassandra://localhost/beers");
      })
      .expect(serviceKey(new Env.ServiceKey()))
      .expect(clusterBuilderProvider)
      .expect(contactPoints("localhost"))
      .expect(port(9042))
      .expect(codecRegistry)
      .expect(bind("beers", Cluster.class))
      .expect(bind(null, Cluster.class))
      .expect(bind("beers", Session.class))
      .expect(bind(null, Session.class))
      .expect(connect("beers"))
      .expect(mapper)
      .expect(bind("beers", MappingManager.class))
      .expect(bind(null, MappingManager.class))
      .expect(datastore)
      .expect(bind("beers", Datastore.class))
      .expect(bind(null, Datastore.class))
      .expect(routeMapper).expect(onStop)
      .run(unit -> {
        new Cassandra(() -> unit.get(Cluster.Builder.class))
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:31,代码来源:CassandraTest.java

示例7: onStop

import com.datastax.driver.core.Configuration; //导入依赖的package包/类
@Test
public void onStop() throws Exception {
  new MockUnit(Env.class, Config.class, Binder.class, Cluster.class, Cluster.Builder.class,
      Configuration.class, Session.class)
      .expect(clusterBuilder)
      .expect(serviceKey(new Env.ServiceKey()))
      .expect(contactPoints("localhost"))
      .expect(port(9042))
      .expect(codecRegistry)
      .expect(bind("beers", Cluster.class))
      .expect(bind(null, Cluster.class))
      .expect(bind("beers", Session.class))
      .expect(bind(null, Session.class))
      .expect(connect("beers"))
      .expect(mapper)
      .expect(bind("beers", MappingManager.class))
      .expect(bind(null, MappingManager.class))
      .expect(datastore)
      .expect(bind("beers", Datastore.class))
      .expect(bind(null, Datastore.class))
      .expect(routeMapper).expect(onStop)
      .expect(unit -> {
        Session session = unit.get(Session.class);
        session.close();

        Cluster cluster = unit.get(Cluster.class);
        cluster.close();
      })
      .run(unit -> {
        new Cassandra("cassandra://localhost/beers")
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      }, unit -> {
        unit.captured(Throwing.Runnable.class).iterator().next().run();
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:36,代码来源:CassandraTest.java

示例8: onStopSessionerr

import com.datastax.driver.core.Configuration; //导入依赖的package包/类
@Test
public void onStopSessionerr() throws Exception {
  new MockUnit(Env.class, Config.class, Binder.class, Cluster.class, Cluster.Builder.class,
      Configuration.class, Session.class)
      .expect(clusterBuilder)
      .expect(serviceKey(new Env.ServiceKey()))
      .expect(contactPoints("localhost"))
      .expect(port(9042))
      .expect(codecRegistry)
      .expect(bind("beers", Cluster.class))
      .expect(bind(null, Cluster.class))
      .expect(bind("beers", Session.class))
      .expect(bind(null, Session.class))
      .expect(connect("beers"))
      .expect(mapper)
      .expect(bind("beers", MappingManager.class))
      .expect(bind(null, MappingManager.class))
      .expect(datastore)
      .expect(bind("beers", Datastore.class))
      .expect(bind(null, Datastore.class))
      .expect(routeMapper).expect(onStop)
      .expect(unit -> {
        Session session = unit.get(Session.class);
        session.close();
        expectLastCall().andThrow(new IllegalStateException("intentional err"));

        Cluster cluster = unit.get(Cluster.class);
        cluster.close();
      })
      .run(unit -> {
        new Cassandra("cassandra://localhost/beers")
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      }, unit -> {
        unit.captured(Throwing.Runnable.class).iterator().next().run();
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:37,代码来源:CassandraTest.java

示例9: withAccessor

import com.datastax.driver.core.Configuration; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void withAccessor() throws Exception {
  Object value = new Object();
  new MockUnit(Env.class, Config.class, Binder.class, Cluster.class, Cluster.Builder.class,
      Configuration.class, Session.class)
      .expect(clusterBuilder)
      .expect(serviceKey(new Env.ServiceKey()))
      .expect(contactPoints("localhost"))
      .expect(port(9042))
      .expect(codecRegistry)
      .expect(bind("beers", Cluster.class))
      .expect(bind(null, Cluster.class))
      .expect(bind("beers", Session.class))
      .expect(bind(null, Session.class))
      .expect(connect("beers"))
      .expect(mapper)
      .expect(bind("beers", MappingManager.class))
      .expect(bind(null, MappingManager.class))
      .expect(datastore)
      .expect(bind("beers", Datastore.class))
      .expect(bind(null, Datastore.class))
      .expect(routeMapper).expect(onStop)
      .expect(unit -> {
        MappingManager manager = unit.get(MappingManager.class);
        expect(manager.createAccessor(Object.class)).andReturn(value);

        AnnotatedBindingBuilder<Object> abb = unit.mock(AnnotatedBindingBuilder.class);
        abb.toInstance(value);

        Binder binder = unit.get(Binder.class);
        expect(binder.bind(Object.class)).andReturn(abb);
      })
      .run(unit -> {
        new Cassandra("cassandra://localhost/beers")
            .accesor(Object.class)
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:40,代码来源:CassandraTest.java

示例10: doWithCluster

import com.datastax.driver.core.Configuration; //导入依赖的package包/类
@Test
public void doWithCluster() throws Exception {
  new MockUnit(Env.class, Config.class, Binder.class, Cluster.class, Cluster.Builder.class,
      Configuration.class, Session.class, StateListener.class)
      .expect(clusterBuilder)
      .expect(serviceKey(new Env.ServiceKey()))
      .expect(contactPoints("localhost"))
      .expect(port(9042))
      .expect(codecRegistry)
      .expect(bind("beers", Cluster.class))
      .expect(bind(null, Cluster.class))
      .expect(bind("beers", Session.class))
      .expect(bind(null, Session.class))
      .expect(connect("beers"))
      .expect(mapper)
      .expect(bind("beers", MappingManager.class))
      .expect(bind(null, MappingManager.class))
      .expect(datastore)
      .expect(bind("beers", Datastore.class))
      .expect(bind(null, Datastore.class))
      .expect(routeMapper).expect(onStop)
      .expect(unit -> {
        Cluster cluster = unit.get(Cluster.class);
        expect(cluster.register(unit.get(StateListener.class))).andReturn(cluster);
      })
      .run(unit -> {
        new Cassandra("cassandra://localhost/beers")
            .doWithCluster(c -> c.register(unit.get(StateListener.class)))
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:32,代码来源:CassandraTest.java

示例11: doWithClusterBuilder

import com.datastax.driver.core.Configuration; //导入依赖的package包/类
@Test
public void doWithClusterBuilder() throws Exception {
  new MockUnit(Env.class, Config.class, Binder.class, Cluster.class, Cluster.Builder.class,
      Configuration.class, Session.class)
      .expect(clusterBuilder)
      .expect(serviceKey(new Env.ServiceKey()))
      .expect(contactPoints("localhost"))
      .expect(port(9042))
      .expect(codecRegistry)
      .expect(bind("beers", Cluster.class))
      .expect(bind(null, Cluster.class))
      .expect(bind("beers", Session.class))
      .expect(bind(null, Session.class))
      .expect(connect("beers"))
      .expect(mapper)
      .expect(bind("beers", MappingManager.class))
      .expect(bind(null, MappingManager.class))
      .expect(datastore)
      .expect(bind("beers", Datastore.class))
      .expect(bind(null, Datastore.class))
      .expect(unit -> {
        Builder builder = unit.get(Cluster.Builder.class);
        expect(builder.withClusterName("mycluster")).andReturn(builder);
      })
      .expect(routeMapper).expect(onStop)
      .run(unit -> {
        new Cassandra("cassandra://localhost/beers")
            .doWithClusterBuilder(b -> {
              b.withClusterName("mycluster");
            })
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:34,代码来源:CassandraTest.java

示例12: shouldCreateClusterWithConfig

import com.datastax.driver.core.Configuration; //导入依赖的package包/类
@Test
public void shouldCreateClusterWithConfig() throws Exception {

	CassandraServiceInfo info = new CassandraServiceInfo("local",
			Collections.singletonList("127.0.0.1"), 9142);

	CassandraClusterConfig config = new CassandraClusterConfig();
	config.setCompression(ProtocolOptions.Compression.NONE);
	config.setPoolingOptions(new PoolingOptions().setPoolTimeoutMillis(1234));
	config.setQueryOptions(new QueryOptions());
	config.setProtocolVersion(ProtocolVersion.NEWEST_SUPPORTED);
	config.setLoadBalancingPolicy(new RoundRobinPolicy());
	config.setReconnectionPolicy(new ConstantReconnectionPolicy(1));
	config.setRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE);
	config.setSocketOptions(new SocketOptions());

	Cluster cluster = creator.create(info, config);

	Configuration configuration = cluster.getConfiguration();

	assertThat(configuration.getProtocolOptions().getCompression(),
			is(config.getCompression()));
	assertThat(configuration.getQueryOptions(), is(config.getQueryOptions()));
	assertThat(configuration.getSocketOptions(), is(config.getSocketOptions()));

	Policies policies = configuration.getPolicies();
	assertThat(policies.getLoadBalancingPolicy(),
			is(config.getLoadBalancingPolicy()));
	assertThat(policies.getReconnectionPolicy(), is(config.getReconnectionPolicy()));
	assertThat(policies.getRetryPolicy(), is(config.getRetryPolicy()));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-connectors,代码行数:32,代码来源:CassandraClusterCreatorTest.java

示例13: TestCluster

import com.datastax.driver.core.Configuration; //导入依赖的package包/类
public TestCluster(String name, List<InetSocketAddress> contactPoints, Configuration configuration) {
	super(name, contactPoints, configuration);
}
 
开发者ID:BreakTheMonolith,项目名称:btm-DropwizardHealthChecks,代码行数:4,代码来源:CassandraHealthCheckTest.java

示例14: getConfiguration

import com.datastax.driver.core.Configuration; //导入依赖的package包/类
public Configuration getConfiguration() {
	return configuration;
}
 
开发者ID:joef551,项目名称:camel-cql,代码行数:4,代码来源:ClusterBean.java

示例15: setConfiguration

import com.datastax.driver.core.Configuration; //导入依赖的package包/类
public void setConfiguration(Configuration configuration) {
	this.configuration = configuration;
}
 
开发者ID:joef551,项目名称:camel-cql,代码行数:4,代码来源:ClusterBean.java


注:本文中的com.datastax.driver.core.Configuration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。