@Override
public void init(final MetaMorphosisBroker metaMorphosisBroker, final Properties props) {
this.broker = metaMorphosisBroker;
this.props = props;
if (this.props == null) {
throw new MetamorphosisServerStartupException("Null samsa_master properties");
}
this.recoverOffset = Boolean.valueOf(this.props.getProperty("recoverOffset", "false"));
// ��Ҫrecover offset����ʱ�Ȳ�������zookeeper�ϣ���recover֮���ע����ȥ
if (this.recoverOffset) {
this.broker.getBrokerZooKeeper().getZkConfig().zkEnable = false;
}
final int callbackThreadCount =
Integer.parseInt(props.getProperty("callbackThreadCount", String.valueOf(DEFAULT_CB_THREADPOOL_SIZE)));
final String slave = props.getProperty("slave");
if (StringUtils.isBlank(slave)) {
throw new IllegalArgumentException("Blank slave");
}
this.setConfigs(props);
final ClientConfig clientConfig = new ClientConfig();
// ֻʹ��1��reactor
clientConfig.setSelectorPoolSize(1);
clientConfig.setWireFormatType(new MetamorphosisWireFormatType());
try {
this.remotingClient = RemotingFactory.newRemotingClient(clientConfig);
this.remotingClient.start();
this.masterProcessor =
new SamsaCommandProcessor(metaMorphosisBroker.getStoreManager(),
metaMorphosisBroker.getExecutorsManager(), metaMorphosisBroker.getStatsManager(),
metaMorphosisBroker.getRemotingServer(), metaMorphosisBroker.getMetaConfig(),
metaMorphosisBroker.getIdWorker(), metaMorphosisBroker.getBrokerZooKeeper(),
this.remotingClient, metaMorphosisBroker.getConsumerFilterManager(), slave,
callbackThreadCount, this.sendToSlaveTimeoutInMills, this.checkSlaveIntervalInMills,
this.slaveContinuousFailureThreshold);
// �滻������
this.broker.setBrokerProcessor(this.masterProcessor);
log.info("Init samsa mater successfully with config:" + props);
}
catch (final NotifyRemotingException e) {
throw new MetamorphosisServerStartupException("Init master processor failed", e);
}
catch (final InterruptedException e) {
Thread.currentThread().interrupt();
}
}