Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge core CoordinatorClient with MSQ CoordinatorServiceClient. #14652

Merged
merged 6 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ private DataSegmentTimelineView makeDataSegmentTimelineView()
{
return (dataSource, intervals) -> {
final Collection<DataSegment> dataSegments =
context.coordinatorClient().fetchUsedSegmentsInDataSourceForIntervals(dataSource, intervals);
FutureUtils.getUnchecked(context.coordinatorClient().fetchUsedSegments(dataSource, intervals), true);

if (dataSegments.isEmpty()) {
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.apache.druid.msq.exec;

import com.google.errorprone.annotations.concurrent.GuardedBy;
import org.apache.druid.client.coordinator.CoordinatorClient;
import org.apache.druid.collections.ReferenceCountingResourceHolder;
import org.apache.druid.collections.ResourceHolder;
import org.apache.druid.common.guava.FutureUtils;
Expand All @@ -28,7 +29,6 @@
import org.apache.druid.java.util.common.io.Closer;
import org.apache.druid.msq.counters.ChannelCounters;
import org.apache.druid.msq.querykit.DataSegmentProvider;
import org.apache.druid.msq.rpc.CoordinatorServiceClient;
import org.apache.druid.segment.IndexIO;
import org.apache.druid.segment.QueryableIndex;
import org.apache.druid.segment.QueryableIndexSegment;
Expand All @@ -52,13 +52,13 @@
*/
public class TaskDataSegmentProvider implements DataSegmentProvider
{
private final CoordinatorServiceClient coordinatorClient;
private final CoordinatorClient coordinatorClient;
private final SegmentCacheManager segmentCacheManager;
private final IndexIO indexIO;
private final ConcurrentHashMap<SegmentId, SegmentHolder> holders;

public TaskDataSegmentProvider(
CoordinatorServiceClient coordinatorClient,
CoordinatorClient coordinatorClient,
SegmentCacheManager segmentCacheManager,
IndexIO indexIO
)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.apache.druid.msq.indexing.client.WorkerChatHandler;
import org.apache.druid.msq.kernel.FrameContext;
import org.apache.druid.msq.kernel.QueryDefinition;
import org.apache.druid.msq.rpc.CoordinatorServiceClient;
import org.apache.druid.rpc.ServiceClientFactory;
import org.apache.druid.rpc.ServiceLocations;
import org.apache.druid.rpc.ServiceLocator;
Expand Down Expand Up @@ -95,8 +94,6 @@ public IndexerWorkerContext(
public static IndexerWorkerContext createProductionInstance(final TaskToolbox toolbox, final Injector injector)
{
final IndexIO indexIO = injector.getInstance(IndexIO.class);
final CoordinatorServiceClient coordinatorServiceClient =
injector.getInstance(CoordinatorServiceClient.class).withRetryPolicy(StandardRetryPolicy.unlimited());
final SegmentCacheManager segmentCacheManager =
injector.getInstance(SegmentCacheManagerFactory.class)
.manufacturate(new File(toolbox.getIndexingTmpDir(), "segment-fetch"));
Expand All @@ -107,7 +104,7 @@ public static IndexerWorkerContext createProductionInstance(final TaskToolbox to
toolbox,
injector,
indexIO,
new TaskDataSegmentProvider(coordinatorServiceClient, segmentCacheManager, indexIO),
new TaskDataSegmentProvider(toolbox.getCoordinatorClient(), segmentCacheManager, indexIO),
serviceClientFactory
);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
org.apache.druid.msq.guice.MSQExternalDataSourceModule
org.apache.druid.msq.guice.MSQIndexingModule
org.apache.druid.msq.guice.MSQDurableStorageModule
org.apache.druid.msq.guice.MSQServiceClientModule
org.apache.druid.msq.guice.MSQSqlModule
org.apache.druid.msq.guice.SqlTaskModule
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import org.apache.druid.client.coordinator.NoopCoordinatorClient;
import org.apache.druid.collections.ResourceHolder;
import org.apache.druid.collections.bitmap.BitmapFactory;
import org.apache.druid.collections.bitmap.RoaringBitmapFactory;
Expand All @@ -41,8 +42,6 @@
import org.apache.druid.java.util.common.jackson.JacksonUtils;
import org.apache.druid.java.util.emitter.EmittingLogger;
import org.apache.druid.msq.counters.ChannelCounters;
import org.apache.druid.msq.rpc.CoordinatorServiceClient;
import org.apache.druid.rpc.ServiceRetryPolicy;
import org.apache.druid.segment.DimensionHandler;
import org.apache.druid.segment.IndexIO;
import org.apache.druid.segment.Metadata;
Expand Down Expand Up @@ -149,7 +148,7 @@ public void setUp() throws Exception
);

provider = new TaskDataSegmentProvider(
new TestCoordinatorServiceClientImpl(),
new TestCoordinatorClientImpl(),
cacheManager,
indexIO
);
Expand Down Expand Up @@ -229,7 +228,7 @@ public void testConcurrency()
Assert.assertArrayEquals(new String[]{}, cacheDir.list());
}

private class TestCoordinatorServiceClientImpl implements CoordinatorServiceClient
private class TestCoordinatorClientImpl extends NoopCoordinatorClient
{
@Override
public ListenableFuture<DataSegment> fetchUsedSegment(String dataSource, String segmentId)
Expand All @@ -242,12 +241,6 @@ public ListenableFuture<DataSegment> fetchUsedSegment(String dataSource, String

return Futures.immediateFailedFuture(new ISE("No such segment[%s] for dataSource[%s]", segmentId, dataSource));
}

@Override
public CoordinatorServiceClient withRetryPolicy(ServiceRetryPolicy retryPolicy)
{
return this;
}
}

@JsonTypeName("test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,18 @@ public MSQTestControllerContext(
this.injector = injector;
this.taskActionClient = taskActionClient;
coordinatorClient = Mockito.mock(CoordinatorClient.class);
Mockito.when(coordinatorClient.fetchUsedSegmentsInDataSourceForIntervals(
Mockito.when(coordinatorClient.fetchUsedSegments(
ArgumentMatchers.anyString(),
ArgumentMatchers.anyList()
)
).thenAnswer(invocation ->
(injector.getInstance(SpecificSegmentsQuerySegmentWalker.class)
.getSegments()
.stream()
.filter(dataSegment -> dataSegment.getDataSource().equals(invocation.getArguments()[0]))
.collect(Collectors.toList())
Futures.immediateFuture(
injector.getInstance(SpecificSegmentsQuerySegmentWalker.class)
.getSegments()
.stream()
.filter(dataSegment -> dataSegment.getDataSource()
.equals(invocation.getArguments()[0]))
.collect(Collectors.toList())
)
);
this.workerMemoryParameters = workerMemoryParameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.druid.java.util.metrics.MonitorScheduler;
import org.apache.druid.query.QueryProcessingPool;
import org.apache.druid.query.QueryRunnerFactoryConglomerate;
import org.apache.druid.rpc.StandardRetryPolicy;
import org.apache.druid.rpc.indexing.OverlordClient;
import org.apache.druid.segment.IndexIO;
import org.apache.druid.segment.IndexMergerV9Factory;
Expand Down Expand Up @@ -245,8 +246,11 @@ public TaskToolbox build(TaskConfig config, Task task)
.chatHandlerProvider(chatHandlerProvider)
.rowIngestionMetersFactory(rowIngestionMetersFactory)
.appenderatorsManager(appenderatorsManager)
.overlordClient(overlordClient)
.coordinatorClient(coordinatorClient)
// Most tasks are written in such a way that if an Overlord or Coordinator RPC fails, the task fails.
// Set the retry policy to "about an hour", so tasks are resilient to brief Coordinator/Overlord problems.
// Calls will still eventually fail if problems persist.
.overlordClient(overlordClient.withRetryPolicy(StandardRetryPolicy.aboutAnHour()))
.coordinatorClient(coordinatorClient.withRetryPolicy(StandardRetryPolicy.aboutAnHour()))
.supervisorTaskClientProvider(supervisorTaskClientProvider)
.shuffleClient(shuffleClient)
.taskLogPusher(taskLogPusher)
Expand Down
Loading