use of org.apache.flume.FlumeException in project MSEC by Tencent.
the class ProtobufSource method start.
@Override
public void start() {
logger.info("Source starting");
counterGroup.incrementAndGet("open.attempts");
handlerService = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("protobuf-handler-%d").build());
try {
SocketAddress bindPoint = new InetSocketAddress(hostName, port);
serverSocket = ServerSocketChannel.open();
serverSocket.socket().setReuseAddress(true);
serverSocket.socket().bind(bindPoint);
logger.info("Created serverSocket:{}", serverSocket);
} catch (IOException e) {
counterGroup.incrementAndGet("open.errors");
logger.error("Unable to bind to socket. Exception follows.", e);
throw new FlumeException(e);
}
AcceptHandler acceptRunnable = new AcceptHandler();
acceptThreadShouldStop.set(false);
acceptRunnable.counterGroup = counterGroup;
acceptRunnable.handlerService = handlerService;
acceptRunnable.shouldStop = acceptThreadShouldStop;
acceptRunnable.source = this;
acceptRunnable.serverSocket = serverSocket;
acceptThread = new Thread(acceptRunnable);
acceptThread.start();
logger.debug("Source started");
super.start();
}
use of org.apache.flume.FlumeException in project ignite by apache.
the class IgniteSink method start.
/**
* Starts a grid and initializes an event transformer.
*/
@SuppressWarnings("unchecked")
@Override
public synchronized void start() {
A.notNull(springCfgPath, "Ignite config file");
A.notNull(cacheName, "Cache name");
A.notNull(eventTransformerCls, "Event transformer class");
sinkCounter.start();
try {
if (ignite == null)
ignite = Ignition.start(springCfgPath);
if (eventTransformerCls != null && !eventTransformerCls.isEmpty()) {
Class<? extends EventTransformer> clazz = (Class<? extends EventTransformer<Event, Object, Object>>) Class.forName(eventTransformerCls);
eventTransformer = clazz.newInstance();
}
} catch (Exception e) {
log.error("Failed to start grid", e);
sinkCounter.incrementConnectionFailedCount();
throw new FlumeException("Failed to start grid", e);
}
sinkCounter.incrementConnectionCreatedCount();
super.start();
}
Aggregations