zookeeper.server.ServerCnxn $ EndOfStreamException:无法从客户端读取其他数据

时间:2018-07-30 16:58:53

标签: java apache apache-zookeeper apache-storm

我已经在Windows 7 Professional上安装了IntelliJ Community 2018.1。运行Java 1.8.0.172 jdk。

我正在运行Edureka教程中与Apache Storm相关的Simple Java代码。

非常简单和基本。只需从喷口中散出几个整数,螺栓便会将每个数字加倍并重新发出。

我没有运行任何本地或远程zk / storm集群。我依靠代码以某种方式自行生成的ZK / Storm实例。我在本地没有任何Storm目录。我所拥有的只是IntelliJ,pom.xml中的依赖项很少。

这就是我的Windows主机文件中的内容。


localhost sandbox.hortonworks.com sandbox-hdp.hortonworks.com sandbox-hdf.hortonworks.com
127.0.0.1 sandbox.hortonworks.com sandbox-hdp.hortonworks.com sandbox-hdf.hortonworks.com

运行Java程序时,始终出现此错误:-


org.apache.storm.shade.org.apache.zookeeper.server.ServerCnxn$EndOfStreamException: Unable to read additional data from client sessionid 0x164ebfb3e3e000f, likely client has closed socket

这是我编写代码的步骤:-

(1)在IntelliJ中创建新的Maven项目。

(2)将依赖项部分添加到POM.xml,以便导入Storm-core库。一切都很好。

    <dependencies>
    <dependency>
        <groupId>org.apache.storm</groupId>
        <artifactId>storm-core</artifactId>
        <version>1.1.1</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

(4)在IntelliJ中为Spout创建Java类。

import org.apache.storm.spout.SpoutOutputCollector;
import org.apache.storm.task.TopologyContext;
import org.apache.storm.topology.OutputFieldsDeclarer;
import org.apache.storm.topology.base.BaseRichSpout;
import org.apache.storm.tuple.Fields;
import org.apache.storm.tuple.Values;

import java.util.Map;

public class IntegerSpout extends BaseRichSpout {

SpoutOutputCollector myspoutOutputCollector;
private Integer index = 2;

public void open(Map map, TopologyContext topologyContext, SpoutOutputCollector spoutOutputCollector) {
    this.myspoutOutputCollector = spoutOutputCollector;
        }

public void nextTuple() {
    //Emit 100 numbers from the Spout.
    if (index <100) {
        System.out.println("Index is " + Integer.toString(index));
        this.myspoutOutputCollector.emit(new Values(index));
        index++;
    }
}

public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {
    outputFieldsDeclarer.declare(new Fields("field"));
}

}

(5)将这些数字从喷嘴注入到一个(乘数?)螺栓中,该螺栓将每个数字翻倍,并进一步散发出去。简单而直接。

import org.apache.storm.topology.BasicOutputCollector;
import org.apache.storm.topology.OutputFieldsDeclarer;
import org.apache.storm.topology.base.BaseBasicBolt;
import org.apache.storm.tuple.Fields;
import org.apache.storm.tuple.Tuple;
import org.apache.storm.tuple.Values;

public class MultiplierBolt extends BaseBasicBolt {
public void execute(Tuple tuple, BasicOutputCollector basicOutputCollector) {
    Integer number = tuple.getInteger(0);
    number*= 2;
    basicOutputCollector.emit(new Values(number));
}

public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {
    outputFieldsDeclarer.declare(new Fields("field"));
}

}

(6)现在编写一个带有main()的Main类,该main类定义一个拓扑并将喷口连接到螺栓,然后将其提交执行。

import org.apache.storm.Config;
import org.apache.storm.LocalCluster;
import org.apache.storm.topology.TopologyBuilder;

public class MainTopology {

public static void main(String[] args) {
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("IntegerSpout", new IntegerSpout());
    builder.setBolt("MultiplierBolt", new MultiplierBolt()).shuffleGrouping("IntegerSpout");

    Config config = new Config();
    config.setDebug(true);

    LocalCluster localCluster = new LocalCluster();

    try {
        localCluster.submitTopology("HelloTopology", config, builder.createTopology());
        Thread.sleep(1000);
    } catch (Exception e) {
        System.out.println("Exception Raised");
        e.printStackTrace();
    } finally {
        localCluster.shutdown();
    };
}

}

就是这样。现在只需编译并运行。我的日志中大部分都是异常和错误。

[NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2000] WARN  o.a.s.s.o.a.z.s.NIOServerCnxn - caught end of stream exception org.apache.storm.shade.org.apache.zookeeper.server.ServerCnxn$EndOfStreamException: Unable to read additional data from client sessionid 0x164ebf470410009, likely client has closed socket

任何帮助指针将不胜感激。

TIA。

授予

0 个答案:

没有答案