本文整理汇总了Java中org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException类的典型用法代码示例。如果您正苦于以下问题:Java ConfigException类的具体用法?Java ConfigException怎么用?Java ConfigException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConfigException类属于org.apache.zookeeper.server.quorum.QuorumPeerConfig包,在下文中一共展示了ConfigException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeAndRun
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; //导入依赖的package包/类
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);
}
}
示例2: initializeAndRun
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; //导入依赖的package包/类
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);
}
示例3: QuorumMaj
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; //导入依赖的package包/类
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;
}
示例4: splitWithLeadingHostname
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; //导入依赖的package包/类
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(":");
}
}
示例5: initializeAndRun
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; //导入依赖的package包/类
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);
}
}
示例6: initializeAndRun
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; //导入依赖的package包/类
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);
}
示例7: addConfiguration
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; //导入依赖的package包/类
/**
* 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);
}
}
示例8: testWithMinSessionTimeoutGreaterThanMaxSessionTimeout
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; //导入依赖的package包/类
/**
* 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
}
}
示例9: initializeAndRun
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; //导入依赖的package包/类
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);
}
示例10: initializeAndRun
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; //导入依赖的package包/类
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);
}
}
示例11: initializeAndRun
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; //导入依赖的package包/类
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);
}
示例12: testWithMinSessionTimeoutGreaterThanMaxSessionTimeout
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; //导入依赖的package包/类
/**
* 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
}
}
示例13: setUp
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; //导入依赖的package包/类
@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);
}
示例14: MiniAvatarCluster
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; //导入依赖的package包/类
/**
* 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));
}
示例15: createZooKeeperConf
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; //导入依赖的package包/类
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;
}