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


##########
server/src/main/java/org/apache/druid/server/coordination/ZkCoordinator.java:
##########
@@ -92,40 +77,17 @@
 
       log.info("Starting zkCoordinator for server[%s]", me.getName());
 
-      final String loadQueueLocation = 
ZKPaths.makePath(zkPaths.getLoadQueuePath(), me.getName());
-      final String servedSegmentsLocation = 
ZKPaths.makePath(zkPaths.getServedSegmentsPath(), me.getName());
-      final String liveSegmentsLocation = 
ZKPaths.makePath(zkPaths.getLiveSegmentsPath(), me.getName());
+      if (announcerConfig.isSkipSegmentAnnouncementOnZk()) {
+        log.info("Skipping zkPath creation as segment announcement on ZK is 
disabled.");
+        started = true;
+        return;
+      }
 
-      loadQueueCache = new PathChildrenCache(
-          curator,
-          loadQueueLocation,
-          true,
-          true,
-          Execs.singleThreaded("ZkCoordinator")
-      );
+      final String liveSegmentsLocation = 
ZKPaths.makePath(zkPaths.getLiveSegmentsPath(), me.getName());

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



##########
server/src/test/java/org/apache/druid/server/coordination/ZkCoordinatorTest.java:
##########
@@ -65,100 +47,55 @@
     }
   };
 
-  @Before
-  public void setUp() throws Exception
+  @Test(timeout = 60_000L)
+  public void testSegmentPathIsCreatedIfZkAnnouncementIsEnabled() throws 
Exception
   {
-    setupServerAndCurator();
-    curator.start();
-    curator.blockUntilConnected();
+    testSegmentPathCreated(true);
   }
 
-  @After
-  public void tearDown()
+  @Test(timeout = 60_000L)
+  public void testSegmentPathIsNotCreatedIfZkAnnouncementIsDisabled() throws 
Exception
   {
-    tearDownServerAndCurator();
+    testSegmentPathCreated(false);
   }
 
-  @Test(timeout = 60_000L)
-  public void testLoadDrop() throws Exception
+  private void testSegmentPathCreated(boolean announceSegmentsOnZk) throws 
Exception
   {
-    EmittingLogger.registerEmitter(new NoopServiceEmitter());
-    DataSegment segment = new DataSegment(
-        "test",
-        Intervals.of("P1d/2011-04-02"),
-        "v0",
-        ImmutableMap.of("version", "v0", "interval", 
Intervals.of("P1d/2011-04-02"), "cacheDir", "/no"),
-        Arrays.asList("dim1", "dim2", "dim3"),
-        Arrays.asList("metric1", "metric2"),
-        NoneShardSpec.instance(),
-        IndexIO.CURRENT_VERSION_ID,
-        123L
+    final String liveSegmentsPath = ZKPaths.makePath(
+        zkPaths.getLiveSegmentsPath(),
+        me.getName()
     );
 
-    CountDownLatch loadLatch = new CountDownLatch(1);
-    CountDownLatch dropLatch = new CountDownLatch(1);
+    final EnsurePath mockEnsurePath = EasyMock.mock(EnsurePath.class);
+    final CuratorFramework mockCurator = EasyMock.mock(CuratorFramework.class);
 
-    SegmentLoadDropHandler segmentLoadDropHandler = new SegmentLoadDropHandler(
-        new SegmentLoaderConfig(),
-        EasyMock.createNiceMock(DataSegmentAnnouncer.class),
-        EasyMock.createNiceMock(SegmentManager.class)
-    )
-    {
-      @Override
-      public void addSegment(DataSegment s, DataSegmentChangeCallback callback)
-      {
-        if (segment.getId().equals(s.getId())) {
-          loadLatch.countDown();
-          callback.execute();
-        }
-      }
+    if (announceSegmentsOnZk) {
+      
EasyMock.expect(mockCurator.newNamespaceAwareEnsurePath(liveSegmentsPath))

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



##########
server/src/test/java/org/apache/druid/server/coordination/ZkCoordinatorTest.java:
##########
@@ -65,100 +47,55 @@
     }
   };
 
-  @Before
-  public void setUp() throws Exception
+  @Test(timeout = 60_000L)
+  public void testSegmentPathIsCreatedIfZkAnnouncementIsEnabled() throws 
Exception
   {
-    setupServerAndCurator();
-    curator.start();
-    curator.blockUntilConnected();
+    testSegmentPathCreated(true);
   }
 
-  @After
-  public void tearDown()
+  @Test(timeout = 60_000L)
+  public void testSegmentPathIsNotCreatedIfZkAnnouncementIsDisabled() throws 
Exception
   {
-    tearDownServerAndCurator();
+    testSegmentPathCreated(false);
   }
 
-  @Test(timeout = 60_000L)
-  public void testLoadDrop() throws Exception
+  private void testSegmentPathCreated(boolean announceSegmentsOnZk) throws 
Exception
   {
-    EmittingLogger.registerEmitter(new NoopServiceEmitter());
-    DataSegment segment = new DataSegment(
-        "test",
-        Intervals.of("P1d/2011-04-02"),
-        "v0",
-        ImmutableMap.of("version", "v0", "interval", 
Intervals.of("P1d/2011-04-02"), "cacheDir", "/no"),
-        Arrays.asList("dim1", "dim2", "dim3"),
-        Arrays.asList("metric1", "metric2"),
-        NoneShardSpec.instance(),
-        IndexIO.CURRENT_VERSION_ID,
-        123L
+    final String liveSegmentsPath = ZKPaths.makePath(
+        zkPaths.getLiveSegmentsPath(),

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



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