本文介绍了Fiware-Cygnus mongoSink元数据持久性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Mongo接收器(来自具有元数据数据结构的实体的数据)坚持使用天鹅绒.到目前为止,我还无法实现这一目标.

I'm trying to persist with cygnus using a Mongo sink, data from entities with metadata data estructures. So far, I haven't been able to achieve that.

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

I'm using cygnus version 0.13.0. Seems to be possible to save metadata info using MySQL and CKAN persistence sinks.

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

¿Is it possible too using Mongo?¿Is it configuration matter?

在此先感谢您的帮助.

Thanks in advance for any help.

推荐答案

Cygnus不在MongoDB中存储属性元数据.这是因为在MongoDB中保留时,我们使用Cygnus的内部用法,对此问题施加了强大的约束.

Cygnus does not store the attribute metadata in MongoDB. This is because the internal usage we make of Cygnus when persisting in MongoDB, which imposes a strong constraint regarding this issue.

无论如何,修改自己的代码以解决此问题应该相对容易.只需看一下这种方法:

Anyway, modifying the code in a fork of yourself in order to fix this should be relatively easy. Simply have a look on this method:

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

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

Passing an additional parameter String attrMd and appending this value to the doc variable should do the trick:

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

这篇关于Fiware-Cygnus mongoSink元数据持久性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 18:24