kura - 通过 Mqtt 远程安装部署包失败
kura - remote installation of deployment package via Mqtt fails
我在远程安装部署包时遇到问题,以下是我在请求主题上发送的指标 - $EDC/amir-kura/test-client/DEPLOY-V2/EXEC/download
job.id=12345678910L
dp.uri=file:/home/amir/Downloads/org.eclipse.kura.example.hello_osgi/resources/dp/hello_osgi.dp
dp.name=hello_osgi
dp.version=1.0.0
dp.download.protocol=HTTPS
dp.install.system.update=false
包下载成功,因为我在 Notify
主题-$EDC/amir-kura/new-client/DEPLOY-V2/NOTIFY/test-client/download
上收到以下回复
{dp.download.size=0,
dp.download.progress=100,
dp.download.status=COMPLETED,
job.id=12345678910,
client.id=test-client}
但是,安装失败。以下是我的 kura 控制台-
15:06:07,357 [MQTT Call: test-client] INFO CloudServiceImpl:440 - Message arrived on topic: $EDC/amir-kura/test-client/DEPLOY-V2/EXEC/download
15:06:07,382 [pool-2-thread-2] INFO CloudDeploymentHandlerV2:459 - About to download and install package at URL file:/home/amir/Downloads/org.eclipse.kura.example.hello_osgi/resources/dp/hello_osgi.dp
15:06:07,382 [pool-2-thread-2] INFO CloudDeploymentHandlerV2:468 - Downloading package from URL: file:/home/amir/Downloads/org.eclipse.kura.example.hello_osgi/resources/dp/hello_osgi.dp
15:06:07,387 [pool-12-thread-1] INFO DataServiceImpl:441 - Storing message on topic :$EDC/#account-name/new-client/DEPLOY-V2/NOTIFY/test-client/download, priority: 1
15:06:07,389 [pool-12-thread-1] INFO DataServiceImpl:444 - Stored message on topic :$EDC/#account-name/new-client/DEPLOY-V2/NOTIFY/test-client/download, priority: 1
15:06:07,402 [DataServiceImpl:Submit] INFO MqttDataTransport:512 - Publishing message on topic: $EDC/amir-kura/new-client/DEPLOY-V2/NOTIFY/test-client/download with QoS: 1
15:06:07,403 [pool-12-thread-1] INFO DownloadImpl:131 - Ready to install
15:06:07,405 [pool-2-thread-2] INFO DataServiceImpl:441 - Storing message on topic :$EDC/#account-name/new-client/DEPLOY-V2/REPLY/REQUEST_M2UIS65D0O7DFILVRH9QF80QKE, priority: 1
15:06:07,423 [pool-2-thread-2] INFO DataServiceImpl:444 - Stored message on topic :$EDC/#account-name/new-client/DEPLOY-V2/REPLY/REQUEST_M2UIS65D0O7DFILVRH9QF80QKE, priority: 1
15:06:07,430 [DataServiceImpl:Submit] INFO MqttDataTransport:512 - Publishing message on topic: $EDC/amir-kura/new-client/DEPLOY-V2/REPLY/REQUEST_M2UIS65D0O7DFILVRH9QF80QKE with QoS: 0
!SESSION 2017-05-16 14:51:45.651 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_121
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_IN
Command-line arguments: -dev file:/home/amir/eclipse/workspaces/kura/.metadata/.plugins/org.eclipse.pde.core/Kura_Emulator_Linux/dev.properties -os linux -ws gtk -arch x86_64 -consoleLog -console
!ENTRY org.apache.felix.deploymentadmin 4 0 2017-05-16 15:06:07.499
!MESSAGE Stream does not contain a valid deployment package: missing manifest!
15:06:07,500 [pool-12-thread-1] INFO InstallImpl:135 - Install failed!
15:06:07,509 [pool-12-thread-1] INFO DataServiceImpl:441 - Storing message on topic :$EDC/#account-name/new-client/DEPLOY-V2/NOTIFY/test-client/install, priority: 1
15:06:07,535 [pool-12-thread-1] INFO DataServiceImpl:444 - Stored message on topic :$EDC/#account-name/new-client/DEPLOY-V2/NOTIFY/test-client/install, priority: 1
15:06:07,550 [DataServiceImpl:Submit] INFO MqttDataTransport:512 - Publishing message on topic: $EDC/amir-kura/new-client/DEPLOY-V2/NOTIFY/test-client/install with QoS: 1
15:06:07,684 [MQTT Call: test-client] INFO DataServiceImpl:376 - Confirmed message ID: 1348 to store
15:06:07,935 [MQTT Call: test-client] INFO DataServiceImpl:376 - Confirmed message ID: 1350 to store
根据错误,我正在发送一个无效的部署包,因为它缺少 Manifest
,但我已经创建了 .dp
文件,如 Hello World Example 中所述。
我该如何解决这个问题?似乎没有其他人遇到过这个问题
构建部署包时需要注意两点。
- Manifest 必须是 DP 文件(只是一个 ZIP 文件)中的第一个条目
- 包含包的顺序很重要,它们必须包含在 DP 中,其顺序与它们在清单
中声明的顺序相同
显示为第一个条目
MANIFEST.MF 文件包含在 META-INF/
目录中。按照 ZIP 标准,您可以在文件中添加一个条目来创建目录,并在文件中添加第二个条目。这是 DP 格式不支持的,因此您必须直接添加具有完整路径的文件作为生成的 DP 文件中的第一个条目。
例如,使用 maven-antrun-plugin
打包 DP 您可以在 <jar>
命令上使用 filesonly="true"
属性:
<jar destfile="${basedir}/../you.final.dp_1.0.0.dp"
manifest="${project.build.directory}/dp_stage/META-INF/MANIFEST.MF"
includes="" filesonly="true">
<filelist dir="${project.build.directory}/dp_stage/" files="${sortedFiles}"/>
</jar>
捆绑包顺序
如果您的部署包包含多个包,则它们必须包含在与清单相同的顺序中。您可以使用字母顺序,这是可以预测的并且效果很好:-)
将您的 JAR 复制到一个文件夹中,然后以排序的方式将它们添加到 DP。使用相同的 maven-antrun-plugin
:
<copy file="${basedir}/../project/target/first.bundle_1.0.0.jar"
todir="${project.build.directory}/dp_stage/bundles/" />
<copy file="${basedir}/../project2/target/second.bundle_1.0.0.jar"
todir="${project.build.directory}/dp_stage/bundles/" />
<!-- Files MUST be included in the jar in the same order as they are declared in the DP MANIFEST.
I used alphabetical order. -->
<!-- https://ant.apache.org/manual/Tasks/jar.html -->
<local name="sortedFiles"/>
<pathconvert property="sortedFiles" pathsep="${line.separator}">
<sort>
<fileset dir="${project.build.directory}/dp_stage/" includes="bundles/*"/>
</sort>
</pathconvert>
我在 github 上有个人 project 正是这样做的,看看以供参考。
POM which calls maven-antrun-plugin
Ant task to build DP
我在@Amir 评论后添加第二个答案。另一个答案没有解决实际问题,但在某些其他情况下可能会有所帮助。
我认为问题出在发送到 DEPLOY-V2
cloudlet 的指标上。
dp.uri=file:/home/amir/Downloads/org.eclipse.kura.example.hello_osgi/resources/dp/hello_osgi.dp
dp.download.protocol=HTTPS
通知中还有这样的指示:
dp.download.size=0
URI 表示它是本地文件系统上的文件,但协议表示使用 HTTPS。
如果你看 DEPLOY-V2 documentation 你会读到
Kura 1.4.0 introduces a new version of the DEPLOY application named “DEPLOY-V2”. The main feature introduced is related to a different approach for package distribution: instead of receiving the package inside a MQTT message, the device receives only a download request with all the information needed to perform an independent download via HTTP.
dp.uri (String). Mandatory. Represents the URI of the deployment package.
dp.download.protocol (String) Mandatory. Specifies the protocol to be used to download the bundles/shell scripts. Must be set to HTTP or HTTPS.
您需要提供有效的 HTTP URL 才能从中下载 DP。
我在远程安装部署包时遇到问题,以下是我在请求主题上发送的指标 - $EDC/amir-kura/test-client/DEPLOY-V2/EXEC/download
job.id=12345678910L
dp.uri=file:/home/amir/Downloads/org.eclipse.kura.example.hello_osgi/resources/dp/hello_osgi.dp
dp.name=hello_osgi
dp.version=1.0.0
dp.download.protocol=HTTPS
dp.install.system.update=false
包下载成功,因为我在 Notify
主题-$EDC/amir-kura/new-client/DEPLOY-V2/NOTIFY/test-client/download
{dp.download.size=0,
dp.download.progress=100,
dp.download.status=COMPLETED,
job.id=12345678910,
client.id=test-client}
但是,安装失败。以下是我的 kura 控制台-
15:06:07,357 [MQTT Call: test-client] INFO CloudServiceImpl:440 - Message arrived on topic: $EDC/amir-kura/test-client/DEPLOY-V2/EXEC/download
15:06:07,382 [pool-2-thread-2] INFO CloudDeploymentHandlerV2:459 - About to download and install package at URL file:/home/amir/Downloads/org.eclipse.kura.example.hello_osgi/resources/dp/hello_osgi.dp
15:06:07,382 [pool-2-thread-2] INFO CloudDeploymentHandlerV2:468 - Downloading package from URL: file:/home/amir/Downloads/org.eclipse.kura.example.hello_osgi/resources/dp/hello_osgi.dp
15:06:07,387 [pool-12-thread-1] INFO DataServiceImpl:441 - Storing message on topic :$EDC/#account-name/new-client/DEPLOY-V2/NOTIFY/test-client/download, priority: 1
15:06:07,389 [pool-12-thread-1] INFO DataServiceImpl:444 - Stored message on topic :$EDC/#account-name/new-client/DEPLOY-V2/NOTIFY/test-client/download, priority: 1
15:06:07,402 [DataServiceImpl:Submit] INFO MqttDataTransport:512 - Publishing message on topic: $EDC/amir-kura/new-client/DEPLOY-V2/NOTIFY/test-client/download with QoS: 1
15:06:07,403 [pool-12-thread-1] INFO DownloadImpl:131 - Ready to install
15:06:07,405 [pool-2-thread-2] INFO DataServiceImpl:441 - Storing message on topic :$EDC/#account-name/new-client/DEPLOY-V2/REPLY/REQUEST_M2UIS65D0O7DFILVRH9QF80QKE, priority: 1
15:06:07,423 [pool-2-thread-2] INFO DataServiceImpl:444 - Stored message on topic :$EDC/#account-name/new-client/DEPLOY-V2/REPLY/REQUEST_M2UIS65D0O7DFILVRH9QF80QKE, priority: 1
15:06:07,430 [DataServiceImpl:Submit] INFO MqttDataTransport:512 - Publishing message on topic: $EDC/amir-kura/new-client/DEPLOY-V2/REPLY/REQUEST_M2UIS65D0O7DFILVRH9QF80QKE with QoS: 0
!SESSION 2017-05-16 14:51:45.651 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_121
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_IN
Command-line arguments: -dev file:/home/amir/eclipse/workspaces/kura/.metadata/.plugins/org.eclipse.pde.core/Kura_Emulator_Linux/dev.properties -os linux -ws gtk -arch x86_64 -consoleLog -console
!ENTRY org.apache.felix.deploymentadmin 4 0 2017-05-16 15:06:07.499
!MESSAGE Stream does not contain a valid deployment package: missing manifest!
15:06:07,500 [pool-12-thread-1] INFO InstallImpl:135 - Install failed!
15:06:07,509 [pool-12-thread-1] INFO DataServiceImpl:441 - Storing message on topic :$EDC/#account-name/new-client/DEPLOY-V2/NOTIFY/test-client/install, priority: 1
15:06:07,535 [pool-12-thread-1] INFO DataServiceImpl:444 - Stored message on topic :$EDC/#account-name/new-client/DEPLOY-V2/NOTIFY/test-client/install, priority: 1
15:06:07,550 [DataServiceImpl:Submit] INFO MqttDataTransport:512 - Publishing message on topic: $EDC/amir-kura/new-client/DEPLOY-V2/NOTIFY/test-client/install with QoS: 1
15:06:07,684 [MQTT Call: test-client] INFO DataServiceImpl:376 - Confirmed message ID: 1348 to store
15:06:07,935 [MQTT Call: test-client] INFO DataServiceImpl:376 - Confirmed message ID: 1350 to store
根据错误,我正在发送一个无效的部署包,因为它缺少 Manifest
,但我已经创建了 .dp
文件,如 Hello World Example 中所述。
我该如何解决这个问题?似乎没有其他人遇到过这个问题
构建部署包时需要注意两点。
- Manifest 必须是 DP 文件(只是一个 ZIP 文件)中的第一个条目
- 包含包的顺序很重要,它们必须包含在 DP 中,其顺序与它们在清单 中声明的顺序相同
显示为第一个条目
MANIFEST.MF 文件包含在 META-INF/
目录中。按照 ZIP 标准,您可以在文件中添加一个条目来创建目录,并在文件中添加第二个条目。这是 DP 格式不支持的,因此您必须直接添加具有完整路径的文件作为生成的 DP 文件中的第一个条目。
例如,使用 maven-antrun-plugin
打包 DP 您可以在 <jar>
命令上使用 filesonly="true"
属性:
<jar destfile="${basedir}/../you.final.dp_1.0.0.dp"
manifest="${project.build.directory}/dp_stage/META-INF/MANIFEST.MF"
includes="" filesonly="true">
<filelist dir="${project.build.directory}/dp_stage/" files="${sortedFiles}"/>
</jar>
捆绑包顺序
如果您的部署包包含多个包,则它们必须包含在与清单相同的顺序中。您可以使用字母顺序,这是可以预测的并且效果很好:-)
将您的 JAR 复制到一个文件夹中,然后以排序的方式将它们添加到 DP。使用相同的 maven-antrun-plugin
:
<copy file="${basedir}/../project/target/first.bundle_1.0.0.jar"
todir="${project.build.directory}/dp_stage/bundles/" />
<copy file="${basedir}/../project2/target/second.bundle_1.0.0.jar"
todir="${project.build.directory}/dp_stage/bundles/" />
<!-- Files MUST be included in the jar in the same order as they are declared in the DP MANIFEST.
I used alphabetical order. -->
<!-- https://ant.apache.org/manual/Tasks/jar.html -->
<local name="sortedFiles"/>
<pathconvert property="sortedFiles" pathsep="${line.separator}">
<sort>
<fileset dir="${project.build.directory}/dp_stage/" includes="bundles/*"/>
</sort>
</pathconvert>
我在 github 上有个人 project 正是这样做的,看看以供参考。
POM which calls maven-antrun-plugin
Ant task to build DP
我在@Amir 评论后添加第二个答案。另一个答案没有解决实际问题,但在某些其他情况下可能会有所帮助。
我认为问题出在发送到 DEPLOY-V2
cloudlet 的指标上。
dp.uri=file:/home/amir/Downloads/org.eclipse.kura.example.hello_osgi/resources/dp/hello_osgi.dp
dp.download.protocol=HTTPS
通知中还有这样的指示:
dp.download.size=0
URI 表示它是本地文件系统上的文件,但协议表示使用 HTTPS。
如果你看 DEPLOY-V2 documentation 你会读到
Kura 1.4.0 introduces a new version of the DEPLOY application named “DEPLOY-V2”. The main feature introduced is related to a different approach for package distribution: instead of receiving the package inside a MQTT message, the device receives only a download request with all the information needed to perform an independent download via HTTP.
dp.uri (String). Mandatory. Represents the URI of the deployment package. dp.download.protocol (String) Mandatory. Specifies the protocol to be used to download the bundles/shell scripts. Must be set to HTTP or HTTPS.
您需要提供有效的 HTTP URL 才能从中下载 DP。