File tree 2 files changed +24
-2
lines changed
src/main/java/io/hops/metadata/ndb
2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -159,5 +159,10 @@ public EntityDataAccess getDataAccess(Class type) {
159
159
public boolean hasResources (double threshold ) throws StorageException {
160
160
return MysqlServerConnector .hasResources (threshold );
161
161
}
162
-
162
+
163
+ @ Override
164
+ public float getResourceMemUtilization () throws StorageException {
165
+ return MysqlServerConnector .getResourceMemUtilization ();
166
+ }
167
+
163
168
}
Original file line number Diff line number Diff line change @@ -297,7 +297,24 @@ public String getClusterConnectString() {
297
297
public String getDatabaseName () {
298
298
throw new UnsupportedOperationException ("Not supported yet." ); //To change body of generated methods, choose Tools | Templates.
299
299
}
300
-
300
+
301
+ public static float getResourceMemUtilization () throws StorageException {
302
+ return MySQLQueryHelper .execute ("SELECT memory_type, used, total FROM " +
303
+ "ndbinfo.memoryusage where memory_type = \" Data memory\" " ,
304
+ new MySQLQueryHelper .ResultSetHandler <Float >() {
305
+ @ Override
306
+ public Float handle (ResultSet result )
307
+ throws SQLException {
308
+ while (result .next ()) {
309
+ long used = result .getLong ("used" );
310
+ long total = result .getLong ("total" );
311
+ return Float .valueOf ((float ) (((float )used / (float ) total ) * 100.0 ));
312
+ }
313
+ return Float .valueOf (-1 );
314
+ }
315
+ });
316
+ }
317
+
301
318
public static boolean hasResources (final double threshold ) throws StorageException {
302
319
return MySQLQueryHelper .execute ("SELECT memory_type, used, total FROM " +
303
320
"ndbinfo.memoryusage where memory_type = \" Data memory\" " ,
You can’t perform that action at this time.
0 commit comments