Skip to content

Commit dce2291

Browse files
committed
Merge pull request apache#587 from datastax/java1050
JAVA-1050: Backport JAVA-819 to 2.1
2 parents 2acbffe + 8568560 commit dce2291

28 files changed

Lines changed: 1764 additions & 262 deletions

changelog/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- [improvement] JAVA-1021: Improve error message when connect() is called with an invalid keyspace name.
2424
- [improvement] JAVA-879: Mapper.map() accepts mapper-generated and user queries.
2525
- [bug] JAVA-1100: Exception when connecting with shaded java driver in OSGI
26+
- [bug] JAVA-819: Expose more errors in RetryPolicy + provide idempotent-aware wrapper.
2627

2728
Merged from 2.0 branch:
2829

driver-core/src/main/java/com/datastax/driver/core/Metrics.java

Lines changed: 103 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,17 +272,25 @@ public class Errors {
272272
private final Counter writeTimeouts = registry.counter("write-timeouts");
273273
private final Counter readTimeouts = registry.counter("read-timeouts");
274274
private final Counter unavailables = registry.counter("unavailables");
275+
private final Counter clientTimeouts = registry.counter("client-timeouts");
275276

276277
private final Counter otherErrors = registry.counter("other-errors");
277278

278279
private final Counter retries = registry.counter("retries");
279280
private final Counter retriesOnWriteTimeout = registry.counter("retries-on-write-timeout");
280281
private final Counter retriesOnReadTimeout = registry.counter("retries-on-read-timeout");
281282
private final Counter retriesOnUnavailable = registry.counter("retries-on-unavailable");
283+
private final Counter retriesOnClientTimeout = registry.counter("retries-on-client-timeout");
284+
private final Counter retriesOnConnectionError = registry.counter("retries-on-connection-error");
285+
private final Counter retriesOnOtherErrors = registry.counter("retries-on-other-errors");
286+
282287
private final Counter ignores = registry.counter("ignores");
283288
private final Counter ignoresOnWriteTimeout = registry.counter("ignores-on-write-timeout");
284289
private final Counter ignoresOnReadTimeout = registry.counter("ignores-on-read-timeout");
285290
private final Counter ignoresOnUnavailable = registry.counter("ignores-on-unavailable");
291+
private final Counter ignoresOnClientTimeout = registry.counter("ignores-on-client-timeout");
292+
private final Counter ignoresOnConnectionError = registry.counter("ignores-on-connection-error");
293+
private final Counter ignoresOnOtherErrors = registry.counter("ignores-on-other-errors");
286294

287295
private final Counter speculativeExecutions = registry.counter("speculative-executions");
288296

@@ -334,6 +342,16 @@ public Counter getUnavailables() {
334342
return unavailables;
335343
}
336344

345+
/**
346+
* Returns the number of requests that timed out before the driver
347+
* received a response.
348+
*
349+
* @return the number of client timeouts.
350+
*/
351+
public Counter getClientTimeouts() {
352+
return clientTimeouts;
353+
}
354+
337355
/**
338356
* Returns the number of requests that returned errors not accounted for by
339357
* another metric. This includes all types of invalid requests.
@@ -349,7 +367,7 @@ public Counter getOthers() {
349367
* Returns the number of times a request was retried due to the
350368
* {@link com.datastax.driver.core.policies.RetryPolicy}.
351369
*
352-
* @return the number of times a requests was retried due to the
370+
* @return the number of times a request was retried due to the
353371
* {@link com.datastax.driver.core.policies.RetryPolicy}.
354372
*/
355373
public Counter getRetries() {
@@ -361,7 +379,7 @@ public Counter getRetries() {
361379
* {@link com.datastax.driver.core.policies.RetryPolicy}, after a
362380
* read timed out.
363381
*
364-
* @return the number of times a requests was retried due to the
382+
* @return the number of times a request was retried due to the
365383
* {@link com.datastax.driver.core.policies.RetryPolicy}, after a
366384
* read timed out.
367385
*/
@@ -374,7 +392,7 @@ public Counter getRetriesOnReadTimeout() {
374392
* {@link com.datastax.driver.core.policies.RetryPolicy}, after a
375393
* write timed out.
376394
*
377-
* @return the number of times a requests was retried due to the
395+
* @return the number of times a request was retried due to the
378396
* {@link com.datastax.driver.core.policies.RetryPolicy}, after a
379397
* write timed out.
380398
*/
@@ -387,14 +405,53 @@ public Counter getRetriesOnWriteTimeout() {
387405
* {@link com.datastax.driver.core.policies.RetryPolicy}, after an
388406
* unavailable exception.
389407
*
390-
* @return the number of times a requests was retried due to the
408+
* @return the number of times a request was retried due to the
391409
* {@link com.datastax.driver.core.policies.RetryPolicy}, after an
392410
* unavailable exception.
393411
*/
394412
public Counter getRetriesOnUnavailable() {
395413
return retriesOnUnavailable;
396414
}
397415

416+
/**
417+
* Returns the number of times a request was retried due to the
418+
* {@link com.datastax.driver.core.policies.RetryPolicy}, after a
419+
* client timeout.
420+
*
421+
* @return the number of times a request was retried due to the
422+
* {@link com.datastax.driver.core.policies.RetryPolicy}, after a
423+
* client timeout.
424+
*/
425+
public Counter getRetriesOnClientTimeout() {
426+
return retriesOnClientTimeout;
427+
}
428+
429+
/**
430+
* Returns the number of times a request was retried due to the
431+
* {@link com.datastax.driver.core.policies.RetryPolicy}, after a
432+
* connection error.
433+
*
434+
* @return the number of times a request was retried due to the
435+
* {@link com.datastax.driver.core.policies.RetryPolicy}, after a
436+
* connection error.
437+
*/
438+
public Counter getRetriesOnConnectionError() {
439+
return retriesOnConnectionError;
440+
}
441+
442+
/**
443+
* Returns the number of times a request was retried due to the
444+
* {@link com.datastax.driver.core.policies.RetryPolicy}, after an
445+
* unexpected error.
446+
*
447+
* @return the number of times a request was retried due to the
448+
* {@link com.datastax.driver.core.policies.RetryPolicy}, after an
449+
* unexpected error.
450+
*/
451+
public Counter getRetriesOnOtherErrors() {
452+
return retriesOnOtherErrors;
453+
}
454+
398455
/**
399456
* Returns the number of times a request was ignored
400457
* due to the {@link com.datastax.driver.core.policies.RetryPolicy}, for
@@ -412,7 +469,7 @@ public Counter getIgnores() {
412469
* {@link com.datastax.driver.core.policies.RetryPolicy}, after a
413470
* read timed out.
414471
*
415-
* @return the number of times a requests was ignored due to the
472+
* @return the number of times a request was ignored due to the
416473
* {@link com.datastax.driver.core.policies.RetryPolicy}, after a
417474
* read timed out.
418475
*/
@@ -425,7 +482,7 @@ public Counter getIgnoresOnReadTimeout() {
425482
* {@link com.datastax.driver.core.policies.RetryPolicy}, after a
426483
* write timed out.
427484
*
428-
* @return the number of times a requests was ignored due to the
485+
* @return the number of times a request was ignored due to the
429486
* {@link com.datastax.driver.core.policies.RetryPolicy}, after a
430487
* write timed out.
431488
*/
@@ -438,14 +495,53 @@ public Counter getIgnoresOnWriteTimeout() {
438495
* {@link com.datastax.driver.core.policies.RetryPolicy}, after an
439496
* unavailable exception.
440497
*
441-
* @return the number of times a requests was ignored due to the
498+
* @return the number of times a request was ignored due to the
442499
* {@link com.datastax.driver.core.policies.RetryPolicy}, after an
443500
* unavailable exception.
444501
*/
445502
public Counter getIgnoresOnUnavailable() {
446503
return ignoresOnUnavailable;
447504
}
448505

506+
/**
507+
* Returns the number of times a request was ignored due to the
508+
* {@link com.datastax.driver.core.policies.RetryPolicy}, after a
509+
* client timeout.
510+
*
511+
* @return the number of times a request was ignored due to the
512+
* {@link com.datastax.driver.core.policies.RetryPolicy}, after a
513+
* client timeout.
514+
*/
515+
public Counter getIgnoresOnClientTimeout() {
516+
return ignoresOnClientTimeout;
517+
}
518+
519+
/**
520+
* Returns the number of times a request was ignored due to the
521+
* {@link com.datastax.driver.core.policies.RetryPolicy}, after a
522+
* connection error.
523+
*
524+
* @return the number of times a request was ignored due to the
525+
* {@link com.datastax.driver.core.policies.RetryPolicy}, after a
526+
* connection error.
527+
*/
528+
public Counter getIgnoresOnConnectionError() {
529+
return ignoresOnConnectionError;
530+
}
531+
532+
/**
533+
* Returns the number of times a request was ignored due to the
534+
* {@link com.datastax.driver.core.policies.RetryPolicy}, after an
535+
* unexpected error.
536+
*
537+
* @return the number of times a request was ignored due to the
538+
* {@link com.datastax.driver.core.policies.RetryPolicy}, after an
539+
* unexpected error.
540+
*/
541+
public Counter getIgnoresOnOtherErrors() {
542+
return ignoresOnOtherErrors;
543+
}
544+
449545
/**
450546
* Returns the number of times a speculative execution was started
451547
* because a previous execution did not complete within the delay

0 commit comments

Comments
 (0)