Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Use a Builder to create Transaction Managers #2459

Merged
merged 12 commits into from
Oct 19, 2017
Merged

Conversation

tpetracca
Copy link
Contributor

@tpetracca tpetracca commented Oct 10, 2017

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 Reviewable

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()));
Copy link
Contributor Author

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-io
Copy link

codecov-io commented Oct 10, 2017

Codecov Report

Merging #2459 into develop will increase coverage by 0.01%.
The diff coverage is 53.73%.

Impacted file tree graph

@@              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
Impacted Files Coverage Δ Complexity Δ
.../palantir/atlasdb/server/AtlasDbServiceServer.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...ntir/atlasdb/console/module/AtlasCoreModule.groovy 16.66% <0%> (+0.59%) 0 <0> (ø) ⬇️
...ain/java/com/palantir/atlasdb/factory/Leaders.java 95.06% <100%> (ø) 0 <0> (ø) ⬇️
.../palantir/atlasdb/factory/TransactionManagers.java 77.6% <55.17%> (-7.6%) 5 <0> (ø)
...palantir/leader/proxy/AwaitingLeadershipProxy.java 70.11% <0%> (-2.3%) 0% <0%> (ø)
...alantir/lock/client/LockRefreshingLockService.java 58.82% <0%> (-1.48%) 10% <0%> (-1%)
...tion/impl/AbstractSerializableTransactionTest.java 85.75% <0%> (+0.54%) 34% <0%> (ø) ⬇️
...ain/java/com/palantir/paxos/PaxosStateLogImpl.java 87.28% <0%> (+1.69%) 0% <0%> (ø) ⬇️
...ain/java/com/palantir/paxos/PaxosProposerImpl.java 91.66% <0%> (+3.33%) 0% <0%> (ø) ⬇️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c7dec4c...37b81fc. Read the comment docs.

@tpetracca tpetracca force-pushed the tomp/tms-builder branch 2 times, most recently from bc77ba7 to b899cca Compare October 10, 2017 20:38
@jeremyk-91 jeremyk-91 self-requested a review October 10, 2017 21:16
Copy link
Contributor

@schlosna schlosna left a 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() {
Copy link
Contributor

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

Copy link
Contributor Author

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();
}
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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(
Copy link
Contributor

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)

@gsheasby
Copy link
Contributor

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.

@tpetracca
Copy link
Contributor Author

@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

@tpetracca
Copy link
Contributor Author

Breaks have been rolled back and release notes updated. Arbitrarily chose 0.70, can change that to whatever we want when we release.

Copy link
Contributor

@nziebart nziebart left a 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) {
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

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).

Copy link
Contributor Author

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,
Copy link
Contributor

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?

Copy link
Contributor Author

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.
Copy link
Contributor

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)

@gsheasby gsheasby self-assigned this Oct 16, 2017
Copy link
Contributor

@gsheasby gsheasby left a 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()
Copy link
Contributor

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
Copy link
Contributor

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...

Copy link
Contributor

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.

@gsheasby gsheasby assigned nziebart and unassigned gsheasby Oct 17, 2017
@tpetracca
Copy link
Contributor Author

image

Copy link
Contributor

@gsheasby gsheasby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, ok then

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants