【问题标题】:Export Hazelcast Configuration to file将 Hazelcast 配置导出到文件
【发布时间】:2015-01-15 14:15:49
【问题描述】:

有人知道将 hazelcast 配置导出到文件的方法吗?

我知道导入它,有以下几种方式:

  1. hazelcast.config 系统属性
  2. 工作目录中的hazelcast.xml文件
  3. 类路径上的hazelcast.xml
  4. hazelcast.jar 自带的hazelcast-default.xml

但是,如果我想将实际配置保存为 xml,我该怎么办?也许出于备份目的。我该怎么做?

【问题讨论】:

    标签: java file config hazelcast


    【解决方案1】:

    我不知道配置导出器,但在 Hazaelcast 配置类 com.hazelcast.config.Config 上有 getter 方法。您可以使用它们为您的地图、列表、多地图、组等提取配置。例如:

    Map<String, ListConfig> listConfigs = config.getListConfigs();
    for(ListConfig listConfig = listConfigs.values()) {
        // export the configuration to an output file
        System.out.println("List: " + listConfig.getName()+" has max size: "+listConfig.getMaxSize());
    }
    

    【讨论】:

    • 是的,我看到了这个,但是我想要一个完整的配置,所以我可以使用这个,如果我想在一些失败后备份应用程序等。这就是为什么我需要整个 hazelcast config.xml跨度>
    • 你可以获得整个配置,因为你有其他的东西地图、多地图等的吸气剂。如果你通过 xml 创建你的配置,那么更简单的选择就是备份这些文件。
    • 我想知道是否有内置函数,因为我不想写我的onw配置格式文件。
    猜你喜欢
    • 2019-07-10
    • 2021-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-10
    • 2012-05-16
    • 1970-01-01
    相关资源
    最近更新 更多