Search in sources :

Example 1 with SourceSplitRequest

use of com.google.api.services.dataflow.model.SourceSplitRequest in project beam by apache.

the class SourceOperationExecutorFactoryTest method testCreateDefault.

@Test
public void testCreateDefault() throws Exception {
    SourceOperationRequest request = new SourceOperationRequest().setName("name").setOriginalName("original").setSystemName("system").setStageName("stage").setSplit(new SourceSplitRequest());
    DataflowOperationContext mockOperation = Mockito.mock(DataflowOperationContext.class);
    Mockito.when(executionContext.createOperationContext(Mockito.isA(NameContext.class))).thenReturn(mockOperation);
    SourceOperationExecutor sourceOperationExecutor = SourceOperationExecutorFactory.create(PipelineOptionsFactory.create(), request, null, executionContext, "STAGE");
    assertThat(sourceOperationExecutor, instanceOf(WorkerCustomSourceOperationExecutor.class));
}
Also used : SourceOperationRequest(com.google.api.services.dataflow.model.SourceOperationRequest) NameContext(org.apache.beam.runners.dataflow.worker.counters.NameContext) SourceSplitRequest(com.google.api.services.dataflow.model.SourceSplitRequest) Test(org.junit.Test)

Example 2 with SourceSplitRequest

use of com.google.api.services.dataflow.model.SourceSplitRequest in project beam by apache.

the class NoOpSourceOperationExecutorTest method setUp.

@Before
public void setUp() {
    SourceSplitRequest splitRequest = new SourceSplitRequest();
    SourceOperationRequest operationRequest = new SourceOperationRequest().setSplit(splitRequest);
    executor = new NoOpSourceOperationExecutor(operationRequest);
}
Also used : SourceOperationRequest(com.google.api.services.dataflow.model.SourceOperationRequest) SourceSplitRequest(com.google.api.services.dataflow.model.SourceSplitRequest) Before(org.junit.Before)

Example 3 with SourceSplitRequest

use of com.google.api.services.dataflow.model.SourceSplitRequest in project beam by apache.

the class WorkerCustomSourceOperationExecutor method execute.

@Override
public void execute() throws Exception {
    LOG.debug("Executing source operation");
    try (Closeable stateTrackerCloser = executionStateTracker.activate()) {
        try (Closeable stateCloser = executionStateTracker.enterState(executionState)) {
            SourceSplitRequest split = request.getSplit();
            if (split != null) {
                this.response = WorkerCustomSources.performSplit(split, options);
            } else {
                throw new UnsupportedOperationException("Unsupported source operation request: " + request);
            }
        }
    }
    LOG.debug("Source operation execution complete");
}
Also used : Closeable(java.io.Closeable) SourceSplitRequest(com.google.api.services.dataflow.model.SourceSplitRequest)

Example 4 with SourceSplitRequest

use of com.google.api.services.dataflow.model.SourceSplitRequest in project beam by apache.

the class WorkerCustomSourcesTest method performSplit.

static SourceSplitResponse performSplit(com.google.api.services.dataflow.model.Source source, PipelineOptions options, @Nullable Long desiredBundleSizeBytes, @Nullable Integer numBundlesLimitForTest, @Nullable Long apiByteLimitForTest) throws Exception {
    SourceSplitRequest splitRequest = new SourceSplitRequest();
    splitRequest.setSource(source);
    if (desiredBundleSizeBytes != null) {
        splitRequest.setOptions(new SourceSplitOptions().setDesiredBundleSizeBytes(desiredBundleSizeBytes));
    }
    SourceOperationResponse response = WorkerCustomSources.performSplitWithApiLimit(splitRequest, options, MoreObjects.firstNonNull(numBundlesLimitForTest, WorkerCustomSources.DEFAULT_NUM_BUNDLES_LIMIT), MoreObjects.firstNonNull(apiByteLimitForTest, WorkerCustomSources.DATAFLOW_SPLIT_RESPONSE_API_SIZE_LIMIT));
    return response.getSplit();
}
Also used : SourceSplitOptions(com.google.api.services.dataflow.model.SourceSplitOptions) SourceSplitRequest(com.google.api.services.dataflow.model.SourceSplitRequest) SourceOperationResponse(com.google.api.services.dataflow.model.SourceOperationResponse)

Aggregations

SourceSplitRequest (com.google.api.services.dataflow.model.SourceSplitRequest)4 SourceOperationRequest (com.google.api.services.dataflow.model.SourceOperationRequest)2 SourceOperationResponse (com.google.api.services.dataflow.model.SourceOperationResponse)1 SourceSplitOptions (com.google.api.services.dataflow.model.SourceSplitOptions)1 Closeable (java.io.Closeable)1 NameContext (org.apache.beam.runners.dataflow.worker.counters.NameContext)1 Before (org.junit.Before)1 Test (org.junit.Test)1