You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/09/08 20:51:50 UTC

[GitHub] [druid] suneet-s commented on a change in pull request #10363: fix injection failure of StorageLocationSelectorStrategy objects

suneet-s commented on a change in pull request #10363:
URL: https://github.com/apache/druid/pull/10363#discussion_r485188552



##########
File path: server/src/main/java/org/apache/druid/segment/loading/LeastBytesUsedStorageLocationSelectorStrategy.java
##########
@@ -36,7 +38,13 @@
 
   private List<StorageLocation> storageLocations;
 
-  public LeastBytesUsedStorageLocationSelectorStrategy(List<StorageLocation> storageLocations)
+  @JsonCreator
+  public LeastBytesUsedStorageLocationSelectorStrategy()
+  {
+  }
+
+  @VisibleForTesting
+  LeastBytesUsedStorageLocationSelectorStrategy(List<StorageLocation> storageLocations)

Review comment:
       I think this approach is brittle and might break when a new implementation of `StorageLocationSelectorStrategy` is added. Instead, I think we should make `List<StorageLocation> storageLocations` injectable instead via a module, something like
   
   ```
   @Provides
   @Singleton
   public List<StorageLocation> provideStorageLocations(SegmentLoaderConfig config)
   {
     this.locations = new ArrayList<>();
     for (StorageLocationConfig locationConfig : config.getLocations()) {
       locations.add(
           new StorageLocation(
               locationConfig.getPath(),
               locationConfig.getMaxSize(),
               locationConfig.getFreeSpacePercent()
           )
       );
   return locations;
   }
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org