本文整理汇总了Java中org.apache.flume.api.RpcClientConfigurationConstants类的典型用法代码示例。如果您正苦于以下问题:Java RpcClientConfigurationConstants类的具体用法?Java RpcClientConfigurationConstants怎么用?Java RpcClientConfigurationConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RpcClientConfigurationConstants类属于org.apache.flume.api包,在下文中一共展示了RpcClientConfigurationConstants类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeRpcClient
import org.apache.flume.api.RpcClientConfigurationConstants; //导入依赖的package包/类
@Override
protected RpcClient initializeRpcClient(Properties props) {
// Only one thread is enough, since only one sink thread processes
// transactions at any given time. Each sink owns its own Rpc client.
props.setProperty(RpcClientConfigurationConstants.CONFIG_CONNECTION_POOL_SIZE,
String.valueOf(1));
boolean enableKerberos = Boolean.parseBoolean(
props.getProperty(RpcClientConfigurationConstants.KERBEROS_KEY, "false"));
if (enableKerberos) {
return SecureRpcClientFactory.getThriftInstance(props);
} else {
props.setProperty(RpcClientConfigurationConstants.CONFIG_CLIENT_TYPE,
RpcClientFactory.ClientType.THRIFT.name());
return RpcClientFactory.getInstance(props);
}
}
示例2: activateOptions
import org.apache.flume.api.RpcClientConfigurationConstants; //导入依赖的package包/类
/**
* Activate the options set using <tt>setPort()</tt>
* and <tt>setHostname()</tt>
*
* @throws FlumeException if the <tt>hostname</tt> and
* <tt>port</tt> combination is invalid.
*/
@Override
public void activateOptions() throws FlumeException {
Properties props = new Properties();
props.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS, "h1");
props.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS_PREFIX + "h1",
hostname + ":" + port);
props.setProperty(RpcClientConfigurationConstants.CONFIG_CONNECT_TIMEOUT,
String.valueOf(timeout));
props.setProperty(RpcClientConfigurationConstants.CONFIG_REQUEST_TIMEOUT,
String.valueOf(timeout));
try {
rpcClient = RpcClientFactory.getInstance(props);
if (layout != null) {
layout.activateOptions();
}
} catch (FlumeException e) {
String errormsg = "RPC client creation failed! " + e.getMessage();
LogLog.error(errormsg);
if (unsafeMode) {
return;
}
throw e;
}
}
示例3: setProperties
import org.apache.flume.api.RpcClientConfigurationConstants; //导入依赖的package包/类
/**
* set the properties for the RPC connection. There are many
* more properties than are reflected here. See
* RpcClientConfiguratonConstants for more info.
*/
private void setProperties() {
/* this is the default for NiOClientSocketChannelFactory, which is
* called by NettyAvroRpcClient which is called from the
* RpcClientFactory. Setting it explicitly here to avoid a warning
* message that would otherwise be printed. We shouldn't really
* have to do this. :-)
*/
int maxIoWorkers = Runtime.getRuntime().availableProcessors() * 2;
rpcProperties = new Properties();
rpcProperties.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS, "h1");
rpcProperties.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS_PREFIX + "h1",
hostname + ":" + port);
rpcProperties.setProperty(RpcClientConfigurationConstants.CONFIG_BATCH_SIZE,
String.valueOf(rpcBatchSize));
rpcProperties.setProperty(RpcClientConfigurationConstants.MAX_IO_WORKERS,
String.valueOf(maxIoWorkers));
}
示例4: setUp
import org.apache.flume.api.RpcClientConfigurationConstants; //导入依赖的package包/类
@Before
public void setUp() {
port = random.nextInt(50000) + 1024;
props.clear();
props.setProperty("hosts", "h1");
props.setProperty("hosts.h1", "0.0.0.0:" + String.valueOf(port));
props.setProperty(RpcClientConfigurationConstants.CONFIG_BATCH_SIZE, "10");
props.setProperty(RpcClientConfigurationConstants.CONFIG_REQUEST_TIMEOUT, "2000");
channel = new MemoryChannel();
source = new ThriftSource();
}
示例5: getProperties
import org.apache.flume.api.RpcClientConfigurationConstants; //导入依赖的package包/类
private Properties getProperties(String hosts, String selector,
String maxBackoff, long timeout) throws FlumeException {
if (StringUtils.isEmpty(hosts)) {
throw new FlumeException("hosts must not be null");
}
Properties props = new Properties();
String[] hostsAndPorts = hosts.split("\\s+");
StringBuilder names = new StringBuilder();
for (int i = 0; i < hostsAndPorts.length; i++) {
String hostAndPort = hostsAndPorts[i];
String name = "h" + i;
props.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS_PREFIX + name,
hostAndPort);
names.append(name).append(" ");
}
props.put(RpcClientConfigurationConstants.CONFIG_HOSTS, names.toString());
props.put(RpcClientConfigurationConstants.CONFIG_CLIENT_TYPE,
ClientType.DEFAULT_LOADBALANCE.toString());
if (!StringUtils.isEmpty(selector)) {
props.put(RpcClientConfigurationConstants.CONFIG_HOST_SELECTOR, selector);
}
if (!StringUtils.isEmpty(maxBackoff)) {
long millis = Long.parseLong(maxBackoff.trim());
if (millis <= 0) {
throw new FlumeException(
"Misconfigured max backoff, value must be greater than 0");
}
props.put(RpcClientConfigurationConstants.CONFIG_BACKOFF, String.valueOf(true));
props.put(RpcClientConfigurationConstants.CONFIG_MAX_BACKOFF, maxBackoff);
}
props.setProperty(RpcClientConfigurationConstants.CONFIG_CONNECT_TIMEOUT,
String.valueOf(timeout));
props.setProperty(RpcClientConfigurationConstants.CONFIG_REQUEST_TIMEOUT,
String.valueOf(timeout));
return props;
}
示例6: activateOptions
import org.apache.flume.api.RpcClientConfigurationConstants; //导入依赖的package包/类
@Override
public void activateOptions() throws FlumeException {
DATE_FORMAT = new SimpleDateFormat(dateFormat);
props.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS, "h1");
props.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS_PREFIX + "h1", hostname + ":" + port);
props.setProperty(RpcClientConfigurationConstants.CONFIG_CONNECT_TIMEOUT, String.valueOf(timeout));
props.setProperty(RpcClientConfigurationConstants.CONFIG_REQUEST_TIMEOUT, String.valueOf(timeout));
props.setProperty(RpcClientConfigurationConstants.MAX_IO_WORKERS, String.valueOf(maxIoWorkers));
if (layout != null) {
layout.activateOptions();
}
fireConnector();
}
示例7: main
import org.apache.flume.api.RpcClientConfigurationConstants; //导入依赖的package包/类
public static void main(String[] args) throws FileNotFoundException,
IOException, EventDeliveryException {
if (args.length == 0) {
System.out
.println("AvroClient {host} {port} {numOfEvents}");
return;
}
String host = args[0];
int port = Integer.parseInt(args[1]);
int numberOfEvents = Integer.parseInt(args[2]);
Properties starterProp = new Properties();
starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS, "h1");
starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS_PREFIX + "h1", host + ":" + port);
NettyAvroRpcClient client = (NettyAvroRpcClient) RpcClientFactory
.getInstance(starterProp);
System.out.println("Starting");
for (int i = 0; i < numberOfEvents; i++) {
if (i%100 == 0) {
System.out.print(".");
}
SimpleEvent event = generateEvent(i);
client.append(event);
}
System.out.println();
System.out.println("Done");
}
示例8: getProperties
import org.apache.flume.api.RpcClientConfigurationConstants; //导入依赖的package包/类
private Properties getProperties(String hosts, String selector,
String maxBackoff) throws FlumeException {
if (StringUtils.isEmpty(hosts)) {
throw new IllegalArgumentException("hosts must not be null");
}
Properties props = new Properties();
String[] hostsAndPorts = hosts.split("\\s+");
StringBuilder names = new StringBuilder();
for (int i = 0; i < hostsAndPorts.length; i++) {
String hostAndPort = hostsAndPorts[i];
String name = "h" + i;
props.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS_PREFIX + name,
hostAndPort);
names.append(name).append(" ");
}
props.put(RpcClientConfigurationConstants.CONFIG_HOSTS, names.toString());
props.put(RpcClientConfigurationConstants.CONFIG_CLIENT_TYPE,
ClientType.DEFAULT_LOADBALANCE.toString());
if (!StringUtils.isEmpty(selector)) {
props.put(RpcClientConfigurationConstants.CONFIG_HOST_SELECTOR, selector);
}
if (!StringUtils.isEmpty(maxBackoff)) {
long millis = Long.parseLong(maxBackoff.trim());
if (millis <= 0) {
throw new IllegalArgumentException(
"Misconfigured max backoff, value must be greater than 0");
}
props.put(RpcClientConfigurationConstants.CONFIG_BACKOFF,
String.valueOf(true));
props.put(RpcClientConfigurationConstants.CONFIG_MAX_BACKOFF, maxBackoff);
}
return props;
}
示例9: getClient
import org.apache.flume.api.RpcClientConfigurationConstants; //导入依赖的package包/类
private NettyAvroRpcClient getClient() {
Properties starterProp = new Properties();
starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS, "h1");
String hostPort = flumeHostPortList.get(flumeHost);
starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS_PREFIX + "h1", hostPort);
flumeHost++;
if (flumeHost == flumeHostPortList.size()) { flumeHost = 0; }
LOG.info("EventProcessor: Trying to connect to " + hostPort);
NettyAvroRpcClient client = (NettyAvroRpcClient) RpcClientFactory.getInstance(starterProp);
LOG.info("EventProcessor: Connected to " + hostPort);
return client;
}
示例10: getStockLocalClient
import org.apache.flume.api.RpcClientConfigurationConstants; //导入依赖的package包/类
public static AvroAsyncRpcClient getStockLocalClient(int port, Properties starterProp) {
starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS, "h1");
starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS_PREFIX + "h1", "127.0.0.1" + ":" + port);
AvroAsyncRpcClient client = new AvroAsyncRpcClient(starterProp, 2);
return client;
}
示例11: getStockLocalClient
import org.apache.flume.api.RpcClientConfigurationConstants; //导入依赖的package包/类
public static NettyAvroAsyncRpcClient getStockLocalClient(int port, Properties starterProp) {
starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS, "h1");
starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS_PREFIX + "h1", "127.0.0.1" + ":" + port);
NettyAvroAsyncRpcClient client = new NettyAvroAsyncRpcClient( starterProp);
return client;
}