Java Ninja Chronicles By Norris Shelton

Things I learned in the pursuit of code

I needed to iterate over the values contained in a replicatedMap. I thought it would be as simple as:

hz.<Long, GameInfo>replicatedMap(DO.DESK_MAP, DO.DESK_MAP).values();

It would show that there were 2006 entries, but I couldn’t touch them.

I later stumbled upon the following:

hz.mapValues(DO.DESK_MAP);

This gave me a Collection of the values that I could iterate over.

February 26th, 2015

Posted In: Hazelcast, Java, java ninja, Javaninja

Tags: , , , ,

4 Comments

  • Vikas says:

    Can you please give me example how did you use replicatedMap.. ? I have defined replicatedMap in my spring hazecast xml, I do not know how do we know if we have to call getReplicatedMap or Just getMap ?

    • sheltonn says:

      I used it in a loop.

      Collection cashDesks = hz.mapValues(DO.DESK_MAP);
      for (CashDesk cashDesk : cashDesks) {
      // normal object operations
      }

  • Scott says:

    I thought you would like to know, it looks like you’ve misspelled the word “sould” on your website. Silly mistakes can ruin your site’s credibility. In the past I’ve used a tool like SpellingScan.com to keep mistakes off my website.

    -Scott Matthews Sr.

Leave a Reply

Your email address will not be published. Required fields are marked *

WP to LinkedIn Auto Publish Powered By : XYZScripts.com