-
Notifications
You must be signed in to change notification settings - Fork 15
Use a Builder to create Transaction Managers #2459
Conversation
KeyValueService kvs = ProfilingKeyValueService.create(rawKvs, config.getKvsSlowLogThresholdMillis()); | ||
kvs = SweepStatsKeyValueService.create(kvs, | ||
new TimelockTimestampServiceAdapter(lockAndTimestampServices.timelock())); | ||
kvs = TracingKeyValueService.create(kvs); | ||
kvs = AtlasDbMetrics.instrument(KeyValueService.class, kvs, MetricRegistry.name(KeyValueService.class)); | ||
kvs = AtlasDbMetrics.instrument( | ||
KeyValueService.class, kvs, MetricRegistry.name(KeyValueService.class, options.derivedUserAgent())); |
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.
regression: need to delete the user agent
Codecov Report
@@ Coverage Diff @@
## develop #2459 +/- ##
=============================================
+ Coverage 60.05% 60.07% +0.01%
- Complexity 4658 4661 +3
=============================================
Files 859 859
Lines 40025 40057 +32
Branches 4071 4071
=============================================
+ Hits 24039 24063 +24
- Misses 14521 14534 +13
+ Partials 1465 1460 -5
Continue to review full report at Codecov.
|
bc77ba7
to
b899cca
Compare
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.
👍 overall I like this much better than existing
abstract Set<Schema> schemas(); | ||
|
||
@Value.Default | ||
Consumer<Object> env() { |
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: should we rename this? env has felt weird outside context of dropwizard
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 call it registrar
or resourceRegistrar
in other places where I've done similar things
public static class Builder extends ImmutableTransactionManagers.Builder { | ||
public SerializableTransactionManager buildSerializable() { | ||
return build().serializable(); | ||
} |
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.
do we need to expose buildSnapshot
?
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.
we could? this got me to feature parity
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.
yeah I think we're good with just Serializable
. that's all the current API gives you
* Create a {@link SerializableTransactionManager} with provided configurations, {@link Schema}, | ||
* and an environment in which to register HTTP server endpoints. | ||
*/ | ||
public static SerializableTransactionManager create( |
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.
Can we keep these methods around, but mark them as deprecated? Seems nicer to me than breaking the world, and allows us to add some kind of lotion to the bandaid before ripping it off - with some time, the bandaid might fall painlessly off on its own.
(OK, I think I've taken the metaphor far enough)
Would like to avoid breaks at this time if at all possible, especially as we are trying to push a release to the internal behemoth ASAP. |
@gsheasby basically only willing to "deprecate" if we decide up-front at what version we will remove and then actually do it then; so let's decide on that so I can add it to the release notes |
Breaks have been rolled back and release notes updated. Arbitrarily chose 0.70, can change that to whatever we want when we release. |
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.
LGTM aside from some minor comments
@@ -62,22 +62,22 @@ private Leaders() { | |||
* Creates a LeaderElectionService using the supplied configuration and | |||
* registers appropriate endpoints for that service. | |||
*/ | |||
public static LeaderElectionService create(Environment env, LeaderConfig config) { |
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.
any reason to change this to a Consumer
? it's a little less obvious what it is now
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.
(wouldn't be opposed to renaming the class EndpointRegistrar
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.
Mostly it just seemed unnecessary? the interface is exactly that of a Consumer. And I've had issues in the past where I needed to pull atlasdb-config sadness on to my classpath just to get access to that interface (though on 2nd thought I could have worked around that).
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.
Also makes it match how TimelockAgent works
KeyValueService kvs, | ||
SerializableTransactionManager transactionManager, | ||
SweepTaskRunner sweepRunner, | ||
BackgroundSweeperPerformanceLogger sweepPerfLogger, | ||
Supplier<SweepBatchConfig> sweepBatchConfig, | ||
com.google.common.base.Supplier<SweepBatchConfig> sweepBatchConfig, |
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.
ick. can these just be java suppliers?
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 wasn't a change; you'll notice I swapped the import from guava to java to prevent un-suspecting contributors such as myself from adding more guava things without realizing. We can move these to java in a separate PR
* - |deprecated| |improved| | ||
- ``SerializableTransactionManager`` is now created via an immutable builder instead of a long list of individual arguments. Use ``TransactionManagers.builder()`` | ||
to get the builder and once completely configured, build the transaction manager via the builder's ``.buildSerializable()`` method. | ||
The existing ``create`` methods are deprecated and will be removed in a future 0.70 release. |
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.
how about we give a date here instead. November 15th
? (about a month)
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 certainly looks a lot nicer than what we had before, but I'm wondering if we can't pull out the value-type-ness of this class into TransactionManagerConfig. Then the usage would look like:
TransactionManagerConfig config = TransactionManagerConfig.builder()
.config(config)
.schemas(ETE_SCHEMAS)
.registrar(environment.jersey()::register)
.build();
TransactionManager manager = TransactionManagers.buildSerialiable(config);
Thoughts, @nziebart?
sslSocketFactory, | ||
atlasSchema, | ||
(resource) -> {}); | ||
SerializableTransactionManager tm = TransactionManagers.builder() |
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 had no idea this file existed... at some point we should move it into actual docs.
@@ -105,23 +107,64 @@ | |||
import com.palantir.timestamp.TimestampStoreInvalidator; | |||
import com.palantir.util.OptionalResolver; | |||
|
|||
public final class TransactionManagers { | |||
|
|||
@Value.Immutable |
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 kind of weird to think of this class as a value type...
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 think might be less strange to reason that all of these fields are TransactionManagerOptions
, and that is the value type here.
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.
well, ok then
6fb75bc
to
37b81fc
Compare
Goals (and why): Resolves #2164
Implementation Description (bullets):
Concerns (what feedback would you like?): There are breaking developer changes here. I want to make even more of these in a better version of #2457; should we just rip the band-aid off all at once?
Where should we start reviewing?: TransactionMangers.java
Priority (whenever / two weeks / yesterday): Ideally today or tomorrow. I'm kind of considering this blocking #2457 which I need a real version of for internal backup service ASAP.
This change is