protected void initializeAndRun(String[] args)
throws ConfigException, IOException
{
try {
ManagedUtil.registerLog4jMBeans();
} catch (JMException e) {
LOG.warn("Unable to register log4j JMX control", e);
}
//再次解析配置文件(我也是醉了呀,又解析一遍!!!,写这段的人你出来我保证不打你)
ServerConfig config = new ServerConfig();
if (args.length == 1) {
config.parse(args[0]);
} else {
config.parse(args);
}
runFromConfig(config);
}
java类org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException的实例源码
ZooKeeperServerMain.java 文件源码
项目:fuck_zookeeper
阅读 33
收藏 0
点赞 0
评论 0
QuorumMaj.java 文件源码
项目:https-github.com-apache-zookeeper
阅读 39
收藏 0
点赞 0
评论 0
public QuorumMaj(Properties props) throws ConfigException {
for (Entry<Object, Object> entry : props.entrySet()) {
String key = entry.getKey().toString();
String value = entry.getValue().toString();
if (key.startsWith("server.")) {
int dot = key.indexOf('.');
long sid = Long.parseLong(key.substring(dot + 1));
QuorumServer qs = new QuorumServer(sid, value);
allMembers.put(Long.valueOf(sid), qs);
if (qs.type == LearnerType.PARTICIPANT)
votingMembers.put(Long.valueOf(sid), qs);
else {
observingMembers.put(Long.valueOf(sid), qs);
}
} else if (key.equals("version")) {
version = Long.parseLong(value, 16);
}
}
half = votingMembers.size() / 2;
}
QuorumPeer.java 文件源码
项目:https-github.com-apache-zookeeper
阅读 31
收藏 0
点赞 0
评论 0
private static String[] splitWithLeadingHostname(String s)
throws ConfigException
{
/* Does it start with an IPv6 literal? */
if (s.startsWith("[")) {
int i = s.indexOf("]:");
if (i < 0) {
throw new ConfigException(s + " starts with '[' but has no matching ']:'");
}
String[] sa = s.substring(i + 2).split(":");
String[] nsa = new String[sa.length + 1];
nsa[0] = s.substring(1, i);
System.arraycopy(sa, 0, nsa, 1, sa.length);
return nsa;
} else {
return s.split(":");
}
}
QuorumPeerMain.java 文件源码
项目:https-github.com-apache-zookeeper
阅读 31
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException, AdminServerException
{
QuorumPeerConfig config = new QuorumPeerConfig();
if (args.length == 1) {
config.parse(args[0]);
}
// Start and schedule the the purge task
DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
.getDataDir(), config.getDataLogDir(), config
.getSnapRetainCount(), config.getPurgeInterval());
purgeMgr.start();
if (args.length == 1 && config.isDistributed()) {
runFromConfig(config);
} else {
LOG.warn("Either no config or no quorum defined in config, running "
+ " in standalone mode");
// there is only server in the quorum -- run as standalone
ZooKeeperServerMain.main(args);
}
}
ZooKeeperServerMain.java 文件源码
项目:https-github.com-apache-zookeeper
阅读 27
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException, AdminServerException
{
try {
ManagedUtil.registerLog4jMBeans();
} catch (JMException e) {
LOG.warn("Unable to register log4j JMX control", e);
}
ServerConfig config = new ServerConfig();
if (args.length == 1) {
config.parse(args[0]);
} else {
config.parse(args);
}
runFromConfig(config);
}
ZKConfig.java 文件源码
项目:https-github.com-apache-zookeeper
阅读 28
收藏 0
点赞 0
评论 0
/**
* Add a configuration resource. The properties form this configuration will
* overwrite corresponding already loaded property and system property
*
* @param configFile
* Configuration file.
*/
public void addConfiguration(File configFile) throws ConfigException {
LOG.info("Reading configuration from: {}", configFile.getAbsolutePath());
try {
configFile = (new VerifyingFileFactory.Builder(LOG).warnForRelativePath().failForNonExistingPath().build())
.validate(configFile);
Properties cfg = new Properties();
FileInputStream in = new FileInputStream(configFile);
try {
cfg.load(in);
} finally {
in.close();
}
parseProperties(cfg);
} catch (IOException | IllegalArgumentException e) {
LOG.error("Error while configuration from: {}", configFile.getAbsolutePath(), e);
throw new ConfigException("Error while processing " + configFile.getAbsolutePath(), e);
}
}
ZooKeeperServerMainTest.java 文件源码
项目:https-github.com-apache-zookeeper
阅读 28
收藏 0
点赞 0
评论 0
/**
* Test verifies that the server shouldn't allow minsessiontimeout >
* maxsessiontimeout
*/
@Test
public void testWithMinSessionTimeoutGreaterThanMaxSessionTimeout()
throws Exception {
ClientBase.setupTestEnv();
final int CLIENT_PORT = PortAssignment.unique();
final int tickTime = 2000;
final int minSessionTimeout = 20 * tickTime + 1000; // min is higher
final int maxSessionTimeout = tickTime * 2 - 100; // max is lower
final String configs = "maxSessionTimeout=" + maxSessionTimeout + "\n"
+ "minSessionTimeout=" + minSessionTimeout + "\n";
MainThread main = new MainThread(CLIENT_PORT, true, configs);
String args[] = new String[1];
args[0] = main.confFile.toString();
try {
main.main.initializeAndRun(args);
Assert.fail("Must throw exception as "
+ "minsessiontimeout > maxsessiontimeout");
} catch (ConfigException iae) {
// expected
}
}
QuorumPeerMain.java 文件源码
项目:ZooKeeper
阅读 31
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException
{
QuorumPeerConfig config = new QuorumPeerConfig();
if (args.length == 1) {
config.parse(args[0]);
}
// Start and schedule the the purge task
DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
.getDataDir(), config.getDataLogDir(), config
.getSnapRetainCount(), config.getPurgeInterval());
purgeMgr.start();
if (args.length == 1 && config.servers.size() > 0) {
runFromConfig(config);
} else {
LOG.warn("Either no config or no quorum defined in config, running "
+ " in standalone mode");
// there is only server in the quorum -- run as standalone
ZooKeeperServerMain.main(args);
}
}
ZooKeeperServerMain.java 文件源码
项目:ZooKeeper
阅读 30
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException
{
try {
ManagedUtil.registerLog4jMBeans();
} catch (JMException e) {
LOG.warn("Unable to register log4j JMX control", e);
}
ServerConfig config = new ServerConfig();
if (args.length == 1) {
config.parse(args[0]);
} else {
config.parse(args);
}
runFromConfig(config);
}
QuorumPeerMain.java 文件源码
项目:StreamProcessingInfrastructure
阅读 29
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException
{
QuorumPeerConfig config = new QuorumPeerConfig();
if (args.length == 1) {
config.parse(args[0]);
}
// Start and schedule the the purge task
DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
.getDataDir(), config.getDataLogDir(), config
.getSnapRetainCount(), config.getPurgeInterval());
purgeMgr.start();
if (args.length == 1 && config.servers.size() > 0) {
runFromConfig(config);
} else {
LOG.warn("Either no config or no quorum defined in config, running "
+ " in standalone mode");
// there is only server in the quorum -- run as standalone
ZooKeeperServerMain.main(args);
}
}
ZooKeeperServerMain.java 文件源码
项目:StreamProcessingInfrastructure
阅读 24
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException
{
try {
ManagedUtil.registerLog4jMBeans();
} catch (JMException e) {
LOG.warn("Unable to register log4j JMX control", e);
}
ServerConfig config = new ServerConfig();
if (args.length == 1) {
config.parse(args[0]);
} else {
config.parse(args);
}
runFromConfig(config);
}
QuorumPeerMain.java 文件源码
项目:bigstreams
阅读 28
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException
{
QuorumPeerConfig config = new QuorumPeerConfig();
if (args.length == 1) {
config.parse(args[0]);
}
// Start and schedule the the purge task
DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
.getDataDir(), config.getDataLogDir(), config
.getSnapRetainCount(), config.getPurgeInterval());
purgeMgr.start();
if (args.length == 1 && config.servers.size() > 0) {
runFromConfig(config);
} else {
LOG.warn("Either no config or no quorum defined in config, running "
+ " in standalone mode");
// there is only server in the quorum -- run as standalone
ZooKeeperServerMain.main(args);
}
}
ZooKeeperServerMain.java 文件源码
项目:bigstreams
阅读 28
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException
{
try {
ManagedUtil.registerLog4jMBeans();
} catch (JMException e) {
LOG.warn("Unable to register log4j JMX control", e);
}
ServerConfig config = new ServerConfig();
if (args.length == 1) {
config.parse(args[0]);
} else {
config.parse(args);
}
runFromConfig(config);
}
QuorumPeerMain.java 文件源码
项目:bigstreams
阅读 31
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException
{
QuorumPeerConfig config = new QuorumPeerConfig();
if (args.length == 1) {
config.parse(args[0]);
}
if (args.length == 1 && config.servers.size() > 0) {
runFromConfig(config);
} else {
LOG.warn("Either no config or no quorum defined in config, running "
+ " in standalone mode");
// there is only server in the quorum -- run as standalone
ZooKeeperServerMain.main(args);
}
}
ZooKeeperServerMain.java 文件源码
项目:bigstreams
阅读 36
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException
{
try {
ManagedUtil.registerLog4jMBeans();
} catch (JMException e) {
LOG.warn("Unable to register log4j JMX control", e);
}
ServerConfig config = new ServerConfig();
if (args.length == 1) {
config.parse(args[0]);
} else {
config.parse(args);
}
runFromConfig(config);
}
QuorumPeerMain.java 文件源码
项目:zookeeper-src-learning
阅读 41
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException
{
QuorumPeerConfig config = new QuorumPeerConfig();
if (args.length == 1) {
config.parse(args[0]);
}
// Start and schedule the the purge task
DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
.getDataDir(), config.getDataLogDir(), config
.getSnapRetainCount(), config.getPurgeInterval());
purgeMgr.start();
if (args.length == 1 && config.servers.size() > 0) {
runFromConfig(config);
} else {
LOG.warn("Either no config or no quorum defined in config, running "
+ " in standalone mode");
// there is only server in the quorum -- run as standalone
ZooKeeperServerMain.main(args);
}
}
ZooKeeperServerMain.java 文件源码
项目:zookeeper-src-learning
阅读 31
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException {
try {
ManagedUtil.registerLog4jMBeans();
} catch (JMException e) {
LOG.warn("Unable to register log4j JMX control", e);
}
ServerConfig config = new ServerConfig();
if (args.length == 1) {
config.parse(args[0]);
} else {
config.parse(args);
}
runFromConfig(config);
}
ZooKeeperServerMain.java 文件源码
项目:zookeeper
阅读 28
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException
{
try {
ManagedUtil.registerLog4jMBeans();
} catch (JMException e) {
LOG.warn("Unable to register log4j JMX control", e);
}
ServerConfig config = new ServerConfig();
if (args.length == 1) {
config.parse(args[0]);
} else {
config.parse(args);
}
runFromConfig(config);
}
QuorumMaj.java 文件源码
项目:SecureKeeper
阅读 28
收藏 0
点赞 0
评论 0
public QuorumMaj(Properties props) throws ConfigException {
for (Entry<Object, Object> entry : props.entrySet()) {
String key = entry.getKey().toString();
String value = entry.getValue().toString();
if (key.startsWith("server.")) {
int dot = key.indexOf('.');
long sid = Long.parseLong(key.substring(dot + 1));
QuorumServer qs = new QuorumServer(sid, value);
allMembers.put(Long.valueOf(sid), qs);
if (qs.type == LearnerType.PARTICIPANT)
votingMembers.put(Long.valueOf(sid), qs);
else {
observingMembers.put(Long.valueOf(sid), qs);
}
} else if (key.equals("version")) {
version = Long.parseLong(value, 16);
}
}
half = votingMembers.size() / 2;
}
QuorumPeerMain.java 文件源码
项目:SecureKeeper
阅读 28
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException, AdminServerException
{
QuorumPeerConfig config = new QuorumPeerConfig();
if (args.length == 1) {
config.parse(args[0]);
}
// Start and schedule the the purge task
DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
.getDataDir(), config.getDataLogDir(), config
.getSnapRetainCount(), config.getPurgeInterval());
purgeMgr.start();
if (args.length == 1 && config.isDistributed()) {
runFromConfig(config);
} else {
LOG.warn("Either no config or no quorum defined in config, running "
+ " in standalone mode");
// there is only server in the quorum -- run as standalone
ZooKeeperServerMain.main(args);
}
}
ZooKeeperServerMain.java 文件源码
项目:SecureKeeper
阅读 29
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException, AdminServerException
{
try {
ManagedUtil.registerLog4jMBeans();
} catch (JMException e) {
LOG.warn("Unable to register log4j JMX control", e);
}
ServerConfig config = new ServerConfig();
if (args.length == 1) {
config.parse(args[0]);
} else {
config.parse(args);
}
runFromConfig(config);
}
ZooKeeperServerMainTest.java 文件源码
项目:SecureKeeper
阅读 31
收藏 0
点赞 0
评论 0
/**
* Test verifies that the server shouldn't allow minsessiontimeout >
* maxsessiontimeout
*/
@Test
public void testWithMinSessionTimeoutGreaterThanMaxSessionTimeout()
throws Exception {
ClientBase.setupTestEnv();
final int CLIENT_PORT = PortAssignment.unique();
final int tickTime = 2000;
final int minSessionTimeout = 20 * tickTime + 1000; // min is higher
final int maxSessionTimeout = tickTime * 2 - 100; // max is lower
final String configs = "maxSessionTimeout=" + maxSessionTimeout + "\n"
+ "minSessionTimeout=" + minSessionTimeout + "\n";
MainThread main = new MainThread(CLIENT_PORT, false, configs);
String args[] = new String[1];
args[0] = main.confFile.toString();
try {
main.main.initializeAndRun(args);
Assert.fail("Must throw exception as "
+ "minsessiontimeout > maxsessiontimeout");
} catch (ConfigException iae) {
// expected
}
}
QuorumMaj.java 文件源码
项目:SecureKeeper
阅读 29
收藏 0
点赞 0
评论 0
public QuorumMaj(Properties props) throws ConfigException {
for (Entry<Object, Object> entry : props.entrySet()) {
String key = entry.getKey().toString();
String value = entry.getValue().toString();
if (key.startsWith("server.")) {
int dot = key.indexOf('.');
long sid = Long.parseLong(key.substring(dot + 1));
QuorumServer qs = new QuorumServer(sid, value);
allMembers.put(Long.valueOf(sid), qs);
if (qs.type == LearnerType.PARTICIPANT)
votingMembers.put(Long.valueOf(sid), qs);
else {
observingMembers.put(Long.valueOf(sid), qs);
}
} else if (key.equals("version")) {
version = Long.parseLong(value, 16);
}
}
half = votingMembers.size() / 2;
}
QuorumPeerMain.java 文件源码
项目:SecureKeeper
阅读 28
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException, AdminServerException
{
QuorumPeerConfig config = new QuorumPeerConfig();
if (args.length == 1) {
config.parse(args[0]);
}
// Start and schedule the the purge task
DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
.getDataDir(), config.getDataLogDir(), config
.getSnapRetainCount(), config.getPurgeInterval());
purgeMgr.start();
if (args.length == 1 && config.isDistributed()) {
runFromConfig(config);
} else {
LOG.warn("Either no config or no quorum defined in config, running "
+ " in standalone mode");
// there is only server in the quorum -- run as standalone
ZooKeeperServerMain.main(args);
}
}
ZooKeeperServerMain.java 文件源码
项目:SecureKeeper
阅读 26
收藏 0
点赞 0
评论 0
protected void initializeAndRun(String[] args)
throws ConfigException, IOException, AdminServerException
{
try {
ManagedUtil.registerLog4jMBeans();
} catch (JMException e) {
LOG.warn("Unable to register log4j JMX control", e);
}
ServerConfig config = new ServerConfig();
if (args.length == 1) {
config.parse(args[0]);
} else {
config.parse(args);
}
runFromConfig(config);
}
ZooKeeperServerMainTest.java 文件源码
项目:SecureKeeper
阅读 33
收藏 0
点赞 0
评论 0
/**
* Test verifies that the server shouldn't allow minsessiontimeout >
* maxsessiontimeout
*/
@Test
public void testWithMinSessionTimeoutGreaterThanMaxSessionTimeout()
throws Exception {
ClientBase.setupTestEnv();
final int CLIENT_PORT = PortAssignment.unique();
final int tickTime = 2000;
final int minSessionTimeout = 20 * tickTime + 1000; // min is higher
final int maxSessionTimeout = tickTime * 2 - 100; // max is lower
final String configs = "maxSessionTimeout=" + maxSessionTimeout + "\n"
+ "minSessionTimeout=" + minSessionTimeout + "\n";
MainThread main = new MainThread(CLIENT_PORT, false, configs);
String args[] = new String[1];
args[0] = main.confFile.toString();
try {
main.main.initializeAndRun(args);
Assert.fail("Must throw exception as "
+ "minsessiontimeout > maxsessiontimeout");
} catch (ConfigException iae) {
// expected
}
}
TestSimpleGetNotification.java 文件源码
项目:hadoop-EAR
阅读 25
收藏 0
点赞 0
评论 0
@Before
public void setUp() throws IOException, ConfigException, InterruptedException {
new File(TEST_DIR).mkdirs();
conf = NotifierTestUtil.initGenericConf();
String editsLocation = TEST_DIR + "/tmp/hadoop/name";
conf.set(AvatarNode.DFS_SHARED_EDITS_DIR0_KEY, editsLocation + "0");
conf.set(AvatarNode.DFS_SHARED_EDITS_DIR1_KEY, editsLocation + "1");
cluster = new MiniAvatarCluster.Builder(conf).numDataNodes(3).enableQJM(false)
.federation(true).build();
nameService = conf.get(FSConstants.DFS_FEDERATION_NAMESERVICES);
fileSys = cluster.getFileSystem();
localhostAddr = InetAddress.getLocalHost().getHostName();
DFSUtil.setGenericConf(conf, nameService, AvatarNode.DFS_SHARED_EDITS_DIR0_KEY,
AvatarNode.DFS_SHARED_EDITS_DIR1_KEY);
}
MiniAvatarCluster.java 文件源码
项目:hadoop-EAR
阅读 31
收藏 0
点赞 0
评论 0
/**
* Modify the config and start up the servers. The rpc and info ports for
* servers are guaranteed to use free ports.
* <p>
* NameNode and DataNode directory creation and configuration will be
* managed by this class.
*
* @param conf the base configuration to use in starting the servers. This
* will be modified as necessary.
* @param numDataNodes Number of DataNodes to start; may be zero
* @param format if true, format the NameNode and DataNodes before starting up
* @param racks array of strings indicating the rack that each DataNode is on
* @param hosts array of strings indicating the hostname of each DataNode
* @param numNameNodes Number of NameNodes to start;
* @param federation if true, we start it with federation configure;
*/
public MiniAvatarCluster(Configuration conf,
int numDataNodes,
boolean format,
String[] racks,
String[] hosts,
int numNameNodes,
boolean federation,
long[] simulatedCapacities)
throws IOException, ConfigException, InterruptedException {
this(new Builder(conf).numDataNodes(numDataNodes).format(format)
.racks(racks)
.hosts(hosts)
.numNameNodes(numNameNodes)
.federation(federation)
.simulatedCapacities(simulatedCapacities));
}
MiniAvatarCluster.java 文件源码
项目:hadoop-EAR
阅读 32
收藏 0
点赞 0
评论 0
private static ServerConfig createZooKeeperConf()
throws IOException, ConfigException {
// create conf file
File zkConfDir = new File(TEST_DIR);
zkConfDir.mkdirs();
File zkConfFile = new File(ZK_CONF_FILE);
zkConfFile.delete();
zkConfFile.createNewFile();
Properties zkConfProps = new Properties();
zkConfProps.setProperty("tickTime", "2000");
zkConfProps.setProperty("dataDir", ZK_DATA_DIR);
zkConfProps.setProperty("clientPort", new Integer(zkClientPort).toString());
zkConfProps.setProperty("maxClientCnxns", "500");
zkConfProps.store(new FileOutputStream(zkConfFile), "");
// create config object
ServerConfig zkConf = new ServerConfig();
zkConf.parse(ZK_CONF_FILE);
return zkConf;
}
MiniAvatarCluster.java 文件源码
项目:hadoop-EAR
阅读 24
收藏 0
点赞 0
评论 0
public static void createAndStartZooKeeper()
throws IOException, ConfigException, InterruptedException {
logStateChange("Creating zookeeper server");
AvatarShell.retrySleep = 1000;
ServerConfig zkConf = createZooKeeperConf();
zooKeeper = new ZooKeeperServer();
FileTxnSnapLog ftxn = new
FileTxnSnapLog(new File(zkConf.getDataLogDir()),
new File(zkConf.getDataDir()));
zooKeeper.setTxnLogFactory(ftxn);
zooKeeper.setTickTime(zkConf.getTickTime());
zooKeeper.setMinSessionTimeout(zkConf.getMinSessionTimeout());
zooKeeper.setMaxSessionTimeout(zkConf.getMaxSessionTimeout());
cnxnFactory = new NIOServerCnxnFactory();
cnxnFactory.configure(zkConf.getClientPortAddress(),
zkConf.getMaxClientCnxns());
cnxnFactory.startup(zooKeeper);
logStateChange("Creating zookeeper server - completed");
}