美文网首页
openfire 属性困惑

openfire 属性困惑

作者: pcgreat | 来源:发表于2018-09-17 17:14 被阅读44次

    openfire 有 openfire.xml , 和数据库 保存配置属性 。当你用数据库 保存属性的情况下 , 如果你的一台 服务器 加入了集群 ,并且 修改了属性 ,比如说 5701 端口 变成 5101 端口 , 那么 集群的其他机器 是否 也会受到影响 。 答案是 肯定的 , 因为 不同服务器公用了 ofProperty , 同name 的 属性 都会覆盖 。

    CREATE TABLE   (
      name        VARCHAR(100)              NOT NULL,
      propValue   TEXT                      NOT NULL,
      encrypted   INTEGER,
      PRIMARY KEY (name)
    );
    mysql> select * from ofProperty;
    +--------------------------------------------------+----------------------------------------------------------------------+-----------+------+
    | name                                             | propValue                                                            | encrypted | iv   |
    +--------------------------------------------------+----------------------------------------------------------------------+-----------+------+
    | admin.authorizedJIDs                             | admin@192.168.2.1,pc@192.168.2.1,kkkk1@192.168.2.1                   |         0 | NULL |
    | adminConsole.port                                | 9090                                                                 |         0 | NULL |
    | adminConsole.securePort                          | 9091                                                                 |         0 | NULL |
    | connectionProvider.className                     | org.jivesoftware.database.DefaultConnectionProvider                  |         0 | NULL |
    | database.defaultProvider.connectionTimeout       | 1.0                                                                  |         0 | NULL |
    | database.defaultProvider.driver                  | com.mysql.jdbc.Driver                                                |         0 | NULL |
    | database.defaultProvider.maxConnections          | 25                                                                   |         0 | NULL |
    | database.defaultProvider.maxWaitTime             | 500                                                                  |         0 | NULL |
    | database.defaultProvider.minConnections          | 5                                                                    |         0 | NULL |
    | database.defaultProvider.minIdleTime             | 900000                                                               |         0 | NULL |
    | database.defaultProvider.password                | 83feb78c84190b5719f5cb1d000f9eb8ea97aca4f5432e2a                     |         1 | NULL |
    | database.defaultProvider.serverURL               | jdbc:mysql://192.168.201.106:3306/test?rewriteBatchedStatements=true |         0 | NULL |
    | database.defaultProvider.testAfterUse            | false                                                                |         0 | NULL |
    | database.defaultProvider.testBeforeUse           | false                                                                |         0 | NULL |
    | database.defaultProvider.testSQL                 | select 1                                                             |         0 | NULL |
    | database.defaultProvider.testTimeout             | 500                                                                  |         0 | NULL |
    | database.defaultProvider.timeBetweenEvictionRuns | 30000                                                                |         0 | NULL |
    | database.defaultProvider.username                | 261bf87d039345f83cc733c7deccda5cba2b2a1d9da53e33                     |         1 | NULL |
    | locale                                           | en                                                                   |         0 | NULL |
    | passwordKey                                      | pZ2Ihyfvmdc7Nyx                                                      |         0 | NULL |
    | provider.admin.className                         | org.jivesoftware.openfire.admin.DefaultAdminProvider                 |         0 | NULL |
    | provider.auth.className                          | org.jivesoftware.openfire.auth.DefaultAuthProvider                   |         0 | NULL |
    | provider.group.className                         | org.jivesoftware.openfire.group.DefaultGroupProvider                 |         0 | NULL |
    | provider.lockout.className                       | org.jivesoftware.openfire.lockout.DefaultLockOutProvider             |         0 | NULL |
    | provider.securityAudit.className                 | org.jivesoftware.openfire.security.DefaultSecurityAuditProvider      |         0 | NULL |
    | provider.user.className                          | org.jivesoftware.openfire.user.DefaultUserProvider                   |         0 | NULL |
    | provider.vcard.className                         | org.jivesoftware.openfire.vcard.DefaultVCardProvider                 |         0 | NULL |
    | sasl.scram-sha-1.iteration-count                 | 4096                                                                 |         0 | NULL |
    | setup                                            | true                                                                 |         0 | NULL |
    | update.lastCheck                                 | 1537149072695                                                        |         0 | NULL |
    | xmpp.auth.anonymous                              | false                                                                |         0 | NULL |
    | xmpp.domain                                      | 192.168.2.1                                                          |         0 | NULL |
    | xmpp.fqdn                                        | 192.168.2.1                                                          |         0 | NULL |
    | xmpp.session.conflict-limit                      | 0                                                                    |         0 | NULL |
    | xmpp.socket.ssl.active                           | true                                                                 |         0 | NULL |
    +--------------------------------------------------+----------------------------------------------------------------------+-----------+------+
    

    核心方法JiveProperties#put方法

    /**
         * Saves a property, optionally encrypting it
         * 
         * @param key
         *            The name of the property
         * @param value
         *            The value of the property
         * @param isEncrypted
         *            {@code true} to encrypt the property, {@code true} to leave in plain text
         * @return The previous value associated with {@code key}, or {@code null} if there was no mapping for
         *         {@code key}.
         */
        public String put(String key, String value, boolean isEncrypted) {
            if (value == null) {
                // This is the same as deleting, so remove it.
                return remove(key);
            }
            if (key == null) {
                throw new NullPointerException("Key cannot be null. Key=" +
                        key + ", value=" + value);
            }
            if (key.endsWith(".")) {
                key = key.substring(0, key.length()-1);
            }
            key = key.trim();
            String result;
            synchronized (this) {
                if (properties.containsKey(key)) {
                    updateProperty(key, value, isEncrypted);
                }
                else {
                    insertProperty(key, value, isEncrypted);
                }
    
                result = properties.put(key, value);
                encrypted.put(key, isEncrypted);
                // We now know the database is correct - so we can remove the entry from security.conf
                JiveGlobals.clearXMLPropertyEncryptionEntry(key);
            }
    
            // Generate event.
            Map<String, Object> params = new HashMap<>();
            params.put("value", value);
            PropertyEventDispatcher.dispatchEvent(key, PropertyEventDispatcher.EventType.property_set, params);
    
            // Send update to other cluster members.
            CacheFactory.doClusterTask(PropertyClusterEventTask.createPutTask(key, value, isEncrypted));
    
            return result;
        }
    

    简单说 xml 属性 最终同步到数据库 。 通知本机监听 ,通知集群监听

    相关文章

      网友评论

          本文标题:openfire 属性困惑

          本文链接:https://www.haomeiwen.com/subject/sfngwftx.html