List of usage examples for java.util HashMap keySet
public Set<K> keySet()
From source file:com.yahoo.ycsb.db.RedisClient.java
@Override public int update(String table, String key, HashMap<String, ByteIterator> values) { for (String st : values.keySet()) { values.put(st, compress(values.get(st))); }/*from www . j av a2 s .c o m*/ if (cluster) { int ret = jedisCluster.hmset(key, StringByteIterator.getStringMap(values)).equals("OK") ? 0 : 1; if (sync) jedisCluster.wait(key, slaveCount, 0); return ret; } else { int ret = jedis.hmset(key, StringByteIterator.getStringMap(values)).equals("OK") ? 0 : 1; if (sync) jedisCluster.wait(key, slaveCount, 0); return ret; } }
From source file:it.cnr.icar.eric.server.event.EventManager.java
private void onEventInternal(ServerRequestContext context, AuditableEventType ebAuditableEventType) { try {/*w ww.j a v a 2 s . c om*/ javax.xml.bind.Marshaller marshaller = BindingUtility.getInstance().getJAXBContext().createMarshaller(); marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); //marshaller.marshal(ae, System.err); //Get the HashMap where keys are the Subscriptions that match this event //and values are the matchedObjects for that Subscription. HashMap<SubscriptionType, List<IdentifiableType>> subscriptionsMap = subscriptionMatcher .getMatchedSubscriptionsMap(context, ebAuditableEventType); //Process each matching Subscription Iterator<SubscriptionType> subscriptionsIter = subscriptionsMap.keySet().iterator(); while (subscriptionsIter.hasNext()) { SubscriptionType subscription = subscriptionsIter.next(); processSubscription(context, subscription, (subscriptionsMap.get(subscription)), ebAuditableEventType); } } catch (Exception e) { try { context.rollback(); } catch (RegistryException e1) { log.error(e1, e1); } log.error(ServerResourceBundle.getInstance().getString("message.ExceptionCaughtOnEvent"), e); } try { context.commit(); } catch (RegistryException e) { log.error(e, e); } }
From source file:edu.mit.mobile.android.locast.net.NetworkClient.java
/** * Generates a query string from a hashmap of query parameters. * * @param parameters//from www.ja v a 2 s. com * @return */ static public String toQueryString(HashMap<String, Object> parameters) { final StringBuilder query = new StringBuilder(); for (final Iterator<String> i = parameters.keySet().iterator(); i.hasNext();) { final String key = i.next(); query.append(key).append('='); final Object val = parameters.get(key); if (val instanceof Date) { query.append(dateFormat.format(val)); } else { query.append(val.toString()); } if (i.hasNext()) { query.append("&"); } } return query.toString(); }
From source file:com.yahoo.ycsb.db.RedisClient.java
@Override public int insert(String table, String key, HashMap<String, ByteIterator> values) { for (String st : values.keySet()) { values.put(st, compress(values.get(st))); }/*from w ww . ja v a 2 s.c om*/ if (cluster) { if (jedisCluster.hmset(key, StringByteIterator.getStringMap(values)).equals("OK")) { jedisCluster.zadd(INDEX_KEY, hash(key), key); if (sync) jedisCluster.wait(key, slaveCount, 0); return 0; } } else { if (jedis.hmset(key, StringByteIterator.getStringMap(values)).equals("OK")) { jedis.zadd(INDEX_KEY, hash(key), key); if (sync) jedisCluster.wait(key, slaveCount, 0); return 0; } } return 1; }
From source file:com.tacitknowledge.util.migration.DistributedJdbcMigrationLauncherFactoryTest.java
/** * Make sure we get notified of patch application * /*from w w w. j a va2 s . c o m*/ * @exception Exception if anything goes wrong */ public void testDistributedMigrationEvents() throws Exception { // There should be five listener on the main process // 1) the distributed launcher // 2) this test object // 3-5) the three sub-launchers assertEquals(5, launcher.getMigrationProcess().getListeners().size()); // The sub-MigrationProcesses should have one listener each - the sub-launcher HashMap controlledSystems = ((DistributedMigrationProcess) launcher.getMigrationProcess()) .getControlledSystems(); for (Iterator controlledSystemIter = controlledSystems.keySet().iterator(); controlledSystemIter .hasNext();) { String controlledSystemName = (String) controlledSystemIter.next(); JdbcMigrationLauncher subLauncher = (JdbcMigrationLauncher) controlledSystems.get(controlledSystemName); MigrationProcess subProcess = subLauncher.getMigrationProcess(); assertEquals(1, subProcess.getListeners().size()); } // Now do the migrations, and make sure we get the right number of events DistributedMigrationProcess process = (DistributedMigrationProcess) launcher.getMigrationProcess(); int currentPatchlevel = 3; setReportedPatchLevel(process.getControlledSystems().values(), currentPatchlevel); int patches = process.doMigrations(currentPatchlevel, context); assertEquals(4, patches); assertEquals(4, getMigrationStartedCount()); assertEquals(4, getMigrationSuccessCount()); }
From source file:com.thoughtworks.go.domain.scm.SCMs.java
private void validateFingerprintUniqueness() { HashMap<String, SCMs> map = new HashMap<>(); for (SCM scm : this) { String fingerprint = scm.getFingerprint(); if (!map.containsKey(fingerprint)) { map.put(fingerprint, new SCMs()); }//from w w w .j a va2 s .co m map.get(fingerprint).add(scm); } for (String fingerprint : map.keySet()) { SCMs scmsWithSameFingerprint = map.get(fingerprint); if (scmsWithSameFingerprint.size() > 1) { List<String> scmNames = new ArrayList<>(); for (SCM scm : scmsWithSameFingerprint) { scmNames.add(scm.getName()); } for (SCM scm : scmsWithSameFingerprint) { scm.addError(SCM.SCM_ID, String.format("Cannot save SCM, found duplicate SCMs. %s", StringUtils.join(scmNames, ", "))); } } } }
From source file:edu.stevens.cpe.reservior.Reservoir.java
/** * Subscribe each neuron to events from its neighbors * @throws ReserviorException // www. j av a 2 s . co m */ private void initConnections() throws ReserviorException { for (int i = 0; i < neurons.length; i++) { HashMap<Integer, Double> indexMapping = topology.getConnections(i); //Using the indexes obtain the actual neurons HashMap<String, Double> connections = new HashMap<String, Double>(); Iterator<Integer> it = indexMapping.keySet().iterator(); while (it.hasNext()) { Integer index = it.next(); connections.put(neurons[index].getName(), indexMapping.get(index)); } neurons[i].subscribe(connections); } }
From source file:hydrograph.ui.graph.debugconverter.SchemaHelper.java
private ComponentsOutputSchema getComponentOutputSchema(ComponentsOutputSchema componentsOutputSchema, Component componentObject) { HashMap<String, ComponentsOutputSchema> componentOutputSchema = (HashMap<String, ComponentsOutputSchema>) componentObject .getProperties().get(Constants.SCHEMA_TO_PROPAGATE); Set<String> keys = componentOutputSchema.keySet(); for (String key : keys) { componentsOutputSchema = componentOutputSchema.get(key); }/*from ww w . j a va 2 s. c o m*/ return componentsOutputSchema; }
From source file:com.tacitknowledge.util.migration.jdbc.DistributedJdbcMigrationLauncherFactoryTest.java
/** * Make sure we get notified of patch application * * @throws Exception if anything goes wrong *//* w w w. j av a 2 s . com*/ public void testDistributedMigrationEvents() throws Exception { // There should be five listener on the main process // 1) the distributed launcher // 2) this test object // 3-5) the three sub-launchers assertEquals(5, launcher.getMigrationProcess().getListeners().size()); // The sub-MigrationProcesses should have one listener each - the sub-launcher HashMap controlledSystems = ((DistributedMigrationProcess) launcher.getMigrationProcess()) .getControlledSystems(); for (Iterator controlledSystemIter = controlledSystems.keySet().iterator(); controlledSystemIter .hasNext();) { String controlledSystemName = (String) controlledSystemIter.next(); JdbcMigrationLauncher subLauncher = (JdbcMigrationLauncher) controlledSystems.get(controlledSystemName); MigrationProcess subProcess = subLauncher.getMigrationProcess(); assertEquals(1, subProcess.getListeners().size()); } // Now do the migrations, and make sure we get the right number of events DistributedMigrationProcess process = (DistributedMigrationProcess) launcher.getMigrationProcess(); int currentPatchlevel = 3; setReportedPatchLevel(process.getControlledSystems().values(), currentPatchlevel); int patches = process.doMigrations(MockBuilder.getPatchInfoStore(currentPatchlevel), context); assertEquals(4, patches); assertEquals(4, getMigrationStartedCount()); assertEquals(4, getMigrationSuccessCount()); }
From source file:edu.umn.cs.spatialHadoop.util.TemporalIndexManager.java
private int getMatchesCountFromMap(HashMap<String, Boolean> pathsMap, String matchingString) { int matchesCount = 0; for (String pathsMapKey : pathsMap.keySet()) { if (pathsMapKey.contains(matchingString)) { matchesCount++;/* w w w . j a va 2s . co m*/ } } return matchesCount; }