當前位置: 首頁>>代碼示例>>Java>>正文


Java IMap.put方法代碼示例

本文整理匯總了Java中com.hazelcast.core.IMap.put方法的典型用法代碼示例。如果您正苦於以下問題:Java IMap.put方法的具體用法?Java IMap.put怎麽用?Java IMap.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hazelcast.core.IMap的用法示例。


在下文中一共展示了IMap.put方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createFutureEvent

import com.hazelcast.core.IMap; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:hazelcast,項目名稱:betleopard,代碼行數:24,代碼來源:RandomSimulationUtils.java

示例2: testClientCache

import com.hazelcast.core.IMap; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void testClientCache() {
    CacheStartupHookProvider start = new CacheStartupHookProvider();
    start.onStartup();

    final IMap<String, Client> clients = CacheStartupHookProvider.hz.getMap("clients");

    Client client = clients.get("f7d42348-c647-4efb-a52d-4c5787421e72");
    System.out.println("client = " + client);

    client.setClientType(Client.ClientTypeEnum.fromValue("trusted"));

    clients.put("f7d42348-c647-4efb-a52d-4c5787421e72", client);
    System.out.println("clients size = " + clients.size());

    clients.delete("f7d42348-c647-4efb-a52d-4c5787421e72");
    System.out.println("clients size = " + clients.size());

    CacheShutdownHookProvider shutdown = new CacheShutdownHookProvider();
    shutdown.onShutdown();

}
 
開發者ID:networknt,項目名稱:light-oauth2,代碼行數:24,代碼來源:CacheStartupHookProviderTest.java

示例3: main

import com.hazelcast.core.IMap; //導入方法依賴的package包/類
public static void main(String[] args) {
	HazelcastInstance ins = Hazelcast.newHazelcastInstance();
	IMap<Integer, String> map = ins.getMap("");
	map.addEntryListener(new ListenerExample(), true);//添加自定義監聽器
	map.put(1, "Grand Theft Auto");
	map.put(1, "Final Fantasy");
	map.put(2, "World Of Warcraft");
	
	HazelcastInstance insex = Hazelcast.newHazelcastInstance();
	IMap<Integer, String> mapex = insex.getMap("");
	
	System.out.println(mapex.get(1));
	System.out.println(mapex.get(2));
	mapex.remove(1);
	mapex.remove(2);
	System.exit(0);
}
 
開發者ID:chkui,項目名稱:hazelcast-demo,代碼行數:18,代碼來源:ListenerDemo.java

示例4: handle

import com.hazelcast.core.IMap; //導入方法依賴的package包/類
@Override
public void handle(InventoryItemCreated event) {
    IMap<String, InventoryItemListItem> inventoryItems = getInventoryItemsMap();

    String id = event.id.toString();

    InventoryItemListItem item = inventoryItems.get(id);
    if (item == null) {
        item = new InventoryItemListItem();
        item.id = id;
        item.name = event.getName();
        item.version = event.version;

        inventoryItems.put(id, item);
    }
}
 
開發者ID:vgoldin,項目名稱:cqrs-eventsourcing-kafka,代碼行數:17,代碼來源:InventoryItemCreatedHandler.java

示例5: testGlobalCustomSerializationConfiguredProgrammaticallyForClientConfig

import com.hazelcast.core.IMap; //導入方法依賴的package包/類
@Test
public void testGlobalCustomSerializationConfiguredProgrammaticallyForClientConfig() {
    Config memberConfig = new Config();
    SubZero.useAsGlobalSerializer(memberConfig);
    hazelcastFactory.newHazelcastInstance(memberConfig);

    String mapName = randomMapName();
    ClientConfig config = new ClientConfig();

    SubZero.useAsGlobalSerializer(config, MyGlobalUserSerlizationConfig.class);

    HazelcastInstance member = hazelcastFactory.newHazelcastClient(config);
    IMap<Integer, AnotherNonSerializableObject> myMap = member.getMap(mapName);
    myMap.put(0, new AnotherNonSerializableObject());
    AnotherNonSerializableObject fromCache = myMap.get(0);

    assertEquals("deserialized", fromCache.name);
}
 
開發者ID:jerrinot,項目名稱:subzero,代碼行數:19,代碼來源:TestCustomerSerializers.java

示例6: cacheMetrics

