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 2018/05/17 18:28:23 UTC
svn commit: r1831801 - in /uima/uima-ducc/trunk/uima-ducc-web/src/main:
java/org/apache/uima/ducc/ws/server/ java/org/apache/uima/ducc/ws/state/
java/org/apache/uima/ducc/ws/state/monitoring/ webapp/root/
Author: degenaro
Date: Thu May 17 18:28:23 2018
New Revision: 1831801
URL: http://svn.apache.org/viewvc?rev=1831801&view=rev
Log: (empty)
Added:
uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/state/
uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/state/monitoring/
uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/state/monitoring/INodeState.java (with props)
uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/state/monitoring/NodeState.java (with props)
Modified:
uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerClassic.java
uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java
uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/system.machines.jsp
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerClassic.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerClassic.java?rev=1831801&r1=1831800&r2=1831801&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerClassic.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerClassic.java Thu May 17 18:28:23 2018
@@ -86,6 +86,8 @@ import org.apache.uima.ducc.ws.registry.
import org.apache.uima.ducc.ws.registry.sort.ServicesSortCache;
import org.apache.uima.ducc.ws.server.DuccCookies.DisplayStyle;
import org.apache.uima.ducc.ws.server.IWebMonitor.MonitorType;
+import org.apache.uima.ducc.ws.state.monitoring.INodeState;
+import org.apache.uima.ducc.ws.state.monitoring.NodeState;
import org.apache.uima.ducc.ws.types.NodeId;
import org.apache.uima.ducc.ws.types.UserId;
import org.apache.uima.ducc.ws.utils.FormatHelper.Precision;
@@ -101,6 +103,8 @@ public class DuccHandlerClassic extends
private static BrokerHelper brokerHelper = BrokerHelper.getInstance();
private static DatabaseHelper databaseHelper = DatabaseHelper.getInstance();
+ private static INodeState nodeState = NodeState.getInstance();
+
private static IDuccHead dh = DuccHead.getInstance();
public final String classicJobs = duccContextClassic+"-jobs-data";
@@ -1809,6 +1813,10 @@ public class DuccHandlerClassic extends
row.append("<td>");
row.append(sb);
row.append("</td>");
+ // Online
+ row.append("<td>");
+ row.append(nodeState.getOnline(machineInfo.getName(), "-"));
+ row.append("</td>");
// IP
row.append("<td>");
row.append(machineInfo.getIp());
@@ -2019,6 +2027,10 @@ public class DuccHandlerClassic extends
row.append("<td>");
row.append(""+"Total");
row.append("</td>");
+ // Online
+ row.append("<td>");
+ row.append("");
+ row.append("</td>");
// IP
row.append("<td>");
row.append("");
@@ -2081,6 +2093,10 @@ public class DuccHandlerClassic extends
row.append("<td>");
row.append("");
row.append("</td>");
+ // Online
+ row.append("<td>");
+ row.append("");
+ row.append("</td>");
// IP
row.append("<td>");
row.append("");
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java?rev=1831801&r1=1831800&r2=1831801&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java Thu May 17 18:28:23 2018
@@ -95,6 +95,8 @@ import org.apache.uima.ducc.ws.server.Du
import org.apache.uima.ducc.ws.server.Helper.AllocationType;
import org.apache.uima.ducc.ws.server.IWebMonitor.MonitorType;
import org.apache.uima.ducc.ws.server.JsonHelper.JobProcessList;
+import org.apache.uima.ducc.ws.state.monitoring.INodeState;
+import org.apache.uima.ducc.ws.state.monitoring.NodeState;
import org.apache.uima.ducc.ws.types.NodeId;
import org.apache.uima.ducc.ws.types.UserId;
import org.apache.uima.ducc.ws.utils.FormatHelper.Precision;
@@ -122,6 +124,8 @@ public class DuccHandlerJsonFormat exten
private static JsonHelper jh = new JsonHelper();
+ private static INodeState nodeState = NodeState.getInstance();
+
private static IDuccHead dh = DuccHead.getInstance();
//private static PagingObserver pagingObserver = PagingObserver.getInstance();
@@ -1796,6 +1800,8 @@ public class DuccHandlerJsonFormat exten
sb.append(status);
}
row.add(new JsonPrimitive(sb.toString()));
+ // Online
+ row.add(new JsonPrimitive(nodeState.getOnline(machineInfo.getName(), "-")));
// IP
row.add(new JsonPrimitive(machineInfo.getIp()));
// Name
@@ -1927,6 +1933,8 @@ public class DuccHandlerJsonFormat exten
private void noMachines(JsonArray row, String reason) {
// Status
row.add(new JsonPrimitive(reason));
+ // Online
+ row.add(new JsonPrimitive(""));
// IP
row.add(new JsonPrimitive(""));
// Name
@@ -2016,6 +2024,8 @@ public class DuccHandlerJsonFormat exten
row = new JsonArray();
// Status
row.add(new JsonPrimitive("Total"));
+ // Online
+ row.add(new JsonPrimitive(""));
// IP
row.add(new JsonPrimitive(""));
// Name
Added: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/state/monitoring/INodeState.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/state/monitoring/INodeState.java?rev=1831801&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/state/monitoring/INodeState.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/state/monitoring/INodeState.java Thu May 17 18:28:23 2018
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.ws.state.monitoring;
+
+public interface INodeState {
+ public String getOnline(String node, String otherwise);
+ // admin
+ public void start();
+ public void stop();
+ public boolean status(); // true=running, false=stopped
+}
Propchange: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/state/monitoring/INodeState.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/state/monitoring/NodeState.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/state/monitoring/NodeState.java?rev=1831801&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/state/monitoring/NodeState.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/state/monitoring/NodeState.java Thu May 17 18:28:23 2018
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.ws.state.monitoring;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.uima.ducc.common.persistence.rm.IRmPersistence;
+import org.apache.uima.ducc.common.utils.DuccLogger;
+import org.apache.uima.ducc.common.utils.id.DuccId;
+
+/*
+ * class to manage fetching of node status from datastore table, which is managed by RM
+ */
+public class NodeState implements INodeState {
+
+ private static DuccLogger logger = DuccLogger.getLogger(NodeState.class);
+ private static DuccId jobid = null;
+
+ private static INodeState instance = null;
+
+ public static INodeState getInstance() {
+ if(instance == null) {
+ instance = new NodeState();
+ }
+ return instance;
+ }
+
+ private Map<String, Map<String, Object>> map_empty = new HashMap<String, Map<String, Object>>();
+
+ private Map<String, Map<String, Object>> map = map_empty;
+ private Monitor monitor = null;
+
+ private String key_online = "online";
+
+ private NodeState() {
+ start();
+ }
+
+ // admin function to start monitoring thread
+ @Override
+ public void start() {
+ if(monitor == null) {
+ monitor = new Monitor();
+ monitor.start();
+ monitor.up();
+ }
+ }
+
+ // admin function to stop monitoring thread
+ @Override
+ public void stop() {
+ if(monitor != null) {
+ monitor.down();
+ monitor = null;
+ }
+ }
+
+ // admin function to get status of monitoring thread
+ @Override
+ public boolean status() {
+ boolean retVal = false;
+ if(monitor != null) {
+ monitor.status();
+ }
+ return retVal;
+ }
+
+ // general function to get online status for node
+ @Override
+ public String getOnline(String node, String otherwise) {
+ String location = "getOnline";
+ String retVal = otherwise;
+ if(node != null) {
+ if(map.size() > 0) {
+ for(Entry<String, Map<String, Object>> entry : map.entrySet()) {
+ String key = entry.getKey();
+ if(key.equals(node)) {
+ logger.debug(location, jobid, key+"=="+node);
+ Map<String, Object> value = entry.getValue();
+ Boolean value_online = (Boolean) value.get(key_online);
+ retVal = ""+value_online;
+ logger.debug(location, jobid, node+"=="+retVal);
+ break;
+ }
+ else {
+ logger.debug(location, jobid, key+"!="+node);
+ }
+ }
+ }
+ else {
+ logger.warn(location, jobid, "size:"+0);
+ }
+ }
+ else {
+ logger.error(location, jobid, "node:"+node);
+ }
+ return retVal;
+ }
+
+ // monitoring thread
+ private class Monitor extends Thread {
+
+ private AtomicBoolean run_flag = new AtomicBoolean(true);
+ private long sleep_seconds = 60;
+ private long sleep_millis = sleep_seconds*1000;
+
+ public Monitor() {
+ up();
+ }
+
+ // fetch new results from datastore every interval
+ public void run() {
+ String location = "";
+ logger.info(location, jobid, "start");
+ while(run_flag.get()) {
+ try {
+ map = fetch();
+ Thread.sleep(sleep_millis);
+ }
+ catch(Exception e) {
+ // ignore
+ }
+ }
+ logger.info(location, jobid, "stop");
+ }
+
+ // stop monitoring thread
+ public void up() {
+ run_flag.set(true);
+ }
+
+ // start monitoring thread
+ public void down() {
+ run_flag.set(false);
+ }
+
+ // get status of monitoring thread
+ public boolean status() {
+ return run_flag.get();
+ }
+
+ // configure datastore access
+ private IRmPersistence configure() throws Exception {
+ String location = "configure";
+ IRmPersistence retVal = null;
+ String class_name = System.getProperty("ducc.rm.persistence.impl");
+ logger.debug(location, jobid, class_name);
+ @SuppressWarnings("unchecked")
+ Class<IRmPersistence> iss = (Class<IRmPersistence>) Class.forName(class_name);
+ retVal = (IRmPersistence) iss.newInstance();
+ retVal.init(logger);
+ return retVal;
+ }
+
+ // fetch node status map from datastore
+ private Map<String, Map<String, Object>> fetch() throws Exception {
+ String location = "fetch";
+ Map<String, Map<String, Object>> retVal = map_empty;
+ try {
+ IRmPersistence persistence = configure();
+ retVal = persistence.getAllMachines();
+ logger.debug(location, jobid, "map:"+retVal.size());
+ }
+ catch(Exception e) {
+ logger.error(location, jobid, e);
+ }
+ return retVal;
+ }
+ }
+
+}
Propchange: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/state/monitoring/NodeState.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/system.machines.jsp
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/system.machines.jsp?rev=1831801&r1=1831800&r2=1831801&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/system.machines.jsp (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/system.machines.jsp Thu May 17 18:28:23 2018
@@ -39,7 +39,6 @@ under the License.
"sAjaxSource": "ducc-servlet/json-format-aaData-machines",
aaSorting: [],
"fnRowCallback" : function(nRow,aData,iDisplayIndex) {
- $('td:eq(4)' , nRow).css( "text-align", "right" );
$('td:eq(5)' , nRow).css( "text-align", "right" );
$('td:eq(6)' , nRow).css( "text-align", "right" );
$('td:eq(7)' , nRow).css( "text-align", "right" );
@@ -47,6 +46,7 @@ under the License.
$('td:eq(9)' , nRow).css( "text-align", "right" );
$('td:eq(10)' , nRow).css( "text-align", "right" );
$('td:eq(11)' , nRow).css( "text-align", "right" );
+ $('td:eq(12)' , nRow).css( "text-align", "right" );
return nRow;
},
} );
@@ -106,7 +106,8 @@ if (table_style.equals("scroll")) {
<table id="machines-table" width="100%">
<thead>
<tr class="ducc-header">
- <th align="left" title="The current status">Status</th>
+ <th align="left" title="The heartbeat status, as reported to ducc-mon">Status</th>
+ <th align="left" title="The online status, as determined by resource manager">Online</th>
<th align="left" title="The host IP">IP</th>
<th align="left" title="The host name">Name</th>
<th align="left" title="The host node pool">Nodepool</th>
@@ -136,7 +137,8 @@ if (table_style.equals("classic")) {
<table class="sortable">
<thead>
<tr class="ducc-head">
- <th align="left" class="none" title="The current status">Status</th>
+ <th align="left" class="none" title="The heartbeat status, as reported to ducc-mon">Status</th>
+ <th align="left" class="none" title="The online status, as determined by resource manager">Online</th>
<th align="left" class="none" title="The host IP">IP</th>
<th align="left" class="none" title="The host name">Name</th>
<th align="left" class="none" title="The host node pool">Nodepool</th>