-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump couchbase sdk to 3_4_3. #1663
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dnault @programmatix for review.
78f8f29
to
78feaaf
Compare
JsonObject jo = JsonObject.create(); | ||
optsBuilt.injectParams(jo); | ||
return jo; | ||
private static ClassicCoreQueryOps kvOps = new ClassicCoreQueryOps(Core.create(CoreEnvironment.builder().build(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final?
kvOps -> queryOps ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed - it's a static methods not needed.
options.parameters((JsonArray) query.getParameters()); | ||
} else { | ||
} else if( query.getParameters() instanceof JsonObject && !((JsonObject)query.getParameters()).isEmpty()){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: formatting
IntelliJ tip: Command-Option-Shift-L, then select "Only changes uncommitted to VCS"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's sorcery!!
optsBuilt.injectParams(jo); | ||
return jo; | ||
public static JsonObject getQueryOpts(QueryOptions.Built optsBuilt) { | ||
return JsonObject.fromJson(ClassicCoreQueryOps.convertOptions(optsBuilt).toString().getBytes()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getBytes(StandardCharsets.UTF_8)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed getQueryOpts() method completely as it is only needed in one place. (to transform GetOptions into TransactionGetOptions)
@@ -93,7 +94,7 @@ TestClusterConfig _start() throws Exception { | |||
// no means to create a bucket on Capella | |||
// have not created config() yet. | |||
boolean usingCloud = seedHost.endsWith("cloud.couchbase.com"); | |||
bucketname = usingCloud ? "my_bucket" : UUID.randomUUID().toString(); | |||
bucketname = "my_bucket"; // usingCloud ? "my_bucket" : UUID.randomUUID().toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: remove commented-out code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. This shouldn't be in the change.
couchbaseTemplate.removeByQuery(User.class).withConsistency(QueryScanConsistency.REQUEST_PLUS).all(); | ||
break; | ||
} catch (Exception e) { | ||
e.printStackTrace(); // gives IndexFailureException if the lock is still active |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this hide other exceptions that aren't expected? (Sure, it logs the stack trace, but nobody's going to look at it if the test "passes".)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this hide other exceptions that aren't expected?
It prevents an exception in the finally() from showing instead of the actual test failure showing.
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import com.couchbase.client.core.Core; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import? (not just a NIT, because Core is potentially on the chopping block)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed. Along with the other related, unused imports.
txOptions.parameters((JsonObject)value); | ||
}else if(value instanceof JsonArray) { | ||
txOptions.parameters((JsonArray) value); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else throw if not null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
@@ -100,11 +101,10 @@ public Flux<RemoveResult> all() { | |||
} else { | |||
TransactionQueryOptions opts = OptionsBuilder | |||
.buildTransactionQueryOptions(buildQueryOptions(pArgs.getOptions())); | |||
ObjectNode convertedOptions = com.couchbase.client.java.transactions.internal.OptionsUtil | |||
.createTransactionOptions(pArgs.getScope() == null ? null : rs, statement, opts); | |||
CoreQueryContext queryContext = CollectionIdentifier.DEFAULT_SCOPE.equals(rs.name()) ? null : CoreQueryContext.of(rs.bucketName(), rs.name()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's always necessary to send a CoreQueryContext to satisfy The Platform That Shall Not Be Publically Named. This is what ultimately causes a query_context to be sent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted. I opened a separate ticket for this #1671.
return transactionContext.get().getCore() | ||
.queryBlocking(statement, template.getBucketName(), pArgs.getScope(), convertedOptions, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot that Spring was using these internals directly. Let's get these methods annotated with the new annotation so breakage like this doesn't happen again.
for (Map.Entry<String, Object> entry : optsJson.toMap().entrySet()) { | ||
txOptions.raw(entry.getKey(), entry.getValue()); | ||
if(!entry.getKey().equals("args")) { | ||
txOptions.raw(entry.getKey(), entry.getValue()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Continue to not feel good about this approach to clone a QueryOptions into a TransactionQueryOptions... It won't handle things like the JsonSerializer, for example.
JsonObject jo = JsonObject.create(); | ||
optsBuilt.injectParams(jo); | ||
return jo; | ||
public static JsonObject getQueryOpts(QueryOptions.Built optsBuilt) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't feel great turning QueryOptions into JSON, and it also calls into the internal method ClassicCoreQueryOps.convertOptions, Luckily, I don't think this getQueryOpts is necessary anymore. It's called from two places:
- buildQueryOptions. Which only uses it for getScanConsistency. But that's not needed anymore. QueryOptions.Built now implements CoreQueryOptions so you can call scanConsistency() directly on it.
- buildTransactionQueryOptions. As mentioned above I already feel a bit queasy about this solution of converting a QueryOptions into JSON and then using that to set raw parameters on a TransactionQueryOptions. And now with CoreQueryOptions you don't need it - you can copy over the parameters one by one (now including the serializer).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the getQueryOptions() method as it is only needed in buildTransactionQueryOptions.
I opened a new ticket #1672 for better handling of TransactionGetOptions.
78feaaf
to
05bd415
Compare
05bd415
to
4b527eb
Compare
options.parameters((JsonArray) query.getParameters()); | ||
} else { | ||
} else if( query.getParameters() instanceof JsonObject && !((JsonObject)query.getParameters()).isEmpty()){ | ||
options.parameters((JsonObject) query.getParameters()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was previously broken - it was overwriting options.parameters() with empty query.parameters()
@@ -93,7 +94,7 @@ TestClusterConfig _start() throws Exception { | |||
// no means to create a bucket on Capella | |||
// have not created config() yet. | |||
boolean usingCloud = seedHost.endsWith("cloud.couchbase.com"); | |||
bucketname = usingCloud ? "my_bucket" : UUID.randomUUID().toString(); | |||
bucketname = "my_bucket"; // usingCloud ? "my_bucket" : UUID.randomUUID().toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. This shouldn't be in the change.
JsonObject jo = JsonObject.create(); | ||
optsBuilt.injectParams(jo); | ||
return jo; | ||
private static ClassicCoreQueryOps kvOps = new ClassicCoreQueryOps(Core.create(CoreEnvironment.builder().build(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed - it's a static methods not needed.
optsBuilt.injectParams(jo); | ||
return jo; | ||
public static JsonObject getQueryOpts(QueryOptions.Built optsBuilt) { | ||
return JsonObject.fromJson(ClassicCoreQueryOps.convertOptions(optsBuilt).toString().getBytes()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed getQueryOpts() method completely as it is only needed in one place. (to transform GetOptions into TransactionGetOptions)
couchbaseTemplate.removeByQuery(User.class).withConsistency(QueryScanConsistency.REQUEST_PLUS).all(); | ||
break; | ||
} catch (Exception e) { | ||
e.printStackTrace(); // gives IndexFailureException if the lock is still active |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this hide other exceptions that aren't expected?
It prevents an exception in the finally() from showing instead of the actual test failure showing.
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import com.couchbase.client.core.Core; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed. Along with the other related, unused imports.
txOptions.parameters((JsonObject)value); | ||
}else if(value instanceof JsonArray) { | ||
txOptions.parameters((JsonArray) value); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
options.parameters((JsonArray) query.getParameters()); | ||
} else { | ||
} else if( query.getParameters() instanceof JsonObject && !((JsonObject)query.getParameters()).isEmpty()){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's sorcery!!
@@ -100,11 +101,10 @@ public Flux<RemoveResult> all() { | |||
} else { | |||
TransactionQueryOptions opts = OptionsBuilder | |||
.buildTransactionQueryOptions(buildQueryOptions(pArgs.getOptions())); | |||
ObjectNode convertedOptions = com.couchbase.client.java.transactions.internal.OptionsUtil | |||
.createTransactionOptions(pArgs.getScope() == null ? null : rs, statement, opts); | |||
CoreQueryContext queryContext = CollectionIdentifier.DEFAULT_SCOPE.equals(rs.name()) ? null : CoreQueryContext.of(rs.bucketName(), rs.name()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted. I opened a separate ticket for this #1671.
JsonObject jo = JsonObject.create(); | ||
optsBuilt.injectParams(jo); | ||
return jo; | ||
public static JsonObject getQueryOpts(QueryOptions.Built optsBuilt) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the getQueryOptions() method as it is only needed in buildTransactionQueryOptions.
I opened a new ticket #1672 for better handling of TransactionGetOptions.
Requires some refactoring around @Stability.Internal APIs. Also fixed a test to get it to pass.
Closes #1661,#1662.