Commit 5e0ccf28 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Remove config module dans sample configuration file, their are no more usefull.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1278 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 678b3615
# Note: Unless otherwise noted, all parameters in this configuration file
# must be identical for all nodes in a given cluster.
# Default parameters.
[DEFAULT]
# The cluster name
# This must be set.
# It must be a name unique to a given cluster, to prevent foreign
# misconfigured nodes from interfering.
name:
# The list of master nodes
# Master nodes not not in this list will be rejected by the cluster.
# This list should be identical for all nodes in a given cluster for
# maximum availability.
master_nodes: 127.0.0.1:10010 127.0.0.1:10011
# Partition table configuration
# Data in the cluster is distributed among nodes using a partition table, which
# has the following parameters.
# Replicas: How many copies of a partition should exist at a time.
# 0 means no redundancy
# 1 means there is a spare copy of all partitions
replicas: 1
# Partitions: How data spreads among storage nodes. This number must be at
# least equal to the number of storage nodes the cluster contains.
# IMPORTANT: This must not be changed once the cluster contains data.
partitions: 20
# MySQL credentials
# MySQL username and password used by storage nodes to access data.
# This user must have the right to drop & create tables in his database
# (see storage node configuration sections).
# This can be overriden in individual storage configurations.
user: neo
password: neo
# Individual nodes parameters
# Some parameters makes no sense to be defined in [DEFAULT] section.
# They are:
# server: The ip:port the node will listen on.
# database: Storage nodes only. The MySQL database to use to store data.
# Those database must be created manualy.
# Admin node
[admin]
server: 127.0.0.1:5555
# Master nodes
[master1]
server: 127.0.0.1:10010
[master2]
server: 127.0.0.1:10011
# Storage nodes
[storage1]
database: neo1
server: 127.0.0.1:10020
[storage2]
database: neo2
server: 127.0.0.1:10021
[storage3]
database: neo3
server: 127.0.0.1:10022
[storage4]
database: neo4
server: 127.0.0.1:10023
#
# Copyright (C) 2006-2009 Nexedi SA
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from ConfigParser import SafeConfigParser
from neo import logging
class ConfigurationManager:
"""This class provides support for parsing a configuration file."""
# The default values for a config file.
default_config_dict = {'database' : 'test',
'user' : 'test',
'password' : None,
'server' : '127.0.0.1',
'connector' : 'SocketConnector',
'master_nodes' : '',
'replicas' : '0',
'partitions' : '1009',
'name' : 'main'}
# The default port to which master nodes listen when none is specified.
default_master_port = 10100
def __init__(self, config_file, section):
parser = SafeConfigParser(self.default_config_dict)
logging.debug('reading a configuration from %s', config_file)
parser.read(config_file)
self.parser = parser
self.section = section
def __getitem__(self, key):
return self.parser.get(self.section, key)
def getDatabase(self):
return self['database']
def getUser(self):
return self['user']
def getPassword(self):
return self['password']
def getServer(self):
server = self['server']
if ':' in server:
ip_address, port = server.split(':')
port = int(port)
else:
ip_address = server
port = self.default_master_port
return ip_address, port
def getReplicas(self):
return int(self['replicas'])
def getPartitions(self):
return int(self['partitions'])
def getConnector(self):
return str(self['connector'])
def getName(self):
return self['name']
def getMasterNodeList(self):
master_nodes = self['master_nodes']
master_node_list = []
# A list of master nodes separated by whitespace.
for node in master_nodes.split():
if not node:
continue
if ':' in node:
ip_address, port = node.split(':')
port = int(port)
else:
ip_address = node
port = self.default_master_port
master_node_list.append((ip_address, port))
return master_node_list
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment