fc483eb9417c12257385da79be66dbe023d16221
[samza.git] / samza-core / src / main / java / org / apache / samza / config / ZkConfig.java
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20 package org.apache.samza.config;
21
22 public class ZkConfig extends MapConfig {
23 // Connection string for ZK, format: :<hostname>:<port>,..."
24 public static final String ZK_CONNECT = "coordinator.zk.connect";
25 public static final String ZK_SESSION_TIMEOUT_MS = "coordinator.zk.session-timeout-ms";
26 public static final String ZK_CONNECTION_TIMEOUT_MS = "coordinator.zk.connection-timeout-ms";
27
28 public static final int DEFAULT_CONNECTION_TIMEOUT_MS = 60000;
29 public static final int DEFAULT_SESSION_TIMEOUT_MS = 30000;
30 public static final String ZK_BARRIER_TIMEOUT_MS = "coordinator.zk.barrier-timeout-ms";
31 public static final int DEFAULT_BARRIER_TIMEOUT_MS = 40000;
32
33 public ZkConfig(Config config) {
34 super(config);
35 }
36
37 public String getZkConnect() {
38 if (!containsKey(ZK_CONNECT)) {
39 throw new ConfigException("Missing " + ZK_CONNECT + " config!");
40 }
41 return get(ZK_CONNECT);
42 }
43
44 public int getZkSessionTimeoutMs() {
45 return getInt(ZK_SESSION_TIMEOUT_MS, DEFAULT_SESSION_TIMEOUT_MS);
46 }
47
48 public int getZkConnectionTimeoutMs() {
49 return getInt(ZK_CONNECTION_TIMEOUT_MS, DEFAULT_CONNECTION_TIMEOUT_MS);
50 }
51
52 public int getZkBarrierTimeoutMs() {
53 return getInt(ZK_BARRIER_TIMEOUT_MS, DEFAULT_BARRIER_TIMEOUT_MS);
54 }
55 }