@Override public boolean isEmpty() { return map.isEmpty(); }
@Override public boolean isEmpty() { return delegate.isEmpty(); }
@Override public boolean isEmpty() { return delegate.isEmpty(); }
@Override public boolean isEmpty() { return candidateDataMap.isEmpty(); }
public void run() { IMap map = hazelcast.getMap("myMap"); map.isEmpty(); } }, 3);
@Override public boolean resetLimit(String key) { IMap<Object, Object> map = hz.getMap(key); if (map == null || map.isEmpty()) { return false; } map.clear(); map.destroy(); return true; }
@Override public void run(String... arg0) throws Exception { IMap<String, String> helloMap = this.hazelcastInstance.getMap("hello"); if (!helloMap.isEmpty()) { LOGGER.info("Skip loading '{}', not empty", helloMap.getName()); } else { Arrays.stream(GREETINGS).forEach(pair -> { helloMap.set(pair[0], pair[1]); }); LOGGER.info("Loaded {} into '{}'", GREETINGS.length, helloMap.getName()); } }
/** * <p>Spring will inject the {@code @Bean} objects in to the * constructor. Use this as a convenient point to initialise * maps rather than let this occur on first use. * </p> * * @param hazelcastInstance Spring {@code @Bean} * @param jetInstance Spring {@code @Bean} */ public ApplicationCLI(HazelcastInstance hazelcastInstance, JetInstance jetInstance) { this.hazelcastInstance = hazelcastInstance; this.jetInstance = jetInstance; // Initialise all maps for (String iMapName : Constants.IMAP_NAMES) { this.hazelcastInstance.getMap(iMapName); } // Populate maps if needed, first member in cluster IMap<String, Integer> stockMap = this.hazelcastInstance.getMap(Constants.IMAP_NAME_STOCK); if (stockMap.isEmpty()) { for (Object[] item : Constants.TESTDATA) { String key = item[0].toString(); Integer value = Integer.valueOf(item[1].toString()); stockMap.set(key, value); } log.info("Loaded {} into IMap '{}'", Constants.TESTDATA.length, stockMap.getName()); } }
/** * <P> * List the contents of the maps. * </P> */ @CliCommand(value = "list", help = "List the contents of the maps") public void list() { IMap<PersonKey, PersonValue> personMap = this.hazelcastInstance.getMap("person"); IMap<String, LifeValue> lifeMap = this.hazelcastInstance.getMap("life"); if (personMap.isEmpty()) { System.out.println("Map 'person' is empty, run 'load' first"); } if (lifeMap.isEmpty()) { System.out.println("Map 'life' is empty, run 'join' first"); } String[] mapNames = { "person", "deaths", "life" }; for (String mapName : mapNames) { IMap<?, ?> map = this.hazelcastInstance.getMap(mapName); System.out.printf("MAP : '%s'%n", mapName); for (Object key : map.keySet()) { System.out.printf(" => '%s' : '%s'%n", key, map.get(key)); } System.out.printf("[%d row%s]%n", map.size(), (map.size() == 1 ? "" : "s")); } }
/** * <P> * Search <U>keys</U> but return <U>values</U> from the <I>key-value</I> store. * </P> * <P> * The only way this differs from a normal query is the key field is prefixed by * "{@code __key}" to indicate it is a field in the key not the value. * </P> * <P> * "{@code __key}" refers to the whole key. * </P> * <P> * "{@code __key.lastName}" refers to one field in the key. * </P> */ @CliCommand(value = "howard", help = "Find all people with last name 'Howard'") @SuppressWarnings("unchecked") public String howard() { IMap<PersonKey, PersonValue> personMap = this.hazelcastInstance.getMap("person"); if (personMap.isEmpty()) { return "Map is empty, run 'load' first"; } Predicate<PersonKey, PersonValue> predicate = new SqlPredicate("__key.lastName = 'Howard'"); System.out.printf("PREDICATE : '%s'%n", predicate); Collection<PersonValue> personValues = personMap.values(predicate); personValues.forEach(personValue -> System.out.printf("PERSON : '%s'%n", personValue)); return String.format("[%d row%s]", personValues.size(), (personValues.size() == 1 ? "" : "s")); }
/** * <P> * For each entry in the <I>key-value</I> store, display which partition it is * in, and which server JVM is currently hosting this partition. * </P> * <P> * Try varying the number of JVMs in the cluster and rerunning. Entries stay in * the same partition as they were, but this partition may move. * </P> */ @CliCommand(value = "location", help = "Display the location of each entry") public String location() { IMap<PersonKey, PersonValue> personMap = this.hazelcastInstance.getMap("person"); if (personMap.isEmpty()) { return "Map is empty, run 'load' first"; } Set<PersonKey> keySet = personMap.keySet(); keySet.forEach(personKey -> { System.out.printf("PERSON : '%s' : PARTITION '%s'%n", personKey, this.hazelcastInstance.getPartitionService().getPartition(personKey)); }); return String.format("[%d row%s]", keySet.size(), (keySet.size() == 1 ? "" : "s")); }
if (personMap.isEmpty()) { return "Map is empty, run 'load' first";
/** * Load the airport data into the airport map, once per cluster. */ private void loadAirports() { IMap<String, Airport> airportsMap = hazelcastInstance.getMap(MyConstants.MAP_NAME_AIRPORTS); if (!airportsMap.isEmpty()) { log.info("Skip loading '{}', not empty", airportsMap.getName()); } else { for (int i = 0; i < TestData.AIRPORTS.length; i++) { Object[] airportData = TestData.AIRPORTS[i]; Airport airport = new Airport(); airport.setCode(airportData[0].toString()); airport.setDescription(airportData[1].toString()); airport.setLatitude(Double.parseDouble(airportData[2].toString())); airport.setLongitude(Double.parseDouble(airportData[3].toString())); airportsMap.put(airport.getCode(), airport); } log.info("Loaded {} into '{}'", TestData.AIRPORTS.length, airportsMap.getName()); } } }
if (lifeMap.isEmpty()) { return "Map is empty, run 'join' first";
/** * <P> * Use a Jet pipeline to join two maps into a third. Essentially, materialising * a view. * </P> */ @CliCommand(value = "join", help = "Join birth with death to produce life") public String join() { IMap<PersonKey, PersonValue> personMap = this.hazelcastInstance.getMap("person"); IMap<String, LifeValue> lifeMap = this.hazelcastInstance.getMap("life"); if (personMap.isEmpty()) { return "Map is empty, run 'load' first"; } // Remove old results lifeMap.clear(); // Prepare the execution plan Pipeline pipeline = MyJoinPipeline.build(); // Run the join System.out.println("Running : " + pipeline); this.jetInstance.newJob(pipeline).join(); return "Done"; }
@Verify public void verify() { if (removeOnStop) { assertEquals("Map should be empty, but has size: ", 0, map.size()); assertTrue("Map should be empty, but has size: ", map.isEmpty()); } }
@Verify public void verify() throws Exception { if(removeOnStop){ assertEquals("Map should be empty, but has size:", 0, map.size()); assertTrue("Map should be empty, but has size:", map.isEmpty()); } }
/** * Return true if one or more of the DNodes reported an error. */ private boolean checkForFailure() { IMap<String, String> deployErrorPanel = context.getCoordinationStructures().getDeployErrorPanel( version); if (!isReplicaBalancingEnabled) { return !deployErrorPanel.isEmpty(); } // If replica balancing is enabled we check whether we could survive after the failed DNodes Set<String> failedDNodes = new HashSet<String>(deployErrorPanel.keySet()); // Check if deploy needs to be canceled or if the system could auto-rebalance itself afterwards for (DeployRequest deployRequest : deployRequests) { for (ReplicationEntry repEntry : deployRequest.getReplicationMap()) { if (failedDNodes.containsAll(repEntry.getNodes())) { // There is AT LEAST one partition that depends on the failed DNodes so the deploy must fail! return true; } } } return false; } } /* End ManageDeploy */
if (hazelcastGroupsConfig.isEmpty()) {
if (hazelcastGroupsConfig.isEmpty()) {