void unregisterContainer(ContainerId containerId) { LlapNodeId llapNodeId = containerToNodeMap.remove(containerId); if (llapNodeId == null) { // Possible since either container / task can be unregistered. return; } BiMap<ContainerId, TezTaskAttemptID> bMap = nodeMap.get(llapNodeId); TezTaskAttemptID matched = null; if (bMap != null) { synchronized(bMap) { matched = bMap.remove(containerId); } if (bMap.isEmpty()) { nodeMap.remove(llapNodeId); } } // Remove the container mapping if (matched != null) { attemptToNodeMap.remove(matched); uniqueNodeMap.remove(matched); } }
void unregisterTaskAttempt(TezTaskAttemptID attemptId) { uniqueNodeMap.remove(attemptId); LlapNodeId llapNodeId; synchronized (attemptToNodeMap) { llapNodeId = attemptToNodeMap.remove(attemptId); if (llapNodeId == null) { // Possible since either container / task can be unregistered. return; } } BiMap<ContainerId, TezTaskAttemptID> bMap = nodeMap.get(llapNodeId); ContainerId matched = null; if (bMap != null) { synchronized(bMap) { matched = bMap.inverse().remove(attemptId); } if (bMap.isEmpty()) { nodeMap.remove(llapNodeId); } } // Remove the container mapping if (matched != null) { containerToNodeMap.remove(matched); } }
public void testBiMapEntrySetIteratorRemove() { BiMap<Integer, String> map = HashBiMap.create(); map.put(1, "one"); Set<Entry<Integer, String>> entries = map.entrySet(); Iterator<Entry<Integer, String>> iterator = entries.iterator(); Entry<Integer, String> entry = iterator.next(); entry.setValue("two"); // changes the iterator's current entry value assertEquals("two", map.get(1)); assertEquals(Integer.valueOf(1), map.inverse().get("two")); iterator.remove(); // removes the updated entry assertTrue(map.isEmpty()); }
/** * Determines the event class that the serialized event is for. * * @param eventData * @return The event class the given eventData describes, or null if it is unknown. */ public Class<? extends Event> getEventClass(EntityData.Event eventData) { if (eventData.hasType()) { EventMetadata<? extends Event> metadata = null; if (!idTable.isEmpty()) { Class<? extends Event> eventClass = idTable.inverse().get(eventData.getType()); if (eventClass != null) { metadata = eventLibrary.getMetadata(eventClass); } } if (metadata == null) { logger.warn("Unable to deserialize unknown event with id: {}", eventData.getType()); return null; } return metadata.getType(); } logger.warn("Unable to deserialize event, no type provided."); return null; }
@Override public PlanWithProperties visitSpatialJoin(SpatialJoinNode node, HashComputationSet parentPreference) { PlanWithProperties left = planAndEnforce(node.getLeft(), new HashComputationSet(), true, new HashComputationSet()); PlanWithProperties right = planAndEnforce(node.getRight(), new HashComputationSet(), true, new HashComputationSet()); verify(left.getHashSymbols().isEmpty(), "probe side of the spatial join should not include hash symbols"); verify(right.getHashSymbols().isEmpty(), "build side of the spatial join should not include hash symbols"); return new PlanWithProperties( replaceChildren(node, ImmutableList.of(left.getNode(), right.getNode())), ImmutableMap.of()); }
if (componentData.hasTypeIndex()) { ComponentMetadata<? extends Component> metadata = null; if (!idTable.isEmpty()) { Class<? extends Component> componentClass = idTable.inverse().get(componentData.getTypeIndex()); if (componentClass != null) {
@Override public boolean deleteAdminUser( UUID userId ) throws Exception { // make sure user is not attached to any orgs BiMap<UUID, String> orgMap = getOrganizationsForAdminUser(userId); if (!orgMap.isEmpty()) { // cannot delete admin user that is attached to orgs logger.info("Cannot delete admin user {} -- admin user is attached to {} orgs", userId, orgMap.size()); return false; } EntityRef userRef = new SimpleEntityRef(User.ENTITY_TYPE, userId); // delete mongo password deleteUserMongoPassword(smf.getManagementAppId(), userRef); // delete user password deleteUserPassword(smf.getManagementAppId(), userRef); // delete user token deleteUserToken(smf.getManagementAppId(), userRef); // delete user entity emf.getEntityManager(smf.getManagementAppId()).delete(userRef); return true; }
public void buildGuidIndex() { guidIndex = new HashMap<EClass, Map<String, IdEObject>>(); if (objects.isEmpty()) { return; } for (EClassifier classifier : objects.values().iterator().next().eClass().getEPackage().getEClassifiers()) { if (classifier instanceof EClass) { Map<String, IdEObject> map = new TreeMap<String, IdEObject>(); guidIndex.put((EClass) classifier, map); } } EClass ifcRootEclass = packageMetaData.getEClass("IfcRoot"); EStructuralFeature guidFeature = ifcRootEclass.getEStructuralFeature("GlobalId"); for (Long key : objects.keySet()) { IdEObject value = objects.get((Long) key); if (ifcRootEclass.isSuperTypeOf(value.eClass())) { Object guid = value.eGet(guidFeature); if (guid != null) { guidIndex.get(value.eClass()).put((String)guid, value); } } } }