本文整理汇总了Java中com.hazelcast.core.HazelcastInstance.getMap方法的典型用法代码示例。如果您正苦于以下问题:Java HazelcastInstance.getMap方法的具体用法?Java HazelcastInstance.getMap怎么用?Java HazelcastInstance.getMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hazelcast.core.HazelcastInstance
的用法示例。
在下文中一共展示了HazelcastInstance.getMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.hazelcast.core.HazelcastInstance; //导入方法依赖的package包/类
public static void main(String[] args) {
Config cfg = new Config();
HazelcastInstance instance = Hazelcast.newHazelcastInstance(cfg);
Map<Integer, String> mapCustomers = instance.getMap("customers");
mapCustomers.put(1, "Joe");
mapCustomers.put(2, "Ali");
mapCustomers.put(3, "Avi");
System.out.println("Customer with key 1: "+ mapCustomers.get(1));
System.out.println("Map Size:" + mapCustomers.size());
Queue<String> queueCustomers = instance.getQueue("customers");
queueCustomers.offer("Tom");
queueCustomers.offer("Mary");
queueCustomers.offer("Jane");
System.out.println("First customer: " + queueCustomers.poll());
System.out.println("Second customer: "+ queueCustomers.peek());
System.out.println("Queue size: " + queueCustomers.size());
}
示例2: HazelcastTicketRegistry
import com.hazelcast.core.HazelcastInstance; //导入方法依赖的package包/类
/**
* Instantiates a new Hazelcast ticket registry.
*
* @param hz An instance of {@code HazelcastInstance}
* @param mapName Name of map to use
* @param ticketGrantingTicketTimeoutInSeconds TTL for TGT entries
* @param serviceTicketTimeoutInSeconds TTL for ST entries
* @param pageSize the page size
*/
@Autowired
public HazelcastTicketRegistry(
@Qualifier("hazelcast")
final HazelcastInstance hz,
@Value("${hz.mapname:tickets}")
final String mapName,
@Value("${tgt.maxTimeToLiveInSeconds:28800}")
final long ticketGrantingTicketTimeoutInSeconds,
@Value("${st.timeToKillInSeconds:10}")
final long serviceTicketTimeoutInSeconds,
@Value("${hz.page.size:500}")
final int pageSize) {
this.registry = hz.getMap(mapName);
this.ticketGrantingTicketTimeoutInSeconds = ticketGrantingTicketTimeoutInSeconds;
this.serviceTicketTimeoutInSeconds = serviceTicketTimeoutInSeconds;
this.hz = hz;
this.pageSize = pageSize;
}
示例3: HazelcastTicketRegistry
import com.hazelcast.core.HazelcastInstance; //导入方法依赖的package包/类
/**
* @param hz An instance of {@code HazelcastInstance}
* @param mapName Name of map to use
* @param ticketGrantingTicketTimeoutInSeconds TTL for TGT entries
* @param serviceTicketTimeoutInSeconds TTL for ST entries
*/
@Autowired
public HazelcastTicketRegistry(
@Qualifier("hazelcast")
final HazelcastInstance hz,
@Value("${hz.mapname:tickets}")
final String mapName,
@Value("${tgt.maxTimeToLiveInSeconds:28800}")
final long ticketGrantingTicketTimeoutInSeconds,
@Value("${st.timeToKillInSeconds:10}")
final long serviceTicketTimeoutInSeconds) {
this.registry = hz.getMap(mapName);
this.ticketGrantingTicketTimeoutInSeconds = ticketGrantingTicketTimeoutInSeconds;
this.serviceTicketTimeoutInSeconds = serviceTicketTimeoutInSeconds;
this.hz = hz;
}
示例4: executeSchemaChange
import com.hazelcast.core.HazelcastInstance; //导入方法依赖的package包/类
/**
* Main method for executing the schema conversion to Hazelcast.
* The method just needs to be called statically as it operates on files created during the initial
* schema conversion process.
*/
public static void executeSchemaChange() {
Config cfg = new Config();
HazelcastInstance instance = Hazelcast.newHazelcastInstance(cfg);
mapNodes = instance.getMap("nodes");
mapEdges = instance.getMap("edges");
mapLabels = instance.getMap("labels");
mapOut = instance.getMap("out");
mapIn = instance.getMap("in");
nodesMap();
edgesMap();
exampleQueries();
}
示例5: testGlobalCustomDelegateSerializationConfiguredProgrammaticallyForClientConfig
import com.hazelcast.core.HazelcastInstance; //导入方法依赖的package包/类
@Test
public void testGlobalCustomDelegateSerializationConfiguredProgrammaticallyForClientConfig() {
Config memberConfig = new Config();
SubZero.useAsGlobalSerializer(memberConfig);
hazelcastFactory.newHazelcastInstance(memberConfig);
String mapName = randomMapName();
ClientConfig config = new ClientConfig();
SubZero.useAsGlobalSerializer(config, MyGlobalDelegateSerlizationConfig.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);
}
示例6: main
import com.hazelcast.core.HazelcastInstance; //导入方法依赖的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);
}
示例7: hazelcastFileTrackerStorage
import com.hazelcast.core.HazelcastInstance; //导入方法依赖的package包/类
@Bean
public HazelcastFileTrackerStorage hazelcastFileTrackerStorage() {
HazelcastInstance hazelcastInstance = beanFactory
.getBean(HazelcastInstance.class);
IMap<FileTrackingStatusKey, FileTrackingStatus> fileTrackerMemory = hazelcastInstance
.getMap(DistributedMapNames.MAP.FILE_TRACKER_MAP.toString());
IMap<String, AgentContact> agentSet = hazelcastInstance
.getMap(DistributedMapNames.MAP.AGENT_NAMES.toString());
IMap<String, LogTypeContact> logTypeSet = hazelcastInstance
.getMap(DistributedMapNames.MAP.LOG_TYPES.toString());
return new HazelcastFileTrackerStorage(fileTrackerMemory, logTypeSet,
agentSet);
}
示例8: testAttributeInvalidate
import com.hazelcast.core.HazelcastInstance; //导入方法依赖的package包/类
@Test(timeout = 80000)
public void testAttributeInvalidate() throws Exception {
CookieStore cookieStore = new BasicCookieStore();
executeRequest("write", SERVER_PORT_1, cookieStore);
String value = executeRequest("read", SERVER_PORT_1, cookieStore);
assertEquals("value", value);
value = executeRequest("invalidate", SERVER_PORT_1, cookieStore);
assertEquals("true", value);
HazelcastInstance instance = createHazelcastInstance();
IMap<Object, Object> map = instance.getMap("default");
assertEquals(0, map.size());
}
示例9: main
import com.hazelcast.core.HazelcastInstance; //导入方法依赖的package包/类
public static void main(String[] args) {
ClientConfig clientConfig = new ClientConfig();
clientConfig.addAddress("127.0.0.1:5701");
HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
IMap map = client.getMap("customers");
System.out.println("Map Size:" + map.size());
client.getDurableExecutorService("hello").submit(new HazelcastJob(() -> System.out.println("Hello")));
}
示例10: HazelcastTicketRegistry
import com.hazelcast.core.HazelcastInstance; //导入方法依赖的package包/类
/**
* @param hz An instance of <code>HazelcastInstance</code>
* @param mapName Name of map to use
* @param ticketGrantingTicketTimoutInSeconds TTL for TGT entries
* @param serviceTicketTimeoutInSeconds TTL for ST entries
*/
public HazelcastTicketRegistry(final HazelcastInstance hz,
final String mapName,
final long ticketGrantingTicketTimoutInSeconds,
final long serviceTicketTimeoutInSeconds) {
logInitialization(hz, mapName, ticketGrantingTicketTimoutInSeconds, serviceTicketTimeoutInSeconds);
this.registry = hz.getMap(mapName);
this.ticketGrantingTicketTimoutInSeconds = ticketGrantingTicketTimoutInSeconds;
this.serviceTicketTimeoutInSeconds = serviceTicketTimeoutInSeconds;
this.hz = hz;
}
示例11: fillModel
import com.hazelcast.core.HazelcastInstance; //导入方法依赖的package包/类
public void fillModel(@NotNull Map<String, Object> model, @NotNull HttpServletRequest request) {
HazelcastInstance instance = Hazelcast.getHazelcastInstanceByName(INSTANCE_NAME);
if (instance != null) {
IMap<String, byte[]> taskCache = instance.getMap(TASK_CACHE_NAME);
LocalMapStats statistics = taskCache.getLocalMapStats();
model.put("statistics", statistics);
}
}
示例12: main
import com.hazelcast.core.HazelcastInstance; //导入方法依赖的package包/类
public static void main(String[] args) {
ClientConfig clientConfig = new ClientConfig();
HazelcastInstance instance = HazelcastClient.newHazelcastClient(clientConfig);
Map<Integer, String> clusterMap = instance.getMap("MyMap");
Queue<String> clusterQueue = instance.getQueue("MyQueue");
System.out.println("Map Value:" + clusterMap.get(1));
System.out.println("Queue Size :" + clusterQueue.size());
System.out.println("Queue Value 1:" + clusterQueue.poll());
System.out.println("Queue Value 2:" + clusterQueue.poll());
System.out.println("Queue Size :" + clusterQueue.size());
}
示例13: main
import com.hazelcast.core.HazelcastInstance; //导入方法依赖的package包/类
public static void main(String[] args) {
//创建一个 hazelcastInstance实例
HazelcastInstance instance = Hazelcast.newHazelcastInstance();
Map<Integer, String> clusterMap = instance.getMap("MyMap");
Queue<String> clusterQueue = instance.getQueue("MyQueue");
System.out.println("Map Value:" + clusterMap.get(1));
System.out.println("Queue Size :" + clusterQueue.size());
System.out.println("Queue Value 1:" + clusterQueue.poll());
System.out.println("Queue Value 2:" + clusterQueue.poll());
System.out.println("Queue Size :" + clusterQueue.size());
}
示例14: main
import com.hazelcast.core.HazelcastInstance; //导入方法依赖的package包/类
public static void main(String[] args) {
// 创建一个 hazelcastInstance实例
HazelcastInstance instance = Hazelcast.newHazelcastInstance();
// 创建集群Map
Map<Integer, String> clusterMap = instance.getMap("MyMap");
clusterMap.put(1, "Hello hazelcast map!");
// 创建集群Queue
Queue<String> clusterQueue = instance.getQueue("MyQueue");
clusterQueue.offer("Hello hazelcast!");
clusterQueue.offer("Hello hazelcast queue!");
}
示例15: testGlobalCustomSerializerRegisteredInDefaultConfigFile
import com.hazelcast.core.HazelcastInstance; //导入方法依赖的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);
}