Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.net.UnknownHostException;
- import com.hazelcast.client.config.ClientConfig;
- import com.hazelcast.config.Config;
- import com.hazelcast.core.Hazelcast;
- import com.hazelcast.client.HazelcastClient;
- import com.hazelcast.core.HazelcastInstance;
- import com.hazelcast.map.IMap;
- import java.util.Map;
- import java.util.Scanner;
- import java.awt.event.KeyAdapter;
- import java.awt.event.KeyEvent;
- public class HInstance {
- public static void main(String[] args) throws UnknownHostException {
- Scanner scan = new Scanner(System.in);
- HazelcastInstance hz = HazelcastClient.newHazelcastClient();
- IMap map = hz.getMap("firmaa");
- System.out.println("Witaj w firmie przewozowej!");
- System.out.println(" ");
- System.out.println("1. Dodaj dane kierowcy");
- System.out.println("2. Wyswietl dane kierowcy");
- System.out.println("3. Zmien nazwisko kierowcy");
- System.out.println("4. Usuwanie mapy");
- System.out.println("5. Dopisz nowego studenta do listy");
- Integer menuSelected = scan.nextInt();
- if(menuSelected == 1){
- map.put("Artur", "Urbanski");
- map.get("key");
- System.out.println("Dodano Artur -> Urbanski");
- hz.shutdown();
- }
- if(menuSelected == 2){
- ClientConfig clientConfig = HConfig.getClientConfig();
- HazelcastInstance client = HazelcastClient.newHazelcastClient( clientConfig );
- IMap<Long, Student> students = client.getMap( "firmaa" );
- System.out.println("Wszyscy studenci: ");
- for(Map.Entry<Long, Student> e : students.entrySet()) {
- System.out.println(e.getKey() + " => " + e.getValue());
- }
- hz.shutdown();
- }
- if(menuSelected == 3) {
- map.get("key");
- map.replace("Artur", "Urbanski", "UrbanskiJava");
- System.out.println("Poprawnie zamieniono nazwisko na UrbanskiJava ");
- hz.shutdown();
- }
- if(menuSelected == 4){
- hz.getMap("firmaa").destroy();
- System.out.println("Usunieto mape");
- hz.shutdown();
- }
- if(menuSelected == 5){
- map.putIfAbsent("Michal", "Kowalski");
- System.out.println("Dopisany do listy nowego studenta!!");
- hz.shutdown();
- }
- }
- }
- }
- github.com/shfx17
Add Comment
Please, Sign In to add comment