首页 文章

Fiware - Cygnus mongoSink元数据持久性

提问于
浏览
2

我正在尝试使用Mongo接收器,来自具有元数据数据结构的实体的数据来持续使用cygnus . 到目前为止,我还没有实现这一目标 .

我正在使用cygnus版本0.13.0 . 似乎可以使用MySQL和CKAN持久性接收器来保存元数据信息 .

¿是否有可能使用Mongo? ¿配置是否重要?

在此先感谢您的帮助 .

2 回答

  • 1

    Cygnus不会将属性元数据存储在MongoDB中 . 这是因为我们在MongoDB中持久化时对Cygnus进行了内部使用,这对此问题施加了强烈约束 .

    无论如何,为了解决这个问题而修改自己的代码应该相对容易 . 只需看看这个方法:

    private Document createDoc(long recvTimeTs, String entityId, String entityType, String attrName, String attrType, String attrValue) {
    

    传递一个额外的参数 String attrMd 并将此值附加到 doc 变量应该可以解决这个问题:

    private Document createDoc(long recvTimeTs, String entityId, String entityType, String attrName, String attrType, String attrValue, String attrMd) {
        Document doc = new Document("recvTime", new Date(recvTimeTs));
    
        switch (dataModel) {
            case DMBYSERVICEPATH:
                doc.append("entityId", entityId)
                        .append("entityType", entityType)
                        .append("attrName", attrName)
                        .append("attrType", attrType)
                        .append("attrValue", attrValue)
                        .append("attrMd", attrMd);
                break;
            case DMBYENTITY:
                doc.append("attrName", attrName)
                        .append("attrType", attrType)
                        .append("attrValue", attrValue)
                        .append("attrMd", attrMd);
                break;
            case DMBYATTRIBUTE:
                doc.append("attrType", attrType)
                        .append("attrValue", attrValue)
                        .append("attrMd", attrMd);
                break;
            default:
                return null; // this will never be reached
        } // switch
    
        return doc;
    } // createDoc
    
  • 0

    从版本1.8.0开始,FIWARE CYGNUS添加了元数据支持 . 正如您在配置文件的template中所看到的,您唯一需要做的就是将属性 cygnus-ngsi.sinks.mongo-sink.attr_metadata_store 设置为True,默认情况下将其设置为False .

    问候!

相关问题