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/08/15 20:18:20 UTC
svn commit: r1756422 - in /uima/uima-ducc/trunk:
uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/
uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/
uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrat...
Author: degenaro
Date: Mon Aug 15 20:18:20 2016
New Revision: 1756422
URL: http://svn.apache.org/viewvc?rev=1756422&view=rev
Log:
UIMA-5057 DUCC Orchestrator (OR) handle down JD node
Added:
uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/
uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/DbMachine.java (with props)
uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/DbQuery.java (with props)
uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/IDbMachine.java (with props)
uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdEvent.java (with props)
Modified:
uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorComponent.java (contents, props changed)
uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorHelper.java
uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/StateJobAccounting.java
uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/config/OrchestratorConfiguration.java
uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/factory/JobFactory.java
uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdReservation.java
uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdScheduler.java
uima/uima-ducc/trunk/uima-ducc-orchestrator/src/test/java/org/apache/uima/ducc/orchestrator/jd/scheduler/test/TestHelper.java
uima/uima-ducc/trunk/uima-ducc-orchestrator/src/test/java/org/apache/uima/ducc/orchestrator/jd/scheduler/test/TestSuite.java
uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/jd/JobDriverStateExchanger.java
uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdReplyEvent.java
uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdRequestEvent.java
uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/DuccProcess.java
Added: uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/DbMachine.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/DbMachine.java?rev=1756422&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/DbMachine.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/DbMachine.java Mon Aug 15 20:18:20 2016
@@ -0,0 +1,135 @@
+/*
+ * 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.common.db;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class DbMachine implements IDbMachine{
+
+ private Map<String, Object> map = new HashMap<String, Object>();
+
+ private enum Key {
+ classes, // [weekly urgent background normal reserve JobDriver high debug low standalone fixed]
+ reservable, // [true]
+ share_order, // [2]
+ assignments, // [0]
+ blacklisted, // [false]
+ memory, // [30]
+ online, // [true]
+ ip, // [192.168.4.4]
+ heartbeats, // [0]
+ nodepool, // [--default--]
+ shares_left, // [2]
+ quantum, // [15]
+ name, // [bluejws67-4]
+ responsive, // [true]
+ };
+
+ public DbMachine(Map<String, Object> map) {
+ initMap(map);
+ }
+
+ private void initMap(Map<String, Object> value) {
+ if(value != null) {
+ map.putAll(value);
+ }
+ }
+
+ public List<String> getClasses() {
+ List<String> retVal = new ArrayList<String>();
+ String classes = (String) map.get(Key.classes.name());
+ if(classes != null) {
+ String[] array = classes.split("\\s+");
+ if(array != null) {
+ retVal = Arrays.asList(array);
+ }
+ }
+ return retVal;
+ }
+
+ public Boolean getReservable() {
+ Boolean retVal = (Boolean) map.get(Key.reservable.name());
+ return retVal;
+ }
+
+ public Integer getShareOrder() {
+ Integer retVal = (Integer) map.get(Key.share_order.name());
+ return retVal;
+ }
+
+ public Integer getAssignments() {
+ Integer retVal = (Integer) map.get(Key.assignments.name());
+ return retVal;
+ }
+
+ public Boolean getBlacklisted() {
+ Boolean retVal = (Boolean) map.get(Key.blacklisted.name());
+ return retVal;
+ }
+
+ public Integer getMemory() {
+ Integer retVal = (Integer) map.get(Key.memory.name());
+ return retVal;
+ }
+
+ public Boolean getOnline() {
+ Boolean retVal = (Boolean) map.get(Key.online.name());
+ return retVal;
+ }
+
+ public String getIp() {
+ String retVal = (String) map.get(Key.ip.name());
+ return retVal;
+ }
+
+ public Integer getHeartbeats() {
+ Integer retVal = (Integer) map.get(Key.heartbeats.name());
+ return retVal;
+ }
+
+ public String getNodePool() {
+ String retVal = (String) map.get(Key.nodepool.name());
+ return retVal;
+ }
+
+ public Integer getSharesLeft() {
+ Integer retVal = (Integer) map.get(Key.shares_left.name());
+ return retVal;
+ }
+
+ public Integer getQuantum() {
+ Integer retVal = (Integer) map.get(Key.quantum.name());
+ return retVal;
+ }
+
+ public String getName() {
+ String retVal = (String) map.get(Key.name.name());
+ return retVal;
+ }
+
+ public Boolean getResponsive() {
+ Boolean retVal = (Boolean) map.get(Key.responsive.name());
+ return retVal;
+ }
+
+}
Propchange: uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/DbMachine.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/DbMachine.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/DbQuery.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/DbQuery.java?rev=1756422&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/DbQuery.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/DbQuery.java Mon Aug 15 20:18:20 2016
@@ -0,0 +1,134 @@
+/*
+ * 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.common.db;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.log4j.MDC;
+import org.apache.uima.ducc.common.main.DuccService;
+import org.apache.uima.ducc.common.persistence.rm.IRmPersistence;
+import org.apache.uima.ducc.common.persistence.rm.RmPersistenceFactory;
+import org.apache.uima.ducc.common.utils.DuccLogger;
+import org.apache.uima.ducc.common.utils.DuccPropertiesResolver;
+import org.apache.uima.ducc.common.utils.id.DuccId;
+
+public class DbQuery {
+
+ private static DuccLogger logger = null;
+ private static DuccId jobid = null;
+
+ private static DbQuery instance = null;
+
+ private static boolean enabled = true;
+
+ private IRmPersistence persistence = null;
+
+ static {
+ synchronized(DbQuery.class) {
+ if(instance == null) {
+ instance = new DbQuery();
+ }
+ }
+ }
+
+ private static void createLogger(Object object) {
+ logger = DuccService.getDuccLogger(object.getClass().getName());
+ }
+
+ private DbQuery() {
+ createLogger(this);
+ DuccPropertiesResolver dpr = DuccPropertiesResolver.getInstance();
+ String value;
+ value = dpr.getProperty(DuccPropertiesResolver.ducc_database_host);
+ if(value != null) {
+ if(value.equalsIgnoreCase(DuccPropertiesResolver.ducc_database_disabled)) {
+ enabled = false;
+ }
+ }
+ String component = (String) MDC.get("COMPONENT");
+ persistence = RmPersistenceFactory.getInstance(this.getClass().getName(),component);
+ }
+
+ public static DbQuery getInstance() {
+ return instance;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public boolean isUp() {
+ return (getMapMachines().size() > 0);
+ }
+
+ public static void dumpMap(Map<String, IDbMachine> dbMachineMap) {
+ String location = "dumpMap";
+ if(dbMachineMap != null) {
+ if(!dbMachineMap.isEmpty()) {
+ for(Entry<String, IDbMachine> entry : dbMachineMap.entrySet()) {
+ String key = entry.getKey();
+ String value = entry.getValue().getIp();
+ logger.debug(location, jobid, "host="+key+" "+"ip="+value);
+ }
+ }
+ else {
+ logger.debug(location, jobid, "map is empty");
+ }
+ }
+ else {
+ logger.debug(location, jobid, "map is null");
+ }
+ }
+
+ public Map<String, IDbMachine> getMapMachines() {
+ String location = "getMapMachines";
+ Map<String, IDbMachine> retVal = new HashMap<String, IDbMachine>();
+ if(isEnabled()) {
+ try {
+ Map<String, Map<String, Object>> state = persistence.getAllMachines();
+ if(!state.isEmpty()) {
+ for ( String key : state.keySet() ) {
+ Map<String, Object> entry = state.get(key);
+ DbMachine value = new DbMachine(entry);
+ retVal.put(key, value);
+ }
+ }
+ else {
+ logger.info(location, jobid, "map is empty");
+ }
+ }
+ catch(Exception e) {
+ logger.error(location, jobid, e);
+ }
+ }
+ else {
+ logger.info(location, jobid, "enabled="+enabled);
+ }
+ dumpMap(retVal);
+ return retVal;
+ }
+
+ public void close() {
+ if(persistence != null) {
+ persistence.close();
+ }
+ }
+}
Propchange: uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/DbQuery.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/DbQuery.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/IDbMachine.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/IDbMachine.java?rev=1756422&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/IDbMachine.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/IDbMachine.java Mon Aug 15 20:18:20 2016
@@ -0,0 +1,35 @@
+/*
+ * 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.common.db;
+
+public interface IDbMachine {
+ public Boolean getReservable();
+ public Integer getShareOrder();
+ public Integer getAssignments();
+ public Boolean getBlacklisted();
+ public Integer getMemory();
+ public Boolean getOnline();
+ public String getIp();
+ public Integer getHeartbeats();
+ public String getNodePool();
+ public Integer getSharesLeft();
+ public Integer getQuantum();
+ public String getName();
+ public Boolean getResponsive();
+}
Propchange: uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/IDbMachine.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/db/IDbMachine.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorComponent.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorComponent.java?rev=1756422&r1=1756421&r2=1756422&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorComponent.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorComponent.java Mon Aug 15 20:18:20 2016
@@ -395,8 +395,16 @@ implements Orchestrator {
stateManager.reconcileState(dsr);
String sid = ""+duccId.getFriendly();
DuccWorkJob duccWorkJob = (DuccWorkJob) WorkMapHelper.cloneDuccWork(workMap, sid, this, methodName);
- IDuccProcessMap processMap = duccWorkJob.getProcessMap();
- duccEvent.setProcessMap(new DuccProcessMap(processMap));
+ if(duccWorkJob != null) {
+ IDuccProcessMap processMap = duccWorkJob.getProcessMap();
+ duccEvent.setProcessMap(new DuccProcessMap(processMap));
+
+ }
+ else {
+ String text = "not found in map";
+ duccEvent.setKillDriverReason(text);
+ logger.warn(methodName, duccId, text);
+ }
}
logger.trace(methodName, null, messages.fetch("exit"));
}
Propchange: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorComponent.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorHelper.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorHelper.java?rev=1756422&r1=1756421&r2=1756422&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorHelper.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorHelper.java Mon Aug 15 20:18:20 2016
@@ -212,8 +212,9 @@ public class OrchestratorHelper {
public static void jdDeallocate(IDuccWorkJob job, IDuccProcess jdProcess) {
String location = "jdDeallocate";
if(job != null) {
- DuccId jobId = job.getDuccId();
+ DuccId jobIdentity = job.getDuccId();
if(jdProcess != null) {
+ DuccId driverIdentity = (DuccId) jdProcess.getDuccId();
JdScheduler jdScheduler = JdScheduler.getInstance();
ProcessState processState = jdProcess.getProcessState();
if(processState != null) {
@@ -224,22 +225,20 @@ public class OrchestratorHelper {
case Stopped:
case Killed:
case Abandoned:
- DuccId jdId = jdProcess.getDuccId();
- DuccId jdProcessDuccId = (DuccId) jdId;
- jdScheduler.deallocate(jdProcessDuccId, jobId);
- logger.debug(location, jobId, "state: "+processState);
+ jdScheduler.deallocate(jobIdentity, driverIdentity);
+ logger.debug(location, driverIdentity, "state: "+processState);
break;
default:
- logger.debug(location, jobId, "state: "+processState);
+ logger.debug(location, jobIdentity, "state: "+processState);
break;
}
}
else {
- logger.debug(location, jobId, "state: "+processState);
+ logger.debug(location, jobIdentity, "state: "+processState);
}
}
else {
- logger.debug(location, jobId, "jdProcess: "+jdProcess);
+ logger.debug(location, jobIdentity, "jdProcess: "+jdProcess);
}
}
else {
@@ -251,7 +250,7 @@ public class OrchestratorHelper {
String location = "jdDeallocate";
JdScheduler jdScheduler = JdScheduler.getInstance();
if(job != null) {
- DuccId jobId = job.getDuccId();
+ DuccId jobIdentity = job.getDuccId();
DuccWorkPopDriver driver = job.getDriver();
if(driver != null) {
IDuccProcessMap processMap = job.getDriver().getProcessMap();
@@ -267,26 +266,25 @@ public class OrchestratorHelper {
case Stopped:
case Killed:
case Abandoned:
- DuccId jdId = entry.getKey();
- DuccId jdProcessDuccId = (DuccId) jdId;
- jdScheduler.deallocate(jdProcessDuccId, jobId);
+ DuccId driverIdentity = entry.getKey();
+ jdScheduler.deallocate(jobIdentity, driverIdentity);
break;
default:
- logger.debug(location, jobId, "state: "+processState);
+ logger.debug(location, jobIdentity, "state: "+processState);
break;
}
}
else {
- logger.debug(location, jobId, "state: "+processState);
+ logger.debug(location, jobIdentity, "state: "+processState);
}
}
}
else {
- logger.debug(location, jobId, "map: "+processMap);
+ logger.debug(location, jobIdentity, "map: "+processMap);
}
}
else {
- logger.debug(location, jobId, "driver: "+driver);
+ logger.debug(location, jobIdentity, "driver: "+driver);
}
}
else {
Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/StateJobAccounting.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/StateJobAccounting.java?rev=1756422&r1=1756421&r2=1756422&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/StateJobAccounting.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/StateJobAccounting.java Mon Aug 15 20:18:20 2016
@@ -85,6 +85,7 @@ public class StateJobAccounting {
public boolean stateChange(IDuccWorkJob job, JobState state) {
String methodName = "stateChange";
boolean retVal = false;
+ logger.debug(methodName, job.getDuccId(), job.getCompletionType()+" "+job.getCompletionRationale());
JobState prev = job.getJobState();
JobState next = state;
switch(prev) {
Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/config/OrchestratorConfiguration.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/config/OrchestratorConfiguration.java?rev=1756422&r1=1756421&r2=1756422&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/config/OrchestratorConfiguration.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/config/OrchestratorConfiguration.java Mon Aug 15 20:18:20 2016
@@ -167,6 +167,8 @@ public class OrchestratorConfiguration {
JdRequestEvent jdRequestEvent = exchange.getIn().getBody(JdRequestEvent.class);
JdReplyEvent jdReplyEvent = new JdReplyEvent();
jdReplyEvent.setProcessMap(jdRequestEvent.getProcessMap());
+ String killDriverReason = jdRequestEvent.getKillDriverReason();
+ jdReplyEvent.setKillDriverReason(killDriverReason);
exchange.getIn().setBody(jdReplyEvent);
}
if(obj instanceof DuccWorkRequestEvent) {
Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/factory/JobFactory.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/factory/JobFactory.java?rev=1756422&r1=1756421&r2=1756422&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/factory/JobFactory.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/factory/JobFactory.java Mon Aug 15 20:18:20 2016
@@ -385,22 +385,22 @@ public class JobFactory implements IJobF
DuccWorkPopDriver driver = new DuccWorkPopDriver(); // No longer need the 8-arg constructor
driver.setCommandLine(driverCommandLine);
//
- DuccId jdId = jdIdFactory.next();
+ DuccId processIdentity = jdIdFactory.next();
int friendlyId = driver.getProcessMap().size();
- jdId.setFriendly(friendlyId);
- DuccId jdProcessDuccId = (DuccId) jdId;
- NodeIdentity nodeIdentity = jdScheduler.allocate(jdProcessDuccId, job.getDuccId());
+ processIdentity.setFriendly(friendlyId);
+ DuccId jobIdentity = (DuccId) job.getDuccId();
+ NodeIdentity nodeIdentity = jdScheduler.allocate(jobIdentity, processIdentity);
if(nodeIdentity == null) {
throw new ResourceUnavailableForJobDriverException();
}
- DuccProcess driverProcess = new DuccProcess(jdId,nodeIdentity,ProcessType.Pop);
+ DuccProcess driverProcess = new DuccProcess(processIdentity,nodeIdentity,ProcessType.Pop);
long driver_max_size_in_bytes = JobFactoryHelper.getByteSizeJobDriver();
CGroupManager.assign(job.getDuccId(), driverProcess, driver_max_size_in_bytes);
OrUtil.setResourceState(job, driverProcess, ResourceState.Allocated);
driverProcess.setNodeIdentity(nodeIdentity);
driver.getProcessMap().put(driverProcess.getDuccId(), driverProcess);
//
- orchestratorCommonArea.getProcessAccounting().addProcess(jdId, job.getDuccId());
+ orchestratorCommonArea.getProcessAccounting().addProcess(processIdentity, jobIdentity);
//
job.setDriver(driver);
}
Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdReservation.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdReservation.java?rev=1756422&r1=1756421&r2=1756422&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdReservation.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdReservation.java Mon Aug 15 20:18:20 2016
@@ -130,20 +130,20 @@ public class JdReservation extends JdRes
return retVal;
}
- protected NodeIdentity allocate(DuccId jdId, DuccId jobId) {
- NodeIdentity retVal = allocate(jdId, jobId, getSizeOfSlice());
+ protected NodeIdentity allocate(DuccId jobIdentity, DuccId driverIdentity) {
+ NodeIdentity retVal = allocate(jobIdentity, driverIdentity, getSizeOfSlice());
return retVal;
}
- protected NodeIdentity allocate(DuccId jdId, DuccId jobId, SizeBytes size) {
+ protected NodeIdentity allocate(DuccId jobIdentity, DuccId driverIdentity, SizeBytes size) {
String location = "allocate";
NodeIdentity retVal = null;
ConcurrentHashMap<DuccId, SizeBytes> map = getMap();
- if(jdId != null) {
+ if(jobIdentity != null) {
synchronized(this) {
- if(!map.containsKey(jdId)) {
+ if(!map.containsKey(jobIdentity)) {
if(!isFull()) {
- SizeBytes previous = map.putIfAbsent(jdId, size);
+ SizeBytes previous = map.putIfAbsent(jobIdentity, size);
if(previous == null) {
retVal = getNodeIdentity();
}
@@ -151,25 +151,25 @@ public class JdReservation extends JdRes
}
}
if(retVal != null) {
- logger.info(location, jobId, "jdId:"+jdId+" "+"host: "+retVal.getName()+" "+"size: "+map.size());
+ logger.info(location, jobIdentity, "driverId:"+driverIdentity+" "+"host: "+retVal.getName()+" "+"size: "+map.size());
}
}
return retVal;
}
- protected NodeIdentity deallocate(DuccId jdId, DuccId jobId) {
+ protected NodeIdentity deallocate(DuccId jobIdentity, DuccId driverIdentity) {
String location = "deallocate";
NodeIdentity retVal = null;
ConcurrentHashMap<DuccId, SizeBytes> map = getMap();
- if(jdId != null) {
+ if(jobIdentity != null) {
synchronized(this) {
- if(map.containsKey(jdId)) {
- map.remove(jdId);
+ if(map.containsKey(jobIdentity)) {
+ map.remove(jobIdentity);
retVal = getNodeIdentity();
}
}
if(retVal != null) {
- logger.info(location, jobId, "jdId:"+jdId+" "+"host: "+retVal.getName()+" "+"size: "+map.size());
+ logger.info(location, jobIdentity, "driverId:"+driverIdentity+" "+"host: "+retVal.getName()+" "+"size: "+map.size());
}
}
return retVal;
Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdScheduler.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdScheduler.java?rev=1756422&r1=1756421&r2=1756422&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdScheduler.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdScheduler.java Mon Aug 15 20:18:20 2016
@@ -21,6 +21,7 @@ package org.apache.uima.ducc.orchestrato
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -29,22 +30,31 @@ import java.util.concurrent.atomic.Atomi
import org.apache.uima.ducc.common.NodeIdentity;
import org.apache.uima.ducc.common.SizeBytes;
import org.apache.uima.ducc.common.config.CommonConfiguration;
+import org.apache.uima.ducc.common.db.DbQuery;
+import org.apache.uima.ducc.common.db.IDbMachine;
import org.apache.uima.ducc.common.utils.DuccLogger;
+import org.apache.uima.ducc.common.utils.TimeStamp;
import org.apache.uima.ducc.common.utils.id.DuccId;
import org.apache.uima.ducc.orchestrator.OrchestratorCheckpoint;
import org.apache.uima.ducc.orchestrator.OrchestratorCommonArea;
import org.apache.uima.ducc.orchestrator.ReservationFactory;
+import org.apache.uima.ducc.orchestrator.StateManager;
import org.apache.uima.ducc.orchestrator.WorkMapHelper;
import org.apache.uima.ducc.transport.event.cli.ReservationRequestProperties;
import org.apache.uima.ducc.transport.event.cli.ReservationSpecificationProperties;
+import org.apache.uima.ducc.transport.event.common.DuccWorkJob;
import org.apache.uima.ducc.transport.event.common.DuccWorkMap;
import org.apache.uima.ducc.transport.event.common.DuccWorkReservation;
+import org.apache.uima.ducc.transport.event.common.IDuccCompletionType.JobCompletionType;
import org.apache.uima.ducc.transport.event.common.IDuccCompletionType.ReservationCompletionType;
import org.apache.uima.ducc.transport.event.common.IDuccSchedulingInfo;
import org.apache.uima.ducc.transport.event.common.IDuccState.ReservationState;
+import org.apache.uima.ducc.transport.event.common.IDuccTypes.DuccType;
import org.apache.uima.ducc.transport.event.common.IDuccWork;
import org.apache.uima.ducc.transport.event.common.IDuccWorkMap;
import org.apache.uima.ducc.transport.event.common.IDuccWorkReservation;
+import org.apache.uima.ducc.transport.event.common.IRationale;
+import org.apache.uima.ducc.transport.event.common.IResourceState.ProcessDeallocationType;
import org.apache.uima.ducc.transport.event.common.JdReservationBean;
import org.apache.uima.ducc.transport.event.common.Rationale;
@@ -57,6 +67,8 @@ public class JdScheduler {
private static JdScheduler instance = new JdScheduler();
+ private static OrchestratorCommonArea orchestratorCommonArea = OrchestratorCommonArea.getInstance();
+
public static JdScheduler getInstance() {
return instance;
}
@@ -96,18 +108,17 @@ public class JdScheduler {
try {
IDuccWorkMap dwm = OrchestratorCommonArea.getInstance().getWorkMap();
for(Entry<DuccId, JdReservation> entry : map.entrySet()) {
- DuccId jdReservationDuccId = entry.getKey();
- DuccId duccId = (DuccId) jdReservationDuccId;
- IDuccWork dw = dwm.findDuccWork(duccId);
+ DuccId reservationIdentity = entry.getKey();
+ IDuccWork dw = dwm.findDuccWork(reservationIdentity);
if(dw instanceof IDuccWorkReservation) {
IDuccWorkReservation dwr = (IDuccWorkReservation) dw;
- List<JdReservationBean> jdReservationBeanList = getJdReservationBeanList(jdReservationDuccId);
+ List<JdReservationBean> jdReservationBeanList = getJdReservationBeanList(reservationIdentity);
dwr.setJdReservationBeanList(jdReservationBeanList);
if(jdReservationBeanList != null) {
- logger.debug(location, duccId, "size: "+jdReservationBeanList.size());
+ logger.debug(location, reservationIdentity, "size: "+jdReservationBeanList.size());
}
else {
- logger.debug(location, duccId, "size: "+null);
+ logger.debug(location, reservationIdentity, "size: "+null);
}
}
}
@@ -157,6 +168,125 @@ public class JdScheduler {
}
}
return count;
+ }
+
+ // Fetch Reservations on given node (name)
+
+ private List<JdReservation> getJdReservationsByName(String name) {
+ String location = "getJdReservationByName";
+ List<JdReservation> retVal = new ArrayList<JdReservation>();
+ try {
+ if(name != null) {
+ for(Entry<DuccId, JdReservation> entry : map.entrySet()) {
+ String host = entry.getValue().getHost();
+ if(host.equals(name)) {
+ retVal.add(entry.getValue());
+ break;
+ }
+ }
+ }
+ }
+ catch(Exception e) {
+ logger.error(location, jobid, e);
+ }
+ return retVal;
+ }
+
+ // Cancel Reservation
+
+ private void cancelReservation(JdReservation jdReservation, String reason) {
+ String location = "cancelReservation";
+ try {
+ DuccId reservationIdentity = jdReservation.getDuccId();
+ DuccWorkMap workMap = orchestratorCommonArea.getWorkMap();
+ String id = ""+reservationIdentity.getFriendly();
+ DuccWorkReservation duccWorkReservation = (DuccWorkReservation) WorkMapHelper.findDuccWork(workMap, DuccType.Reservation, id, this, location);
+ switch(duccWorkReservation.getReservationState()) {
+ case Completed:
+ break;
+ default:
+ JdHostProperties jdHostProperties = new JdHostProperties();
+ duccWorkReservation.getStandardInfo().setCancelUser(jdHostProperties.getHostUser());
+ duccWorkReservation.getStandardInfo().setDateOfCompletion(TimeStamp.getCurrentMillis());
+ duccWorkReservation.stateChange(ReservationState.Completed);
+ duccWorkReservation.complete(ReservationCompletionType.CanceledBySystem);
+ IRationale rationale = new Rationale(reason);
+ duccWorkReservation.setCompletionRationale(rationale);
+ OrchestratorCheckpoint.getInstance().saveState();
+ logger.warn(location, reservationIdentity, reason);
+ break;
+ }
+ }
+ catch(Exception e) {
+ logger.error(location, jobid, e);
+ }
+ }
+
+ // Cancel Jobs
+
+ private void cancelJobs(JdReservation jdReservation, String reason) {
+ String location = "cancelJobs";
+ try {
+ Map<DuccId, SizeBytes> map = jdReservation.getMap();
+ for(Entry<DuccId, SizeBytes> entry : map.entrySet()) {
+ DuccId jobIdentity = entry.getKey();
+ DuccWorkMap workMap = orchestratorCommonArea.getWorkMap();
+ String id = ""+jobIdentity.getFriendly();
+ DuccWorkJob duccWorkJob = (DuccWorkJob) WorkMapHelper.findDuccWork(workMap, DuccType.Job, id, this, location);
+ IRationale rationale = new Rationale(reason.toString());
+ JobCompletionType jobCompletionType = JobCompletionType.CanceledBySystem;
+
+ StateManager stateManager = StateManager.getInstance();
+ stateManager.jobTerminate(duccWorkJob, jobCompletionType, rationale, ProcessDeallocationType.JobCanceled);
+
+ OrchestratorCheckpoint.getInstance().saveState();
+ logger.warn(location, jobIdentity, reason);
+ }
+ }
+ catch(Exception e) {
+ logger.error(location, jobid, e);
+ }
+ }
+
+ // Handle down JD node
+
+ private void handleDownNode(JdReservation jdReservation) {
+ String location = "handleDownNode";
+ try {
+ if(jdReservation != null) {
+ String host = jdReservation.getHost();
+ String text = "job driver node down: "+host;
+ cancelReservation(jdReservation, text);
+ cancelJobs(jdReservation, text);
+ }
+ }
+ catch(Exception e) {
+ logger.error(location, jobid, e);
+ }
+ }
+
+ // Monitor for down JD nodes
+
+ private void monitor() {
+ String location = "monitor";
+ try {
+ Map<String, IDbMachine> qMap = DbQuery.getInstance().getMapMachines();
+ for(Entry<String, IDbMachine> entry : qMap.entrySet()) {
+ Boolean responsive = entry.getValue().getResponsive();
+ if(!responsive.booleanValue()) {
+ String name = entry.getValue().getName();
+ List<JdReservation> list = getJdReservationsByName(name);
+ if(list != null) {
+ for(JdReservation jdReservation : list) {
+ handleDownNode(jdReservation);
+ }
+ }
+ }
+ }
+ }
+ catch(Exception e) {
+ logger.error(location, jobid, e);
+ }
}
// Process an OR publication.
@@ -164,8 +294,8 @@ public class JdScheduler {
public void handle(IDuccWorkMap dwm) {
String location = "handle";
try {
+ monitor();
if(dwm != null) {
- logger.debug(location, jobid, "dwm size: "+dwm.size());
JdHostProperties jdHostProperties = new JdHostProperties();
resourceAccounting(dwm, jdHostProperties);
resourceAdjustment(dwm, jdHostProperties);
@@ -223,8 +353,8 @@ public class JdScheduler {
known.remove(entry.getKey());
}
}
- for(DuccId jdReservationDuccId : known) {
- reservationVanished(jdReservationDuccId);
+ for(DuccId reservationIdentity : known) {
+ reservationVanished(reservationIdentity);
}
}
if(pendingFlag) {
@@ -347,29 +477,28 @@ public class JdScheduler {
//
long slicesReserveDesired = getSlicesReserveDesired(jdHostProperties);
long slicesReserveActual = getSlicesReserveActual();
- DuccId duccId = dwr.getDuccId();
- logger.debug(location, duccId, "actual: "+slicesReserveActual+" "+"desired: "+slicesReserveDesired);
+ DuccId reservationIdentity = dwr.getDuccId();
+ logger.debug(location, reservationIdentity, "actual: "+slicesReserveActual+" "+"desired: "+slicesReserveDesired);
}
// Return an unused JD Reservation.
private void reservationDivest(IDuccWorkMap dwm, JdHostProperties jdHostProperties) {
String location = "reservationDivest";
- DuccId jdReservationDuccId = null;
+ DuccId reservationIdentity = null;
synchronized(this) {
for(Entry<DuccId, JdReservation> entry : map.entrySet()) {
JdReservation jdReservation = entry.getValue();
if(jdReservation.isEmpty()) {
- jdReservationDuccId = entry.getKey();
- map.remove(jdReservationDuccId);
+ reservationIdentity = entry.getKey();
+ map.remove(reservationIdentity);
break;
}
jdReservation = null;
}
}
- if(jdReservationDuccId != null) {
- DuccId duccId = (DuccId) jdReservationDuccId;
- IDuccWork dw = dwm.findDuccWork(duccId);
+ if(reservationIdentity != null) {
+ IDuccWork dw = dwm.findDuccWork(reservationIdentity);
if(dw != null) {
IDuccWorkReservation dwr = (IDuccWorkReservation) dw;
// state: Completed
@@ -381,7 +510,7 @@ public class JdScheduler {
}
long slicesReserveDesired = getSlicesReserveDesired(jdHostProperties);
long slicesReserveActual = getSlicesReserveActual();
- logger.debug(location, jobid, "actual: "+slicesReserveActual+" "+"desired: "+slicesReserveDesired);
+ logger.debug(location, reservationIdentity, "actual: "+slicesReserveActual+" "+"desired: "+slicesReserveDesired);
}
// Nothing to do.
@@ -399,23 +528,22 @@ public class JdScheduler {
if(jdReservationBeanList != null) {
for(JdReservationBean entry : jdReservationBeanList) {
JdReservation jdReservation = (JdReservation) entry;
- DuccId jdReservationDuccId = jdReservation.getDuccId();
- map.put(jdReservationDuccId, jdReservation);
+ DuccId reservationIdentity = jdReservation.getDuccId();
+ map.put(reservationIdentity, jdReservation);
}
}
}
// Return a list of JDs (DuccId's) allocated on a JD Reservation.
- public List<JdReservationBean> getJdReservationBeanList(DuccId jdReservationDuccId) {
+ public List<JdReservationBean> getJdReservationBeanList(DuccId reservationIdentity) {
String location = "getJdReservationBeanList";
List<JdReservationBean> jdReservationBeanList = new ArrayList<JdReservationBean>();
for(Entry<DuccId, JdReservation> entry : map.entrySet()) {
JdReservation jdReservation = entry.getValue();
- if(jdReservationDuccId.equals(jdReservation.getDuccId())) {
+ if(reservationIdentity.equals(jdReservation.getDuccId())) {
jdReservationBeanList.add(jdReservation);
- DuccId duccId = (DuccId) jdReservationDuccId;
- logger.trace(location, duccId, jdReservationBeanList.size());
+ logger.trace(location, reservationIdentity, jdReservationBeanList.size());
}
}
return jdReservationBeanList;
@@ -445,23 +573,22 @@ public class JdScheduler {
private void reservationUp(IDuccWorkReservation dwr, JdHostProperties jdHostProperties) {
String location = "reservationUp";
- DuccId duccId = dwr.getDuccId();
- DuccId jdReservationDuccId = (DuccId) duccId;
+ DuccId reservationIdentity = dwr.getDuccId();
JdReservation jdReservation = null;
SizeBytes reservationSize = JdHelper.getReservationSize(dwr);
SizeBytes sliceSize = JdHelper.getSliceSize(jdHostProperties);
- jdReservation = map.get(jdReservationDuccId);
+ jdReservation = map.get(reservationIdentity);
if(jdReservation == null) {
jdReservation = new JdReservation(dwr, reservationSize, sliceSize);
- map.putIfAbsent(jdReservationDuccId, jdReservation);
+ map.putIfAbsent(reservationIdentity, jdReservation);
}
else if(!jdReservation.isUp()) {
jdReservation = new JdReservation(dwr, reservationSize, sliceSize);
- map.putIfAbsent(jdReservationDuccId, jdReservation);
+ map.putIfAbsent(reservationIdentity, jdReservation);
}
- jdReservation = map.get(jdReservationDuccId);
+ jdReservation = map.get(reservationIdentity);
if(jdReservation != null) {
- logger.debug(location, duccId, "host: "+jdReservation.getHost());
+ logger.debug(location, reservationIdentity, "host: "+jdReservation.getHost());
}
}
@@ -469,19 +596,18 @@ public class JdScheduler {
private void reservationDown(IDuccWorkReservation dwr) {
String location = "reservationDown";
- DuccId duccId = dwr.getDuccId();
- DuccId jdReservationDuccId = (DuccId) duccId;
+ DuccId reservationIdentity = dwr.getDuccId();
JdReservation jdReservation = null;
List<JdReservation> list = new ArrayList<JdReservation>();
synchronized(this) {
- jdReservation = map.get(jdReservationDuccId);
+ jdReservation = map.get(reservationIdentity);
if(jdReservation != null) {
- map.remove(jdReservationDuccId);
+ map.remove(reservationIdentity);
list.add(jdReservation);
}
}
if(list.size() > 0) {
- logger.info(location, duccId, list.size());
+ logger.info(location, reservationIdentity, list.size());
defunct(list);
}
}
@@ -490,34 +616,33 @@ public class JdScheduler {
private void reservationOther(IDuccWorkReservation dwr, JdHostProperties jdHostProperties) {
String location = " reservationOther";
- DuccId duccId = dwr.getDuccId();
- DuccId jdReservationDuccId = (DuccId) duccId;
+ DuccId reservationIdentity = dwr.getDuccId();
JdReservation jdReservation = null;
SizeBytes reservationSize = JdHelper.getReservationSize(dwr);
SizeBytes sliceSize = JdHelper.getSliceSize(jdHostProperties);
- jdReservation = map.get(jdReservationDuccId);
+ jdReservation = map.get(reservationIdentity);
if(jdReservation == null) {
jdReservation = new JdReservation(dwr, reservationSize, sliceSize);
- map.putIfAbsent(jdReservationDuccId, jdReservation);
+ map.putIfAbsent(reservationIdentity, jdReservation);
}
- jdReservation = map.get(jdReservationDuccId);
- logger.trace(location, duccId, "total: "+countReservationsTotal()+" "+"up: "+countReservationsUp());
+ jdReservation = map.get(reservationIdentity);
+ logger.trace(location, reservationIdentity, "total: "+countReservationsTotal()+" "+"up: "+countReservationsUp());
}
// Handle a JD Reservation that has disappeared for the Orchestrator publication.
- private void reservationVanished(DuccId jdReservationDuccId) {
+ private void reservationVanished(DuccId reservationIdentity) {
String location = "reservationVanished";
List<JdReservation> list = new ArrayList<JdReservation>();
synchronized(this) {
- JdReservation jdReservation = map.get(jdReservationDuccId);
+ JdReservation jdReservation = map.get(reservationIdentity);
if(jdReservation != null) {
- jdReservation = map.remove(jdReservationDuccId);
+ jdReservation = map.remove(reservationIdentity);
list.add(jdReservation);
}
}
if(list.size() > 0) {
- DuccId duccId = (DuccId) jdReservationDuccId;
+ DuccId duccId = (DuccId) reservationIdentity;
logger.info(location, duccId, list.size());
defunct(list);
}
@@ -542,22 +667,24 @@ public class JdScheduler {
//TODO phase I = kill Job
//TODO phase II = start new JD
if(jdReservation != null) {
- DuccId duccId = (DuccId) jdReservation.getDuccId();
- logger.debug(location, duccId, "host: "+jdReservation.getHost());
+ DuccId reservationIdentity = (DuccId) jdReservation.getDuccId();
+ logger.debug(location, reservationIdentity, "host: "+jdReservation.getHost());
}
}
// Get a slice, if one is available.
- public NodeIdentity allocate(DuccId jdId, DuccId jobId) {
+ public NodeIdentity allocate(DuccId jobIdentity, DuccId driverIdentity) {
String location = "allocate";
NodeIdentity nodeIdentity = null;
- if(jdId != null) {
+ if(jobIdentity != null) {
String host = null;
synchronized(this) {
for(Entry<DuccId, JdReservation> entry : map.entrySet()) {
JdReservation jdReservation = entry.getValue();
- nodeIdentity = jdReservation.allocate(jdId, jobId);
+ host = jdReservation.getHost();
+ logger.debug(location, jobIdentity, "host: "+host+" "+"job: "+jobIdentity);
+ nodeIdentity = jdReservation.allocate(jobIdentity, driverIdentity);
if(nodeIdentity != null) {
host = nodeIdentity.getName();
changes.set(true);
@@ -566,7 +693,7 @@ public class JdScheduler {
}
}
if(nodeIdentity != null) {
- logger.debug(location, jobId, "jdId:"+jdId+" "+"host: "+host);
+ logger.debug(location, jobIdentity, "host: "+host+" "+"job: "+jobIdentity);
}
}
return nodeIdentity;
@@ -574,18 +701,18 @@ public class JdScheduler {
// Return a slice.
- public void deallocate(DuccId jdId, DuccId jobId) {
+ public void deallocate(DuccId jobIdentity, DuccId driverIdentity) {
String location = "deallocate";
NodeIdentity nodeIdentity = null;
- if(jdId != null) {
+ if(jobIdentity != null) {
String host = null;
- logger.debug(location, jobId, "map size: "+map.size());
+ logger.debug(location, jobIdentity, "map size: "+map.size());
synchronized(this) {
for(Entry<DuccId, JdReservation> entry : map.entrySet()) {
JdReservation jdReservation = entry.getValue();
- logger.debug(location, jobId, "get host: "+jdReservation.getHost());
- logger.debug(location, jobId, "jdId: "+jdId);
- nodeIdentity = jdReservation.deallocate(jdId, jobId);
+ host = jdReservation.getHost();
+ logger.debug(location, jobIdentity, "host: "+host+" "+"job: "+jobIdentity);
+ nodeIdentity = jdReservation.deallocate(jobIdentity, driverIdentity);
if(nodeIdentity != null) {
host = nodeIdentity.getName();
changes.set(true);
@@ -594,47 +721,47 @@ public class JdScheduler {
}
}
if(nodeIdentity != null) {
- logger.debug(location, jobId, "jdId:"+jdId+" "+"host: "+host);
+ logger.debug(location, jobIdentity, "host: "+host+" "+"job: "+jobIdentity);
}
}
}
// Return the number of slices total for the specified JD Reservation.
- public int countSlicesTotal(DuccId duccId) {
+ public int countSlicesTotal(DuccId reservationIdentity) {
String location = "countSlicesTotal";
int count = 0;
- JdReservation jdReservation = map.get(duccId);
+ JdReservation jdReservation = map.get(reservationIdentity);
if(jdReservation != null) {
count += jdReservation.getSlicesTotal();
}
- logger.trace(location, duccId, count);
+ logger.trace(location, reservationIdentity, count);
return count;
}
// Return the number of slices inuse for the specified JD Reservation.
- public int countSlicesInuse(DuccId duccId) {
+ public int countSlicesInuse(DuccId reservationIdentity) {
String location = "countSlicesInuse";
int count = 0;
- JdReservation jdReservation = map.get(duccId);
+ JdReservation jdReservation = map.get(reservationIdentity);
if(jdReservation != null) {
count += jdReservation.getSlicesInuse();
}
- logger.trace(location, duccId, count);
+ logger.trace(location, reservationIdentity, count);
return count;
}
// Return the number of slices available for the specified JD Reservation.
- public int countSlicesAvailable(DuccId duccId) {
+ public int countSlicesAvailable(DuccId reservationIdentity) {
String location = "countSlicesAvailable";
int count = 0;
- JdReservation jdReservation = map.get(duccId);
+ JdReservation jdReservation = map.get(reservationIdentity);
if(jdReservation != null) {
count += jdReservation.getSlicesAvailable();
}
- logger.trace(location, duccId, count);
+ logger.trace(location, reservationIdentity, count);
return count;
}
Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/test/java/org/apache/uima/ducc/orchestrator/jd/scheduler/test/TestHelper.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/test/java/org/apache/uima/ducc/orchestrator/jd/scheduler/test/TestHelper.java?rev=1756422&r1=1756421&r2=1756422&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/test/java/org/apache/uima/ducc/orchestrator/jd/scheduler/test/TestHelper.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/test/java/org/apache/uima/ducc/orchestrator/jd/scheduler/test/TestHelper.java Mon Aug 15 20:18:20 2016
@@ -35,6 +35,7 @@ import org.apache.uima.ducc.transport.ev
public class TestHelper {
private static AtomicInteger jdNumber = new AtomicInteger(0);
+ private static AtomicInteger jpNumber = new AtomicInteger(0);
private static AtomicInteger hostNumber = new AtomicInteger(0);
@@ -100,11 +101,20 @@ public class TestHelper {
return dwr;
}
- public static DuccId getJdId() {
+ public static DuccId getJobIdentity() {
DuccId jdId = new DuccId(jdNumber.getAndIncrement());
+ long friendly = jdId.getFriendly();
+ System.out.println("friendly:"+friendly);
return jdId;
}
+ public static DuccId getProcessIdentity() {
+ DuccId jpId = new DuccId(jpNumber.getAndIncrement());
+ long friendly = jpId.getFriendly();
+ System.out.println("friendly:"+friendly);
+ return jpId;
+ }
+
public static void assign(IDuccWorkReservation dwr) {
IDuccReservationMap rm = dwr.getReservationMap();
DuccId duccId = new DuccId(hostNumber.get());
Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/test/java/org/apache/uima/ducc/orchestrator/jd/scheduler/test/TestSuite.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/test/java/org/apache/uima/ducc/orchestrator/jd/scheduler/test/TestSuite.java?rev=1756422&r1=1756421&r2=1756422&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/test/java/org/apache/uima/ducc/orchestrator/jd/scheduler/test/TestSuite.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/test/java/org/apache/uima/ducc/orchestrator/jd/scheduler/test/TestSuite.java Mon Aug 15 20:18:20 2016
@@ -251,19 +251,20 @@ public class TestSuite {
HashMap<DuccId,DuccId> map = new HashMap<DuccId,DuccId>();
int expectedInuse = 5;
for(int i=0; i < expectedInuse; i++) {
- DuccId jdId = TestHelper.getJdId();
- map.put(jdId, jdId);
- DuccId jdProcessDuccId = (DuccId) jdId;
- NodeIdentity nodeIdentity = jdScheduler.allocate(jdProcessDuccId, jobId);
+ DuccId jobIdentity = TestHelper.getJobIdentity();
+ DuccId processIdentity = TestHelper.getProcessIdentity();
+ logger.info("jdId", jobIdentity, processIdentity);
+ map.put(jobIdentity, processIdentity);
+ NodeIdentity nodeIdentity = jdScheduler.allocate(jobIdentity, processIdentity);
assertTrue(nodeIdentity != null);
randomPublication(jdScheduler, dwm);
}
assertTrue(jdScheduler.countSlicesInuse() == expectedInuse);
assertTrue(jdScheduler.countSlicesTotal() > 0);
for(Entry<DuccId, DuccId> entry : map.entrySet()) {
- DuccId jdId = entry.getKey();
- DuccId jdProcessDuccId = (DuccId) jdId;
- jdScheduler.deallocate(jdProcessDuccId, jobId);
+ DuccId jobIdentity = entry.getKey();
+ DuccId processIdentity = entry.getValue();
+ jdScheduler.deallocate(jobIdentity, processIdentity);
randomPublication(jdScheduler, dwm);
}
publication(jdScheduler, dwm);
@@ -272,13 +273,13 @@ public class TestSuite {
//
int allocations = 0;
while(allocations < 100) {
- DuccId jdId = TestHelper.getJdId();
- DuccId jdProcessDuccId = (DuccId) jdId;
- map.put(jdId, jdId);
- NodeIdentity nodeIdentity = jdScheduler.allocate(jdProcessDuccId, jobId);
+ DuccId jobIdentity = TestHelper.getJobIdentity();
+ DuccId processIdentity = TestHelper.getProcessIdentity();
+ map.put(jobIdentity, processIdentity);
+ NodeIdentity nodeIdentity = jdScheduler.allocate(jobIdentity, processIdentity);
if(nodeIdentity == null) {
publication(jdScheduler, dwm);
- nodeIdentity = jdScheduler.allocate(jdProcessDuccId, jobId);
+ nodeIdentity = jdScheduler.allocate(jobIdentity, processIdentity);
}
//assertTrue(nodeIdentity != null);
randomPublication(jdScheduler, dwm);
Modified: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/jd/JobDriverStateExchanger.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/jd/JobDriverStateExchanger.java?rev=1756422&r1=1756421&r2=1756422&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/jd/JobDriverStateExchanger.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/jd/JobDriverStateExchanger.java Mon Aug 15 20:18:20 2016
@@ -176,9 +176,28 @@ public class JobDriverStateExchanger ext
return jdRequestEvent;
}
+ private void abortIfTold(JdReplyEvent jdReplyEvent) {
+ String location = "abortIfTold";
+ if(jdReplyEvent != null) {
+ String killDriverReason = jdReplyEvent.getKillDriverReason();
+ if(killDriverReason != null) {
+ int code = 255;
+ StringBuffer sb = new StringBuffer();
+ sb.append("System Exit");
+ sb.append(" ");
+ sb.append("code="+code);
+ sb.append(" ");
+ sb.append("reason="+killDriverReason);
+ logger.warn(location, jobid, sb.toString());
+ System.exit(code);
+ }
+ }
+ }
+
private void handle(JdReplyEvent jdReplyEvent) {
String location = "handle";
try {
+ abortIfTold(jdReplyEvent);
JobDriver jd = JobDriver.getInstance();
IMessageHandler mh = jd.getMessageHandler();
setProcessMap(jdReplyEvent.getProcessMap());
Added: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdEvent.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdEvent.java?rev=1756422&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdEvent.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdEvent.java Mon Aug 15 20:18:20 2016
@@ -0,0 +1,63 @@
+/*
+ * 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.transport.event;
+
+import org.apache.uima.ducc.transport.event.common.IDuccProcessMap;
+import org.apache.uima.ducc.transport.event.jd.IDriverStatusReport;
+
+@SuppressWarnings("serial")
+public class JdEvent extends AbstractDuccJobEvent {
+
+ private IDriverStatusReport driverStatusReport = null;
+ private IDuccProcessMap processMap = null;
+
+ private String killDriverReason = null;
+
+ public JdEvent() {
+ super(EventType.JD_STATE);
+ }
+
+ public IDriverStatusReport getDriverStatusReport() {
+ return driverStatusReport;
+ }
+
+ public void setDriverStatusReport(IDriverStatusReport value) {
+ driverStatusReport = value;
+ }
+
+ public IDuccProcessMap getProcessMap() {
+ return processMap;
+ }
+
+ public void setProcessMap(IDuccProcessMap value) {
+ processMap = value;
+ }
+
+ public void setKillDriverReason(String value) {
+ killDriverReason = value;
+ }
+
+ public String getKillDriverReason() {
+ return killDriverReason;
+ }
+
+ public boolean isKillDriver() {
+ return (getKillDriverReason() != null);
+ }
+}
Propchange: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdEvent.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdReplyEvent.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdReplyEvent.java?rev=1756422&r1=1756421&r2=1756422&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdReplyEvent.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdReplyEvent.java Mon Aug 15 20:18:20 2016
@@ -19,6 +19,6 @@
package org.apache.uima.ducc.transport.event;
@SuppressWarnings("serial")
-public class JdReplyEvent extends JdRequestEvent {
+public class JdReplyEvent extends JdEvent {
}
Modified: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdRequestEvent.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdRequestEvent.java?rev=1756422&r1=1756421&r2=1756422&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdRequestEvent.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/JdRequestEvent.java Mon Aug 15 20:18:20 2016
@@ -18,32 +18,7 @@
*/
package org.apache.uima.ducc.transport.event;
-import org.apache.uima.ducc.transport.event.common.IDuccProcessMap;
-import org.apache.uima.ducc.transport.event.jd.IDriverStatusReport;
-
@SuppressWarnings("serial")
-public class JdRequestEvent extends AbstractDuccJobEvent {
-
- private IDriverStatusReport driverStatusReport = null;
- private IDuccProcessMap processMap = null;
-
- public JdRequestEvent() {
- super(EventType.JD_STATE);
- }
-
- public IDriverStatusReport getDriverStatusReport() {
- return driverStatusReport;
- }
-
- public void setDriverStatusReport(IDriverStatusReport value) {
- driverStatusReport = value;
- }
+public class JdRequestEvent extends JdEvent {
- public IDuccProcessMap getProcessMap() {
- return processMap;
- }
-
- public void setProcessMap(IDuccProcessMap value) {
- processMap = value;
- }
}
Modified: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/DuccProcess.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/DuccProcess.java?rev=1756422&r1=1756421&r2=1756422&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/DuccProcess.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/DuccProcess.java Mon Aug 15 20:18:20 2016
@@ -149,6 +149,7 @@ public class DuccProcess implements IDuc
public void setProcessState(ProcessState processState) {
this.processState = processState;
+ setEndTimes();
}
/*
@@ -163,6 +164,32 @@ public class DuccProcess implements IDuc
Undefined
*/
+ private void setEndTime(ITimeWindow tw) {
+ if(tw != null) {
+ if(tw.getStart() != null) {
+ if(tw.getEnd() == null) {
+ tw.setEndLong(System.currentTimeMillis());
+ }
+ }
+ }
+ }
+
+ private void setEndTimes() {
+ switch(getProcessState()) {
+ case LaunchFailed:
+ case Stopped:
+ case Failed:
+ case FailedInitialization:
+ case InitializationTimeout:
+ case Killed:
+ setEndTime(timeWindowInit);
+ setEndTime(timeWindowRun);
+ break;
+ default:
+ break;
+ }
+ }
+
public void advanceProcessState(ProcessState nextProcessState) {
switch(getProcessState()) {
case Starting:
@@ -216,6 +243,7 @@ public class DuccProcess implements IDuc
}
break;
}
+ setEndTimes();
}