@Override public void stop() { classLoaders.clear(); bundles.clear(); classCache.clear(); resourceCache.clear(); }
/** * Yields all percepts that are currently available. * * @return a list of percepts or an empty-list if perceiving failed */ protected Collection<Percept> getAllPercepts() { Map<String, Collection<Percept>> percepts = null; while (percepts == null) { try { percepts = ei.getAllPercepts(getName()); } catch (PerceiveException e) { } catch (NoEnvironmentException e) { } } Collection<Percept> ret = new LinkedList<Percept>(); for (Collection<Percept> ps : percepts.values()) { ret.addAll(ps); } // sweep mental attitudes if there has been a restart // TODO maybe use simulation-id int step = -1; for (Percept p : ret) { if (p.getName().equals("step")) { step = new Integer(p.getParameters().get(0).toProlog()).intValue(); break; } } if (step != -1 && step < oldStep) { println("sweeping mental attitudes"); beliefs.clear(); goals.clear(); } if (step != -1) oldStep = step; return ret; }
@Override public void abort() { synchronized (fieldTree) { fieldNames.clear(); fieldTree.clear(); } }
public void testMaxAssessAuthority() { List<AssessDeptPrincipal> prin = new ArrayList<AssessDeptPrincipal>(); AssessDeptPrincipal p = new AssessDeptPrincipal(); p.setDeptId("463"); p.setDeptName("浙江事业部"); p.setPrincipal("003998"); prin.add(p); Set<String> auths = new HashSet<String>(); auths.add("2005"); // 是否具有全国权限 MarketAssessUtils.maxAssessAuthority(prin, auths); auths.clear(); auths.add("2004"); // 是否具有经营本部权限 MarketAssessUtils.maxAssessAuthority(prin, auths); auths.clear(); auths.add("2003"); // 是否具有事业部权限 MarketAssessUtils.maxAssessAuthority(prin, auths); auths.clear(); auths.add("2002"); // 是否具有大区权限 MarketAssessUtils.maxAssessAuthority(prin, auths); auths.clear(); auths.add("2001"); // 是否具有营业区权限 MarketAssessUtils.maxAssessAuthority(null, auths); auths.clear(); MarketAssessUtils.maxAssessAuthority(null, auths); }
public void loadHashes() { if (texts == null) { return; } String[] files = texts.list(); if (files == null) { return; } System.out.println("files: " + files); synchronized (have) { synchronized (want) { have.clear(); want.clear(); for (int x = 0; x < files.length; x++) { File f = new File(texts, files[x]); if (f.length() > 0) { log("I have: " + files[x]); have.add(files[x]); } else { log("I want: " + files[x]); want.add(files[x]); } } } } }
/** * Generates initial connected sets in bulk, from a graph. All sets are created visible, and are * give a default name. */ private void init(final UndirectedGraph<Spot, DefaultWeightedEdge> graph) { vertexToID = new HashMap<Spot, Integer>(); edgeToID = new HashMap<DefaultWeightedEdge, Integer>(); IDcounter = 0; visibility = new HashMap<Integer, Boolean>(); names = new HashMap<Integer, String>(); connectedVertexSets = new HashMap<Integer, Set<Spot>>(); connectedEdgeSets = new HashMap<Integer, Set<DefaultWeightedEdge>>(); edgesAdded.clear(); edgesModified.clear(); edgesRemoved.clear(); tracksUpdated.clear(); final Set<Spot> vertexSet = graph.vertexSet(); if (vertexSet.size() > 0) { final BreadthFirstIterator<Spot, DefaultWeightedEdge> i = new BreadthFirstIterator<Spot, DefaultWeightedEdge>(graph, null); i.addTraversalListener(new MyTraversalListener()); while (i.hasNext()) { i.next(); } } }
@Override public synchronized void stop() { if (!live) { return; } live = false; logger.finest("Stopping ConnectionManager"); if (acceptorThread != null) { acceptorThread.shutdown(); } for (SocketChannelWrapper socketChannel : acceptedSockets) { closeResource(socketChannel); } for (Connection conn : connectionsMap.values()) { destroySilently(conn); } for (TcpIpConnection conn : activeConnections) { destroySilently(conn); } ioThreadingModel.shutdown(); acceptedSockets.clear(); connectionsInProgress.clear(); connectionsMap.clear(); monitors.clear(); activeConnections.clear(); }
private void loadLdapUser() { try { LoadLdapUser loadLdapUser = new LoadLdapUser(getParameter()); loadLdapUser = ServiceFactory.lookupCommandService().executeCommand(loadLdapUser); personSet.clear(); List<PersonInfo> personList = loadLdapUser.getPersonList(); if (personList != null) { List<PersonInfo> accountList = new ArrayList<PersonInfo>(personList); personSet.addAll(accountList); } // Get the content for the viewer, setInput will call getElements in the // contentProvider refreshTable(); } catch (SizeLimitExceededException sizeLimitExceededException) { log.warn("To many results ehen searching for LDAP users."); // $NON-NLS-1$ if (log.isDebugEnabled()) { log.debug("stacktrace: ", sizeLimitExceededException); // $NON-NLS-1$ } personSet.clear(); refreshTable(); MessageDialog.openInformation( getShell(), Messages.LdapImportDialog_6, Messages.LdapImportDialog_7); } catch (Throwable t) { log.error("Error while setting table data", t); // $NON-NLS-1$ personSet.clear(); refreshTable(); MessageDialog.openError( getShell(), Messages.LdapImportDialog_45, Messages.LdapImportDialog_1); } }
private BlockNode processMonitorEnter( IRegion curRegion, BlockNode block, InsnNode insn, RegionStack stack) { SynchronizedRegion synchRegion = new SynchronizedRegion(curRegion, insn); synchRegion.getSubBlocks().add(block); curRegion.getSubBlocks().add(synchRegion); Set<BlockNode> exits = new HashSet<BlockNode>(); cacheSet.clear(); traverseMonitorExits(synchRegion, insn.getArg(0), block, exits, cacheSet); for (InsnNode exitInsn : synchRegion.getExitInsns()) { InstructionRemover.unbindInsn(mth, exitInsn); } BlockNode body = getNextBlock(block); if (body == null) { ErrorsCounter.methodError(mth, "Unexpected end of synchronized block"); return null; } BlockNode exit; if (exits.size() == 1) { exit = getNextBlock(exits.iterator().next()); } else { cacheSet.clear(); exit = traverseMonitorExitsCross(body, exits, cacheSet); } stack.push(synchRegion); stack.addExit(exit); synchRegion.getSubBlocks().add(makeRegion(body, stack)); stack.pop(); return exit; }
private List<Node> getClosestNodes( Key k, int n, int index, Bucket[] buckets, Collection<Node> exclude) { final List<Node> $ = new ArrayList<Node>(); final Set<Node> t = new HashSet<Node>(); if (index < 0) index = 0; buckets[index].addNodesTo($); if ($.size() < n) { // look in other buckets for (int i = 1; $.size() < n; ++i) { if (index + i < buckets.length) { buckets[index + i].addNodesTo(t); t.removeAll(exclude); $.addAll(t); t.clear(); } if (0 <= index - i) { buckets[index - i].addNodesTo(t); t.removeAll(exclude); $.addAll(t); t.clear(); } if (buckets.length <= index + i && index - i < 0) break; } } return $; }
public FloatWritable evaluate(final List<String> a, final List<String> b) { if (a == null && b == null) { return new FloatWritable(0.f); } else if (a == null || b == null) { return new FloatWritable(1.f); } final int asize = a.size(); final int bsize = b.size(); if (asize == 0 && bsize == 0) { return new FloatWritable(0.f); } else if (asize == 0 || bsize == 0) { return new FloatWritable(1.f); } union.addAll(a); union.addAll(b); float unionSize = union.size(); union.clear(); intersect.addAll(a); intersect.retainAll(b); float intersectSize = intersect.size(); intersect.clear(); float j = intersectSize / unionSize; return new FloatWritable(1.f - j); }
public static void clearTokens() { TokenLibrary.reset(); TokenStore.reset(); tokenSet.clear(); ppiSet.clear(); PreParserFactory.clear(); }
protected void clausify( OWLAxioms.DisjunctiveRule rule, boolean restrictToNamed, OWLAxiom originalAxiom) { m_headAtoms.clear(); m_bodyAtoms.clear(); m_abstractVariables.clear(); for (SWRLAtom atom : rule.m_body) m_bodyAtoms.add(atom.accept(this)); for (SWRLAtom atom : rule.m_head) m_headAtoms.add(atom.accept(this)); if (restrictToNamed) { for (Variable variable : m_abstractVariables) m_bodyAtoms.add(Atom.create(AtomicConcept.INTERNAL_NAMED, variable)); } DLClause dlClause = DLClause.create( m_headAtoms.toArray(new Atom[m_headAtoms.size()]), m_bodyAtoms.toArray(new Atom[m_bodyAtoms.size()])); Collection<OWLAxiom> originalAxioms = m_dlClauses_map.get(dlClause); if (originalAxioms == null) { originalAxioms = new ArrayList<OWLAxiom>(); m_dlClauses_map.put(dlClause, originalAxioms); } originalAxioms.add(originalAxiom); m_headAtoms.clear(); m_bodyAtoms.clear(); m_abstractVariables.clear(); }
public static void flushAllStaticData() { IMMEDIATELY_DOWNED_HOSTS.clear(); HUNG_CONNECT_HOSTS.clear(); HUNG_READ_HOSTS.clear(); HUNG_WRITE_HOSTS.clear(); flushConnectionAttempts(); }
protected PatternSet doCopyFrom(PatternSet from) { includes.clear(); excludes.clear(); includeSpecs.clear(); excludeSpecs.clear(); caseSensitive = from.caseSensitive; if (from instanceof IntersectionPatternSet) { PatternSet other = ((IntersectionPatternSet) from).other; PatternSet otherCopy = new PatternSet().copyFrom(other); PatternSet intersectCopy = new IntersectionPatternSet(otherCopy); intersectCopy.includes.addAll(from.includes); intersectCopy.excludes.addAll(from.excludes); intersectCopy.includeSpecs.addAll(from.includeSpecs); intersectCopy.excludeSpecs.addAll(from.excludeSpecs); includeSpecs.add(intersectCopy.getAsSpec()); } else { includes.addAll(from.includes); excludes.addAll(from.excludes); includeSpecs.addAll(from.includeSpecs); excludeSpecs.addAll(from.excludeSpecs); } return this; }
private void updateAttributesWithParent(boolean notify) { // Remove the previous inherited attributes. for (AttributeType attr : inheritedRequiredAttributes) { attributes.getAvailableListModel().add(attr); attributes.getSelectedListModel1().remove(attr); } for (AttributeType attr : inheritedOptionalAttributes) { attributes.getAvailableListModel().add(attr); attributes.getSelectedListModel2().remove(attr); } inheritedOptionalAttributes.clear(); inheritedRequiredAttributes.clear(); for (ObjectClass p : getObjectClassSuperiors()) { inheritedRequiredAttributes.addAll(p.getRequiredAttributeChain()); inheritedOptionalAttributes.addAll(p.getOptionalAttributeChain()); } for (AttributeType attr : inheritedRequiredAttributes) { attributes.getAvailableListModel().remove(attr); attributes.getSelectedListModel1().add(attr); } for (AttributeType attr : inheritedOptionalAttributes) { attributes.getAvailableListModel().remove(attr); attributes.getSelectedListModel2().add(attr); } Collection<AttributeType> unmovableItems = new ArrayList<>(inheritedRequiredAttributes); unmovableItems.addAll(inheritedOptionalAttributes); attributes.setUnmovableItems(unmovableItems); if (notify) { notifyAttributesChanged(); } }
private void updateSelections() { /* Use set intersection/join's to figure out what updates have been done */ /* First, find which temporary bonuses have been removed, and which have been added */ Set<String> newValues = pc.getTempBonusNames(); Set<String> oldValues = new TreeSet<String>(tempBonusWidgets.keySet()); oldValues.removeAll(newValues); newValues.removeAll(tempBonusWidgets.keySet()); if (!newValues.isEmpty()) { addTempBonus(newValues); } if (!oldValues.isEmpty()) { removeTempBonus(oldValues); } /* Now, same for equipment sets. */ newValues.clear(); oldValues.clear(); newValues.addAll(equipSet2Set(pc.getEquipSet())); oldValues.addAll(eqSetWidgets.keySet()); oldValues.removeAll(newValues); newValues.removeAll(eqSetWidgets.keySet()); if (!newValues.isEmpty()) { addEquipSets(newValues); } if (!oldValues.isEmpty()) { removeEquipSets(oldValues); } }
public static void accuracy(Pair[] arrOriginalPair, Pair[] arrSpaceSavingPair) { System.out.println("Accuracy for different value of k "); Set<Integer> originalSet = new HashSet<Integer>(); Set<Integer> spaceSavingSet = new HashSet<Integer>(); int[] kTop = {100, 500, 1000, 5000}; for (int k : kTop) { for (int i = 0; i < k; i++) { originalSet.add(arrOriginalPair[i].keyRet()); spaceSavingSet.add(arrSpaceSavingPair[i].keyRet()); } int count = 0; for (Integer keyInteger : spaceSavingSet) { if (originalSet.contains(keyInteger)) count++; } double result = (double) count / (double) k; System.out.println(k + "," + result); originalSet.clear(); spaceSavingSet.clear(); } for (int i = 0; i < arrSpaceSavingPair.length; i++) { Pair pair = arrSpaceSavingPair[i]; } }
private void loadCurrentDirtyContact() { mCursor = queryDirtyRawContact(null, null); try { if (mCursor.getCount() < sPreDirtyContactMap.size()) { Log.d(TAG, "loadCurrentDirtyContact1+++"); HashSet<DirtyContactEvent> tmpDirtyContactSet = new HashSet<DirtyContactEvent>(); mDirtyContactSet.clear(); mPreDirtyContactSet.clear(); while (mCursor.moveToNext()) { DirtyContactEvent e = getDirtyContactItem(mCursor); tmpDirtyContactSet.add(e); mPreDirtyContactSet.add(e); } Collection<DirtyContactEvent> oldSet = sPreDirtyContactMap.values(); Iterator it = oldSet.iterator(); while (it.hasNext()) { DirtyContactEvent e = (DirtyContactEvent) it.next(); if (!tmpDirtyContactSet.contains(e)) { e.update(DirtyContactEvent.DELETE, 1, 1, e.version); mDirtyContactSet.add(e); Log.d(TAG, e.toString()); } } Log.d(TAG, "loadCurrentDirtyContact1---"); synchronized (mListeners) { for (ContactListener l : mListeners) { l.onContactChange(mDirtyContactSet); } } sPreDirtyContactMap.clear(); it = tmpDirtyContactSet.iterator(); while (it.hasNext()) { DirtyContactEvent e = (DirtyContactEvent) it.next(); sPreDirtyContactMap.put(e._ID, e); } return; } mDirtyContactSet.clear(); Log.d(TAG, "loadCurrentDirtyContact2+++"); while (mCursor.moveToNext()) { DirtyContactEvent e = getDirtyContactItem(mCursor); if (!mPreDirtyContactSet.contains(e)) { mPreDirtyContactSet.add(e); mDirtyContactSet.add(e); sPreDirtyContactMap.put(e._ID, e); Log.d(TAG, e.toString()); } } Log.d(TAG, "loadCurrentDirtyContact2---"); synchronized (mListeners) { for (ContactListener l : mListeners) { l.onContactChange(mDirtyContactSet); } } } finally { Log.d(TAG, "cursor position = " + mCursor.getPosition()); mCursor.close(); } }
/** @param elapsedTime */ @Override public void postChildUpdate(int elapsedTime) { super.postChildUpdate(elapsedTime); keyTyped.clear(); buttonTyped.clear(); charPressed.clear(); }
@Override public void close() { log.trace("Closing the Kafka consumer."); subscribedTopics.clear(); subscribedPartitions.clear(); this.metrics.close(); log.debug("The Kafka consumer has closed."); }
public void destroy() { if (identifiedModifiedCompounds != null) identifiedModifiedCompounds.clear(); if (unidentifiableAtomLinkages != null) unidentifiableAtomLinkages.clear(); if (unidentifiableModifiedResidues != null) unidentifiableModifiedResidues.clear(); unidentifiableAtomLinkages = null; unidentifiableAtomLinkages = null; unidentifiableModifiedResidues = null; }
@Override public synchronized void close() throws Exception { factories.clear(); for (AutoCloseable reg : registrations.values()) { reg.close(); } registrations.clear(); listeners.clear(); }
/** * Updates the <code>iPlanetAMLoggingService<code> service schema. * * @return true if successful otherwise false. */ public boolean migrateService() { boolean isSuccess = false; try { // read the values from AMConfig.properties String logStatus = SystemProperties.get("com.iplanet.am.logStatus"); String resolveHostName = SystemProperties.get("com.sun.identity.log.resolveHostName"); // update default value Set defaultValues = new HashSet(); defaultValues.add("NameID"); UpgradeUtils.addAttributeDefaultValues( SERVICE_NAME, null, schemaType, LOG_ALL_FIELDS_ATTR_NAME, defaultValues); // update choice value Map choiceValuesMap = new HashMap(); choiceValuesMap.put("choiceNameID", defaultValues); UpgradeUtils.addAttributeChoiceValues( SERVICE_NAME, null, schemaType, LOG_ATTR_NAME, choiceValuesMap); // add new attribute schema String fileName = UpgradeUtils.getAbsolutePath(SERVICE_DIR, SCHEMA_FILE); UpgradeUtils.addAttributeToSchema(SERVICE_NAME, schemaType, fileName); // populate the default values for logstatus & resolveHostName // from amconfig.properties defaultValues.clear(); defaultValues.add(logStatus); UpgradeUtils.setAttributeDefaultValues( SERVICE_NAME, null, schemaType, LOG_STATUS_ATTR, defaultValues); defaultValues.clear(); defaultValues.add(resolveHostName); UpgradeUtils.setAttributeDefaultValues( SERVICE_NAME, null, schemaType, RESOLVE_HOSTNAME_ATTR, defaultValues); String histNumFile = UpgradeUtils.getAttributeValueString(SERVICE_NAME, LOG_HIST_NUM_ATTR_NAME, schemaType); if (histNumFile != null && histNumFile.equals(DEFAULT_HIST_NUM)) { defaultValues.clear(); defaultValues.add(NEW_DEFAULT_HIST_NUM); UpgradeUtils.setAttributeDefaultValues( SERVICE_NAME, null, schemaType, LOG_HIST_NUM_ATTR_NAME, defaultValues); } String maxLogSize = UpgradeUtils.getAttributeValueString( SERVICE_NAME, LOG_MAX_FILE_SIZE_ATTR_NAME, schemaType); if (maxLogSize != null && maxLogSize.equals(DEFAULT_LOG_SIZE)) { defaultValues.clear(); defaultValues.add(NEW_DEFAULT_LOG_SIZE); UpgradeUtils.setAttributeDefaultValues( SERVICE_NAME, null, schemaType, LOG_MAX_FILE_SIZE_ATTR_NAME, defaultValues); } isSuccess = true; } catch (UpgradeException e) { UpgradeUtils.debug.error("Error loading data:" + SERVICE_NAME, e); } return isSuccess; }
/** * Test method for {@link * org.identityconnectors.oracle.OracleAttributesReader#readAuthAttributes(java.util.Set, * org.identityconnectors.oracle.OracleUserAttributes)}. */ @Test public final void testReadCreateAuthAttributes() { final OracleAttributesReader reader = new OracleAttributesReader(TestHelpers.createDummyMessages()); OracleUserAttributes.Builder caAttributes = new OracleUserAttributes.Builder(); caAttributes.setUserName("testUser"); Set<Attribute> attributes = new HashSet<Attribute>(); attributes.add( AttributeBuilder.build( OracleConstants.ORACLE_AUTHENTICATION_ATTR_NAME, OracleConstants.ORACLE_AUTH_LOCAL)); attributes.add(AttributeBuilder.buildPassword("myPassword".toCharArray())); reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.assertEquals(OracleAuthentication.LOCAL, caAttributes.getAuth()); Assert.assertNotNull("Password must not be null", caAttributes.getPassword()); attributes.clear(); caAttributes = new OracleUserAttributes.Builder(); caAttributes.setUserName("testUser"); reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.assertNull("Should not set authentication to any default value", caAttributes.getAuth()); Assert.assertNull("Password must be null", caAttributes.getPassword()); // Test for failures attributes.clear(); reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); attributes.add( AttributeBuilder.build( OracleConstants.ORACLE_AUTHENTICATION_ATTR_NAME, "invalid authentication")); try { reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); fail("Must fail for invalid authentication"); } catch (RuntimeException e) { } attributes.clear(); attributes.add( AttributeBuilder.build( OracleConstants.ORACLE_AUTHENTICATION_ATTR_NAME, OracleConstants.ORACLE_AUTH_GLOBAL)); try { reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); fail("Must fail for missing global name"); } catch (RuntimeException e) { } attributes.clear(); attributes.add( AttributeBuilder.build( OracleConstants.ORACLE_AUTHENTICATION_ATTR_NAME, OracleConstants.ORACLE_AUTH_GLOBAL)); attributes.add(AttributeBuilder.build(OracleConstants.ORACLE_GLOBAL_ATTR_NAME, "")); try { reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); fail("Must fail for empty global name"); } catch (RuntimeException e) { } }
@Override public void beforeMethodRun(FeaturesRunner runner, FrameworkMethod method, Object test) throws Exception { File temp = Environment.getDefault().getTemp(); temp.mkdirs(); tempPath = temp.toPath(); tracked.clear(); created.clear(); listener.install(); }
@After public void afterTest() { if (master != null) master.shutdown(); if (testManager != null) testManager.shutdown(); master = null; testManager = null; processes.clear(); stoppedProcesses.clear(); System.err.println("*Test - afterTest() - end"); }
@Override public void disposeComponent() { Disposer.dispose(myConnection); Disposer.dispose(myAlarm); VirtualFileManager.getInstance().removeVirtualFileListener(myFilesListener); myLastHandledGoPathSourcesRoots.clear(); myLastHandledExclusions.clear(); LocalFileSystem.getInstance().removeWatchedRoots(myWatchedRequests); myWatchedRequests.clear(); }
/** Supprimes toutes les instances de {@link ClockListener} enregistrées. */ public synchronized void reset() { listeners.clear(); buffer.clear(); tickCount = 1; if (log.isInfoEnabled()) { log.info("Clock reset"); } }
/** Clears loaded klaxons. */ private static synchronized void clear() { loadingKlaxons.clear(); loadedKlaxons.clear(); File[] files = klaxons.listFiles(); if (files != null) { for (File f : files) { f.delete(); } } }