Search in sources :

Example 1 with SubscriptionGroupManager

use of org.apache.rocketmq.broker.subscription.SubscriptionGroupManager in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class SlaveSynchronize method syncSubscriptionGroupConfig.

private void syncSubscriptionGroupConfig() {
    String masterAddrBak = this.masterAddr;
    if (masterAddrBak != null) {
        try {
            SubscriptionGroupWrapper subscriptionWrapper = this.brokerController.getBrokerOuterAPI().getAllSubscriptionGroupConfig(masterAddrBak);
            if (!this.brokerController.getSubscriptionGroupManager().getDataVersion().equals(subscriptionWrapper.getDataVersion())) {
                SubscriptionGroupManager subscriptionGroupManager = this.brokerController.getSubscriptionGroupManager();
                subscriptionGroupManager.getDataVersion().assignNewOne(subscriptionWrapper.getDataVersion());
                subscriptionGroupManager.getSubscriptionGroupTable().clear();
                subscriptionGroupManager.getSubscriptionGroupTable().putAll(subscriptionWrapper.getSubscriptionGroupTable());
                subscriptionGroupManager.persist();
                log.info("Update slave Subscription Group from master, {}", masterAddrBak);
            }
        } catch (Exception e) {
            log.error("SyncSubscriptionGroup Exception, {}", masterAddrBak, e);
        }
    }
}
Also used : SubscriptionGroupManager(org.apache.rocketmq.broker.subscription.SubscriptionGroupManager) SubscriptionGroupWrapper(org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper) IOException(java.io.IOException)

Example 2 with SubscriptionGroupManager

use of org.apache.rocketmq.broker.subscription.SubscriptionGroupManager in project rocketmq by apache.

the class SlaveSynchronize method syncSubscriptionGroupConfig.

private void syncSubscriptionGroupConfig() {
    String masterAddrBak = this.masterAddr;
    if (masterAddrBak != null) {
        try {
            SubscriptionGroupWrapper subscriptionWrapper = this.brokerController.getBrokerOuterAPI().getAllSubscriptionGroupConfig(masterAddrBak);
            if (!this.brokerController.getSubscriptionGroupManager().getDataVersion().equals(subscriptionWrapper.getDataVersion())) {
                SubscriptionGroupManager subscriptionGroupManager = this.brokerController.getSubscriptionGroupManager();
                subscriptionGroupManager.getDataVersion().assignNewOne(subscriptionWrapper.getDataVersion());
                subscriptionGroupManager.getSubscriptionGroupTable().clear();
                subscriptionGroupManager.getSubscriptionGroupTable().putAll(subscriptionWrapper.getSubscriptionGroupTable());
                subscriptionGroupManager.persist();
                log.info("Update slave Subscription Group from master, {}", masterAddrBak);
            }
        } catch (Exception e) {
            log.error("SyncSubscriptionGroup Exception, {}", masterAddrBak, e);
        }
    }
}
Also used : SubscriptionGroupManager(org.apache.rocketmq.broker.subscription.SubscriptionGroupManager) SubscriptionGroupWrapper(org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)2 SubscriptionGroupManager (org.apache.rocketmq.broker.subscription.SubscriptionGroupManager)2 SubscriptionGroupWrapper (org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper)2