All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alibaba.rocketmq.common.BrokerConfig Maven / Gradle / Ivy

/**
 * Copyright (C) 2010-2013 Alibaba Group Holding Limited
 * 

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *

* http://www.apache.org/licenses/LICENSE-2.0 *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.alibaba.rocketmq.common; import com.alibaba.rocketmq.common.annotation.ImportantField; import com.alibaba.rocketmq.common.constant.PermName; import com.alibaba.rocketmq.remoting.common.RemotingUtil; import java.net.InetAddress; import java.net.UnknownHostException; /** * 服务器配置 * * @author shijia.wxr */ public class BrokerConfig { private String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV)); @ImportantField private String namesrvAddr = System.getProperty(MixAll.NAMESRV_ADDR_PROPERTY, System.getenv(MixAll.NAMESRV_ADDR_ENV)); @ImportantField private String brokerIP1 = RemotingUtil.getLocalAddress(); private String brokerIP2 = RemotingUtil.getLocalAddress(); @ImportantField private String brokerName = localHostName(); @ImportantField private String brokerClusterName = "DefaultCluster"; @ImportantField private long brokerId = MixAll.MASTER_ID; private int brokerPermission = PermName.PERM_READ | PermName.PERM_WRITE; private int defaultTopicQueueNums = 8; // 自动创建Topic功能是否开启(线上建议关闭) @ImportantField private boolean autoCreateTopicEnable = true; // 自动创建以集群名字命名的Topic功能是否开启 private boolean clusterTopicEnable = true; // 自动创建以服务器名字命名的Topic功能是否开启 private boolean brokerTopicEnable = true; // 自动创建订阅组功能是否开启(线上建议关闭) @ImportantField private boolean autoCreateSubscriptionGroup = true; // messageStore的plugin private String messageStorePlugIn = ""; private int sendMessageThreadPoolNums = 16 + Runtime.getRuntime().availableProcessors() * 4; private int pullMessageThreadPoolNums = 16 + Runtime.getRuntime().availableProcessors() * 2; private int adminBrokerThreadPoolNums = 16; private int clientManageThreadPoolNums = 16; private int flushConsumerOffsetInterval = 1000 * 5; private int flushConsumerOffsetHistoryInterval = 1000 * 60; // 是否拒绝接收事务消息 @ImportantField private boolean rejectTransactionMessage = false; // 是否从地址服务器寻找Name Server地址,正式发布后,默认值为false @ImportantField private boolean fetchNamesrvAddrByAddressServer = false; // 发送消息对应的线程池阻塞队列size private int sendThreadPoolQueueCapacity = 100000; // 订阅消息对应的线程池阻塞队列size private int pullThreadPoolQueueCapacity = 100000; // 过滤服务器数量 private int filterServerNums = 0; // Consumer订阅消息时,Broker是否开启长轮询 private boolean longPollingEnable = true; // 如果是短轮询,服务器挂起时间 private long shortPollingTimeMills = 1000; // notify consumerId changed 开关 private boolean notifyConsumerIdsChangedEnable = true; // 高速模式 private boolean highSpeedMode = false; // 商业化日志采集开关 private boolean commercialEnable = true; // 商业化定时消息系数(默认:1) private int commercialTimerCount = 1; //商业化事务消息系数(默认:1) private int commercialTransCount = 1; //商业化大消息系数(默认:1) private int commercialBigCount = 1; // 通过Java堆来传输消息 private boolean transferMsgByHeap = true; // 定时消息最大延迟时间(默认:40天) private int maxDelayTime = 40; //broker所在的Region名称 private String regionId = "DefaultRegion"; public String getRegionId() { return regionId; } public void setRegionId(final String regionId) { this.regionId = regionId; } public boolean isTransferMsgByHeap() { return transferMsgByHeap; } public void setTransferMsgByHeap(final boolean transferMsgByHeap) { this.transferMsgByHeap = transferMsgByHeap; } public static String localHostName() { try { return InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { e.printStackTrace(); } return "DEFAULT_BROKER"; } public String getMessageStorePlugIn() { return messageStorePlugIn; } public void setMessageStorePlugIn(String messageStorePlugIn) { this.messageStorePlugIn = messageStorePlugIn; } public boolean isHighSpeedMode() { return highSpeedMode; } public void setHighSpeedMode(final boolean highSpeedMode) { this.highSpeedMode = highSpeedMode; } public String getRocketmqHome() { return rocketmqHome; } public void setRocketmqHome(String rocketmqHome) { this.rocketmqHome = rocketmqHome; } public String getBrokerName() { return brokerName; } public void setBrokerName(String brokerName) { this.brokerName = brokerName; } public int getBrokerPermission() { return brokerPermission; } public void setBrokerPermission(int brokerPermission) { this.brokerPermission = brokerPermission; } public int getDefaultTopicQueueNums() { return defaultTopicQueueNums; } public void setDefaultTopicQueueNums(int defaultTopicQueueNums) { this.defaultTopicQueueNums = defaultTopicQueueNums; } public boolean isAutoCreateTopicEnable() { return autoCreateTopicEnable; } public void setAutoCreateTopicEnable(boolean autoCreateTopic) { this.autoCreateTopicEnable = autoCreateTopic; } public String getBrokerClusterName() { return brokerClusterName; } public void setBrokerClusterName(String brokerClusterName) { this.brokerClusterName = brokerClusterName; } public String getBrokerIP1() { return brokerIP1; } public void setBrokerIP1(String brokerIP1) { this.brokerIP1 = brokerIP1; } public String getBrokerIP2() { return brokerIP2; } public void setBrokerIP2(String brokerIP2) { this.brokerIP2 = brokerIP2; } public int getSendMessageThreadPoolNums() { return sendMessageThreadPoolNums; } public void setSendMessageThreadPoolNums(int sendMessageThreadPoolNums) { this.sendMessageThreadPoolNums = sendMessageThreadPoolNums; } public int getPullMessageThreadPoolNums() { return pullMessageThreadPoolNums; } public void setPullMessageThreadPoolNums(int pullMessageThreadPoolNums) { this.pullMessageThreadPoolNums = pullMessageThreadPoolNums; } public int getAdminBrokerThreadPoolNums() { return adminBrokerThreadPoolNums; } public void setAdminBrokerThreadPoolNums(int adminBrokerThreadPoolNums) { this.adminBrokerThreadPoolNums = adminBrokerThreadPoolNums; } public int getFlushConsumerOffsetInterval() { return flushConsumerOffsetInterval; } public void setFlushConsumerOffsetInterval(int flushConsumerOffsetInterval) { this.flushConsumerOffsetInterval = flushConsumerOffsetInterval; } public int getFlushConsumerOffsetHistoryInterval() { return flushConsumerOffsetHistoryInterval; } public void setFlushConsumerOffsetHistoryInterval(int flushConsumerOffsetHistoryInterval) { this.flushConsumerOffsetHistoryInterval = flushConsumerOffsetHistoryInterval; } public boolean isClusterTopicEnable() { return clusterTopicEnable; } public void setClusterTopicEnable(boolean clusterTopicEnable) { this.clusterTopicEnable = clusterTopicEnable; } public String getNamesrvAddr() { return namesrvAddr; } public void setNamesrvAddr(String namesrvAddr) { this.namesrvAddr = namesrvAddr; } public long getBrokerId() { return brokerId; } public void setBrokerId(long brokerId) { this.brokerId = brokerId; } public boolean isAutoCreateSubscriptionGroup() { return autoCreateSubscriptionGroup; } public void setAutoCreateSubscriptionGroup(boolean autoCreateSubscriptionGroup) { this.autoCreateSubscriptionGroup = autoCreateSubscriptionGroup; } public boolean isRejectTransactionMessage() { return rejectTransactionMessage; } public void setRejectTransactionMessage(boolean rejectTransactionMessage) { this.rejectTransactionMessage = rejectTransactionMessage; } public boolean isFetchNamesrvAddrByAddressServer() { return fetchNamesrvAddrByAddressServer; } public void setFetchNamesrvAddrByAddressServer(boolean fetchNamesrvAddrByAddressServer) { this.fetchNamesrvAddrByAddressServer = fetchNamesrvAddrByAddressServer; } public int getSendThreadPoolQueueCapacity() { return sendThreadPoolQueueCapacity; } public void setSendThreadPoolQueueCapacity(int sendThreadPoolQueueCapacity) { this.sendThreadPoolQueueCapacity = sendThreadPoolQueueCapacity; } public int getPullThreadPoolQueueCapacity() { return pullThreadPoolQueueCapacity; } public void setPullThreadPoolQueueCapacity(int pullThreadPoolQueueCapacity) { this.pullThreadPoolQueueCapacity = pullThreadPoolQueueCapacity; } public boolean isBrokerTopicEnable() { return brokerTopicEnable; } public void setBrokerTopicEnable(boolean brokerTopicEnable) { this.brokerTopicEnable = brokerTopicEnable; } public int getFilterServerNums() { return filterServerNums; } public void setFilterServerNums(int filterServerNums) { this.filterServerNums = filterServerNums; } public boolean isLongPollingEnable() { return longPollingEnable; } public void setLongPollingEnable(boolean longPollingEnable) { this.longPollingEnable = longPollingEnable; } public boolean isNotifyConsumerIdsChangedEnable() { return notifyConsumerIdsChangedEnable; } public void setNotifyConsumerIdsChangedEnable(boolean notifyConsumerIdsChangedEnable) { this.notifyConsumerIdsChangedEnable = notifyConsumerIdsChangedEnable; } public long getShortPollingTimeMills() { return shortPollingTimeMills; } public void setShortPollingTimeMills(long shortPollingTimeMills) { this.shortPollingTimeMills = shortPollingTimeMills; } public int getClientManageThreadPoolNums() { return clientManageThreadPoolNums; } public void setClientManageThreadPoolNums(int clientManageThreadPoolNums) { this.clientManageThreadPoolNums = clientManageThreadPoolNums; } public boolean isCommercialEnable() { return commercialEnable; } public void setCommercialEnable(final boolean commercialEnable) { this.commercialEnable = commercialEnable; } public int getCommercialTimerCount() { return commercialTimerCount; } public void setCommercialTimerCount(final int commercialTimerCount) { this.commercialTimerCount = commercialTimerCount; } public int getCommercialTransCount() { return commercialTransCount; } public void setCommercialTransCount(final int commercialTransCount) { this.commercialTransCount = commercialTransCount; } public int getCommercialBigCount() { return commercialBigCount; } public void setCommercialBigCount(final int commercialBigCount) { this.commercialBigCount = commercialBigCount; } public int getMaxDelayTime() { return maxDelayTime; } public void setMaxDelayTime(final int maxDelayTime) { this.maxDelayTime = maxDelayTime; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy