[
https://issues.apache.org/jira/browse/CASSANDRA-7841?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14122195#comment-14122195
]
Blake Eggleston commented on CASSANDRA-7841:
--------------------------------------------
I have a couple issues I could use some input on. You can check out my current
progress here:
https://github.com/bdeggleston/cassandra/compare/bdeggleston:C7840...C7841?expand=1
1) StorageService & TokenMetadata: A lot the singletons StorageService depends
on also depend on StorageService, but only for access to the tokenMetadata,
versionedValueFactory, and bootstrap status. In my experimental implementation,
I split this stuff into a separate class called ClusterState, which
StorageService, and several other classes depended on. I'm reaching a point
where I'm going to have to do something similar, and wanted to get some input
on the specifics. Initially, I was thinking of just duplicating the
ClusterState class, but then thought that having separate singletons for the
TokenMetaData, and VersionedValueFactory, and moving the bootstrap status into
the DatabaseDescriptor might be more flexible. I'm not sure that the 3
necessarily need to be kept together.
2) Interface implementations: IAuthorizer, IEndpoint snitch, and a few others
all have implementations with different sets of dependencies, which they will
need to be instantiated with. I know that an autowired DI framework isn't
something we want to do for DI in general, but it seems like it's the right
thing to use in these cases. I'm not married to the idea, but the only
alternatives I can think of at this point would be to check for a single
ultraconstructor which takes all possible dependencies, or using reflection to
work out which constructors are available, and passing the dependencies in that
way, something the DI frameworks already do better than an ad-hoc
implementation. Here are some of the IEndpointSnitch and ReplicationStrategy
classes, and their dependencies:
https://gist.github.com/bdeggleston/d61cfaa89ef6cd8508c4
> Pass static singleton instances into constructors of dependent classes
> ----------------------------------------------------------------------
>
> Key: CASSANDRA-7841
> URL: https://issues.apache.org/jira/browse/CASSANDRA-7841
> Project: Cassandra
> Issue Type: Sub-task
> Reporter: Blake Eggleston
> Assignee: Blake Eggleston
>
> Identify all non-singleton usages of static state (grep for '.instance.'),
> and refactor to pass dependencies into their constructors from their
> instantiating services.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)