Search in sources :

Example 1 with FlumeException

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();
}
Also used : FlumeException(org.apache.flume.FlumeException) InetSocketAddress(java.net.InetSocketAddress) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress)

Example 2 with FlumeException

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();
}
Also used : FlumeException(org.apache.flume.FlumeException) FlumeException(org.apache.flume.FlumeException) EventDeliveryException(org.apache.flume.EventDeliveryException)

Aggregations

FlumeException (org.apache.flume.FlumeException)2 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1 EventDeliveryException (org.apache.flume.EventDeliveryException)1