本文整理匯總了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);
}