diff --git a/server/src/main/java/io/druid/server/http/DatasourcesResource.java b/server/src/main/java/io/druid/server/http/DatasourcesResource.java index e473ca2b008..52988a448bb 100644 --- a/server/src/main/java/io/druid/server/http/DatasourcesResource.java +++ b/server/src/main/java/io/druid/server/http/DatasourcesResource.java @@ -19,7 +19,6 @@ package io.druid.server.http; -import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -123,14 +122,7 @@ public class DatasourcesResource Lists.newArrayList( Iterables.transform( datasources, - new Function>() - { - @Override - public Map apply(DruidDataSource dataSource) - { - return makeSimpleDatasource(dataSource); - } - } + (DruidDataSource dataSource) -> makeSimpleDatasource(dataSource) ) ) ).build(); @@ -140,14 +132,7 @@ public class DatasourcesResource Lists.newArrayList( Iterables.transform( datasources, - new Function() - { - @Override - public String apply(DruidDataSource dataSource) - { - return dataSource.getName(); - } - } + (DruidDataSource dataSource) -> dataSource.getName() ) ) ).build(); @@ -304,7 +289,10 @@ public class DatasourcesResource } Pair> val = getSegment(dataSegment.getIdentifier()); - segments.put(dataSegment.getIdentifier(), ImmutableMap.of("metadata", val.lhs, "servers", val.rhs)); + + if (val != null) { + segments.put(dataSegment.getIdentifier(), ImmutableMap.of("metadata", val.lhs, "servers", val.rhs)); + } } return Response.ok(retVal).build(); @@ -367,7 +355,10 @@ public class DatasourcesResource } Pair> val = getSegment(dataSegment.getIdentifier()); - segments.put(dataSegment.getIdentifier(), ImmutableMap.of("metadata", val.lhs, "servers", val.rhs)); + + if (val != null) { + segments.put(dataSegment.getIdentifier(), ImmutableMap.of("metadata", val.lhs, "servers", val.rhs)); + } } } @@ -427,14 +418,7 @@ public class DatasourcesResource return builder.entity( Iterables.transform( dataSource.getSegments(), - new Function() - { - @Override - public Object apply(DataSegment segment) - { - return segment.getIdentifier(); - } - } + (DataSegment segment) -> segment.getIdentifier() ) ).build(); } @@ -519,14 +503,7 @@ public class DatasourcesResource Iterables.concat( Iterables.transform( serverInventoryView.getInventory(), - new Function() - { - @Override - public DruidDataSource apply(DruidServer input) - { - return input.getDataSource(dataSourceName); - } - } + (DruidServer input) -> input.getDataSource(dataSourceName) ) ); @@ -552,7 +529,7 @@ public class DatasourcesResource return new DruidDataSource( dataSourceName, - ImmutableMap.of() + ImmutableMap.of() ).addSegments(segmentMap); } @@ -672,28 +649,12 @@ public class DatasourcesResource Iterable> lookup = timeline.lookupWithIncompletePartitions(theInterval); FunctionalIterable retval = FunctionalIterable .create(lookup).transformCat( - new Function, Iterable>() - { - @Override - public Iterable apply( - TimelineObjectHolder input - ) - { - return Iterables.transform( + (TimelineObjectHolder input) -> + Iterables.transform( input.getObject(), - new Function, ImmutableSegmentLoadInfo>() - { - @Override - public ImmutableSegmentLoadInfo apply( - PartitionChunk chunk - ) - { - return chunk.getObject().toImmutableSegmentLoadInfo(); - } - } - ); - } - } + (PartitionChunk chunk) -> + chunk.getObject().toImmutableSegmentLoadInfo() + ) ); return Response.ok(retval).build(); }