import com.hazelcast.core.IMap; //導入方法依賴的package包/類
@Test
void cacheMetrics() {
    IMap<String, String> map = h.getMap("my-distributed-map");

    SimpleMeterRegistry registry = new SimpleMeterRegistry();
    HazelcastCacheMetrics.monitor(registry, map, "cache",emptyList());

    map.put("key", "value");
    map.get("key");

    assertThat(registry.mustFind("cache.gets").functionTimer().count()).isEqualTo(1L);
    assertThat(registry.mustFind("cache.puts").functionTimer().count()).isEqualTo(1L);
}
 
開發者ID:micrometer-metrics,項目名稱:micrometer,代碼行數:14,代碼來源:HazelcastCacheMetricsTest.java

示例7: createRandomUsers

import com.hazelcast.core.IMap; //導入方法依賴的package包/類
/**
 * Sets up some random users (to place bets) and stores them in Hazlecast IMDG
 */
public default void createRandomUsers() {
    final IMap<Long, User> users = getClient().getMap("users");

    final String[] firstNames = {"Dave", "Christine", "Sarah", "Sadiq", "Zoe", "Helen", "Mike", "George", "Joanne"};
    final String[] lastNames = {"Baker", "Jones", "Smith", "Singh", "Shah", "Johnson", "Taylor", "Evans", "Howe"};
    final Random r = new Random();
    for (int i = 0; i < NUM_USERS; i++) {
        final User u = CentralFactory.userOf(firstNames[r.nextInt(firstNames.length)], lastNames[r.nextInt(lastNames.length)]);
        users.put(u.getID(), u);
    }
}
 
開發者ID:hazelcast,項目名稱:betleopard,代碼行數:15,代碼來源:RandomSimulationUtils.java

示例8: testTypedSerializer

import com.hazelcast.core.IMap; //導入方法依賴的package包/類
@Test
public void testTypedSerializer() {
    HazelcastInstance[] instances = factory.newInstances(createTypedConfig());
    IMap<Integer, Person> map = instances[0].getMap("myMap");

    Person joe = new Person("Joe");
    map.put(0, joe);

    assertEquals(joe, map.get(0));
}
 
開發者ID:jerrinot,項目名稱:subzero,代碼行數:11,代碼來源:BaseSmokeTests.java

示例9: applyChange

import com.hazelcast.core.IMap; //導入方法依賴的package包/類
@Override
public void applyChange(ConfigChangeRequest configChange) {
    if(readOnly){
        return;
    }
    IMap<String,String> config = hazelcastInstance.getMap(mapReference);
    for(Map.Entry<String, String> en: configChange.getAddedProperties().entrySet()){
        String metaVal = configChange.getAddedProperties().get("_" + en.getKey()+".ttl");
        if(metaVal!=null){
            try {
                long ms = Long.parseLong(metaVal);
                config.put(en.getKey(), en.getValue(), ms, TimeUnit.MILLISECONDS);
            }catch(Exception e){
                LOG.log(Level.WARNING, "Failed to parse TTL in millis: " + metaVal +
                        " for '"+ en.getKey()+"'", e);
                config.put(en.getKey(), en.getValue());
            }
        }else {
            config.put(en.getKey(), en.getValue());
        }
    }
    for(String key: configChange.getRemovedProperties()){
        config.remove(key);
    }
    IList<String> taList = hazelcastInstance.getList("_tamaya.transactions");
    taList.add(configChange.getTransactionID());
    config.put("_tamaya.transaction.lastId", configChange.getTransactionID(), 1, TimeUnit.DAYS);
    config.put("_tamaya.transaction.startedAt", String.valueOf(configChange.getStartedAt()), 1, TimeUnit.DAYS);
    config.flush();
    refresh();
}
 
開發者ID:apache,項目名稱:incubator-tamaya-sandbox,代碼行數:32,代碼來源:HazelcastPropertySource.java

示例10: testGlobalCustomSerializationConfiguredProgrammaticallyForHzConfig

import com.hazelcast.core.IMap; //導入方法依賴的package包/類
@Test
public void testGlobalCustomSerializationConfiguredProgrammaticallyForHzConfig() {
    String mapName = randomMapName();
    Config config = new Config();

    SubZero.useAsGlobalSerializer(config, MyGlobalUserSerlizationConfig.class);

    HazelcastInstance member = hazelcastFactory.newHazelcastInstance(config);
    IMap<Integer, AnotherNonSerializableObject> myMap = member.getMap(mapName);
    myMap.put(0, new AnotherNonSerializableObject());
    AnotherNonSerializableObject fromCache = myMap.get(0);

    assertEquals("deserialized", fromCache.name);
}
 
