View Javadoc

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, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.giraph.zk;
19  
20  import java.net.InetSocketAddress;
21  
22  /**
23   * Zookeeper configuration file.
24   * Originally copied from zookeeper sources to allow
25   * modification on the fly instead of reading from disk.
26   */
27  public class ZookeeperConfig {
28  
29    /** Zookeeper server address */
30    private InetSocketAddress clientPortAddress;
31    /** Snapshot log dir */
32    private String dataDir;
33    /** Transaction log dir */
34    private String dataLogDir;
35    /** minimum session timeout in milliseconds */
36    private int minSessionTimeout = -1;
37    /** maximum session timeout in milliseconds */
38    private int maxSessionTimeout = -1;
39    /**
40     * Get zookeeper server address
41     * @return zookeeper server address
42     */
43    public InetSocketAddress getClientPortAddress() { return clientPortAddress; }
44  
45    /**
46     * Snapshot dir
47     * @return snapshot dir path
48     */
49    public String getDataDir() { return dataDir; }
50  
51    /**
52     * Transaction dir
53     * @return transaction dir path
54     */
55    public String getDataLogDir() {
56      if (dataLogDir == null) {
57        return dataDir;
58      }
59      return dataLogDir;
60    }
61    /** minimum session timeout in milliseconds */
62    public int getMinSessionTimeout() { return minSessionTimeout; }
63    /** maximum session timeout in milliseconds */
64    public int getMaxSessionTimeout() { return maxSessionTimeout; }
65  
66    /**
67     * Set snapshot log dir
68     * @param dataDir snapshot log dir path
69     */
70    public void setDataDir(String dataDir) {
71      this.dataDir = dataDir;
72    }
73  
74    /**
75     * Transaction log dir
76     * @param dataLogDir transaction log dir path
77     */
78    public void setDataLogDir(String dataLogDir) {
79      this.dataLogDir = dataLogDir;
80    }
81  
82    /**
83     * Set zookeeper server address
84     * @param clientPortAddress server address
85     */
86    public void setClientPortAddress(InetSocketAddress clientPortAddress) {
87      this.clientPortAddress = clientPortAddress;
88    }
89  
90    /**
91     * Set minimum session timeout in milliseconds
92     * @param minSessionTimeout min session timeout
93     */
94    public void setMinSessionTimeout(int minSessionTimeout) {
95      this.minSessionTimeout = minSessionTimeout;
96    }
97    /**
98     * Set maximum session timeout in milliseconds
99     * @param maxSessionTimeout max session timeout
100    */
101   public void setMaxSessionTimeout(int maxSessionTimeout) {
102     this.maxSessionTimeout = maxSessionTimeout;
103   }
104 
105 }