private static void checkRequired(Map<String, String> properties, String name) { if (!properties.containsKey(name)) { throw new FlumeException("Required parameter not found " + name); } }
@Override public byte[] getBody() { if (body != null) { try { return body.getBytes(charset); } catch (UnsupportedEncodingException ex) { throw new FlumeException(String.format("%s encoding not supported", charset), ex); } } else { return new byte[0]; } }
@Override public Status appendBatch(List<ThriftFlumeEvent> events) throws TException { throw new FlumeException("Forced Error"); } }
private TServerTransport getTServerTransport() { try { return new TServerSocket(new InetSocketAddress(bindAddress, port)); } catch (Throwable throwable) { throw new FlumeException("Cannot start Thrift source.", throwable); } }
private TailFile openFile(File file, Map<String, String> headers, long inode, long pos) { try { logger.info("Opening file: " + file + ", inode: " + inode + ", pos: " + pos); return new TailFile(file, headers, inode, pos); } catch (IOException e) { throw new FlumeException("Failed opening file: " + file, e); } }
private void callSuperClassOpen() throws FlumeException { try { super.open(); } catch (TTransportException e) { throw new FlumeException("Failed to open SASL transport", e); } } }
@Override public Status append(ThriftFlumeEvent event) throws TException { throw new FlumeException("Forced Error"); }
@Override public Channel create(String name, String type) throws FlumeException { Preconditions.checkNotNull(name, "name"); Preconditions.checkNotNull(type, "type"); logger.info("Creating instance of channel {} type {}", name, type); Class<? extends Channel> channelClass = getClass(type); try { return channelClass.newInstance(); } catch (Exception ex) { throw new FlumeException("Unable to create channel: " + name + ", type: " + type + ", class: " + channelClass.getName(), ex); } }
public static ConfigFilter create(String name, String type) throws FlumeException { Preconditions.checkNotNull(name, "name"); Preconditions.checkNotNull(type, "type"); LOGGER.info("Creating instance of configfilter {}, type {}", name, type); Class<? extends ConfigFilter> aClass = getClass(type); try { ConfigFilter configFilter = aClass.newInstance(); configFilter.setName(name); return configFilter; } catch (Exception ex) { throw new FlumeException("Unable to create configfilter: " + name + ", type: " + type + ", class: " + aClass.getName(), ex); } }
@Override protected synchronized void doStart() { try { consumer = createConsumer(); jmsExceptionCounter = 0; sourceCounter.start(); } catch (JMSException e) { throw new FlumeException("Unable to create consumer", e); } }
@Override public Status append(ThriftFlumeEvent event) throws TException { try { TimeUnit.MILLISECONDS.sleep(1550); } catch (InterruptedException e) { throw new FlumeException("Error", e); } return super.append(event); }
@Override public Status appendBatch(List<ThriftFlumeEvent> events) throws TException { try { TimeUnit.MILLISECONDS.sleep(5000); } catch (InterruptedException e) { throw new FlumeException("Error", e); } return super.appendBatch(events); } }
@Override public void configure(Context context) { conf = new SinkGroupConfiguration("sinkgrp"); try { conf.configure(context); } catch (ConfigurationException e) { throw new FlumeException("Invalid Configuration!", e); } configure(conf); }
@Override public Status appendBatch(List<ThriftFlumeEvent> events) throws TException { try { TimeUnit.MILLISECONDS.sleep(1550); } catch (InterruptedException e) { throw new FlumeException("Error", e); } return super.appendBatch(events); } }
@Override public Status appendBatch(List<ThriftFlumeEvent> events) throws TException { try { if (delay != null) { TimeUnit.MILLISECONDS.sleep(delay.get()); } } catch (InterruptedException e) { throw new FlumeException("Error", e); } return super.appendBatch(events); } }
@Override public Status append(ThriftFlumeEvent event) throws TException { try { TimeUnit.MILLISECONDS.sleep(5000); } catch (InterruptedException e) { throw new FlumeException("Error", e); } return super.append(event); }
@Override public Status append(ThriftFlumeEvent event) throws TException { try { if (delay != null) { TimeUnit.MILLISECONDS.sleep(delay.get()); } } catch (InterruptedException e) { throw new FlumeException("Error", e); } return super.append(event); }
@Override public void stop() { try { if (table != null) { table.close(); } table = null; } catch (IOException e) { throw new FlumeException("Error closing table.", e); } sinkCounter.incrementConnectionClosedCount(); sinkCounter.stop(); }
@Override public synchronized void append(LoggingEvent event) { if (!configured) { String errorMsg = "Flume Log4jAppender not configured correctly! Cannot" + " send events to Flume."; LogLog.error(errorMsg); if (getUnsafeMode()) { return; } throw new FlumeException(errorMsg); } super.append(event); }
public Status process() throws EventDeliveryException { Exception exception = getStartException(); if (exception != null) { throw new FlumeException("Source had error configuring or starting", exception); } if (!isStarted()) { throw new EventDeliveryException("Source is not started. It is in '" + getLifecycleState() + "' state"); } return doProcess(); }