• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Configuration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: configure

import com.datastax.driver.core.Configuration; //导入依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void configure(final Env env, final Config conf, final Binder binder) {
  ConnectionString cstr = Try.apply(() -> ConnectionString.parse(db))
      .orElseGet(() -> ConnectionString.parse(conf.getString(db)));

  ServiceKey serviceKey = env.serviceKey();

  Throwing.Function3<Class, String, Object, Void> bind = (type, name, value) -> {
    serviceKey.generate(type, name, k -> {
      binder.bind(k).toInstance(value);
    });
    return null;
  };

  Cluster.Builder builder = this.builder.get()
      .addContactPoints(cstr.contactPoints())
      .withPort(cstr.port());

  // allow user configure cluster builder
  if (ccbuilder != null) {
    ccbuilder.accept(builder, conf);
  }

  log.debug("Starting {}", cstr);

  Cluster cluster = builder.build();

  // allow user configure cluster
  if (cc != null) {
    cc.accept(cluster, conf);
  }

  /** codecs */
  Configuration configuration = cluster.getConfiguration();
  CodecRegistry codecRegistry = configuration.getCodecRegistry();
  // java 8 codecs
  codecRegistry.register(
      InstantCodec.instance,
      LocalDateCodec.instance,
      LocalTimeCodec.instance);

  hierarchy(cluster.getClass(), type -> bind.apply(type, cstr.keyspace(), cluster));

  /** Session + Mapper */
  Session session = cluster.connect(cstr.keyspace());
  hierarchy(session.getClass(), type -> bind.apply(type, cstr.keyspace(), session));

  MappingManager manager = new MappingManager(session);
  bind.apply(MappingManager.class, cstr.keyspace(), manager);
  bind.apply(Datastore.class, cstr.keyspace(), new Datastore(manager));

  /** accessors */
  accesors.forEach(c -> {
    Object accessor = manager.createAccessor(c);
    binder.bind(c).toInstance(accessor);
  });

  env.router()
      .map(new CassandraMapper());

  env.onStop(() -> {
    log.debug("Stopping {}", cstr);
    Try.run(session::close)
        .onFailure(x -> log.error("session.close() resulted in exception", x));

    cluster.close();

    log.info("Stopped {}", cstr);
  });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:72,代码来源:Cassandra.java


示例17: shouldCreateCluster

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

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

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

	Configuration configuration = cluster.getConfiguration();

	assertThat(configuration.getProtocolOptions().getAuthProvider(),
			is(AuthProvider.NONE));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-connectors,代码行数:14,代码来源:CassandraClusterCreatorTest.java


示例18: shouldCreateClusterWithAuthentication

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

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

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

	Configuration configuration = cluster.getConfiguration();

	assertThat(configuration.getProtocolOptions().getAuthProvider(),
			is(instanceOf(PlainTextAuthProvider.class)));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-connectors,代码行数:14,代码来源:CassandraClusterCreatorTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IWorkingCopyManager类代码示例发布时间:2022-05-22
下一篇:
Java LanguageFormatting类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap