当前位置: 首页>>代码示例>>Java>>正文


Java FlumeException类代码示例

本文整理汇总了Java中org.apache.flume.FlumeException的典型用法代码示例。如果您正苦于以下问题:Java FlumeException类的具体用法?Java FlumeException怎么用?Java FlumeException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FlumeException类属于org.apache.flume包,在下文中一共展示了FlumeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getClient

import org.apache.flume.FlumeException; //导入依赖的package包/类
private synchronized RpcClient getClient(HostInfo info)
    throws FlumeException, EventDeliveryException {
  throwIfClosed();
  String name = info.getReferenceName();
  RpcClient client = clientMap.get(name);
  if (client == null) {
    client = createClient(name);
    clientMap.put(name, client);
  } else if (!client.isActive()) {
    try {
      client.close();
    } catch (Exception ex) {
      LOGGER.warn("Failed to close client for " + info, ex);
    }
    client = createClient(name);
    clientMap.put(name, client);
  }

  return client;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:21,代码来源:LoadBalancingRpcClient.java

示例2: createSSLContext

import org.apache.flume.FlumeException; //导入依赖的package包/类
/**
 * Lifted from ACCUMULO-3318 - Lifted from TSSLTransportFactory in Thrift-0.9.1.
 * The method to create a client socket with an SSLContextFactory object is not visible to us.
 * Have to use * SslConnectionParams instead of TSSLTransportParameters because no getters exist
 * on TSSLTransportParameters.
 */
private static SSLContext createSSLContext(String truststore,
                                           String truststorePassword,
                                           String truststoreType) throws FlumeException {
  SSLContext ctx;
  try {
    ctx = SSLContext.getInstance("TLS");
    TrustManagerFactory tmf;
    tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
    KeyStore ts = null;
    if (truststore != null && truststoreType != null) {
      ts = KeyStore.getInstance(truststoreType);
      ts.load(new FileInputStream(truststore), truststorePassword.toCharArray());
      tmf.init(ts);
    }

    tmf.init(ts);
    ctx.init(null, tmf.getTrustManagers(), null);

  } catch (Exception e) {
    throw new FlumeException("Error creating the transport", e);
  }
  return ctx;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:30,代码来源:ThriftRpcClient.java

示例3: createSSLSocket

import org.apache.flume.FlumeException; //导入依赖的package包/类
private static TSocket createSSLSocket(SSLSocketFactory factory, String host,
                                       int port, int timeout, List<String> excludeProtocols)
    throws FlumeException {
  try {
    SSLSocket socket = (SSLSocket) factory.createSocket(host, port);
    socket.setSoTimeout(timeout);

    List<String> enabledProtocols = new ArrayList<String>();
    for (String protocol : socket.getEnabledProtocols()) {
      if (!excludeProtocols.contains(protocol)) {
        enabledProtocols.add(protocol);
      }
    }
    socket.setEnabledProtocols(enabledProtocols.toArray(new String[0]));
    return new TSocket(socket);
  } catch (Exception e) {
    throw new FlumeException("Could not connect to " + host + " on port " + port, e);
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:20,代码来源:ThriftRpcClient.java

示例4: reflectHflushOrSync

import org.apache.flume.FlumeException; //导入依赖的package包/类
private Method reflectHflushOrSync(FSDataOutputStream os) {
  Method m = null;
  if (os != null) {
    Class<?> fsDataOutputStreamClass = os.getClass();
    try {
      m = fsDataOutputStreamClass.getMethod("hflush");
    } catch (NoSuchMethodException ex) {
      logger.debug("HFlush not found. Will use sync() instead");
      try {
        m = fsDataOutputStreamClass.getMethod("sync");
      } catch (Exception ex1) {
        String msg = "Neither hflush not sync were found. That seems to be " +
            "a problem!";
        logger.error(msg);
        throw new FlumeException(msg, ex1);
      }
    }
  }
  return m;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:21,代码来源:AbstractHDFSWriter.java

示例5: start

import org.apache.flume.FlumeException; //导入依赖的package包/类
/**
 * Start this server, causing it to poll JMX at the configured frequency.
 */
@Override
public void start() {
  try {
    socket = new DatagramSocket();
    hostname = InetAddress.getLocalHost().getHostName();
  } catch (SocketException ex) {
    logger.error("Could not create socket for metrics collection.");
    throw new FlumeException(
            "Could not create socket for metrics collection.", ex);
  } catch (Exception ex2) {
    logger.warn("Unknown error occured", ex2);
  }
  for (HostInfo host : hosts) {
    addresses.add(new InetSocketAddress(
            host.getHostName(), host.getPortNumber()));
  }
  collectorRunnable.server = this;
  if (service.isShutdown() || service.isTerminated()) {
    service = Executors.newSingleThreadScheduledExecutor();
  }
  service.scheduleWithFixedDelay(collectorRunnable, 0,
          pollFrequency, TimeUnit.SECONDS);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:27,代码来源:GangliaServer.java

示例6: testThreeParamBatchAppend

import org.apache.flume.FlumeException; //导入依赖的package包/类
@Test
public void testThreeParamBatchAppend() throws FlumeException,
    EventDeliveryException {
  int batchSize = 7;
  RpcClient client = null;
  Server server = RpcTestUtils.startServer(new OKAvroHandler());
  try {
    client = RpcClientFactory.getDefaultInstance(localhost, server.getPort(),
        batchSize);

    List<Event> events = new ArrayList<Event>();
    for (int i = 0; i < batchSize; i++) {
      events.add(EventBuilder.withBody("evt: " + i, Charset.forName("UTF8")));
    }
    client.appendBatch(events);
  } finally {
    RpcTestUtils.stopServer(server);
    if (client != null) client.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:21,代码来源:TestRpcClientFactory.java

示例7: testPropertiesBatchAppend

import org.apache.flume.FlumeException; //导入依赖的package包/类
@Test
public void testPropertiesBatchAppend() throws FlumeException,
    EventDeliveryException {
  int batchSize = 7;
  RpcClient client = null;
  Server server = RpcTestUtils.startServer(new OKAvroHandler());
  try {
    Properties p = new Properties();
    p.put("hosts", "host1");
    p.put("hosts.host1", localhost + ":" + String.valueOf(server.getPort()));
    p.put("batch-size", String.valueOf(batchSize));
    client = RpcClientFactory.getInstance(p);
    List<Event> events = new ArrayList<Event>();
    for (int i = 0; i < batchSize; i++) {
      events.add(EventBuilder.withBody("evt: " + i, Charset.forName("UTF8")));
    }
    client.appendBatch(events);
  } finally {
    RpcTestUtils.stopServer(server);
    if (client != null) client.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:23,代码来源:TestRpcClientFactory.java

示例8: testTwoParamBatchAppendOverflow

import org.apache.flume.FlumeException; //导入依赖的package包/类
@Test
public void testTwoParamBatchAppendOverflow() throws FlumeException,
    EventDeliveryException {
  RpcClient client = null;
  Server server = RpcTestUtils.startServer(new OKAvroHandler());
  try {
    client = RpcClientFactory.getDefaultInstance(localhost, server.getPort());
    int batchSize = client.getBatchSize();
    int moreThanBatch = batchSize + 1;
    List<Event> events = new ArrayList<Event>();
    for (int i = 0; i < moreThanBatch; i++) {
      events.add(EventBuilder.withBody("evt: " + i, Charset.forName("UTF8")));
    }
    client.appendBatch(events);
  } finally {
    RpcTestUtils.stopServer(server);
    if (client != null) client.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:20,代码来源:TestRpcClientFactory.java

示例9: testCreatingLbClientSingleHost

import org.apache.flume.FlumeException; //导入依赖的package包/类
@Test(expected = FlumeException.class)
public void testCreatingLbClientSingleHost() {
  Server server1 = null;
  RpcClient c = null;
  try {
    server1 = RpcTestUtils.startServer(new OKAvroHandler());
    Properties p = new Properties();
    p.put("host1", "127.0.0.1:" + server1.getPort());
    p.put("hosts", "host1");
    p.put("client.type", "default_loadbalance");
    RpcClientFactory.getInstance(p);
  } finally {
    if (server1 != null) server1.close();
    if (c != null) c.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:17,代码来源:TestLoadBalancingRpcClient.java

示例10: handlerSimpleAppendTest

import org.apache.flume.FlumeException; //导入依赖的package包/类
/**
 * Helper method for testing simple (single) with compression level 6 appends on handlers
 * @param handler
 * @throws FlumeException
 * @throws EventDeliveryException
 */
public static void handlerSimpleAppendTest(AvroSourceProtocol handler,
                                           boolean enableServerCompression,
                                           boolean enableClientCompression, int compressionLevel)
    throws FlumeException, EventDeliveryException {
  NettyAvroRpcClient client = null;
  Server server = startServer(handler, 0, enableServerCompression);
  try {
    Properties starterProp = new Properties();
    if (enableClientCompression) {
      starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_COMPRESSION_TYPE, "deflate");
      starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_COMPRESSION_LEVEL,
                              "" + compressionLevel);
    } else {
      starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_COMPRESSION_TYPE, "none");
    }
    client = getStockLocalClient(server.getPort(), starterProp);
    boolean isActive = client.isActive();
    Assert.assertTrue("Client should be active", isActive);
    client.append(EventBuilder.withBody("wheee!!!", Charset.forName("UTF8")));
  } finally {
    stopServer(server);
    if (client != null) client.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:31,代码来源:RpcTestUtils.java

示例11: activateOptions

import org.apache.flume.FlumeException; //导入依赖的package包/类
/**
 * Activate the options set using <tt>setHosts()</tt>, <tt>setSelector</tt>
 * and <tt>setMaxBackoff</tt>
 *
 * @throws FlumeException
 *           if the LoadBalancingRpcClient cannot be instantiated.
 */
@Override
public void activateOptions() throws FlumeException {
  try {
    final Properties properties = getProperties(hosts, selector, maxBackoff, getTimeout());
    rpcClient = RpcClientFactory.getInstance(properties);
    if (layout != null) {
      layout.activateOptions();
    }
    configured = true;
  } catch (Exception e) {
    String errormsg = "RPC client creation failed! " + e.getMessage();
    LogLog.error(errormsg);
    if (getUnsafeMode()) {
      return;
    }
    throw new FlumeException(e);
  }

}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:27,代码来源:LoadBalancingLog4jAppender.java

示例12: close

import org.apache.flume.FlumeException; //导入依赖的package包/类
/**
 * Closes underlying client.
 * If <tt>append()</tt> is called after this function is called,
 * it will throw an exception.
 * @throws FlumeException if errors occur during close
 */
@Override
public synchronized void close() throws FlumeException {
  // Any append calls after this will result in an Exception.
  if (rpcClient != null) {
    try {
      rpcClient.close();
    } catch (FlumeException ex) {
      LogLog.error("Error while trying to close RpcClient.", ex);
      if (unsafeMode) {
        return;
      }
      throw ex;
    } finally {
      rpcClient = null;
    }
  } else {
    String errorMsg = "Flume log4jappender already closed!";
    LogLog.error(errorMsg);
    if (unsafeMode) {
      return;
    }
    throw new FlumeException(errorMsg);
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:31,代码来源:Log4jAppender.java

示例13: validate

import org.apache.flume.FlumeException; //导入依赖的package包/类
private static void validate(String name,
    Map<String, String> properties) throws FlumeException {

  if (properties.containsKey(SOURCE_TYPE)) {
    checkAllowed(ALLOWED_SOURCES, properties.get(SOURCE_TYPE));
  }
  checkRequired(properties, CHANNEL_TYPE);
  checkAllowed(ALLOWED_CHANNELS, properties.get(CHANNEL_TYPE));
  checkRequired(properties, SINKS);
  String sinkNames = properties.get(SINKS);
  for (String sink : sinkNames.split("\\s+")) {
    if (DISALLOWED_SINK_NAMES.contains(sink.toLowerCase(Locale.ENGLISH))) {
      throw new FlumeException("Sink name " + sink + " is one of the" +
          " disallowed sink names: " + DISALLOWED_SINK_NAMES);
    }
    String key = join(sink, TYPE);
    checkRequired(properties, key);
    checkAllowed(ALLOWED_SINKS, properties.get(key));
  }
  checkRequired(properties, SINK_PROCESSOR_TYPE);
  checkAllowed(ALLOWED_SINK_PROCESSORS, properties.get(SINK_PROCESSOR_TYPE));
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:23,代码来源:EmbeddedAgentConfiguration.java

示例14: getHostsFromString

import org.apache.flume.FlumeException; //导入依赖的package包/类
private List<HostInfo> getHostsFromString(String hosts)
        throws FlumeException {
  List<HostInfo> hostInfoList = new ArrayList<HostInfo>();
  String[] hostsAndPorts = hosts.split(",");
  int i = 0;
  for (String host : hostsAndPorts) {
    String[] hostAndPort = host.split(":");
    if (hostAndPort.length < 2) {
      logger.warn("Invalid ganglia host: ", host);
      continue;
    }
    try {
      hostInfoList.add(new HostInfo("ganglia_host-" + String.valueOf(i),
              hostAndPort[0], Integer.parseInt(hostAndPort[1])));
    } catch (Exception e) {
      logger.warn("Invalid ganglia host: " + host, e);
      continue;
    }
  }
  if (hostInfoList.isEmpty()) {
    throw new FlumeException("No valid ganglia hosts defined!");
  }
  return hostInfoList;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:25,代码来源:GangliaServer.java

示例15: reflectHflushOrSync

import org.apache.flume.FlumeException; //导入依赖的package包/类
private Method reflectHflushOrSync(FSDataOutputStream os) {
  Method m = null;
  if(os != null) {
    Class<?> fsDataOutputStreamClass = os.getClass();
    try {
      m = fsDataOutputStreamClass.getMethod("hflush");
    } catch (NoSuchMethodException ex) {
      logger.debug("HFlush not found. Will use sync() instead");
      try {
        m = fsDataOutputStreamClass.getMethod("sync");
      } catch (Exception ex1) {
        String msg = "Neither hflush not sync were found. That seems to be " +
          "a problem!";
        logger.error(msg);
        throw new FlumeException(msg, ex1);
      }
    }
  }
  return m;
}
 
开发者ID:Transwarp-DE,项目名称:Transwarp-Sample-Code,代码行数:21,代码来源:AbstractHDFSWriter.java


注:本文中的org.apache.flume.FlumeException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。