# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import socorro.lib.ConfigurationManager as cm
import datetime
import stat

#---------------------------------------------------------------------------
# Relational Database Section

databaseHost = cm.Option()
databaseHost.doc = 'the hostname of the database servers'
databaseHost.default = 'localhost'

databasePort = cm.Option()
databasePort.doc = 'the port of the database on the host'
databasePort.default = 5432

databaseName = cm.Option()
databaseName.doc = 'the name of the database within the server'
databaseName.default = 'breakpad'

databaseUserName = cm.Option()
databaseUserName.doc = 'the user name for the database servers'
databaseUserName.default = 'breakpad_rw'

databasePassword = cm.Option()
databasePassword.doc = 'the password for the database user'
databasePassword.default = 'aPassword'

databaseTempbuffers = cm.Option()
databaseTempbuffers.doc = 'temp_buffers setting for use by matviews'
databaseTempbuffers.default = '512MB'

# This is a set of transition parameters to support deprecation
database_hostname = cm.Option()
database_hostname.doc = 'the hostname of the database servers'
database_hostname.default = 'localhost'

database_port = cm.Option()
database_port.doc = 'the port of the database on the host'
database_port.default = 5432

database_name = cm.Option()
database_name.doc = 'the name of the database within the server'
database_name.default = 'breakpad'

database_username = cm.Option()
database_username.doc = 'the user name for the database servers'
database_username.default = 'breakpad_rw'

database_password = cm.Option()
database_password.doc = 'the password for the database user'
database_password.default = 'aPassword'

#---------------------------------------------------------------------------
# RabbitMQ config

rabbitMQUsername = cm.Option()
rabbitMQUsername.doc = 'the username of the rabbitmq user'
rabbitMQUsername.default = 'guest'

rabbitMQPassword = cm.Option()
rabbitMQPassword.doc = 'the password of the rabbitmq user'
rabbitMQPassword.default = 'guest'

rabbitMQHost = cm.Option()
rabbitMQHost.doc = 'the hostname of the rabbitmq service'
rabbitMQHost.default = 'localhost'

rabbitMQPort = cm.Option()
rabbitMQPort.doc = 'the port of the rabbitmq service'
rabbitMQPort.default = 5672

rabbitMQVirtualhost = cm.Option()
rabbitMQVirtualhost.doc = 'the virtual host for rabbitmq'
rabbitMQVirtualhost.default = '/'


rabbitMQStandardQueue = cm.Option()
rabbitMQStandardQueue.doc = 'the standard queue for rabbitmq'
rabbitMQStandardQueue.default = 'socorro.normal'

rabbitMQPriorityQueue = cm.Option()
rabbitMQPriorityQueue.doc = 'the standard queue for rabbitmq'
rabbitMQPriorityQueue.default = 'socorro.priority'

#---------------------------------------------------------------------------
# statsd config

statsdHost = cm.Option()
statsdHost.doc = ''
statsdHost.default = 'localhost'

statsdPort = cm.Option()
statsdPort.doc = '8125'
statsdPort.default = 8125

statsdPrefix = cm.Option()
statsdPrefix.doc = ''
statsdPrefix.default = None

#---------------------------------------------------------------------------
# Crash storage system

jsonFileSuffix = cm.Option()
jsonFileSuffix.doc = 'the suffix used to identify a json file'
jsonFileSuffix.default = '.json'

dumpFileSuffix = cm.Option()
dumpFileSuffix.doc = 'the suffix used to identify a dump file'
dumpFileSuffix.default = '.dump'

#---------------------------------------------------------------------------
# HBase storage system

hbaseStorageClass = cm.Option()
hbaseStorageClass.doc = 'the Socorro classname for HBase storage'
hbaseStorageClass.default = 'socorro.storage.crashstorage.CrashStorageSystemForHBase'
#hbaseStorageClass.default = 'socorro.storage.crashstorage.DualHbaseCrashStorageSystem'
hbaseStorageClass.fromStringConverter = cm.classConverter

hbaseHost = cm.Option()
hbaseHost.doc = 'Hostname for hbase hadoop cluster. May be a VIP or load balancer'
hbaseHost.default = 'crash-stats'

hbasePort = cm.Option()
hbasePort.doc = 'hbase port number'
hbasePort.default = 9090

hbaseTimeout = cm.Option()
hbaseTimeout.doc = 'timeout in milliseconds for an HBase connection'
hbaseTimeout.default = 5000

secondaryHbaseHost = cm.Option()
secondaryHbaseHost.doc = 'Hostname for hbase hadoop cluster. May be a VIP or load balancer'
secondaryHbaseHost.default = 'localhost'

secondaryHbasePort = cm.Option()
secondaryHbasePort.doc = 'hbase port number'
secondaryHbasePort.default = 9090

secondaryHbaseTimeout = cm.Option()
secondaryHbaseTimeout.doc = 'timeout in milliseconds for an HBase connection'
secondaryHbaseTimeout.default = 5000

#---------------------------------------------------------------------------
# misc

processorCheckInTime = cm.Option()
processorCheckInTime.doc = 'the time after which a processor is considered dead (hh:mm:ss)'
processorCheckInTime.default = "00:05:00"
processorCheckInTime.fromStringConverter = lambda x: str(cm.timeDeltaConverter(x))

startWindow = cm.Option()
startWindow.doc = 'The start of the single aggregation window (YYYY-MM-DD [hh:mm:ss])'
startWindow.fromStringConverter = cm.dateTimeConverter

deltaWindow = cm.Option()
deltaWindow.doc = 'The length of the single aggregation window  ([dd:]hh:mm:ss)'
deltaWindow.fromStringConverter = cm.timeDeltaConverter

defaultDeltaWindow = cm.Option()
defaultDeltaWindow.doc = 'The length of the single aggregation window  ([dd:]hh:mm:ss)'
defaultDeltaWindow.fromStringConverter = cm.timeDeltaConverter

# override this default for your particular cron task
defaultDeltaWindow.default = '00:12:00'

endWindow = cm.Option()
endWindow.doc = 'The end of the single aggregation window (YYYY-MM-DD [hh:mm:ss])'
endWindow.fromStringConverter = cm.dateTimeConverter

startDate = cm.Option()
startDate.doc = 'The start of the overall/outer aggregation window (YYYY-MM-DD [hh:mm])'
startDate.fromStringConverter = cm.dateTimeConverter

deltaDate = cm.Option()
deltaDate.doc = 'The length of the overall/outer aggregation window  ([dd:]hh:mm:ss)'
deltaDate.fromStringConverter = cm.timeDeltaConverter

initialDeltaDate = cm.Option()
initialDeltaDate.doc = 'The length of the overall/outer aggregation window  ([dd:]hh:mm:ss)'
initialDeltaDate.fromStringConverter = cm.timeDeltaConverter

# override this default for your particular cron task
initialDeltaDate.default = '4:00:00:00'

minutesPerSlot = cm.Option()
minutesPerSlot.doc = 'how many minutes per leaf directory in the date storage branch'
minutesPerSlot.default = 1

endDate = cm.Option()
endDate.doc = 'The end of the overall/outer aggregation window (YYYY-MM-DD [hh:mm:ss])'
endDate.fromStringConverter = cm.dateTimeConverter

debug = cm.Option()
debug.doc = 'do debug output and routines'
debug.default = False
debug.singleCharacter = 'D'
debug.fromStringConverter = cm.booleanConverter

