Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright (C) FuseSource, Inc.
* http://fusesource.com
*
* Licensed 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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 org.fusesource.fabric.stream.log;
import org.apache.camel.*;
import org.apache.camel.impl.DefaultComponent;
import org.apache.camel.impl.DefaultConsumer;
import org.apache.camel.impl.DefaultEndpoint;
import org.apache.camel.impl.DefaultMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
/**
*
*
*
* @author Hiram Chirino
*/
public class InputBatcher extends DefaultComponent {
private static final transient Logger LOG = LoggerFactory.getLogger(InputBatcherConsumer.class);
public int batchSize = 1024*256;
public long batchTimeout = 1000;
public InputStream is = System.in;
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception {
return new InputBatcherEndpoint(uri, this);
}
class InputBatcherEndpoint extends DefaultEndpoint {
InputBatcherEndpoint(String endpointUri, Component component) {
super(endpointUri, component);
}
@Override
public boolean isSingleton() {
return true;
}
@Override
public Producer createProducer() throws Exception {
throw new UnsupportedOperationException("Producer not supported!");
}
@Override
public Consumer createConsumer(Processor processor) throws Exception {
return new InputBatcherConsumer(this, processor);
}
}
static final Object EOF = new Object();
class InputBatcherConsumer extends DefaultConsumer {
final ArrayBlockingQueue