public void addChild(Identifier child) { addChildren(Collections.singleton(child)); }
public void setParent(Identifier parent) { validateParent(parent.getType()); addInfo(PARENT_INFO_KEY, parent); }
public void addChildren(Set<Identifier> children) { TimelineEntityType thisType = TimelineEntityType.valueOf(getType()); for (Identifier child : children) { validateChild(child, thisType); } Set<Identifier> existingChildren = getChildren(); existingChildren.addAll(children); setChildren(existingChildren); }
@SuppressWarnings("unchecked") public Set<Identifier> getChildren() { Object identifiers = getInfo().get(CHILDREN_INFO_KEY); if (identifiers == null) { return new HashSet<>(); } TimelineEntityType thisType = TimelineEntityType.valueOf(getType()); if (identifiers instanceof Set<?>) { for (Object identifier : (Set<?>) identifiers) { if (!(identifier instanceof Identifier)) { throw new YarnRuntimeException( "Children info contains invalid identifier object"); } else { validateChild((Identifier) identifier, thisType); } } } else { throw new YarnRuntimeException( "Children info is invalid identifier set"); } Set<Identifier> children = (Set<Identifier>) identifiers; return children; }
private void validateParent(String type) { TimelineEntityType parentType = TimelineEntityType.valueOf(type); TimelineEntityType thisType = TimelineEntityType.valueOf(getType()); if (!thisType.isParent(parentType)) { throw new IllegalArgumentException( type + " is not the acceptable parent of " + this.getType()); } }
public void setChildren(Set<Identifier> children) { addInfo(CHILDREN_INFO_KEY, children); }
public Identifier getParent() { Object obj = getInfo().get(PARENT_INFO_KEY); if (obj != null) { if (obj instanceof Identifier) { return (Identifier) obj; } else { throw new YarnRuntimeException( "Parent info is invalid identifier object"); } } return null; }
public void setParent(String type, String id) { setParent(new Identifier(type, id)); }
public void addChild(String type, String id) { addChild(new Identifier(type, id)); }
@XmlElement(name = "id") @Override public String getId() { //Flow id schema: user@flow_name(or id)/run_id String id = super.getId(); if (id == null) { StringBuilder sb = new StringBuilder(); sb.append(getInfo().get(USER_INFO_KEY).toString()); sb.append('@'); sb.append(getInfo().get(FLOW_NAME_INFO_KEY).toString()); sb.append('/'); sb.append(getInfo().get(FLOW_RUN_ID_INFO_KEY).toString()); id = sb.toString(); setId(id); } return id; }
private void validateChild(Identifier child, TimelineEntityType thisType) { TimelineEntityType childType = TimelineEntityType.valueOf(child.getType()); if (!thisType.isChild(childType)) { throw new IllegalArgumentException( child.getType() + " is not the acceptable child of " + this.getType()); } } }