/** * Creates a server region proxy for the given region. * @param r the region * @throws IllegalStateException if the region does not have a pool */ public ServerRegionProxy(Region r) { super(calcPool(r)); assert r instanceof LocalRegion; this.region = (LocalRegion)r; this.regionName = r.getFullPath(); } /**
public String[] listSubRegionPaths(boolean recursive) { SortedSet<String> subregionPaths = new TreeSet<String>(); Set<Region<?, ?>> subregions = region.subregions(recursive); for (Region<?, ?> region : subregions) { subregionPaths.add(region.getFullPath()); } return subregionPaths.toArray(new String[subregionPaths.size()]); }
@Override public void afterCommit(TransactionEvent event) { List<CacheEvent<?, ?>> events = event.getEvents(); for (CacheEvent<?, ?>e : events) { if (!"/testTxEventForRegion".equals(e.getRegion().getFullPath())) { exceptionOccurred = true; } } } }
private void verifyDeadServer(Map<String, ClientPartitionAdvisor> regionMetaData, Region region, int port0, int port1) { ServerLocation sl0 = new ServerLocation("localhost", port0); ServerLocation sl1 = new ServerLocation("localhost", port1); final ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath()); for (Entry entry : prMetaData.getBucketServerLocationsMap_TEST_ONLY().entrySet()) { List servers = (List)entry.getValue(); assertFalse( servers.contains(sl0) ); assertFalse( servers.contains(sl1) ); } }
private void logRegions() { Cache theCache = CacheHelper.getCache(); Set<Region<?, ?>> rootRegions = theCache.rootRegions(); StringBuffer aStr = new StringBuffer(); for (Region aRegion : rootRegions) { aStr.append(aRegion.getFullPath() + ":\n"); for (Object key : aRegion.keySet()) { aStr.append(" " + key + " " + aRegion.get(key) + "\n"); } } Log.getLogWriter().info(aStr.toString()); }
public String createRegion(String regionTemplateName) { synchronized (availableRegions) { RegionDescription regionDescription = RegionHelper.getRegionDescription(regionTemplateName); String regionName = getUniqueRegionName(regionDescription.getRegionName()); Region r = createRegion((regionName), regionTemplateName); availableRegions.add(r); return r.getFullPath(); } }
public void afterCreate(EntryEvent event) { EntryEventImpl ee = (EntryEventImpl)event; logger.debug("BucketListener: o={}, r={}, k={}, nv={}, dm={}", event.getOperation(), event.getRegion().getFullPath(), event.getKey(), ee.getRawNewValue(), event.getDistributedMember()); }
private static void sendKeySetResponseChunk(Region region, List list, boolean lastChunk, ServerConnection servConn) throws IOException { ChunkedMessage chunkedResponseMsg = servConn.getChunkedResponseMessage(); chunkedResponseMsg.setNumberOfParts(1); chunkedResponseMsg.setLastChunk(lastChunk); chunkedResponseMsg.addObjPart(list, zipValues); if (logger.isDebugEnabled()) { logger.debug("{}: Sending {} key set response chunk for region={}{}", servConn.getName(), (lastChunk ? " last " : " "), region.getFullPath(), (logger.isTraceEnabled() ? " keys=" + list + " chunk=<" + chunkedResponseMsg + ">" : "")); } chunkedResponseMsg.sendChunk(servConn); }
protected void updateEntry(Region aRegion, Object key) { QueryObject oldValue = (QueryObject)(aRegion.get(key)); QueryObject newValue = oldValue.modifyWithNewInstance( QueryObject.INCREMENT, 0, /* amount to increment */ false /* log modifications */ ); newValue.extra = key; Log.getLogWriter().info("operation for " + aRegion.getFullPath() + ":" + key + ", updateEntry: replacing key " + key + " with " + newValue.toStringFull()); QueryObject returnVal = (QueryObject)aRegion.put(key, newValue); Log.getLogWriter().info("operation for " + aRegion.getFullPath() + ":" + key + ", updateEntry: Done with call to put (update), returnVal is " + returnVal); }
private void clearLocalRegion(String regionPath) { Region region = gfsh.getCache().getRegion(regionPath); if (region == null) { gfsh.println("Error: Undefined region path " + regionPath); } else { region.localClear(); gfsh.println("Local region cleared: " + region.getFullPath()); } }
public void run2() throws CacheException { Region region = getRootRegion().getSubregion(regionName); region.registerInterest("ALL_KEYS"); getLogWriter().info("client1 registerInterest ALL_KEYS at "+region.getFullPath()); } });
/** Run validation on the PR after recovery (the PR must contain data) */ public static void validateAfterRecovery(Region reg) { Log.getLogWriter().info(reg.getFullPath() + " size is " + reg.size()); if (reg.size() == 0) { throw new TestException("Expected " + reg.getFullPath() + " to have a size > 0, but it has size " + reg.size()); } int redundantCopies = reg.getAttributes().getPartitionAttributes().getRedundantCopies(); ParRegUtil.verifyPRMetaData(reg); ParRegUtil.verifyPrimaries(reg, redundantCopies); ParRegUtil.verifyBucketCopies(reg, redundantCopies); }
/** Log primary and secondary members for the key and value for this event */ public static void logPRMembers(Region reg, Object key) { if (reg.getAttributes().getDataPolicy().withPartitioning()) { Log.getLogWriter().info("For key " + key + " in region " + reg.getFullPath() + " primaryMember: " + PartitionRegionHelper.getPrimaryMemberForKey(reg, key) + " redundantMembers: " + PartitionRegionHelper.getRedundantMembersForKey(reg, key)); } }
public void update(){ int op = UPDATE_OPERATION; try { if (opAllowed(op)){ String callback = getCallback(); updateObject(callback); }else throw new TestException("op " + opCodeToOpName(op) + " not allowed for region " + region.getFullPath()); } catch (Exception e) { handleException("Exception during " + opCodeToOpName(op), e, region); } }
public void invalidateLocal(){ int op = LOCAL_INVALIDATE_OPERATION; try { if (opAllowed(op)){ String callback = getCallback(); invalidateLocalObject(callback); }else throw new TestException("op " + opCodeToOpName(op) + " not allowed for region " + region.getFullPath()); } catch (Exception e) { handleException("Exception during " + opCodeToOpName(op), e, region); } }
/** validation for the valid wan clients with the right prefix * */ public static void validateInvalidSequentialKeysTask() throws Exception { Log.getLogWriter().info("Validating regions for invalid sequential keys"); for (String regionName : regionNames) { Region region = RegionHelper.getRegion(regionName); Set keys = region.keySet(); checkKeys(regionName, INVALID_PRIFIX); // can not check for invalid entries as wan sites may not be connected long requiredSize = WANBlackboard.getInstance().getSharedCounters().read(WANBlackboard.currentEntry_invalid); Log.getLogWriter().info("In Region " + region.getFullPath() + " Entries count is:" + keys.size()); } }
public void run2() throws CacheException { Region region = getRootRegion().getSubregion(regionName); region.getAttributesMutator().addCacheListener(new MyListener(false)); region.registerInterest("ALL_KEYS"); getLogWriter().info("client2 registerInterest ALL_KEYS at "+region.getFullPath()); } });
private static void makeRoom(int percent) { Log.getLogWriter().info("Destroying " + percent + " percent of entries in each region"); Set<Region<?, ?>> regionSet = getAllRegions(); for (Region aRegion: regionSet) { int numToDestroy = (int) (aRegion.size() * (percent * 0.01)); Log.getLogWriter().info("Destroying " + numToDestroy + " in " + aRegion.getFullPath() + " of size " + aRegion.size()); for (Object key: aRegion.keySet()) { aRegion.destroy(key); } } }
/** Verify primaries on all PRs. */ public static void HydraTask_verifyPrimaries() { long verifyController = ResourceManBB.getBB().getSharedCounters().incrementAndRead(ResourceManBB.verifyController2); if (verifyController == 1) { for (Region aRegion : testInstance.regionList) { Log.getLogWriter().info("Verifying " + aRegion.getFullPath()); int redundantCopies = aRegion.getAttributes().getPartitionAttributes().getRedundantCopies(); ParRegUtil.verifyPrimaries(aRegion, redundantCopies); } } }
protected void populateRegion(Region aRegion) { int numVms = TestConfig.getInstance().getTotalVMs() - 1; for (int i = 0; i < numVms; i++) { Object key = NameFactory.getNextPositiveObjectName(); BaseValueHolder anObj = getValueForKey(key); Log.getLogWriter().info("addEntry: calling create for key " + key + ", object " + TestHelper.toString(anObj) + ", region is " + aRegion.getFullPath()); aRegion.create(key, anObj); Log.getLogWriter().info("addEntry: done creating key " + key); } }