開發者ID:jerrinot,項目名稱:subzero,代碼行數:15,代碼來源:TestCustomerSerializers.java

示例11: advise

import com.hazelcast.core.IMap; //導入方法依賴的package包/類
public void advise(HttpProxyRuleBase httpProxyRuleBase) {
    try {
        IMap map = hazelcastInstance.getMap(
                SERVICE_DISCOVERY_REQUEST);
        map.put(httpProxyRuleBase.getId(),httpProxyRuleBase);
    } catch (Exception e) {
        LOG.error("Error sending message:", e);
    }
}
 
開發者ID:nkasvosve,項目名稱:beyondj,代碼行數:10,代碼來源:HazelcastServiceDiscoveryDelegate.java

示例12: respond

import com.hazelcast.core.IMap; //導入方法依賴的package包/類
public void respond(HttpProxyRuleBase httpProxyRuleBase) {
    try {
        IMap map = hazelcastInstance.getMap(
                SERVICE_DISCOVERY_REQUEST);
        map.put(httpProxyRuleBase.getId(),httpProxyRuleBase);
    } catch (Exception e) {
        LOG.error("Error sending message:", e);
    }
}
 
開發者ID:nkasvosve,項目名稱:beyondj,代碼行數:10,代碼來源:HazelcastServiceDiscoveryDelegate.java

示例13: testGlobalCustomSerializerRegisteredInDefaultConfigFile

import com.hazelcast.core.IMap; //導入方法依賴的package包/類
@Test
public void testGlobalCustomSerializerRegisteredInDefaultConfigFile() throws Exception {
    String mapName = randomMapName();
    Config config = new Config();
    SubZero.useAsGlobalSerializer(config);
    HazelcastInstance member = hazelcastFactory.newHazelcastInstance(config);
    IMap<Integer, NonSerializableObjectRegisteredInDefaultConfigFile> myMap = member.getMap(mapName);

    myMap.put(0, new NonSerializableObjectRegisteredInDefaultConfigFile());
    NonSerializableObjectRegisteredInDefaultConfigFile fromCache = myMap.get(0);

    assertEquals("deserialized", fromCache.name);
}
 
開發者ID:jerrinot,項目名稱:subzero,代碼行數:14,代碼來源:TestCustomerSerializers.java

示例14: testTypedCustomSerializerRegisteredInDefaultConfigFile

import com.hazelcast.core.IMap; //導入方法依賴的package包/類
@Test
public void testTypedCustomSerializerRegisteredInDefaultConfigFile() throws Exception {
    String mapName = randomMapName();
    Config config = new Config();
    SubZero.useForClasses(config, NonSerializableObjectRegisteredInDefaultConfigFile.class);
    HazelcastInstance member = hazelcastFactory.newHazelcastInstance(config);
    IMap<Integer, NonSerializableObjectRegisteredInDefaultConfigFile> myMap = member.getMap(mapName);

    myMap.put(0, new NonSerializableObjectRegisteredInDefaultConfigFile());
    NonSerializableObjectRegisteredInDefaultConfigFile fromCache = myMap.get(0);

    assertEquals("deserialized", fromCache.name);
}
 
開發者ID:jerrinot,項目名稱:subzero,代碼行數:14,代碼來源:TestCustomerSerializers.java

示例15: testTypedSerializer_SpecialRegistrationRegisteredInDefaultConfigFile

import com.hazelcast.core.IMap; //導入方法依賴的package包/類
@Test
public void testTypedSerializer_SpecialRegistrationRegisteredInDefaultConfigFile() {
    String mapName = randomMapName();
    Config config = new Config();

    SubZero.useForClasses(config, ClassWithUnmodifieableList.class);
    HazelcastInstance member = hazelcastFactory.newHazelcastInstance(config);
    IMap<Integer, ClassWithUnmodifieableList> myMap = member.getMap(mapName);
    myMap.put(0, new ClassWithUnmodifieableList("foo"));

    //does not throw an exception
    myMap.get(0);
}
 
開發者ID:jerrinot,項目名稱:subzero,代碼行數:14,代碼來源:TestCustomerSerializers.java


注:本文中的com.hazelcast.core.IMap.put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。