/** * Copyright 2016 StreamSets Inc. * <p> * Licensed under the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.streamsets.pipeline.lib.httpsource; import com.streamsets.pipeline.api.BatchMaker; import com.streamsets.pipeline.api.OffsetCommitter; import com.streamsets.pipeline.api.Source; import com.streamsets.pipeline.api.StageException; import com.streamsets.pipeline.lib.http.HttpConfigs; import com.streamsets.pipeline.lib.http.HttpReceiver; public abstract class AbstractHttpServerSource<R extends HttpReceiver> extends AbstractHttpServerProtoSource<R, Source.Context> implements Source, OffsetCommitter { private long counter; public AbstractHttpServerSource(HttpConfigs httpConfigs, R receiver) { super(httpConfigs, receiver); } protected long getProduceSleepMillis() { return 1000; } @Override public String produce(String lastSourceOffset, int maxBatchSize, BatchMaker batchMaker) throws StageException { dispatchHttpReceiverErrors(getProduceSleepMillis()); return "::abstracthttpserversource::" + (counter++) + System.currentTimeMillis(); } @Override public void commit(String offset) throws StageException { } }