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 2019/07/30 23:26:31 UTC

[GitHub] [incubator-druid] ccaominh commented on a change in pull request #8154: Fix `is_realtime` column behavior in sys.segments table

ccaominh commented on a change in pull request #8154: Fix `is_realtime` column behavior in sys.segments table
URL: https://github.com/apache/incubator-druid/pull/8154#discussion_r308983004
 
 

 ##########
 File path: sql/src/main/java/org/apache/druid/sql/calcite/schema/DruidSchema.java
 ##########
 @@ -431,19 +430,27 @@ void removeSegment(final DataSegment segment)
     }
   }
 
-  private void removeServerSegment(final DruidServerMetadata server, final DataSegment segment)
+  @VisibleForTesting
+  void removeServerSegment(final DruidServerMetadata server, final DataSegment segment)
   {
     synchronized (lock) {
       log.debug("Segment[%s] is gone from server[%s]", segment.getId(), server.getName());
       final Map<SegmentId, AvailableSegmentMetadata> knownSegments = segmentMetadataInfo.get(segment.getDataSource());
       final AvailableSegmentMetadata segmentMetadata = knownSegments.get(segment.getId());
-      final Set<String> segmentServers = segmentMetadata.getReplicas();
-      final ImmutableSet<String> servers = FluentIterable.from(segmentServers)
-                                                         .filter(Predicates.not(Predicates.equalTo(server.getName())))
-                                                         .toSet();
+      final Set<DruidServerMetadata> segmentServers = segmentMetadata.getReplicas();
+      final ImmutableSet<DruidServerMetadata> servers = FluentIterable.from(segmentServers)
+                                                                      .filter(Predicates.not(Predicates.equalTo(server)))
+                                                                      .toSet();
+      final DruidServerMetadata realtimeServer = servers.stream()
+                                                  .filter(metadata -> metadata.getType().equals(ServerType.REALTIME))
+                                                  .findAny()
+                                                  .orElse(null);
 
 Review comment:
   Since `findAny()` returns an `Optional`, you could use `Optional.isPresent()` below instead of using `orElse()` to convert to `null`. Another option is to use `anyMatch()` instead of `findAny()`.

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


With regards,
Apache Git Services

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