Skip to content

Commit e71dd10

Browse files
authored
Added hidden options for upcoming cloud DRL (#55)
These are currently meant for testing only.
1 parent 0787a77 commit e71dd10

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

driver/src/main/java/oracle/nosql/driver/ops/Request.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public abstract class Request {
7373
*/
7474
private RateLimiter writeRateLimiter;
7575
private int rateLimitDelayedMs;
76+
private boolean preferThrottling;
77+
private boolean drlOptIn;
7678

7779
/**
7880
* @hidden
@@ -493,6 +495,43 @@ public boolean getIsRefresh() {
493495
*/
494496
public abstract String getTypeName();
495497

498+
/**
499+
* @hidden
500+
* Cloud only
501+
* If using DRL, return immediate throttling error if the
502+
* table is currently over its configured throughput limit.
503+
* Otherwise, allow DRL to delay request processing to match
504+
* table limits (default).
505+
*/
506+
public void setPreferThrottling(boolean preferThrottling) {
507+
this.preferThrottling = preferThrottling;
508+
}
509+
510+
/**
511+
* @hidden
512+
*/
513+
public boolean getPreferThrottling() {
514+
return preferThrottling;
515+
}
516+
517+
/**
518+
* @hidden
519+
* Cloud only
520+
* Opt-in to using Distributed Rate Limiting (DRL). This setting
521+
* will eventually be deprecated, as all requests will eventually
522+
* use DRL unconditionally in the cloud.
523+
*/
524+
public void setDRLOptIn(boolean drlOptIn) {
525+
this.drlOptIn = drlOptIn;
526+
}
527+
528+
/**
529+
* @hidden
530+
*/
531+
public boolean getDRLOptIn() {
532+
return drlOptIn;
533+
}
534+
496535
/**
497536
* @hidden
498537
* Copy internal fields to another Request object.
@@ -509,5 +548,7 @@ public void copyTo(Request other) {
509548
other.setReadRateLimiter(this.readRateLimiter);
510549
other.setWriteRateLimiter(this.writeRateLimiter);
511550
other.setRateLimitDelayedMs(this.rateLimitDelayedMs);
551+
other.setPreferThrottling(this.preferThrottling);
552+
other.setDRLOptIn(this.drlOptIn);
512553
}
513554
}

driver/src/main/java/oracle/nosql/driver/ops/serde/nson/NsonProtocol.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class NsonProtocol {
3030
public static String CONTINUATION_KEY = "ck";
3131
public static String DATA = "d";
3232
public static String DEFINED_TAGS = "dt";
33+
public static String DRL_OPTIN = "dro";
3334
public static String DURABILITY = "du";
3435
public static String END = "en";
3536
public static String ETAG = "et";
@@ -65,6 +66,7 @@ public class NsonProtocol {
6566
public static String OP_CODE = "o";
6667
public static String PATH = "pt";
6768
public static String PAYLOAD = "p";
69+
public static String PREFER_THROTTLING = "pg";
6870
public static String PREPARE = "pp";
6971
public static String PREPARED_QUERY = "pq";
7072
public static String PREPARED_STATEMENT = "ps";
@@ -165,6 +167,7 @@ public class NsonProtocol {
165167
{CONTINUATION_KEY,"CONTINUATION_KEY"},
166168
{DATA,"DATA"},
167169
{DEFINED_TAGS,"DEFINED_TAGS"},
170+
{DRL_OPTIN,"DRL_OPTIN"},
168171
{DURABILITY,"DURABILITY"},
169172
{END,"END"},
170173
{ETAG,"ETAG"},
@@ -200,6 +203,7 @@ public class NsonProtocol {
200203
{OP_CODE,"OP_CODE"},
201204
{PATH,"PATH"},
202205
{PAYLOAD,"PAYLOAD"},
206+
{PREFER_THROTTLING,"PREFER_THROTTLING"},
203207
{PREPARE,"PREPARE"},
204208
{PREPARED_QUERY,"PREPARED_QUERY"},
205209
{PREPARED_STATEMENT,"PREPARED_STATEMENT"},

driver/src/main/java/oracle/nosql/driver/ops/serde/nson/NsonSerializerFactory.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,6 +1792,12 @@ protected static void writeHeader(NsonSerializer ns, int op, Request rq)
17921792
}
17931793
writeMapField(ns, OP_CODE, op);
17941794
writeMapField(ns, TIMEOUT, rq.getTimeoutInternal());
1795+
if (rq.getPreferThrottling()) {
1796+
writeMapField(ns, PREFER_THROTTLING, true);
1797+
}
1798+
if (rq.getDRLOptIn()) {
1799+
writeMapField(ns, DRL_OPTIN, true);
1800+
}
17951801
}
17961802

17971803
/**

0 commit comments

Comments
 (0)