Automic Workload Automation

Expand all | Collapse all

"Modify Status Manually" -- is there any sanctioned, automated or API way to do this?

  • 1.  "Modify Status Manually" -- is there any sanctioned, automated or API way to do this?

    Posted 02-28-2017 05:52 PM
    When we lose the host behind an agent (which happens often because of our commodity/cloud architecture), we get jobs that are permanently in the wrong status, and sometimes they are not a cancelable status. 

    In these situations, we have only been able to "Modify status manually" from the GUI. 

    Is there any automated way to do this override? Ideally, with a java API call? 

    Not at all keen on doing direct SQL updates, but we would really like to automate this behavior in a few cases, so it might be worth it if the procedure is "blessed."


  • 2.  "Modify Status Manually" -- is there any sanctioned, automated or API way to do this?

    Posted 02-28-2017 07:40 PM
    The ModifyTaskState class would be what you need, once you have gathered the list of runs in the wrong state. There's a number of ways to do that, depending on what statuses you're expecting to find. Hopefully it doesn't happen too often, but if it does you could have your process scrape all runs using a GenericStatistics with a certain status using setStatus() and modify the resulting iterator accordingly. 


  • 3.  "Modify Status Manually" -- is there any sanctioned, automated or API way to do this?

    Posted 03-01-2017 03:28 AM
    Which Status do the Jobs have when you lost the agent?

    possibly you could use the script function modify_state in combination with a SQL vara filtering all jobs from activities window.


  • 4.  "Modify Status Manually" -- is there any sanctioned, automated or API way to do this?

    Posted 03-01-2017 02:29 PM
    I've been trying to get into the mindset of using AE scripting if possible, but sadly :MODIFY_STATE appears to only affect the current object.  Modifying information post-Active state appears to only be available via SQL (dangerous) and Java (potentially slower, albeit far more controlled).  I'm make a little example script put I've hit a snag where the system is disallowing my test user from performing an AdoptTask request, so I'm a bit behind.


  • 5.  "Modify Status Manually" -- is there any sanctioned, automated or API way to do this?

    Posted 03-01-2017 02:39 PM
    oops I am sorry, I completely forgot that you can use modify_state only in the object itself and not for other objects.

    And yes, modifying somethin directly in DB is not obly dangerous but can kill data consistency in your system.

    In this case the use of JAVA API is the best (and only) way :-)


  • 6.  "Modify Status Manually" -- is there any sanctioned, automated or API way to do this?

    Posted 03-01-2017 03:22 PM
    Turns out my "snag" was I was using an inquiry-only user for my login credentials.  Need more coffee :)

    Here we go:

    import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import com.uc4.api.Task; import com.uc4.api.TaskFilter; import com.uc4.communication.Connection; import com.uc4.communication.TimeoutException; import com.uc4.communication.requests.ActivityList; import com.uc4.communication.requests.ModifyTaskState; public class RunUpdater {      public static void main (String[] args) throws IOException {           UpdateStatus update = new UpdateStatus(Integer.parseInt(args[0]),args[1]);           update.checkStatus(args[2], Integer.parseInt(args[3]), Integer.parseInt(args[4]));           update.modifyStatus();           update.conn.close();      } } class TaskInfo {      String taskName;      int runID;      int statusCode;      int newStatusCode;            public TaskInfo(String taskName, int runID, int statusCode, int newStatusCode) {           this.taskName = taskName;           this.runID = runID;           this.statusCode = statusCode;           this.newStatusCode = newStatusCode;      }      public String getName() {           return taskName;      }      public int getRunID() {           return runID;      }      public int getStatusCode() {           return statusCode;      }      public int getNewStatusCode() {           return newStatusCode;      } } class UpdateStatus {      private List<TaskInfo> tasksFound = new ArrayList<TaskInfo>();      public Connection conn;            public UpdateStatus(int client, String level) throws IOException {           conn = new ConnectionManager().authenticate(client, level);      }            public void checkStatus(String object, int statusCode, int newStatusCode) throws TimeoutException, IOException {           TaskFilter activeFilter = new TaskFilter();           activeFilter.selectAllObjects();           activeFilter.setObjectName("*" + object + "*");           ActivityList getActiveTasks = new ActivityList(activeFilter);           conn.sendRequestAndWait(getActiveTasks);           if (getActiveTasks.getMessageBox() == null) {                Iterator<Task> activeTasks = getActiveTasks.iterator();                while (activeTasks.hasNext()) {                     Task task = activeTasks.next();                     if (task.getStatusCode() == statusCode) {                          tasksFound.add(new TaskInfo(task.getName(),task.getRunID(),statusCode,newStatusCode));                     }                }           }      }            public void modifyStatus() throws TimeoutException, IOException {           for (TaskInfo taskInfo : tasksFound) {                ModifyTaskState modStatus = new ModifyTaskState(taskInfo.getRunID(), taskInfo.getStatusCode(), taskInfo.getNewStatusCode());                conn.sendRequestAndWait(modStatus);                if (modStatus.getMessageBox() == null) {                     System.out.println("Object " + taskInfo.getName() + " (RunID " + taskInfo.getRunID() + ") was successfully modified from status " + taskInfo.getStatusCode() + " to status " + taskInfo.getNewStatusCode());                }           }      } }
    Example output specifying Client, Level, Search Particle (I used "TEST.JU.RAN"), Status Code, and New Status Code:
    tql70v42s679.pnghttps://us.v-cdn.net/5019921/uploads/editor/ya/tql70v42s679.png" width="724">
    Obviously you are welcome to add to it, etc.  I went a little beyond basic to allow for some flexibility, you can remove the entire TaskInfo class if you wanted to, just makes it easier to track and use elsewhere.  Let me know if you have any questions.


  • 7.  "Modify Status Manually" -- is there any sanctioned, automated or API way to do this?

    Posted 03-01-2017 03:23 PM
    Hi Wolfgang, thanks for looking into it. :-)  

    The most common status is actually "Active" ...because Automic assumes that the job is fine, forever, even if it doesn't hear from the agent for days.

    Without an active agent, you can't kill the job. So we have to manually change the status.

    Is ModifyTaskState still the right function? I actually haven't used the API, am asking on behalf of some developers who don't have access to the GUI. 


  • 8.  "Modify Status Manually" -- is there any sanctioned, automated or API way to do this?

    Posted 03-01-2017 04:00 PM
    Wow, thanks so much Michael, really above and beyond! I will pass this along to the developers. :smile: