-
Notifications
You must be signed in to change notification settings - Fork 277
Expand file tree
/
Copy pathResourceLoader.java
More file actions
92 lines (77 loc) · 2.7 KB
/
Copy pathResourceLoader.java
File metadata and controls
92 lines (77 loc) · 2.7 KB
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
package com.google.appengine.tools.resources;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class ResourceLoader
{
private static ResourceLoader res = null;
private final int PROTOCOL_BUFFER_PORT = 8888;
private final String DB_LOCATION_PROPERTY = "DB_LOCATION";
private static String APPSCALE_CONFIG_DIR = "/etc/appscale";
private final String HADOOP_PATH = "/opt/appscale/AppDB/hadoop-0.20.0";
private final String MEMCACHE_SERVER_IP_PATH = "/memcache_ips";
private final boolean IS_SSL = false;
private final String TMP_LOCATION = "/tmp";
private final String NUM_NODES_LOCATION = "/num_of_nodes";
public static ResourceLoader getResourceLoader()
{
if (res == null) res = new ResourceLoader();
System.out.println("appscale configuration dir is: " + APPSCALE_CONFIG_DIR);
return res;
}
public boolean getDatastoreSecurityMode()
{
// true means SSL(https), otherwise normal http
return IS_SSL;
}
public int getPbServerPort()
{
return PROTOCOL_BUFFER_PORT;
}
public String getPbServerIp()
{
String dbLocation = System.getProperty(DB_LOCATION_PROPERTY);
if (dbLocation != null) return dbLocation;
return null;
}
public String getMemcachedServerIp()
{
return APPSCALE_CONFIG_DIR + MEMCACHE_SERVER_IP_PATH;
}
public String getNumOfNode()
{
return APPSCALE_CONFIG_DIR + NUM_NODES_LOCATION;
}
public String getHadoopHome()
{
return HADOOP_PATH;
}
public String getMrTmpLocation()
{
return TMP_LOCATION;
}
public static String getNginxPort()
{
String versionKey = System.getProperty("APP_NAME") + "_" + System.getProperty("MODULE") + "_" +
System.getProperty("VERSION");
String portFileLocation = "/etc/appscale/port-" + versionKey + ".txt";
BufferedReader br;
try {
br = new BufferedReader(new FileReader(portFileLocation));
} catch (FileNotFoundException e) {
throw new RuntimeException(portFileLocation + " does not exist");
}
try {
return br.readLine();
} catch (IOException e) {
throw new RuntimeException("Error reading from " + portFileLocation);
} finally {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}