Coord resource throws NPE when segments are requested (#4759)

This commit is contained in:
Niketh Sabbineni 2017-10-02 10:13:27 -07:00 committed by Gian Merlino
parent ee7eaccbab
commit 3e9391433d
1 changed files with 18 additions and 57 deletions

View File

@ -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<DruidDataSource, Map<String, Object>>()
{
@Override
public Map<String, Object> 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<DruidDataSource, String>()
{
@Override
public String apply(DruidDataSource dataSource)
{
return dataSource.getName();
}
}
(DruidDataSource dataSource) -> dataSource.getName()
)
)
).build();
@ -304,8 +289,11 @@ public class DatasourcesResource
}
Pair<DataSegment, Set<String>> val = getSegment(dataSegment.getIdentifier());
if (val != null) {
segments.put(dataSegment.getIdentifier(), ImmutableMap.of("metadata", val.lhs, "servers", val.rhs));
}
}
return Response.ok(retVal).build();
}
@ -367,9 +355,12 @@ public class DatasourcesResource
}
Pair<DataSegment, Set<String>> val = getSegment(dataSegment.getIdentifier());
if (val != null) {
segments.put(dataSegment.getIdentifier(), ImmutableMap.of("metadata", val.lhs, "servers", val.rhs));
}
}
}
return Response.ok(retVal).build();
}
@ -427,14 +418,7 @@ public class DatasourcesResource
return builder.entity(
Iterables.transform(
dataSource.getSegments(),
new Function<DataSegment, Object>()
{
@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<DruidServer, DruidDataSource>()
{
@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.<String, String>of()
ImmutableMap.of()
).addSegments(segmentMap);
}
@ -672,28 +649,12 @@ public class DatasourcesResource
Iterable<TimelineObjectHolder<String, SegmentLoadInfo>> lookup = timeline.lookupWithIncompletePartitions(theInterval);
FunctionalIterable<ImmutableSegmentLoadInfo> retval = FunctionalIterable
.create(lookup).transformCat(
new Function<TimelineObjectHolder<String, SegmentLoadInfo>, Iterable<ImmutableSegmentLoadInfo>>()
{
@Override
public Iterable<ImmutableSegmentLoadInfo> apply(
TimelineObjectHolder<String, SegmentLoadInfo> input
)
{
return Iterables.transform(
(TimelineObjectHolder<String, SegmentLoadInfo> input) ->
Iterables.transform(
input.getObject(),
new Function<PartitionChunk<SegmentLoadInfo>, ImmutableSegmentLoadInfo>()
{
@Override
public ImmutableSegmentLoadInfo apply(
PartitionChunk<SegmentLoadInfo> chunk
(PartitionChunk<SegmentLoadInfo> chunk) ->
chunk.getObject().toImmutableSegmentLoadInfo()
)
{
return chunk.getObject().toImmutableSegmentLoadInfo();
}
}
);
}
}
);
return Response.ok(retval).build();
}