本篇文章说明如何通过IDE集成环境来搭建一个Batfish的服务器。并在这个集成环境的基础上进行开发、编译、运行。
1.首先通过如下的网盘链接进行下载,下载包含三个文件,分别是IDEA2019(集成开发工具)的安装包(当然可以自己去官网下载),破解文件以及注册码。新的版本已经不支持仅仅通过注册码进行安装。记住安装的路径。安装完之后不要运行
https://pan.baidu.com/s/1l52GnV4QNVJI2AwyvcbwwQ 提取码:bokg
2.将补丁JetbrainsCrack-4.2-release-enc.jar 放入至刚才安装的bin\目录下,使用pwd命令查看当前目录。
3.在IDEA安装目录的bin目录中找到idea.exe.vmoptions和idea64.exe.vmoptions 这两个文件。编辑在文件的末尾加上刚才补丁的目录。
-javaagent:/home/local/ideaIU-2019.1.3/bin/JetbrainsCrack-release-enc.jar
4.打开IDEA选择激活码激活。
JKHX300590-eyJsaWNlbnNlSWQiOiJKS0hYMzAwNTkwIiwibGljZW5zZWVOYW1lIjoiTmljb2xlIFBvd2VsbCIsImFzc2lnbmVlTmFtZSI6IiIsImFzc2lnbmVlRW1haWwiOiIiLCJsaWNlbnNlUmVzdHJpY3Rpb24iOiJGb3IgZWR1Y2F0aW9uYWwgdXNlIG9ubHkiLCJjaGVja0NvbmN1cnJlbnRVc2UiOmZhbHNlLCJwcm9kdWN0cyI6W3siY29kZSI6IklJIiwicGFpZFVwVG8iOiIyMDE5LTA5LTI0In0seyJjb2RlIjoiQUMiLCJwYWlkVXBUbyI6IjIwMTktMDktMjQifSx7ImNvZGUiOiJEUE4iLCJwYWlkVXBUbyI6IjIwMTktMDktMjQifSx7ImNvZGUiOiJQUyIsInBhaWRVcFRvIjoiMjAxOS0wOS0yNCJ9LHsiY29kZSI6IkdPIiwicGFpZFVwVG8iOiIyMDE5LTA5LTI0In0seyJjb2RlIjoiRE0iLCJwYWlkVXBUbyI6IjIwMTktMDktMjQifSx7ImNvZGUiOiJDTCIsInBhaWRVcFRvIjoiMjAxOS0wOS0yNCJ9LHsiY29kZSI6IlJTMCIsInBhaWRVcFRvIjoiMjA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r8h7Z2gsx5LcIf5kYNsqJ0GavXTVyWh7PYiKX4bs354ZQLUwwa/cG++2+wNWP+HtBhVxMRNTdVhSm38AknZlD+PTAsWGu9GyLmhti2EnVwGybSD2Dxmhxk3IPCkhKAK+pl0eWYGZWG3tJ9mZ7SowcXLWDFAk0lRJnKGFMTggrWjV8GYpw5bq23VmIqqDLgkNzuoog==
原文链接:https://github.com/batfish/batfish/wiki/IntelliJ
原文是说在Preferences菜单栏下,但是现在已经不再这个地方了。File > Settings > Plugins > Browse Repositories
查找如下两个插件,并点击安装install
google-java-format :一种代码风格 Checkstyle-IDEA:验证代码风格是否正确
ANTLR4-generated JAVA文件包含的配置解析文件非常大。为了是IntelliJ编译并检索,需要提升Intellij的默认文件大小
点击Help > Edit Custom Properties然后会有idea.properties文件打开。
#custom IntelliJ IDEA properties
idea.max.intellisense.file.length=500000
#---------------------------------------------------------------------
#Maximum file size (kilobytes) IDE should provide code assistance for.
#The larger file is the slower its editor works and higher overall system memory requirements are
#if code assistance is enabled. Remove this property or set to very large number if you need
#code assistance for any files available regardless their size.
#---------------------------------------------------------------------
idea.max.intellisense.filesize=50000
(1)首先确认batfish_build_all命令能够正确的执行
(2)在batfish的根目录下看不到任何的代码模块
(3)添加模块
i.Open File > Project Structure.
ii.在Modules下点击 + 然后选择 Import Module.
iii.选择batfish目录下的projects文件夹, 选择 Import module from external model > Maven; h点击 Next.
iv.关闭recursive search 然后打开automatic updating. 点击下一步Next.
v.最后会导入 org.batfish:batfish-parent:0.28.1 (取决于版本).点击 Finish完成,之后都是默认
完成第三步之后在Projet的视图中(左上角)可以看到project[batfish-parent],并在它的下面有许多单独的模块
点击projects [batfish-parent] 然后选择 Maven > Reimport,之后点击Build > Build Project就能够编辑运行了
P.S.在运行时可能出现内存不够用的情况,具体提示如下:
Information:Internal caches are corrupted or have outdated format, forcing p_
在原文中推荐将‘进程堆空间’的大小增加到1G或者是更多。最初将内存设置为2G,4G时都扔下出现这个异常,最后设置成为5G(如果是在虚拟机中,需要将虚拟的内存设置大于这个数值)。
File>settings>Build,…>Compiler然后编辑Build process heap size。将数值设置为5000MB
在顶端的菜单栏中有Allinone点击会出现Edit Configuration,然后会出现如下界面,仅仅需要在Before launch中配置如下命令
-pl question -am packge
原文中需要配置两个部分Single instance only和上述命令。但是现在的版本时Allow parallel run。我们不希望能够同时运行多个服务端因此不需要点击。此外上述命令的意思是每次可以自动更新数据包。
如果出现如下界面就是运行成功。在之前安装的pybatfish目录下运行jupyter notebook命令就可以启动客户端了。