-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDataStream.pde
More file actions
196 lines (171 loc) · 4.79 KB
/
DataStream.pde
File metadata and controls
196 lines (171 loc) · 4.79 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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/**
* ---------------------------------------------
* DataStream.pde
* Description: CAVE2 Master Situation Display (MSD)
*
* Class:
* System: Processing 2.2, SUSE 12.1, Windows 7 x64
* Author(s): Andrew Johnson, Arthur Nishimoto
* Copyright (C) 2012-2014
* Electronic Visualization Laboratory, University of Illinois at Chicago
*
* Version Notes:
* ---------------------------------------------
*/
String[][] allElements = new String[37][25];
int[][]allCPUs = new int[37][16];
int[]allGPUs = new int[37];
int[]netIn = new int[37];
int[]netOut = new int[37];
int[]memUsed = new int[37];
String badNode = "";
String pings[];
float clusterReconnectDelay = 10;
float clusterReconnectTimer;
float clusterPingDelay = 1;
float clusterPingTimer;
boolean usingPing1 = false;
boolean usingPing2 = false;
void getData()
{
if ( clusterReconnectTimer > 0 )
{
clusterReconnectTimer -= deltaTime;
return;
}
if ( clusterPingTimer > 0 )
{
clusterPingTimer -= deltaTime;
return;
}
else
{
ping();
clusterPingTimer = clusterUpdateInterval;
}
String lines[] = loadStrings(clusterData);
if ( lines == null )
{
clusterReconnectTimer = clusterReconnectDelay;
connectedToClusterData = false;
allElements = new String[37][25];
allCPUs = new int[37][16];
allGPUs = new int[37];
netIn = new int[37];
netOut = new int[37];
memUsed = new int[37];
}
else
{
connectedToClusterData = true;
}
//try
//{
if (lines != null) {
for (int node = 0 ; node < lines.length; node++) {
String[] elements = splitTokens(lines[node]);
// grab the node name
allElements[node][0] = elements[0];
allElements[node][1] = elements[1];
// uptime may be missing the Days field so we need to handle the special case
if (elements.length == 25) {
for (int j = 2 ; j < 25; j++) {
allElements[node][j] = elements[j];
}
// grab the GPU and Network data
allGPUs[node] = int(allElements[node][21]);
netIn[node] = int(allElements[node][20]);
netOut[node] = int(allElements[node][21]);
memUsed[node] = int(allElements[node][22]) * 100 / 64;
}
if (elements.length == 22 ) {
for (int j = 3 ; j < 24; j++) {
allElements[node][j] = elements[j-2];
}
allElements[node][2] = "0";
//allElements[node][3] = "days";
// grab the GPU and Network data
allGPUs[node] = int(allElements[node][20]);
netIn[node] = int(allElements[node][21]);
netOut[node] = int(allElements[node][22]);
memUsed[node] = int(allElements[node][23]) * 100 / 64;
}
else if (elements.length == 23 ) {
for (int j = 3 ; j < 25; j++) {
allElements[node][j] = elements[j-2];
}
allElements[node][2] = "0";
//allElements[node][3] = "days";
//println(allElements[node]);
// grab the GPU and Network data
allGPUs[node] = int(allElements[node][21]);
netIn[node] = int(allElements[node][22]);
netOut[node] = int(allElements[node][23]);
memUsed[node] = int(allElements[node][24]) * 100 / 64;
}
// grab the CPU core data
for (int core = 0 ; core < 16; core++) {
allCPUs[node][core] = int(allElements[node][core+5]);
}
}
}
//}
//catch( Exception e )
//{
// e.printStackTrace();
//}
}
public void ping()
{
try
{
badNode = "";
// check all the nodes from the first network interface
if( usingPing1 )
{
pings = loadStrings(clusterPing1);
if( pings != null )
{
for (int node = 0 ; node < pings.length; node++)
{
String[] elements = splitTokens(pings[node]);
if (elements[1].equals("DOWN") == true )
{
badNode = elements[0];
nodePing[node-1] = false;
}
else if ( elements[1].equals("UP") == true )
{
if ( node > 0 )
nodePing[node-1] = true;
}
}
}
}
if( usingPing2 )
{
pings = loadStrings(clusterPing2);
if( pings != null )
{
for (int node = 0 ; node < pings.length; node++)
{
String[] elements = splitTokens(pings[node]);
if (elements[1].equals("DOWN") == true )
{
badNode = elements[0];
nodeCavewavePing[node-1] = false;
}
else if ( elements[1].equals("UP") == true )
{
if ( node > 0 )
nodeCavewavePing[node-1] = true;
}
}
}
}
}
catch( Exception e )
{
e.printStackTrace();
}
}