Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-6881

Replace static singletons potentially using dependency injection

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Normal
    • Resolution: Duplicate
    • None
    • None
    • None

    Description

      I have noticed several places in the cassandra codebase where unit,functional, and end-to-end testing is made more difficult due to the pattern of using singleton objects with static initialization.

      An example is StorageProxy

      static final boolean OPTIMIZE_LOCAL_REQUESTS = true; // set to false to test messagingservice path on single node
      

      There is no coverage for this. It turns out to be very difficult to test for a variety of reasons. Mostly that everything it interacts with is hidden behind other static singletons.

      The goal here would be to remove static stuff, have have a context, (spring, guice, or do out own). For the majority of things stop accessing them through static singleton, instead pass the objects (DatabaseDescriptor, Storageproxy) around or get them from the context. I think this will make a clearer API and allow us to provide better coverage on features that cross cut the components. It will also provide us better isolation for things like triggers/ udfs/ as they wont be able to acquire references to things they should not be able to.

      Attachments

        Issue Links

          Activity

            People

              appodictic Edward Capriolo
              appodictic Edward Capriolo
              Edward Capriolo
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: