两个表加载同一驱动后,其中一张表的设备平台找不到
-
我在两个表加载同一驱动后,其中一张表的设备平台找不到,传数据后报错
=java.lang.IllegalStateException: 设备不存在: 3050584303
\ at io.github.airiot.sdk.driver.GlobalContext.lambda$createFields$1(GlobalContext.java:147)
= at java.base/java.util.Optional.orElseThrow(Unknown Source)
S at io.github.airiot.sdk.driver.GlobalContext.createFields(GlobalContext.java:147)
R at io.github.airiot.sdk.driver.GlobalContext.createPoint(GlobalContext.java:199)
R at io.github.airiot.sdk.driver.GlobalContext.createPoint(GlobalContext.java:170)
at io.github.airiot.sdk.driver.data.AbstractDataSender.writePoint(AbstractDataSender.java:257) I at io.github.airiot.demo.driver.parser.Parser03.send(Parser03.java:325) ] at io.github.airiot.demo.driver.handler.ParseHandler.messageReceived(ParseHandler.java:313) ^ at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:88) v at org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler.handleUpstream(IdleStateAwareChannelHandler.java:36) a at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) ~ at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791) L at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296) i at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462) W at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443) \ at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303) n at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) a at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) ~ at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
at org.jboss.netty.handler.timeout.IdleStateHandler.messageReceived(IdleStateHandler.java:294)
n at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
a at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
a at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
L at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
L at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
I at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
] at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
] at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318)
X at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
I at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
U at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
Y at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
P at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
Q at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
3 at java.base/java.lang.Thread.run(Unknown Source)下面这段代码是在driverApp类中设置管道工厂,是因为这里的代码导致的无法获取吗
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("idle",
new IdleStateHandler(hashedWheelTimer, Integer.valueOf(heartTime.trim()), Integer.valueOf(heartTime.trim()), Integer.valueOf(heartTime.trim())));
/pipeline.addLast("decode",new StringDecoder());/
int i =0;
for(DriverSingleConfig.Model<NettyDriverConfig> table : nettyDriverConfig.getTables()){pipeline.addLast("decoder"+i, new MyDecoder()); pipeline.addLast("encode"+i, new StringEncoder()); String tableId = table.getId(); pipeline.addLast("ParseHandler"+i, new ParseHandler(dataSender,tableId)); i++; } return pipeline;
-
可能有两个原因:
- 当使用同一驱动实例的多个表中存在相同的设备编号时, 在发送数据时必须指定 tableId
- 第2个表选择驱动实例保存后, 没有重启驱动