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/11/27 13:31:58 UTC
svn commit: r1847535 - in /uima/uima-ducc/trunk: src/main/admin/
uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/
uima-ducc-common/src/main/java/org/apache/uima/ducc/common/component/
uima-ducc-common/src/main/java/org/apache/uim...
Author: degenaro
Date: Tue Nov 27 13:31:57 2018
New Revision: 1847535
URL: http://svn.apache.org/viewvc?rev=1847535&view=rev
Log:
UIMA-5875 DUCC admin command stop_ducc should accept --all --stop, which comprises --agents followed by --head
Fix targeted stop.
> broadcast of stop_ducc --stop honored only by targeted daemons
Modified:
uima/uima-ducc/trunk/src/main/admin/stop_ducc
uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/TargetableDuccAdminEvent.java
uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/component/AbstractDuccComponent.java
uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccAdmin.java
Modified: uima/uima-ducc/trunk/src/main/admin/stop_ducc
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/src/main/admin/stop_ducc?rev=1847535&r1=1847534&r2=1847535&view=diff
==============================================================================
--- uima/uima-ducc/trunk/src/main/admin/stop_ducc (original)
+++ uima/uima-ducc/trunk/src/main/admin/stop_ducc Tue Nov 27 13:31:57 2018
@@ -286,7 +286,7 @@ class StopDucc(DuccUtil):
def get_db_list(self):
if(self.db_list == None):
self.db_list = self.db_acct_query()
- text = 'list='+str(list)
+ text = 'list='+str(self.db_list)
debug(self._mn(),text)
return self.db_list
@@ -525,6 +525,7 @@ class StopDucc(DuccUtil):
admin = ''
stop_db = False
stop_broker = False
+ # pass 1 remove db,br
for item in list:
node = item[0]
com = item[1]
@@ -540,15 +541,14 @@ class StopDucc(DuccUtil):
component = self.longname[com]
admin = admin+component+'@'+node+' '
# issue command
- admin = admin.strip()
- if(len(admin) > 0):
- admin = str(self.args.stop)+' '+admin
+ admin = admin.split()
+ for item in admin:
if(qflag):
- print 'quiesce: '+admin
- self.ducc_admin('--quiesce',admin)
+ print 'quiesce: '+item
+ self.ducc_admin('--quiesce',item)
else:
- print 'stop: '+admin
- self.ducc_admin('--stop',admin)
+ print 'stop: '+item
+ self.ducc_admin('--stop',item)
# stop broker
if(stop_broker):
self.stop_broker()
Modified: uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/TargetableDuccAdminEvent.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/TargetableDuccAdminEvent.java?rev=1847535&r1=1847534&r2=1847535&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/TargetableDuccAdminEvent.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/TargetableDuccAdminEvent.java Tue Nov 27 13:31:57 2018
@@ -36,5 +36,13 @@ public abstract class TargetableDuccAdmi
public String getTargets() {
return this.targetList;
}
+
+ public String[] getTargetList() {
+ String[] retVal = null;
+ if(targetList != null) {
+ retVal = targetList.split(",");
+ }
+ return retVal;
+ }
}
Modified: uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/component/AbstractDuccComponent.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/component/AbstractDuccComponent.java?rev=1847535&r1=1847534&r2=1847535&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/component/AbstractDuccComponent.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/component/AbstractDuccComponent.java Tue Nov 27 13:31:57 2018
@@ -45,11 +45,11 @@ import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.Route;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.model.RouteDefinition;
+import org.apache.uima.ducc.common.NodeIdentity;
import org.apache.uima.ducc.common.admin.event.DuccAdminEvent;
import org.apache.uima.ducc.common.admin.event.DuccAdminEventKill;
-import org.apache.uima.ducc.common.admin.event.DuccAdminEventQuiesceAndStop;
import org.apache.uima.ducc.common.admin.event.DuccAdminEventStop;
+import org.apache.uima.ducc.common.admin.event.TargetableDuccAdminEvent;
import org.apache.uima.ducc.common.crypto.Crypto;
import org.apache.uima.ducc.common.exception.DuccComponentInitializationException;
import org.apache.uima.ducc.common.exception.DuccConfigurationException;
@@ -637,34 +637,129 @@ public abstract class AbstractDuccCompon
return event instanceof DuccAdminEventKill ||
event instanceof DuccAdminEventStop;
}
+
+ private String getComponent() {
+ return System.getProperty("ducc.deploy.components");
+ }
+
+ private boolean isAgent() {
+ boolean retVal = false;
+ if(getComponent().equals("agent")) {
+ retVal = true;
+ }
+ return retVal;
+ }
+
+ private String getHost() {
+ String host = null;
+ try {
+ NodeIdentity ni = new NodeIdentity();
+ host = ni.getShortName();
+ }
+ catch(Exception e) {
+
+ }
+ return host;
+ }
+
+ private boolean targetedEvent(Object event) {
+ return event instanceof TargetableDuccAdminEvent;
+ }
+
+ private boolean find(String component, String host, String[] list) {
+ String location = "AbstractDuccComponent.find()";
+ boolean retVal = false;
+ if(component != null) {
+ if(host != null) {
+ String token = component+"@"+host;
+ if(list != null) {
+ for(String entry : list) {
+ if(entry != null) {
+ if(entry.equals(token)) {
+ retVal = true;
+ logger.debug(location, jobid, entry+" == "+token);
+ break;
+ }
+ else {
+ logger.debug(location, jobid, entry+" != "+token);
+ }
+ }
+ else {
+ logger.warn(location, jobid, "list entry == null");
+ }
+ }
+ }
+ else {
+ logger.debug(location, jobid, "list == null");
+ }
+ }
+ else {
+ logger.debug(location, jobid, "host == null");
+ }
+ }
+ else {
+ logger.debug(location, jobid, "component == null");
+ }
+ return retVal;
+ }
+
+ private boolean isTarget(TargetableDuccAdminEvent te) {
+ String location = "AbstractDuccComponent.isTarget()";
+ String component = getComponent();
+ String host = getHost();
+ String[] list = te.getTargetList();
+ boolean retVal = find(component,host,list);
+ logger.info(location, jobid, retVal, component, host, "[ "+te.getTargets()+" ]");
+ return retVal;
+ }
+
+ private void killme(Object event) {
+ // start a new thread to process the admin kill event. Need to do this
+ // so that Camel thread associated with admin channel can go back to
+ // its pool. Otherwise, we will not be able to stop the admin channel.
+ Thread th = new Thread(new Runnable() {
+ public void run() {
+ try {
+ delegate.onDuccAdminKillEvent((DuccAdminEvent) event);
+ } catch (Exception e) {
+
+ }
+ }
+ });
+ th.start();
+ }
+
public void process(final Exchange exchange) throws Exception {
- logger.info("AdminEventProcessor.process()", null, "Received Admin Message of Type:"
- + exchange.getIn().getBody().getClass().getName());
- if ( !"agent".equals(System.getProperty("ducc.deploy.components"))) {
- if (killOrStopEvent(exchange.getIn().getBody() ) ) {
- // start a new thread to process the admin kill event. Need to do this
- // so that Camel thread associated with admin channel can go back to
- // its pool. Otherwise, we will not be able to stop the admin channel.
- Thread th = new Thread(new Runnable() {
- public void run() {
- try {
- delegate.onDuccAdminKillEvent((DuccAdminEvent) exchange.getIn().getBody());
- } catch (Exception e) {
-
- }
- }
- });
- th.start();
- } else {
- handleAdminEvent((DuccAdminEvent) exchange.getIn().getBody());
- }
- } else {
- // agent
- handleAdminEvent((DuccAdminEvent) exchange.getIn().getBody());
+
+ String location = "AdminEventProcessor.process()";
+ Object event = exchange.getIn().getBody();
+ logger.info(location, null, "Received Admin Message of Type:" + event.getClass().getName());
+ boolean doProcess = true;
+ if(targetedEvent(event)) {
+ TargetableDuccAdminEvent te = (TargetableDuccAdminEvent) event;
+ if(!isTarget(te)) {
+ doProcess = false;
+ }
}
+ if(doProcess) {
+ if (!isAgent()) {
+ // daemon
+ if (killOrStopEvent(event) ) {
+ killme(event);
+ }
+ else {
+ handleAdminEvent((DuccAdminEvent) exchange.getIn().getBody());
+ }
+ }
+ else {
+ // agent
+ handleAdminEvent((DuccAdminEvent) exchange.getIn().getBody());
+ }
+ }
}
+
}
-
+
/**
* Components interested in receiving DuccAdminEvents should override this method
*/
Modified: uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccAdmin.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccAdmin.java?rev=1847535&r1=1847534&r2=1847535&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccAdmin.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccAdmin.java Tue Nov 27 13:31:57 2018
@@ -225,39 +225,39 @@ public class DuccAdmin extends AbstractD
* @throws Exception
*/
private void killAll() throws Exception {
- // send kill event to all Ducc components via Ducc Admin Channel.
- // This call is non-blocking
- String user = System.getProperty("user.name");
- Crypto crypto = new Crypto(user, true);
- byte[] cypheredMessage = crypto.getSignature();
-
- dispatch(serializeAdminEvent(new DuccAdminEventKill(user, cypheredMessage)));
- System.out.println("DuccAdmin sent Kill to all Ducc processes ...");
+ String user = System.getProperty("user.name");
+ Crypto crypto = new Crypto(user, true);
+ byte[] cypheredMessage = crypto.getSignature();
+ DuccAdminEventKill dae = new DuccAdminEventKill(user, cypheredMessage);
+ dispatch(serializeAdminEvent(dae));
+ System.out.println("DuccAdmin request:"+dae.getClass().getName()+" "+"targets:"+"all");
}
-
private void quiesceAgents(String nodes) throws Exception {
String user = System.getProperty("user.name");
Crypto crypto = new Crypto(user, true);
byte[] cypheredMessage = crypto.getSignature();
-
- dispatch(serializeAdminEvent(new DuccAdminEventStopMetrics(nodes, user, cypheredMessage)));
+ DuccAdminEventStopMetrics dae = new DuccAdminEventStopMetrics(nodes, user, cypheredMessage);
+ dispatch(serializeAdminEvent(dae));
+ System.out.println("DuccAdmin request:"+dae.getClass().getName()+" "+"targets:"+dae.getTargets());
}
public void quiesceAndStop(String nodes) throws Exception {
String user = System.getProperty("user.name");
Crypto crypto = new Crypto(user, true);
byte[] cypheredMessage = crypto.getSignature();
-
- dispatch(serializeAdminEvent(new DuccAdminEventQuiesceAndStop(nodes, user, cypheredMessage)));
+ DuccAdminEventQuiesceAndStop dae = new DuccAdminEventQuiesceAndStop(nodes, user, cypheredMessage);
+ dispatch(serializeAdminEvent(dae));
+ System.out.println("DuccAdmin request:"+dae.getClass().getName()+" "+"targets:"+dae.getTargets());
}
public void stop(String nodes, long waitTimeInSecs) throws Exception {
String user = System.getProperty("user.name");
Crypto crypto = new Crypto(user, true);
byte[] cypheredMessage = crypto.getSignature();
- //System.out.println(">>>>>>>>>>> waitTime:"+waitTimeInSecs+" Targets:"+nodes);
- dispatch(serializeAdminEvent(new DuccAdminEventStop(nodes, waitTimeInSecs, user, cypheredMessage)));
+ DuccAdminEventStop dae = new DuccAdminEventStop(nodes, waitTimeInSecs, user, cypheredMessage);
+ dispatch(serializeAdminEvent(dae));
+ System.out.println("DuccAdmin request:"+dae.getClass().getName()+" "+"targets:"+dae.getTargets());
}
/**