datastax 驱动程序连接 = apache ignite 和 cassandra(您可能希望增加每个主机连接的驱动程序数量)

datastax driver connection = apache ignite and cassandra(you may want to increase the driver number of per-host connections)

组件:apache ignite + apache cassandra。使用默认的 datastax 驱动程序。 在做了几次操作(大约 3-50 亿个实体放入缓存)之后,我们遇到了一种情况,datastax 驱动程序总是从 ignite 重新连接到 cassandra。

2017-02-16 13:29:21.287  INFO 160487 --- [ sys-#441%null%] m.r.t.d.c.m.p.c.c.p.RetryPolicyImpl      :  init cluster
2017-02-16 13:29:21.288  INFO 160487 --- [ sys-#441%null%] com.datastax.driver.core.Cluster         : New Cassandra host <our host> added
2017-02-16 13:29:21.307  INFO 160487 --- [ sys-#441%null%] m.r.t.d.c.m.p.c.c.p.RetryPolicyImpl      :  close cluster
2017-02-16 13:29:23.516  INFO 160487 --- [ sys-#441%null%] com.datastax.driver.core.ClockFactory    : Using native clock to generate timestamps.
2017-02-16 13:29:23.537  INFO 160487 --- [ sys-#441%null%] c.d.d.c.p.DCAwareRoundRobinPolicy        : Using data-center name 'datacenter1' for DCAw

而且这个过程是无休止的,可以通过重启服务器来中断。

基础设施: 1 个服务器 ignite - ~Xmx30g 和 8 个内核。 25 个客户端点燃 ~Xmx1g 和 8 个核心。 1 个节点卡桑德拉。 批量大小(将被放入缓存的实体,然后是 cassandra)大约为 1-2M。

配置数据源=>

 public DataSource dataSource() {
        DataSource dataSource = new DataSource();
        dataSource.setUser(login);
        dataSource.setPassword(pass);
        dataSource.setPort(port);
        dataSource.setContactPoints(host);
        dataSource.setRetryPolicy(retryPolicy);
        dataSource.setFetchSize(10_000);
        dataSource.setReconnectionPolicy(new ConstantReconnectionPolicy(1000));
        dataSource.setLoadBalancingPolicy(DCAwareRoundRobinPolicy.builder().withUsedHostsPerRemoteDc(0).build());
        dataSource.setSocketOptions(new SocketOptions().setReadTimeoutMillis(100_000).setConnectTimeoutMillis(100_00));
        return dataSource;
    }

配置缓存=>

 CacheConfiguration<KeyIgnite, Long> cfg = new CacheConfiguration<>();
        cfg
                .setName(area)
                .setRebalanceMode(CacheRebalanceMode.SYNC)
                .setStartSize(1_000_000)
                .setAtomicityMode(CacheAtomicityMode.ATOMIC)
                .setIndexedTypes(KeyIgnite.class, Long.class)
                .setCacheMode(CacheMode.PARTITIONED)
                .setBackups(0);

        if (!clientMode) {

            CassandraCacheStoreFactory<KeyIgnite, Long> csFactory = new CassandraCacheStoreFactory<>();
            csFactory.setDataSource(ds);
            csFactory.setPersistenceSettings(kv);

//            CassandraCacheStoreFactoryDwh<KeyIgnite, Long> csFactory = new CassandraCacheStoreFactoryDwh<>(ds, kv,params);

            cfg
                    .setCacheStoreFactory(csFactory)
                    .setReadThrough(true)
                    .setWriteThrough(true);
        }

        cfg.setExpiryPolicyFactory(TouchedExpiryPolicy.factoryOf(new Duration(TimeUnit.DAYS, 5)));
        return cfg;

点燃配置 =>:

   TcpDiscoveryMulticastIpFinder finder = new TcpDiscoveryMulticastIpFinder();
        finder.setAddresses(adresses);

        return Ignition.start(
                new IgniteConfiguration()
                        .setClientMode(clientMode)
                        .setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(finder).setNetworkTimeout(10000))
                        .setFailureDetectionTimeout(50000)
                        .setPeerClassLoadingEnabled(false)
                        .setLoadBalancingSpi(new RoundRobinLoadBalancingSpi())

        );

当我们完成多次将项目放入缓存的迭代后,我们得到了这种情况。

包括调试级别后我得到了这条记录:

2017-02-17 17:48:41.570 DEBUG 24816 --- [ sys-#184%null%] com.datastax.driver.core.RequestHandler  : [1071994376-1] Error querying ds-inmemorydb-02t/10.216.28.34:9042 : com.datastax.driver.core.exceptions.DriverException: Timeout while trying to acquire available connection (you may want to increase the driver number of per-host connections)

驱动程序的超时增加有所帮助