You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by cw...@apache.org on 2013/04/23 17:32:52 UTC
svn commit: r1471013 - in
/uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent:
Agent.java NodeAgent.java processors/LinuxProcessMetricsProcessor.java
Author: cwiklik
Date: Tue Apr 23 15:32:52 2013
New Revision: 1471013
URL: http://svn.apache.org/r1471013
Log:
UIMA-2827 Modified agent's code to fetch the Page size from the OS on agent's startup
Modified:
uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/Agent.java
uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java
uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/processors/LinuxProcessMetricsProcessor.java
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/Agent.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/Agent.java?rev=1471013&r1=1471012&r2=1471013&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/Agent.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/Agent.java Tue Apr 23 15:32:52 2013
@@ -40,5 +40,6 @@ public interface Agent extends ProcessLi
public boolean isRogueProcess(String uid, Set<NodeUsersCollector.ProcessInfo> processList, NodeUsersCollector.ProcessInfo cpi ) throws Exception;
public void copyAllUserReservations(TreeMap<String,NodeUsersInfo> map);
public RogueProcessReaper getRogueProcessReaper();
- public boolean isManagedProcess(Set<NodeUsersCollector.ProcessInfo> processList, NodeUsersCollector.ProcessInfo cpi);
+ public boolean isManagedProcess(Set<NodeUsersCollector.ProcessInfo> processList, NodeUsersCollector.ProcessInfo cpi);
+ public int getOSPageSize();
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java?rev=1471013&r1=1471012&r2=1471013&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java Tue Apr 23 15:32:52 2013
@@ -23,6 +23,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileReader;
+import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
@@ -141,6 +142,8 @@ public class NodeAgent extends AbstractD
public boolean virtualAgent = false;
+ public boolean pageSizeFetched = false;
+
/**
* Ctor used exclusively for black-box testing of this class.
*/
@@ -174,6 +177,9 @@ public class NodeAgent extends AbstractD
this.launcher = launcher;
this.configurationFactory = factory;
this.commonProcessDispatcher = factory.getCommonProcessDispatcher(context);
+
+ // fetch Page Size from the OS and cache it
+ getOSPageSize();
if ( System.getProperty("ducc.rm.share.quantum") != null && System.getProperty("ducc.rm.share.quantum").trim().length() > 0 ) {
shareQuantum = Integer.parseInt(System.getProperty("ducc.rm.share.quantum").trim());
@@ -260,22 +266,39 @@ public class NodeAgent extends AbstractD
}
}
- /*
- int nodeStability=0;
- long node_metrics_publish_rate=0;
-
- if ( System.getProperty("ducc.rm.node.stability") != null ) {
- nodeStability = Integer.parseInt(System.getProperty("ducc.rm.node.stability"));
- }
- if ( System.getProperty("ducc.agent.node.metrics.publish.rate") != null ) {
- node_metrics_publish_rate = Long.parseLong(System.getProperty("ducc.agent.node.metrics.publish.rate"));
- }
- */
-// nodeMonitor = new AgentMonitor(this, logger,nodeStability, (int)node_metrics_publish_rate);
-// nodeMonitor.start();
-
}
-
+
+ public int getOSPageSize() {
+ InputStreamReader in = null;
+ int pageSize = 4096; // default
+ if ( !pageSizeFetched ) { // fetch the page size from the OS once and cache it
+ pageSizeFetched = true;
+ try {
+ ProcessBuilder pb = new ProcessBuilder();
+ pb.command(new String[] {"/usr/bin/getconf","PAGESIZE"});
+ pb.redirectErrorStream(true);
+ Process p = pb.start();
+ in = new InputStreamReader(p.getInputStream());
+ BufferedReader reader = new BufferedReader(in);
+ String line=null;
+
+ while ((line = reader.readLine()) != null) {
+ pageSize = Integer.parseInt(line.trim());
+ logger.info("getOSPageSize",null, "OS Page Size:"+pageSize);
+ }
+ } catch(Exception e) {
+ logger.error("getOSPageSize",null,e);
+ } finally {
+ if ( in != null ) {
+ try {
+ in.close();
+ } catch( Exception ex) {}
+ }
+ }
+ }
+
+ return pageSize;
+ }
public void setNodeInfo( Node node ) {
this.node = node;
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/processors/LinuxProcessMetricsProcessor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/processors/LinuxProcessMetricsProcessor.java?rev=1471013&r1=1471012&r2=1471013&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/processors/LinuxProcessMetricsProcessor.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/processors/LinuxProcessMetricsProcessor.java Tue Apr 23 15:32:52 2013
@@ -66,22 +66,17 @@ implements ProcessMetricsProcessor {
this.agent = agent;
pool = Executors.newFixedThreadPool(30);
this.process = process;
- gcStatsCollector = new DuccGarbageStatsCollector(logger, process);
- // read the block size from ducc.properties
- if ( System.getProperty("os.page.size") != null ) {
- try {
- blockSize = Integer.parseInt(System.getProperty("os.page.size"));
- } catch(NumberFormatException e) {
- e.printStackTrace();
- }
- }
- if ( System.getProperty("ducc.agent.share.size.fudge.factor") != null ) {
- try {
- fudgeFactor = Integer.parseInt(System.getProperty("ducc.agent.share.size.fudge.factor"));
- } catch(NumberFormatException e) {
- e.printStackTrace();
- }
- }
+ gcStatsCollector = new DuccGarbageStatsCollector(logger, process);
+
+ blockSize = agent.getOSPageSize();
+
+ if ( System.getProperty("ducc.agent.share.size.fudge.factor") != null ) {
+ try {
+ fudgeFactor = Integer.parseInt(System.getProperty("ducc.agent.share.size.fudge.factor"));
+ } catch(NumberFormatException e) {
+ e.printStackTrace();
+ }
+ }
}
public void close() {
@@ -177,12 +172,5 @@ implements ProcessMetricsProcessor {
}
}
- public static void main(String[] args) {
- try {
-// LinuxProcessMetricsProcessor p = new LinuxProcessMetricsProcessor(null,null,args[0]);
-// p.process(null);
- } catch( Exception e) {
- e.printStackTrace();
- }
- }
+
}