Bug fixes and improvements

+ Add a function to the Tools package to provide the local IP address
and port
+ Add a function to the Tools package to provide a time as formated
string as yyyyMMdd hhmmss.fff
+ Improved the ICCC startup message: Now, the message contains the IP
address and port of the stared server
+ Add a new configuration to specific the necessary Ocean servers' port
(internally, not the public port)
+ The template package reports now which version out of the grid FS is
used.
+ The Ocean server is now bound to the correct IP address and port
(rule: the local IP address!)
+ The order of the system shutdown handlers were wrong!
+ The early ICCC messages problem is now fixed!
+ Fixed an ICCC bug for the case, that a message does not have any
payload!
+ Also the configuration database uses now the correct mgo MongoDB rules
(SetSafe & SetMode)
This commit is contained in:
Thorsten Sommer committed 2014-06-08 11:35:01 +02:00
1 parent 7120a729bd
commit a007db1b79
16 files changed
+145 -26

No files matched your search

+7
View File
@@ -14,6 +14,13 @@ func ICCCHandler(response http.ResponseWriter, request *http.Request) {
}
messageData := map[string][]string(request.PostForm)
if len(messageData) < 3 {
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameNETWORK, `The ICCC message contains not enough data: At least the channel, command and password is required!`)
http.NotFound(response, request)
return
}
channel := messageData[`channel`][0]
command := messageData[`command`][0]
password := messageData[`InternalCommPassword`][0]
+2 -8
View File
@@ -1,9 +1,7 @@
package ICCC
import "strings"
import "container/list"
import "github.com/SommerEngineering/Ocean/Tools"
import "github.com/SommerEngineering/Ocean/ConfigurationDB"
import "github.com/SommerEngineering/Ocean/Log"
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
@@ -14,13 +12,9 @@ func init() {
cacheListenerDatabase = list.New()
listeners = make(map[string]func(data map[string][]string))
allHostsIPAddresses := Tools.ReadAllIPAddresses4ThisHost()
oceanHostnameAndPort := ConfigurationDB.Read(`OceanHostnameAndPort`)
port := oceanHostnameAndPort[strings.Index(oceanHostnameAndPort, `:`):]
correctAddressWithPort = allHostsIPAddresses[0] + port
// Using the local IP address and NOT the configuration "OceanHostnameAndPort":
correctAddressWithPort = Tools.LocalIPAddressAndPort()
initDB()
registerHost2Database()
cacheTimerLogic(false)
initCacheTimer()
}
+24
View File
@@ -8,7 +8,31 @@ import "github.com/SommerEngineering/Ocean/ICCC/Scheme"
import "github.com/SommerEngineering/Ocean/Log"
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
func InitCacheNow() {
startCacheTimerLock.Lock()
defer startCacheTimerLock.Unlock()
if cacheTimerRunning {
return
}
cacheTimerLogic(false)
}
func StartCacheTimer() {
initCacheTimer()
}
func initCacheTimer() {
startCacheTimerLock.Lock()
defer startCacheTimerLock.Unlock()
if cacheTimerRunning {
return
} else {
cacheTimerRunning = true
}
go func() {
for {
cacheTimerLogic(true)
+4 -5
View File
@@ -5,18 +5,17 @@ import "reflect"
import "strconv"
func message2Data(channel, command string, message interface{}) (data map[string][]string) {
data = make(map[string][]string)
data[`command`] = []string{command}
data[`channel`] = []string{channel}
if message == nil {
data = make(map[string][]string)
return
}
element := reflect.ValueOf(message)
elementType := element.Type()
data = make(map[string][]string)
data[`command`] = []string{command}
data[`channel`] = []string{channel}
for i := 0; i < element.NumField(); i++ {
field := element.Field(i)
keyName := elementType.Field(i).Name
+2
View File
@@ -24,5 +24,7 @@ var (
listenersLock sync.RWMutex = sync.RWMutex{}
cacheListenerDatabase *list.List = nil
cacheListenerDatabaseLock sync.RWMutex = sync.RWMutex{}
startCacheTimerLock sync.Mutex = sync.Mutex{}
cacheTimerRunning bool = false
correctAddressWithPort string = ``
)