本文整理汇总了Java中org.apache.flume.CounterGroup类的典型用法代码示例。如果您正苦于以下问题:Java CounterGroup类的具体用法?Java CounterGroup怎么用?Java CounterGroup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CounterGroup类属于org.apache.flume包,在下文中一共展示了CounterGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.apache.flume.CounterGroup; //导入依赖的package包/类
@Override
public void configure(Context context) {
hostname = context.getString(HOST_KEY, ConnectionFactory.DEFAULT_HOST);
port = context.getInteger(PORT_KEY, ConnectionFactory.DEFAULT_AMQP_PORT);
sslEnabled = context.getBoolean(SSL_KEY, false);
virtualHost = context.getString(VHOST_KEY, ConnectionFactory.DEFAULT_VHOST);
username = context.getString(USER_KEY, ConnectionFactory.DEFAULT_USER);
password = context.getString(PASSWORD_KEY, ConnectionFactory.DEFAULT_PASS);
exchange = context.getString(EXCHANGE_KEY, DEFAULT_EXCHANGE);
routingKey = context.getString(ROUTING_KEY, DEFAULT_ROUTING_KEY);
autoProperties = context.getBoolean(AUTO_PROPERTIES_KEY, true);
mandatory = context.getBoolean(MANDATORY_PUBLISH_KEY, false);
publisherConfirms = context.getBoolean(PUBLISHER_CONFIRMS_KEY, false);
counterGroup = new CounterGroup();
counterGroup.setName(getName());
}
示例2: start
import org.apache.flume.CounterGroup; //导入依赖的package包/类
@Override
public void start() {
logger.info("Multi Line Exec source starting with command: {}, event terminator: {}", command, eventTerminator);
executor = Executors.newSingleThreadExecutor();
counterGroup = new CounterGroup();
runner = new ExecRunnable(command, eventTerminator, lineTerminator, getChannelProcessor(), counterGroup,
restart, restartThrottle, logStderr, bufferCount, charset);
// FIXME: Use a callback-like executor / future to signal us upon failure.
runnerFuture = executor.submit(runner);
/*
* NB: This comes at the end rather than the beginning of the method because
* it sets our state to running. We want to make sure the executor is alive
* and well first.
*/
super.start();
logger.debug("Multi Line Exec source started");
}
示例3: NetcatSource
import org.apache.flume.CounterGroup; //导入依赖的package包/类
public NetcatSource() {
super();
port = 0;
counterGroup = new CounterGroup();
acceptThreadShouldStop = new AtomicBoolean(false);
}
示例4: PollingPropertiesFileConfigurationProvider
import org.apache.flume.CounterGroup; //导入依赖的package包/类
public PollingPropertiesFileConfigurationProvider(String agentName,
File file, EventBus eventBus, int interval) {
super(agentName, file);
this.eventBus = eventBus;
this.file = file;
this.interval = interval;
counterGroup = new CounterGroup();
lifecycleState = LifecycleState.IDLE;
}
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:10,代码来源:PollingPropertiesFileConfigurationProvider.java
示例5: testProcessEventDeliveryException
import org.apache.flume.CounterGroup; //导入依赖的package包/类
/**
* Tests the {@link SQSSink#process()} method. Tests the scenario when there is EventDeliveryException when sending
* events to SQS.
* <p>
* <pre>
* Inputs:
* batchSize = 5
* EventDeliveryException is thrown from message sender
*
* Expected Result:
* transaction.begin() is invoked
* transaction.rollback() is invoked
* transaction.close() is invoked
* sinkCounter.incrementBatchCompleteCount() is NOT invoked
* sinkCounter.incrementBatchUnderflowCount() is NOT invoked
* sinkCounter.incrementBatchEmptyCount() is NOT invoked
* sinkCounter.addToEventDrainSuccessCount(txnEventCount) is NOT invoked
* counterGroup.incrementAndGet("transaction.success") is NOT invoked
* EventDeliveryException is rethrown from the sink
*
* </pre>
*/
@Test(expected = EventDeliveryException.class)
public void testProcessEventDeliveryException() throws Exception {
SQSSink underlyingSqsSink = new SQSSink();
SQSSink sqsSink = Mockito.spy(underlyingSqsSink);
SQSMsgSender mockSqsMsgSender = Mockito.mock(SQSMsgSender.class);
Mockito.when(mockSqsMsgSender.send(Mockito.any(Channel.class))).thenThrow(EventDeliveryException.class);
sqsSink.setSqsMsgSender(mockSqsMsgSender);
Context mockContext = Mockito.mock(Context.class);
Mockito.when(mockContext.getString("sqsUrl", null)).thenReturn("http://some.fake.url");
Mockito.when(mockContext.getInteger("batchSize", 10)).thenReturn(5);
Mockito.when(mockContext.getString("region", "us-east-1")).thenReturn(null);
Mockito.when(mockContext.getString("awsAccessKey", "env.AWS_ACCESS_KEY")).thenReturn("SOME FAKE ACCESS KEY");
Mockito.when(mockContext.getString("awsSecretKey", "env.AWS_SECRET_KEY")).thenReturn("SOME FAKE SECRET KEY");
Mockito.when(mockContext.getLong("maxMessageSize", 256L * 1024L)).thenReturn(256L * 1024L);
sqsSink.configure(mockContext);
Channel mockChannel = Mockito.mock(Channel.class);
Transaction mockTransaction = Mockito.mock(Transaction.class);
Mockito.when(mockChannel.getTransaction()).thenReturn(mockTransaction);
Mockito.when(sqsSink.getChannel()).thenReturn(mockChannel);
SinkCounter mockSinkCounter = Mockito.mock(SinkCounter.class);
sqsSink.setSinkCounter(mockSinkCounter);
CounterGroup mockCounterGroup = Mockito.mock(CounterGroup.class);
sqsSink.setCounterGroup(mockCounterGroup);
sqsSink.process();
}
示例6: testProcessException
import org.apache.flume.CounterGroup; //导入依赖的package包/类
/**
* Tests the {@link SQSSink#process()} method. Tests the scenario when there is an Exception when sending events to
* SQS.
* <p>
* <pre>
* Inputs:
* batchSize = 5
* An Exception is thrown from message sender
*
* Expected Result:
* transaction.begin() is invoked
* transaction.rollback() is invoked
* transaction.close() is invoked
* sinkCounter.incrementBatchCompleteCount() is NOT invoked
* sinkCounter.incrementBatchUnderflowCount() is NOT invoked
* sinkCounter.incrementBatchEmptyCount() is NOT invoked
* sinkCounter.addToEventDrainSuccessCount(txnEventCount) is NOT invoked
* counterGroup.incrementAndGet("transaction.success") is NOT invoked
* EventDeliveryException is rethrown from the sink
*
* </pre>
*/
@Test(expected = EventDeliveryException.class)
public void testProcessException() throws Exception {
SQSSink underlyingSqsSink = new SQSSink();
SQSSink sqsSink = Mockito.spy(underlyingSqsSink);
SQSMsgSender mockSqsMsgSender = Mockito.mock(SQSMsgSender.class);
Mockito.when(mockSqsMsgSender.send(Mockito.any(Channel.class))).thenThrow(Exception.class);
sqsSink.setSqsMsgSender(mockSqsMsgSender);
Context mockContext = Mockito.mock(Context.class);
Mockito.when(mockContext.getString("sqsUrl", null)).thenReturn("http://some.fake.url");
Mockito.when(mockContext.getInteger("batchSize", 10)).thenReturn(5);
Mockito.when(mockContext.getString("region", "us-east-1")).thenReturn(null);
Mockito.when(mockContext.getString("awsAccessKey", "env.AWS_ACCESS_KEY")).thenReturn("SOME FAKE ACCESS KEY");
Mockito.when(mockContext.getString("awsSecretKey", "env.AWS_SECRET_KEY")).thenReturn("SOME FAKE SECRET KEY");
Mockito.when(mockContext.getLong("maxMessageSize", 256L * 1024L)).thenReturn(256L * 1024L);
sqsSink.configure(mockContext);
Channel mockChannel = Mockito.mock(Channel.class);
Transaction mockTransaction = Mockito.mock(Transaction.class);
Mockito.when(mockChannel.getTransaction()).thenReturn(mockTransaction);
Mockito.when(sqsSink.getChannel()).thenReturn(mockChannel);
SinkCounter mockSinkCounter = Mockito.mock(SinkCounter.class);
sqsSink.setSinkCounter(mockSinkCounter);
CounterGroup mockCounterGroup = Mockito.mock(CounterGroup.class);
sqsSink.setCounterGroup(mockCounterGroup);
sqsSink.process();
}
示例7: testProcessError
import org.apache.flume.CounterGroup; //导入依赖的package包/类
/**
* Tests the {@link SQSSink#process()} method. Tests the scenario when there is an Error when sending events to
* SQS.
* <p>
* <pre>
* Inputs:
* batchSize = 5
* An Error is thrown from message sender
*
* Expected Result:
* transaction.begin() is invoked
* transaction.rollback() is invoked
* transaction.close() is invoked
* sinkCounter.incrementBatchCompleteCount() is NOT invoked
* sinkCounter.incrementBatchUnderflowCount() is NOT invoked
* sinkCounter.incrementBatchEmptyCount() is NOT invoked
* sinkCounter.addToEventDrainSuccessCount(txnEventCount) is NOT invoked
* counterGroup.incrementAndGet("transaction.success") is NOT invoked
* The same Error is rethrown from the sink
*
* </pre>
*/
@Test(expected = Error.class)
public void testProcessError() throws Exception {
SQSSink underlyingSqsSink = new SQSSink();
SQSSink sqsSink = Mockito.spy(underlyingSqsSink);
SQSMsgSender mockSqsMsgSender = Mockito.mock(SQSMsgSender.class);
Mockito.when(mockSqsMsgSender.send(Mockito.any(Channel.class))).thenThrow(Error.class);
sqsSink.setSqsMsgSender(mockSqsMsgSender);
Context mockContext = Mockito.mock(Context.class);
Mockito.when(mockContext.getString("sqsUrl", null)).thenReturn("http://some.fake.url");
Mockito.when(mockContext.getInteger("batchSize", 10)).thenReturn(5);
Mockito.when(mockContext.getString("region", "us-east-1")).thenReturn(null);
Mockito.when(mockContext.getString("awsAccessKey", "env.AWS_ACCESS_KEY")).thenReturn("SOME FAKE ACCESS KEY");
Mockito.when(mockContext.getString("awsSecretKey", "env.AWS_SECRET_KEY")).thenReturn("SOME FAKE SECRET KEY");
Mockito.when(mockContext.getLong("maxMessageSize", 256L * 1024L)).thenReturn(256L * 1024L);
sqsSink.configure(mockContext);
Channel mockChannel = Mockito.mock(Channel.class);
Transaction mockTransaction = Mockito.mock(Transaction.class);
Mockito.when(mockChannel.getTransaction()).thenReturn(mockTransaction);
Mockito.when(sqsSink.getChannel()).thenReturn(mockChannel);
SinkCounter mockSinkCounter = Mockito.mock(SinkCounter.class);
sqsSink.setSinkCounter(mockSinkCounter);
CounterGroup mockCounterGroup = Mockito.mock(CounterGroup.class);
sqsSink.setCounterGroup(mockCounterGroup);
sqsSink.process();
}
示例8: configure
import org.apache.flume.CounterGroup; //导入依赖的package包/类
@Override
public void configure(Context context) {
// Only the queue name does not have a default value
Configurables.ensureRequiredNonNull(context, QUEUE_KEY);
// Assign all of the configured values
hostname = context.getString(HOST_KEY, ConnectionFactory.DEFAULT_HOST);
port = context.getInteger(PORT_KEY, ConnectionFactory.DEFAULT_AMQP_PORT);
enableSSL = context.getBoolean(SSL_KEY, false);
virtualHost = context.getString(VHOST_KEY, ConnectionFactory.DEFAULT_VHOST);
username = context.getString(USER_KEY, ConnectionFactory.DEFAULT_USER);
password = context.getString(PASSWORD_KEY, ConnectionFactory.DEFAULT_PASS);
queue = context.getString(QUEUE_KEY, null);
autoAck = context.getBoolean(AUTOACK_KEY, false);
requeuing = context.getBoolean(REQUEUING, false);
prefetchCount = context.getInteger(PREFETCH_COUNT_KEY, 0);
timeout = context.getInteger(TIMEOUT_KEY, -1);
consumerThreads = context.getInteger(THREAD_COUNT_KEY, 1);
// Ensure that Flume can connect to RabbitMQ
testRabbitMQConnection();
// Create and configure the counters
sourceCounter = new SourceCounter(getName());
counterGroup = new CounterGroup();
counterGroup.setName(getName());
}
示例9: ExecRunnable
import org.apache.flume.CounterGroup; //导入依赖的package包/类
public ExecRunnable(String command, String eventTerminator, String lineTerminator, ChannelProcessor channelProcessor, CounterGroup counterGroup, boolean restart, long restartThrottle, boolean logStderr, int bufferCount, Charset charset) {
this.command = command;
this.eventTerminator = eventTerminator;
this.lineTerminator = lineTerminator;
this.channelProcessor = channelProcessor;
this.counterGroup = counterGroup;
this.restartThrottle = restartThrottle;
this.bufferCount = bufferCount;
this.restart = restart;
this.logStderr = logStderr;
this.charset = charset;
}
示例10: NullSink
import org.apache.flume.CounterGroup; //导入依赖的package包/类
public NullSink() {
counterGroup = new CounterGroup();
}
示例11: StressSource
import org.apache.flume.CounterGroup; //导入依赖的package包/类
public StressSource() {
counterGroup = new CounterGroup();
}
示例12: PollableSourceRunner
import org.apache.flume.CounterGroup; //导入依赖的package包/类
public PollableSourceRunner() {
shouldStop = new AtomicBoolean();
counterGroup = new CounterGroup();
lifecycleState = LifecycleState.IDLE;
}
示例13: CountingLifecycleAware
import org.apache.flume.CounterGroup; //导入依赖的package包/类
public CountingLifecycleAware() {
lifecycleState = LifecycleState.IDLE;
counterGroup = new CounterGroup();
}
示例14: setUp
import org.apache.flume.CounterGroup; //导入依赖的package包/类
@Before
public void setUp() {
counterGroup = new CounterGroup();
}
示例15: getCounterGroup
import org.apache.flume.CounterGroup; //导入依赖的package包/类
private CounterGroup getCounterGroup(StressSource source) {
return field("counterGroup").ofType(CounterGroup.class).in(source).get();
}