Hi all,

So, I ran into a small problem with my approach.
While refactoring the CLI of the DataNode and the ConfigNode, it turned out 
that at least for the DataNode the order and the time in which services are 
initialized was implicitly handled by the getInstance calls. So switching to 
simply injecting all singletons in the constructor didn’t work and I had to 
undo the changes.

So let me rephrase my proposal a bit.

If it’s just about accessing a singleton, doing so like I did in the 
constructor should be good.
If it’s about initializing the singletons, we will need a manual weaving 
process. I would propose to simply replace the “XYZ.getInstance()” calls with 
“new XYZ()” calls and keeping the reference of that new instance. Inside the 
constructor we could initialize the INSTANCE variable by “INSTANCE = this”.

I’m currently working on making our Singleton relatiionships more visible.

Chris


Von: Christofer Dutz <christofer.d...@c-ware.de>
Datum: Dienstag, 20. August 2024 um 15:21
An: dev@iotdb.apache.org <dev@iotdb.apache.org>
Betreff: AW: [DISCUSS] Starting to implement the "away from singletons" 
transition?
Thinking more about this,

I think the best approach would be to identify the singletons … identify their 
relations … refactor the ones with the least dependencies first.
Then to work ourselves down to DataNode and ConfigNode.

Chris


Von: Christofer Dutz <christofer.d...@c-ware.de>
Datum: Dienstag, 20. August 2024 um 15:10
An: dev@iotdb.apache.org <dev@iotdb.apache.org>
Betreff: [DISCUSS] Starting to implement the "away from singletons" transition?
Hi all,

I have just finished the first PR after we had the discussion about generally 
moving away from singletons a few days ago.

Unfortunately, the first PR I had to deal with was refactoring, so I did this 
for DataNode and ConfigNode, which are the heart and the glue-code of the Data 
node and Config node.
While for the ConfigNode refatoring there were no issues, for the DataNode 
there were isssues related in initializing things in the wrong order. So, my 
initial approach didn’t work for DataNode and I undid this.

I guess for both DataNode as well as ConfigNode (and in the Future AiNode) it 
would genereally make more sense to manually create the instances and weave the 
application.

So now my question to you:
Should I also undo my Singleton-changes for the ConfigNode in this PR: 
https://github.com/apache/iotdb/pull/13194/files#diff-3a715a0e8500c37dd803c5644ee6e7e4ce988fc4d578658b0ea75287ed03f924R116

I’m quite indifferent about it as long as in long term we get rid of the 
singletons.

Chris

Reply via email to