github-advanced-security[bot] commented on code in PR #19537:
URL: https://github.com/apache/druid/pull/19537#discussion_r3336469993


##########
server/src/main/java/org/apache/druid/client/CachingClusteredClient.java:
##########
@@ -823,10 +835,15 @@
         @Nullable byte[] queryCacheKey
     )
     {
-      Hasher hasher = Hashing.sha1().newHasher();
+      final Hasher hasher = Hashing.sha1().newHasher();

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [Hashing.sha1](1) should be avoided because it has been deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11279)



##########
server/src/test/java/org/apache/druid/client/selector/ServerSelectorTest.java:
##########
@@ -168,4 +172,118 @@
     Assert.assertTrue(selector.hasData());
   }
 
+  @Test
+  public void testQueryableHistoricalTiersFiltersHistoricalServers()
+  {
+    final DataSegment segment = DataSegment.builder()

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [DataSegment.builder](1) should be avoided because it has been 
deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11280)



##########
server/src/test/java/org/apache/druid/client/CachingClusteredClientTest.java:
##########
@@ -3222,6 +3222,63 @@
     Assert.assertEquals(1, 
remainingResponseMap.get(queryInclude.getId()).intValue());
   }
 
+  @Test
+  public void testQueryableHistoricalTiersQueryContext()
+  {
+    final Interval interval = Intervals.of("2016-01-01/2016-01-02");
+    final Interval queryInterval = 
Intervals.of("2016-01-01T14:00:00/2016-01-02T14:00:00");
+    final DataSegment dataSegment = new DataSegment(
+        "dataSource",
+        interval,
+        "ver",
+        ImmutableMap.of("type", "hdfs", "path", "/tmp"),
+        ImmutableList.of("product"),
+        ImmutableList.of("visited_sum"),
+        NoneShardSpec.instance(),
+        9,
+        12334
+    );

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [DataSegment.DataSegment](1) should be avoided because it has been 
deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11282)



##########
server/src/test/java/org/apache/druid/client/selector/ServerSelectorTest.java:
##########
@@ -168,4 +172,118 @@
     Assert.assertTrue(selector.hasData());
   }
 
+  @Test
+  public void testQueryableHistoricalTiersFiltersHistoricalServers()
+  {
+    final DataSegment segment = DataSegment.builder()
+                                           
.dataSource("test_broker_server_view")
+                                           .interval(Intervals.of("2012/2013"))
+                                           .loadSpec(ImmutableMap.of("type", 
"local", "path", "somewhere"))
+                                           .version("v1")
+                                           .dimensions(ImmutableList.of())
+                                           .metrics(ImmutableList.of())
+                                           .shardSpec(NoneShardSpec.instance())
+                                           .binaryVersion(9)
+                                           .size(0)
+                                           .build();
+    final ServerSelector selector = new ServerSelector(
+        segment,
+        new HighestPriorityTierSelectorStrategy(new 
RandomServerSelectorStrategy()),
+        HistoricalFilter.IDENTITY_FILTER
+    );
+    final DruidServer coldServer = new DruidServer(
+        "cold",
+        "cold",
+        null,
+        0,
+        null,
+        ServerType.HISTORICAL,
+        "cold",
+        10
+    );
+    final DruidServer hotServer = new DruidServer(
+        "hot",
+        "hot",
+        null,
+        0,
+        null,
+        ServerType.HISTORICAL,
+        "hot",
+        0
+    );
+    selector.addServerAndUpdateSegment(
+        new QueryableDruidServer(coldServer, 
EasyMock.createMock(DirectDruidClient.class)),
+        segment
+    );
+    selector.addServerAndUpdateSegment(
+        new QueryableDruidServer(hotServer, 
EasyMock.createMock(DirectDruidClient.class)),
+        segment
+    );
+
+    final Query<?> hotTierQuery = Druids.newTimeBoundaryQueryBuilder()
+                                        .dataSource("test")
+                                        .intervals("2012/2013")
+                                        .context(ImmutableMap.of(
+                                            
QueryContexts.QUERYABLE_HISTORICAL_TIERS,
+                                            ImmutableList.of("hot")
+                                        ))
+                                        .build();
+    final Query<?> missingTierQuery = Druids.newTimeBoundaryQueryBuilder()
+                                            .dataSource("test")
+                                            .intervals("2012/2013")
+                                            .context(ImmutableMap.of(
+                                                
QueryContexts.QUERYABLE_HISTORICAL_TIERS,
+                                                ImmutableList.of("warm")
+                                            ))
+                                            .build();
+
+    Assert.assertEquals(
+        hotServer,
+        selector.pick(hotTierQuery, CloneQueryMode.EXCLUDECLONES).getServer()
+    );
+    Assert.assertTrue(selector.hasQueryableServer(hotTierQuery, 
CloneQueryMode.EXCLUDECLONES));
+    Assert.assertNull(selector.pick(missingTierQuery, 
CloneQueryMode.EXCLUDECLONES));
+    Assert.assertFalse(selector.hasQueryableServer(missingTierQuery, 
CloneQueryMode.EXCLUDECLONES));
+  }
+
+  @Test
+  public void testQueryableHistoricalTiersDoesNotFallBackToRealtime()
+  {
+    final DataSegment segment = DataSegment.builder()

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [DataSegment.builder](1) should be avoided because it has been 
deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11281)



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to