Skip to content

Commit c705ea5

Browse files
authored
CPP-413 - Enable client-side timestamps by default (datastax#195)
1 parent 77abb06 commit c705ea5

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

cpp-driver/include/cassandra.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -2335,7 +2335,7 @@ cass_cluster_set_tcp_keepalive(CassCluster* cluster,
23352335
* Sets the timestamp generator used to assign timestamps to all requests
23362336
* unless overridden by setting the timestamp on a statement or a batch.
23372337
*
2338-
* <b>Default:</b> server-side timestamp generator.
2338+
* <b>Default:</b> Monotonically increasing, client-side timestamp generator.
23392339
*
23402340
* @cassandra{2.1+}
23412341
*
@@ -10533,7 +10533,7 @@ cass_timestamp_gen_monotonic_new();
1053310533
* @param warning_threshold_us The amount of clock skew, in microseconds, that
1053410534
* must be detected before a warning is triggered. A threshold less than 0 can
1053510535
* be used to disable warnings.
10536-
* @param warning_interval_ms The amount of time, in milliseonds, to wait before
10536+
* @param warning_interval_ms The amount of time, in milliseconds, to wait before
1053710537
* warning again about clock skew. An interval value less than or equal to 0 allows
1053810538
* the warning to be triggered every millisecond.
1053910539
* @return Returns a timestamp generator that must be freed.

cpp-driver/src/config.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Config {
5757
, tcp_keepalive_delay_secs_(CASS_DEFAULT_TCP_KEEPALIVE_DELAY_SECS)
5858
, connection_idle_timeout_secs_(CASS_DEFAULT_IDLE_TIMEOUT_SECS)
5959
, connection_heartbeat_interval_secs_(CASS_DEFAULT_HEARTBEAT_INTERVAL_SECS)
60-
, timestamp_gen_(Memory::allocate<ServerSideTimestampGenerator>())
60+
, timestamp_gen_(Memory::allocate<MonotonicTimestampGenerator>())
6161
, use_schema_(CASS_DEFAULT_USE_SCHEMA)
6262
, use_hostname_resolution_(CASS_DEFAULT_HOSTNAME_RESOLUTION_ENABLED)
6363
, use_randomized_contact_points_(CASS_DEFAULT_USE_RANDOMIZED_CONTACT_POINTS)

cpp-driver/test/integration_tests/src/test_timestamps.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,10 @@ BOOST_AUTO_TEST_CASE(generator)
240240
}
241241

242242
/**
243-
* Test the default timestamp generator.
243+
* Test the server-side generator.
244244
*
245-
* Verifies that the timestamp is set by the server when no timestamp
246-
* generator is set and the timestamp is not set directly on the statement.
245+
* Verifies that the timestamp is set by the server when using the server-side
246+
* generator and the timestamp is not set directly on the statement.
247247
*
248248
* @since 2.1.0
249249
* @jira_ticket CPP-266
@@ -255,6 +255,9 @@ BOOST_AUTO_TEST_CASE(server_side)
255255
CCM::CassVersion version = test_utils::get_version();
256256
if ((version.major_version >= 2 && version.minor_version >= 1) || version.major_version >= 3) {
257257
TimestampsTest tester;
258+
CassTimestampGen* gen = cass_timestamp_gen_server_side_new();
259+
cass_cluster_set_timestamp_gen(tester.cluster, gen);
260+
cass_timestamp_gen_free(gen);
258261
tester.create_session();
259262
// Server-side is the default timestamp generator
260263
std::string table_name("table_" + test_utils::generate_unique_str(tester.uuid_gen));

cpp-driver/topics/basics/client_side_timestamps/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
Cassandra uses timestamps to serialize write operations. That is, values with a
66
more current timestamp are considered to be the most up-to-date version of that
7-
information. By default, timestamps are assigned by Cassandra on the
8-
server-side. This behavior can be overridden by configuring the driver to use a
7+
information. By default, timestamps are assigned by the driver on the
8+
client-side. This behavior can be overridden by configuring the driver to use a
99
timestamp generator or assigning a timestamp directly to a [`CassStatement`] or
1010
[`CassBatch`].
1111

0 commit comments

Comments
 (0)