Java Code Examples for com.hazelcast.map.IMap#keySet()

The following examples show how to use com.hazelcast.map.IMap#keySet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TopicManager.java    From mercury with Apache License 2.0 6 votes vote down vote up
private List<String> listTopics() {
    List<String> result = new ArrayList<>();
    String nodes = HazelcastSetup.NAMESPACE+NODES;
    HazelcastInstance client = HazelcastSetup.getHazelcastClient();
    IMap<String, byte[]> map = client.getMap(nodes);
    String namespace = Platform.getInstance().getNamespace();
    for (String t: map.keySet()) {
        // skip topics that are not in this namespace
        if (namespace != null && !t.endsWith(namespace)) {
            continue;
        }
        if (regularTopicFormat(t)) {
            result.add(t);
        }
    }
    return result;
}
 
Example 2
Source File: TopicManager.java    From mercury with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private List<Map<String, String>> getTopics() throws IOException {
    List<Map<String, String>> result = new ArrayList<>();
    String nodes = HazelcastSetup.NAMESPACE+NODES;
    HazelcastInstance client = HazelcastSetup.getHazelcastClient();
    IMap<String, byte[]> map = client.getMap(nodes);
    String namespace = Platform.getInstance().getNamespace();
    for (String t: map.keySet()) {
        // skip topics that are not in this namespace
        if (namespace != null && !t.endsWith(namespace)) {
            continue;
        }
        Map<String, String> metadata = (Map<String, String>) msgPack.unpack(map.get(t));
        result.add(metadata);
    }
    return result;
}
 
Example 3
Source File: TopicManager.java    From mercury with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private Map<String, String> getTopicsWithTimestamp() throws IOException {
    String nodes = HazelcastSetup.NAMESPACE+NODES;
    HazelcastInstance client = HazelcastSetup.getHazelcastClient();
    IMap<String, byte[]> map = client.getMap(nodes);
    Map<String, String> result = new HashMap<>();
    String namespace = Platform.getInstance().getNamespace();
    for (String t: map.keySet()) {
        // skip topics that are not in this namespace
        if (namespace != null && !t.endsWith(namespace)) {
            continue;
        }
        Map<String, String> metadata = (Map<String, String>) msgPack.unpack(map.get(t));
        if (metadata.containsKey("updated")) {
            result.put(t, metadata.get("updated"));
        }
    }
    return result;
}
 
Example 4
Source File: RandomSimulator.java    From hazelcast-jet-demos with Apache License 2.0 6 votes vote down vote up
/**
 * Set up an event to hang the bets off  
 */
public default void createFutureEvent() {
    // Grab some horses to use as runners in races
    final IMap<Horse, Object> fromHC = getClient().getMap("winners");
    final Set<Horse> horses = fromHC.keySet();

    // Now set up some future-dated events for next Sat
    final LocalDate nextSat = LocalDate.now().with(TemporalAdjusters.next(DayOfWeek.SATURDAY));
    LocalTime raceTime = LocalTime.of(11, 0); // 1100 start
    final Event e = CentralFactory.eventOf("Racing from Epsom", nextSat);
    final Set<Horse> runners = makeRunners(horses, 10);
    for (int i = 0; i < 18; i++) {
        final Map<Horse, Double> runnersWithOdds = makeSimulatedOdds(runners);
        final Race r = CentralFactory.raceOf(LocalDateTime.of(nextSat, raceTime), runnersWithOdds);
        e.addRace(r);

        raceTime = raceTime.plusMinutes(10);
    }
    final IMap<Long, Event> events = getClient().getMap("events");
    events.put(e.getID(), e);
}
 
Example 5
Source File: TestJetMain.java    From hazelcast-jet-demos with Apache License 2.0 6 votes vote down vote up
@Test
public void testBuildDAG() {
    User u = makeUser();
    Bet b = makeBet();
    u.addBet(b);
    assertNotNull(b);
    try {
        IMap<String, ?> ism = jet.getMap(WORST_ID);
        System.out.println(ism);
        System.out.println("Size: " + ism.size());
        for (String s : ism.keySet()) {
            System.out.println(s + " : " + ism.get(s));
        }
    } finally {
        Jet.shutdownAll();
    }
}