You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2016/05/19 10:26:16 UTC

svn commit: r1744552 - /uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccMachinesData.java

Author: degenaro
Date: Thu May 19 10:26:16 2016
New Revision: 1744552

URL: http://svn.apache.org/viewvc?rev=1744552&view=rev
Log:
UIMA-4923 DUCC Web Server (WS) should not display nodes that have been removed from service on Machines page

In non-DB case, WS should round down usable & free sizes for display according to ducc.rm.share.quantum

Modified:
    uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccMachinesData.java

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccMachinesData.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccMachinesData.java?rev=1744552&r1=1744551&r2=1744552&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccMachinesData.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccMachinesData.java Thu May 19 10:26:16 2016
@@ -37,6 +37,7 @@ import org.apache.uima.ducc.common.node.
 import org.apache.uima.ducc.common.node.metrics.NodeUsersInfo.NodeProcess;
 import org.apache.uima.ducc.common.utils.DuccLogger;
 import org.apache.uima.ducc.common.utils.DuccLoggerComponents;
+import org.apache.uima.ducc.common.utils.DuccPropertiesResolver;
 import org.apache.uima.ducc.common.utils.TimeStamp;
 import org.apache.uima.ducc.common.utils.id.DuccId;
 import org.apache.uima.ducc.transport.event.NodeMetricsUpdateDuccEvent;
@@ -436,13 +437,57 @@ public class DuccMachinesData {
 		}
 	}
 	
+	
+	
+	/**
+	 * Adjust memory value by rounding down 
+	 * to multiple of rm.share.quantum GB
+	 */
+	private String calculateMem(long quantum, String memParm) {
+		String location = "calculateMem";
+		String retVal = "0";
+		if(memParm!= null) {
+			String memString = memParm.trim();
+			if(memString.length() > 0) {
+				try {
+					long memRaw = Long.parseLong(memString);
+					long memAdj = (memRaw / quantum) * quantum;
+					retVal = ""+memAdj;
+				}
+				catch(Exception e) {
+					logger.error(location, jobid, e);
+				}
+			}
+		}
+		return retVal;
+	}
+	
+	/**
+	 * Fetch quantum from ducc.properties, default is 1.
+	 */
+	private long getQuantum() {
+		String location = "getQuantum";
+		long retVal = 1;
+		try {
+			DuccPropertiesResolver dpr = DuccPropertiesResolver.getInstance();
+			String quantum = dpr.getFileProperty(DuccPropertiesResolver.ducc_rm_share_quantum);
+			retVal = Long.parseLong(quantum.trim());
+		}
+		catch(Exception e) {
+			logger.error(location, jobid, e);
+		}
+		return retVal;
+	}
+	
 	/**
 	 * Create a machines facts list based 
 	 * in part on the information provided by the Agents, and
 	 * in part on the data comprising the ducc.nodes file.
 	 */
 	private void updateMachineFactsListAgent() {
+		
 		MachineFactsList factsList = new MachineFactsList();
+		long quantum = getQuantum();
 		ConcurrentSkipListMap<MachineInfo,NodeId> sortedMachines = getSortedMachines();
 		Iterator<MachineInfo> iterator;
 		iterator = sortedMachines.keySet().iterator();
@@ -451,8 +496,8 @@ public class DuccMachinesData {
 			String status = machineInfo.getStatus();
 			String ip = machineInfo.getIp();
 			String name = machineInfo.getName();
-			String memTotal = machineInfo.getMemTotal();
-			String memFree = machineInfo.getMemFree();
+			String memTotal = calculateMem(quantum, machineInfo.getMemTotal());
+			String memFree = calculateMem(quantum, machineInfo.getMemFree());
 			String swapInuse = machineInfo.getSwapInuse();
 			String swapDelta = ""+machineInfo.getSwapDelta();
 			String swapFree = machineInfo.getSwapFree();