-
Notifications
You must be signed in to change notification settings - Fork 1
/
vars.go
127 lines (111 loc) · 3.65 KB
/
vars.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
Copyright (C) 2003-2011 Institute for Systems Biology
Seattle, Washington, USA.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package main
import (
"github.com/dlintw/goconf"
"os"
"runtime"
)
const (
year = 60 * 60 * 24 * 365
)
var iobuffersize = 1000
var conbuffersize = 10
var iomonitors = 2
var useTls bool = true
var certpath string = ""
var certorg string = "golem.googlecode.com"
// Sets global variable to enable TLS communications and other related variables (certificate path, organization)
// optional parameters: default.certpath, default.organization, default.tls
func GlobalTls(configFile *goconf.ConfigFile) {
certificatepath, err := configFile.GetString("default", "certpath")
if err != nil {
logger.Warn(err)
} else {
certpath = certificatepath
}
logger.Printf("certpath=[%v]", certpath)
certificateorg, err := configFile.GetString("default", "organization")
if err != nil {
logger.Warn(err)
if certificateorg, err = os.Hostname(); err != nil {
logger.Warn(err)
certificateorg = "golem.googlecode.com"
}
}
certorg = certificateorg
logger.Printf("certorg=[%v]", certorg)
useTlsl, err := configFile.GetBool("default", "tls")
if err != nil {
logger.Warn(err)
useTls = true
} else {
useTls = useTlsl
}
logger.Printf("TLS=[%v]", useTls)
}
// Sets global variable to configure buffersize for master submission channels (stdout, stderr)
// optional parameters: master.buffersize
func SubIOBufferSize(section string, configFile *goconf.ConfigFile) {
bufsize, err := configFile.GetInt(section, "subiobuffersize")
if err != nil {
logger.Warn(err)
} else {
iobuffersize = bufsize
}
logger.Printf("buffersize=[%v]", iobuffersize)
}
// Sets global variable to configure buffersize for channels wrapping connections between worker and master (stdout, stderr)
// optional parameters: master.buffersize
func ConBufferSize(section string, config *goconf.ConfigFile) {
bufsize, err := config.GetInt(section, "conbuffersize")
if err != nil {
logger.Warn(err)
} else {
conbuffersize = bufsize
logger.Printf("conbuffersize=[%v]", conbuffersize)
}
}
//get the number of IO monitors to run per node
func IOMOnitors(config *goconf.ConfigFile) {
iomons, err := config.GetInt("master", "iomonitors")
if err != nil {
logger.Warn(err)
} else {
if iomons > 0 {
iomonitors = iomons
}
}
logger.Printf("iomonitors=[%v]", iomonitors)
}
//get the number of processors to use for golem itself
func GoMaxProc(section string, config *goconf.ConfigFile) {
gomaxproc, err := config.GetInt(section, "gomaxproc")
if err != nil {
logger.Warn(err)
} else {
runtime.GOMAXPROCS(gomaxproc)
logger.Printf("gomaxproc=[%v]", gomaxproc)
}
}
//convenience function for requiring a string in the config file
func GetRequiredString(config *goconf.ConfigFile, section string, key string) (value string) {
value, err := config.GetString(section, key)
if err != nil {
logger.Fatalf("[CONFIG] %v is required: [section=%v]", key, section)
}
return
}