Java Code Examples for org.apache.rocketmq.srvutil.ServerUtil#updateMap()

The following examples show how to use org.apache.rocketmq.srvutil.ServerUtil#updateMap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SubscriptionGroupManager.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public void decode(String jsonString) {
    if (jsonString != null) {
        SubscriptionGroupManager obj = RemotingSerializable.fromJson(jsonString, SubscriptionGroupManager.class);
        if (obj != null) {
            ServerUtil.updateMap(this.subscriptionGroupTable, obj.subscriptionGroupTable);
            this.dataVersion.assignNewOne(obj.dataVersion);
            this.printLoadDataWhenFirstBoot(obj);
        }
    }
}
 
Example 2
Source File: ConsumerOffsetManager.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public void decode(String jsonString) {
    if (jsonString != null) {
        ConsumerOffsetManager obj = RemotingSerializable.fromJson(jsonString, ConsumerOffsetManager.class);
        if (obj != null) {
            ServerUtil.updateMap(this.offsetTable, obj.offsetTable);
        }
    }
}
 
Example 3
Source File: ScheduleMessageService.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public void decode(String jsonString) {
    if (jsonString != null) {
        DelayOffsetSerializeWrapper delayOffsetSerializeWrapper =
            DelayOffsetSerializeWrapper.fromJson(jsonString, DelayOffsetSerializeWrapper.class);
        if (delayOffsetSerializeWrapper != null) {
            ServerUtil.updateMap(this.offsetTable, delayOffsetSerializeWrapper.getOffsetTable());
        }
    }
}
 
Example 4
Source File: SubscriptionGroupManager.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public void decode(String jsonString) {
    if (jsonString != null) {
        SubscriptionGroupManager obj = RemotingSerializable.fromJson(jsonString, SubscriptionGroupManager.class);
        if (obj != null) {
            ServerUtil.updateMap(this.subscriptionGroupTable, obj.subscriptionGroupTable);
            this.dataVersion.assignNewOne(obj.dataVersion);
            this.printLoadDataWhenFirstBoot(obj);
        }
    }
}
 
Example 5
Source File: ConsumerOffsetManager.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public void decode(String jsonString) {
    if (jsonString != null) {
        ConsumerOffsetManager obj = RemotingSerializable.fromJson(jsonString, ConsumerOffsetManager.class);
        if (obj != null) {
            ServerUtil.updateMap(this.offsetTable, obj.offsetTable);
        }
    }
}
 
Example 6
Source File: ScheduleMessageService.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public void decode(String jsonString) {
    if (jsonString != null) {
        DelayOffsetSerializeWrapper delayOffsetSerializeWrapper =
            DelayOffsetSerializeWrapper.fromJson(jsonString, DelayOffsetSerializeWrapper.class);
        if (delayOffsetSerializeWrapper != null) {
            ServerUtil.updateMap(this.offsetTable, delayOffsetSerializeWrapper.getOffsetTable());
        }
    }
}
 
Example 7
Source File: ConsumerFilterManager.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
@Override
public void decode(final String jsonString) {
    ConsumerFilterManager load = RemotingSerializable.fromJson(jsonString, ConsumerFilterManager.class);
    if (load != null && load.filterDataByTopic != null) {
        boolean bloomChanged = false;
        for (String topic : load.filterDataByTopic.keySet()) {
            FilterDataMapByTopic dataMapByTopic = load.filterDataByTopic.get(topic);
            if (dataMapByTopic == null) {
                continue;
            }

            for (String group : dataMapByTopic.getGroupFilterData().keySet()) {

                ConsumerFilterData filterData = dataMapByTopic.getGroupFilterData().get(group);

                if (filterData == null) {
                    continue;
                }

                try {
                    filterData.setCompiledExpression(
                        FilterFactory.INSTANCE.get(filterData.getExpressionType()).compile(filterData.getExpression())
                    );
                } catch (Exception e) {
                    log.error("load filter data error, " + filterData, e);
                }

                // check whether bloom filter is changed
                // if changed, ignore the bit map calculated before.
                if (!this.bloomFilter.isValid(filterData.getBloomFilterData())) {
                    bloomChanged = true;
                    log.info("Bloom filter is changed!So ignore all filter data persisted! {}, {}", this.bloomFilter, filterData.getBloomFilterData());
                    break;
                }

                log.info("load exist consumer filter data: {}", filterData);

                if (filterData.getDeadTime() == 0) {
                    // we think all consumers are dead when load
                    long deadTime = System.currentTimeMillis() - 30 * 1000;
                    filterData.setDeadTime(
                        deadTime <= filterData.getBornTime() ? filterData.getBornTime() : deadTime
                    );
                }
            }
        }

        if (!bloomChanged) {
            ServerUtil.updateMap(this.filterDataByTopic, load.filterDataByTopic);
        }
    }
}
 
Example 8
Source File: CommitLog.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public void setTopicQueueTable(ConcurrentHashMap<String, Long> topicQueueTable) {
    ServerUtil.updateMap(this.topicQueueTable, topicQueueTable);
}
 
Example 9
Source File: ConsumerFilterManager.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
@Override
public void decode(final String jsonString) {
    ConsumerFilterManager load = RemotingSerializable.fromJson(jsonString, ConsumerFilterManager.class);
    if (load != null && load.filterDataByTopic != null) {
        boolean bloomChanged = false;
        for (String topic : load.filterDataByTopic.keySet()) {
            FilterDataMapByTopic dataMapByTopic = load.filterDataByTopic.get(topic);
            if (dataMapByTopic == null) {
                continue;
            }

            for (String group : dataMapByTopic.getGroupFilterData().keySet()) {

                ConsumerFilterData filterData = dataMapByTopic.getGroupFilterData().get(group);

                if (filterData == null) {
                    continue;
                }

                try {
                    filterData.setCompiledExpression(
                        FilterFactory.INSTANCE.get(filterData.getExpressionType()).compile(filterData.getExpression())
                    );
                } catch (Exception e) {
                    log.error("load filter data error, " + filterData, e);
                }

                // check whether bloom filter is changed
                // if changed, ignore the bit map calculated before.
                if (!this.bloomFilter.isValid(filterData.getBloomFilterData())) {
                    bloomChanged = true;
                    log.info("Bloom filter is changed!So ignore all filter data persisted! {}, {}", this.bloomFilter, filterData.getBloomFilterData());
                    break;
                }

                log.info("load exist consumer filter data: {}", filterData);

                if (filterData.getDeadTime() == 0) {
                    // we think all consumers are dead when load
                    long deadTime = System.currentTimeMillis() - 30 * 1000;
                    filterData.setDeadTime(
                        deadTime <= filterData.getBornTime() ? filterData.getBornTime() : deadTime
                    );
                }
            }
        }

        if (!bloomChanged) {
            ServerUtil.updateMap(this.filterDataByTopic, load.filterDataByTopic);
        }
    }
}
 
Example 10
Source File: CommitLog.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public void setTopicQueueTable(ConcurrentHashMap<String, Long> topicQueueTable) {
    ServerUtil.updateMap(this.topicQueueTable, topicQueueTable);
}