@Test public void testHazelcastInstances() { assertNotNull(map1); assertNotNull(map2); assertNotNull(multiMap); assertNotNull(replicatedMap); assertNotNull(queue); assertNotNull(topic); assertNotNull(set); assertNotNull(list); assertNotNull(executorService); assertNotNull(idGenerator); assertNotNull(atomicLong); assertNotNull(atomicReference); assertNotNull(countDownLatch); assertNotNull(semaphore); assertNotNull(lock); assertEquals("map1", map1.getName()); assertEquals("map2", map2.getName()); assertEquals("testMultimap", multiMap.getName()); assertEquals("replicatedMap", replicatedMap.getName()); assertEquals("testQ", queue.getName()); assertEquals("testTopic", topic.getName()); assertEquals("set", set.getName()); assertEquals("list", list.getName()); assertEquals("idGenerator", idGenerator.getName()); assertEquals("atomicLong", atomicLong.getName()); assertEquals("atomicReference", atomicReference.getName()); assertEquals("countDownLatch", countDownLatch.getName()); assertEquals("semaphore", semaphore.getName()); }
public static void logPartitionStatistics( ILogger log, String basename, IMap<Object, Integer> map, boolean printSizes) { MapProxyImpl mapProxy = (MapProxyImpl) map; MapService mapService = (MapService) mapProxy.getService(); MapServiceContext mapServiceContext = mapService.getMapServiceContext(); Collection<Integer> localPartitions = mapServiceContext.getOwnedPartitions(); int localSize = 0; StringBuilder partitionIDs = new StringBuilder(); StringBuilder partitionSizes = new StringBuilder(); String separator = ""; for (int partitionId : localPartitions) { int partitionSize = mapServiceContext.getRecordStore(partitionId, map.getName()).size(); localSize += partitionSize; partitionIDs.append(separator).append(partitionId); partitionSizes.append(separator).append(partitionSize); separator = ", "; } log.info( format( "%s: Local partitions (count %d) (size %d) (avg %.2f) (IDs %s)%s", basename, localPartitions.size(), localSize, localSize / (float) localPartitions.size(), partitionIDs.toString(), printSizes ? format(" (sizes %s)", partitionSizes.toString()) : "")); }
@Test public void runFullQuery() throws Exception { Predicate predicate = Predicates.equal("this", value); QueryResult result = queryRunner.run(map.getName(), predicate, ENTRY); assertEquals(1, result.getRows().size()); assertEquals(map.get(key), toObject(result.getRows().iterator().next().getValue())); }
private boolean isEvictionEnabled(IMap map) { MapProxyImpl mapProxy = (MapProxyImpl) map; MapService mapService = (MapService) mapProxy.getService(); MapServiceContext mapServiceContext = (MapServiceContext) mapService.getMapServiceContext(); MapContainer mapContainer = mapServiceContext.getMapContainer(map.getName()); EvictionPolicy evictionPolicy = mapContainer.getMapConfig().getEvictionPolicy(); return evictionPolicy != NONE; }
private boolean isRecordStoreExpirable(IMap map) { MapProxyImpl mapProxy = (MapProxyImpl) map; MapService mapService = (MapService) mapProxy.getService(); MapServiceContext mapServiceContext = (MapServiceContext) mapService.getMapServiceContext(); PartitionContainer container = mapServiceContext.getPartitionContainer(0); RecordStore recordStore = container.getExistingRecordStore(map.getName()); return recordStore.isExpirable(); }
@Test public void runPartitionScanQueryOnSinglePartition() { Predicate predicate = Predicates.equal("this", value); QueryResult result = queryRunner.runUsingPartitionScanOnSinglePartition( map.getName(), predicate, partitionId, ENTRY); assertEquals(1, result.getRows().size()); assertEquals(map.get(key), toObject(result.getRows().iterator().next().getValue())); }
@Setup public void setup(TestContext testContext) throws Exception { this.testContext = testContext; targetInstance = testContext.getTargetInstance(); testId = testContext.getTestId(); integrityMap = targetInstance.getMap(basename + "Integrity"); stressMap = targetInstance.getMap(basename + "Stress"); integrityThreads = new MapIntegrityThread[mapIntegrityThreadCount]; value = new byte[valueSize]; Random random = new Random(); random.nextBytes(value); if (mapLoad && isMemberNode(targetInstance)) { PartitionService partitionService = targetInstance.getPartitionService(); final Set<Partition> partitionSet = partitionService.getPartitions(); for (Partition partition : partitionSet) { while (partition.getOwner() == null) { Thread.sleep(1000); } } LOGGER.info(testId + ": " + partitionSet.size() + " partitions"); Member localMember = targetInstance.getCluster().getLocalMember(); for (int i = 0; i < totalIntegrityKeys; i++) { Partition partition = partitionService.getPartition(i); if (localMember.equals(partition.getOwner())) { integrityMap.put(i, value); } } LOGGER.info( testId + ": integrityMap=" + integrityMap.getName() + " size=" + integrityMap.size()); Config config = targetInstance.getConfig(); MapConfig mapConfig = config.getMapConfig(integrityMap.getName()); LOGGER.info(testId + ": " + mapConfig); } }
@Verify(global = false) public void verify() throws Exception { if (isMemberNode(targetInstance)) { LOGGER.info(testId + ": cluster size =" + targetInstance.getCluster().getMembers().size()); } LOGGER.info( testId + ": integrityMap=" + integrityMap.getName() + " size=" + integrityMap.size()); int totalErrorCount = 0; int totalNullValueCount = 0; for (MapIntegrityThread integrityThread : integrityThreads) { totalErrorCount += integrityThread.sizeErrorCount; totalNullValueCount += integrityThread.nullValueCount; } LOGGER.info(testId + ": total integrityMapSizeErrorCount=" + totalErrorCount); LOGGER.info(testId + ": total integrityMapNullValueCount=" + totalNullValueCount); assertEquals( testId + ": (verify) integrityMap=" + integrityMap.getName() + " map size ", totalIntegrityKeys, integrityMap.size()); assertEquals(testId + ": (verify) integrityMapSizeErrorCount=", 0, totalErrorCount); assertEquals(testId + ": (verify) integrityMapNullValueCount=", 0, totalNullValueCount); }
@Override public String getName() { return cache.getName(); }
/** * Construct the Cache Set the listeners and cache refreshers later * * @param hcMap the hazelcast Map (IMap) */ public HazelcastCache(IMap hcMap) { super(hcMap.getName(), hcMap); }
@Test public void getMapName() throws InterruptedException { HazelcastClient hClient = getHazelcastClient(); IMap<Object, Object> map = hClient.getMap("getMapName"); assertEquals("getMapName", map.getName()); }
public String getName() { return map.getName(); }