@Override public int compare(Procedure lhs, Procedure rhs) { long cmp = lhs.getParentProcId() - rhs.getParentProcId(); cmp = cmp != 0 ? cmp : lhs.getProcId() - rhs.getProcId(); return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; } });
/** * @param a the first procedure to be compared. * @param b the second procedure to be compared. * @return true if the two procedures have the same parent */ public static boolean haveSameParent(Procedure<?> a, Procedure<?> b) { return a.hasParent() && b.hasParent() && (a.getParentProcId() == b.getParentProcId()); } }
/** * Helper to lookup the root Procedure ID given a specified procedure. */ protected static <T> Long getRootProcedureId(Map<Long, Procedure<T>> procedures, Procedure<T> proc) { while (proc.hasParent()) { proc = procedures.get(proc.getParentProcId()); if (proc == null) { return null; } } return proc.getProcId(); }
private void restoreLocks() { Set<Long> restored = new HashSet<>(); Deque<Procedure<TEnvironment>> stack = new ArrayDeque<>(); procedures.values().forEach(proc -> { for (;;) { if (restored.contains(proc.getProcId())) { restoreLocks(stack, restored); return; } if (!proc.hasParent()) { restoreLock(proc, restored); restoreLocks(stack, restored); return; } stack.push(proc); proc = procedures.get(proc.getParentProcId()); } }); }
public static String describe(Procedure<?> proc) { Map<String, Object> description = new LinkedHashMap<>(); description.put("ID", proc.getProcId()); description.put("PARENT_ID", proc.getParentProcId()); description.put("STATE", proc.getState()); description.put("OWNER", proc.getOwner()); description.put("TYPE", proc.getProcName()); description.put("START_TIME", new Date(proc.getSubmittedTime())); description.put("LAST_UPDATE", new Date(proc.getLastUpdate())); if (proc.isFailed()) { description.put("ERRORS", MasterProcedureUtil.unwrapRemoteIOException(proc).getMessage()); } description.put("PARAMETERS", parametersToObject(proc)); return JRubyFormat.print(description); }
sb.append(getParentProcId());
private void countDownChildren(RootProcedureState<TEnvironment> procStack, Procedure<TEnvironment> procedure) { Procedure<TEnvironment> parent = procedures.get(procedure.getParentProcId()); if (parent == null) { assert procStack.isRollingback(); return; } // If this procedure is the last child awake the parent procedure if (parent.tryRunnable()) { // If we succeeded in making the parent runnable -- i.e. all of its // children have completed, move parent to front of the queue. store.update(parent); scheduler.addFront(parent); LOG.info("Finished subprocedure(s) of " + parent + "; resume parent processing."); return; } }
@Override public boolean hasLockAccess(Procedure<?> proc) { if (exclusiveLockOwnerProcedure == null) { return false; } long lockOwnerId = exclusiveLockOwnerProcedure.getProcId(); if (proc.getProcId() == lockOwnerId) { return true; } if (!proc.hasParent()) { return false; } // fast path to check root procedure if (proc.getRootProcId() == lockOwnerId) { return true; } // check ancestors for (Procedure<?> p = proc;;) { if (p.getParentProcId() == lockOwnerId) { return true; } p = procedureRetriever.apply(p.getParentProcId()); if (p == null || !p.hasParent()) { return false; } } }
@Test public void testBypassingProcedureWithParentRecursive() throws Exception { final RootProcedure proc = new RootProcedure(); long rootId = procExecutor.submitProcedure(proc); htu.waitFor(5000, () -> procExecutor.getProcedures().stream() .filter(p -> p.getParentProcId() == rootId).collect(Collectors.toList()) .size() > 0); SuspendProcedure suspendProcedure = (SuspendProcedure)procExecutor.getProcedures().stream() .filter(p -> p.getParentProcId() == rootId).collect(Collectors.toList()).get(0); assertTrue(procExecutor.bypassProcedure(rootId, 1000, false, true)); htu.waitFor(5000, () -> proc.isSuccess() && proc.isBypass()); LOG.info("{} finished", proc); }
@Test public void testBypassingProcedureWithParent() throws Exception { final RootProcedure proc = new RootProcedure(); long rootId = procExecutor.submitProcedure(proc); htu.waitFor(5000, () -> procExecutor.getProcedures().stream() .filter(p -> p.getParentProcId() == rootId).collect(Collectors.toList()) .size() > 0); SuspendProcedure suspendProcedure = (SuspendProcedure)procExecutor.getProcedures().stream() .filter(p -> p.getParentProcId() == rootId).collect(Collectors.toList()).get(0); assertTrue(procExecutor.bypassProcedure(suspendProcedure.getProcId(), 1000, false, false)); htu.waitFor(5000, () -> proc.isSuccess() && proc.isBypass()); LOG.info("{} finished", proc); }
this.procedures.forEachValue(1 /*Single-threaded*/, v -> v.getParentProcId() == procedure.getProcId()? v: null, current.bypass(getEnvironment()); store.update(procedure); long parentID = current.getParentProcId(); current = getProcedure(parentID);
Procedure<TEnvironment> parent = procedures.get(proc.getParentProcId()); if (parent != null && !proc.isFinished()) { parent.incChildrenLatch();
out.print( proc.getProcId() ); out.write("</td>\n <td>"); out.print( proc.hasParent() ? proc.getParentProcId() : "" ); out.write("</td>\n <td>"); out.print( escapeXml(proc.getState().toString() + (proc.isBypass() ? "(Bypass)" : "")) );
assertEquals(rootProcs.length, loader.getCorruptedCount()); for (Procedure<?> proc : loader.getCorrupted()) { assertTrue(proc.toString(), proc.getParentProcId() <= rootProcs.length); assertTrue(proc.toString(), proc.getProcId() > rootProcs.length && proc.getProcId() <= (rootProcs.length * 2));
builder.setParentId(proc.getParentProcId());
/** * @param a the first procedure to be compared. * @param b the second procedure to be compared. * @return true if the two procedures have the same parent */ public static boolean haveSameParent(final Procedure<?> a, final Procedure<?> b) { return a.hasParent() && b.hasParent() && (a.getParentProcId() == b.getParentProcId()); } }
/** * @param a the first procedure to be compared. * @param b the second procedure to be compared. * @return true if the two procedures have the same parent */ public static boolean haveSameParent(Procedure<?> a, Procedure<?> b) { return a.hasParent() && b.hasParent() && (a.getParentProcId() == b.getParentProcId()); } }
@InterfaceAudience.Private protected static Long getRootProcedureId(final Map<Long, Procedure> procedures, Procedure<?> proc) { while (proc.hasParent()) { proc = procedures.get(proc.getParentProcId()); if (proc == null) return null; } return proc.getProcId(); }
@InterfaceAudience.Private protected static Long getRootProcedureId(final Map<Long, Procedure> procedures, Procedure proc) { while (proc.hasParent()) { proc = procedures.get(proc.getParentProcId()); if (proc == null) return null; } return proc.getProcId(); }
@Test public void testBypassingProcedureWithParent() throws Exception { final RootProcedure proc = new RootProcedure(); long rootId = procExecutor.submitProcedure(proc); htu.waitFor(5000, () -> procExecutor.getProcedures().stream() .filter(p -> p.getParentProcId() == rootId).collect(Collectors.toList()) .size() > 0); SuspendProcedure suspendProcedure = (SuspendProcedure)procExecutor.getProcedures().stream() .filter(p -> p.getParentProcId() == rootId).collect(Collectors.toList()).get(0); assertTrue(procExecutor.bypassProcedure(suspendProcedure.getProcId(), 1000, false, false)); htu.waitFor(5000, () -> proc.isSuccess() && proc.isBypass()); LOG.info("{} finished", proc); }