Bug fixing

+ DB access is now right and uses copied sessions
+ DB session is now specifying the safe state and the mode
+ Fixed the issue with too early ICCC messages regarding to late cache
+ Add the MIME type for Dart
+ Fixed the issuse with wrong order of shutdown handlers
- TODO: Testing of these changes
This commit is contained in:
Thorsten Sommer committed 2014-06-04 21:41:18 +02:00
1 parent 86451938ec
commit 7120a729bd
19 files changed
+85 -48

No files matched your search

+11 -4
View File
@@ -5,15 +5,22 @@ import "labix.org/v2/mgo"
/*
Get the database instance of the MGo Mongo driver.
*/
func DB() (result *mgo.Database) {
result = db
func DB() (session *mgo.Session, database *mgo.Database) {
session = mainSession.Copy()
database = session.DB(databaseDB)
database.Login(databaseUsername, databasePassword)
return
}
/*
Get directly the GridFS instance of the Mgo Mongo driver.
*/
func GridFS() (result *mgo.GridFS) {
result = gridFS
func GridFS() (session *mgo.Session, filesystem *mgo.GridFS) {
session = mainSession.Copy()
database := session.DB(databaseDB)
database.Login(databaseUsername, databasePassword)
filesystem = database.GridFS(`fs`)
return
}
+13 -6
View File
@@ -10,20 +10,20 @@ func init() {
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameDATABASE, `Init the customer database.`)
databaseHost := ConfigurationDB.Read(`CustomerDBHost`)
databaseDB := ConfigurationDB.Read(`CustomerDBDatabase`)
databaseUsername := ConfigurationDB.Read(`CustomerDBUsername`)
databasePassword := ConfigurationDB.Read(`CustomerDBPassword`)
databaseDB = ConfigurationDB.Read(`CustomerDBDatabase`)
databaseUsername = ConfigurationDB.Read(`CustomerDBUsername`)
databasePassword = ConfigurationDB.Read(`CustomerDBPassword`)
// Connect to MongoDB:
if newSession, errDial := mgo.Dial(databaseHost); errDial != nil {
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityUnknown, LM.ImpactUnknown, LM.MessageNameDATABASE, `It was not possible to connect to the MongoDB host `+databaseHost, errDial.Error())
return
} else {
session = newSession
mainSession = newSession
}
// Use the correct database:
db = session.DB(databaseDB)
db := mainSession.DB(databaseDB)
if db == nil {
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameDATABASE, `Was not able to get the customer database.`)
return
@@ -35,8 +35,15 @@ func init() {
return
}
// In case of write operations, wait for the majority of servers to be done:
mainSession.SetSafe(&mgo.Safe{WMode: "majority"})
// Set the consistency mode to read from any secondary server and write to the primary.
// Copied sessions can overwrite this setting of necessary.
mainSession.SetMode(mgo.Eventual, true)
// Get the GridFS:
gridFS = db.GridFS(`fs`)
gridFS := db.GridFS(`fs`)
if gridFS == nil {
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameDATABASE, `Was not able to get the GridFS from the database.`)
return
-2
View File
@@ -14,6 +14,4 @@ This function is called if the Ocean server is shutting down.
*/
func (a ShutdownFunction) Shutdown() {
Log.LogShort(senderName, LM.CategoryAPP, LM.LevelWARN, LM.MessageNameSHUTDOWN, `Close now the customer database connection.`)
db.Logout()
session.Close()
}
+5 -4
View File
@@ -4,8 +4,9 @@ import "labix.org/v2/mgo"
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
var (
session *mgo.Session = nil
db *mgo.Database = nil
gridFS *mgo.GridFS = nil
senderName LM.Sender = `System::CustomerDB`
mainSession *mgo.Session = nil
senderName LM.Sender = `System::CustomerDB`
databaseUsername string = ``
databasePassword string = ``
databaseDB string = ``
)