close() called when transaction is OPEN 一般思路
来源:互联网 发布:python stringbuffer 编辑:程序博客网 时间:2024/05/29 18:18
自定义flume sink 操作的时候,往往可能报这样的错
close() called when transaction is OPEN , close() called when transaction is begin() 等,什么原因造成的???
我也说不清楚,一般是在sink的transaction开始时,处理获取的event,但是没有处理完,又有新的Transaction开始
造成的线程间的干扰吧。也不是很明白,这个错误有时候报,有时候又没了。。。
看一段代码。
Transaction tx = null ;Status status=null;logger.debug("开始一个Transaction");Channel channel= getChannel();try{tx= channel.getTransaction();tx.begin();for(int i=0;i<batchSize;i++){// 使用take方法尽可能的以批量的方式从Channel中读取事件,直到没有更多的事件Event event = channel.take();if(event==null){break;}else{ // 也可以不需要elsebyte[] body = event.getBody();String str=new String(body);logger.info("********************开始插入******");this.storeMongo(str);}}tx.commit();status=Status.READY;}catch (Exception e) { logger.error("can't process events, drop it!", e); if (tx != null) { tx.commit();// commit to drop bad event, otherwise it will enter dead loop. } } finally { if (tx != null) { logger.debug("结束一个Transaction"); tx.close(); } }return status;
我的只能是这样的了,或许有更好的形式,但是一般的结构都这样,也没有固定的标准。 这样的写法是开启一个Transaction后,可以从 Channel中获取较多的event,看source获取的数目。
不敢保证上面的那个错误再出现,我是在虚拟机上没问题,到服务器就出现上面的问题的。。。尴尬噻
0 0
- close() called when transaction is OPEN 一般思路
- What is Called and When
- When is a destructor called?
- When is a destructor called?
- Cannot close a connection while a transaction is still active.
- Which function is called when use virtual function.
- open&close
- How module init function is called when the module is loaded
- close() was never explicitly called on database 和 database is locked 错误原因
- close() was never explicitly called on database 和 database is locked 错误原因
- close() was never explicitly called on database 和 database is locked 错误原因
- when copy constructor called
- When are Constructors Called?
- InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMIT
- The following code fails when ExecMethod is called. Can anyone pinpoint what I am doing wrong?
- 解决MongoDB读数据报异常readEndDocument can only be called when State is END_OF_DOCUMENT
- How to Disable Parallel Transaction Recovery When Parallel Txn Recovery is Active (Doc ID 238507.1)
- When does layoutSubviews get called?
- HDFS介绍
- linux环境变量
- ZCMU—1623
- log4j日志时间与系统时间不一致问题解决方法
- QPrinter
- close() called when transaction is OPEN 一般思路
- 通过反射获取类和父类的属性和属性值
- 【Spring启动过程分析】(1)启动流程简介
- tensorflow-004-RNN02
- 常用工具的注册码及激活方式
- 在Hibernate Validator 中,@NotNull, @NotEmpty和@NotBlank之间的区别是什么?
- udp与tcp区别
- String类和StringBuffer类的区别
- 常用的加密算法有哪些