public static PartitionAttributesData getPartitionAttributesData(PartitionAttributes partAttrs) { int redundantCopies = partAttrs.getRedundantCopies(); long totalMaxMemory = partAttrs.getTotalMaxMemory(); // Total number of buckets for whole region int totalNumBuckets = partAttrs.getTotalNumBuckets(); int localMaxMemory = partAttrs.getLocalMaxMemory(); String colocatedWith = partAttrs.getColocatedWith(); String partitionResolver = null; if (partAttrs.getPartitionResolver() != null) { partitionResolver = partAttrs.getPartitionResolver().getName(); } long recoveryDelay = partAttrs.getRecoveryDelay(); long startupRecoveryDelay = partAttrs.getStartupRecoveryDelay(); String[] partitionListeners = null; if (partAttrs.getPartitionListeners() != null) { partitionListeners = new String[partAttrs.getPartitionListeners().length]; for (int i = 0; i < partAttrs.getPartitionListeners().length; i++) { partitionListeners[i] = (partAttrs.getPartitionListeners())[i].getClass().getCanonicalName(); } } PartitionAttributesData partitionAttributesData = new PartitionAttributesData(redundantCopies, totalMaxMemory, totalNumBuckets, localMaxMemory, colocatedWith, partitionResolver, recoveryDelay, startupRecoveryDelay, partitionListeners); return partitionAttributesData; }
void setColocatedWithRegion(final PartitionedRegion colocatedWithRegion) { this.colocatedWithRegion = colocatedWithRegion; if (colocatedWithRegion != null) { // In colocation chain, child region inherita the fixed partitin // attributes from parent region. this.fixedPAttrs = colocatedWithRegion.getFixedPartitionAttributesImpl(); this.fixedPASet = colocatedWithRegion.fixedPASet; synchronized (colocatedWithRegion.colocatedByList) { colocatedWithRegion.colocatedByList.add(this); } } else { this.fixedPAttrs = this.partitionAttributes.getFixedPartitionAttributes(); this.fixedPASet = 0; } }
/** * Constructor. */ PartitionRegionConfig(int prId, String path, PartitionAttributes prAtt, Scope sc) { this.prId = prId; this.pAttrs = (PartitionAttributesImpl)prAtt; this.scope = sc; this.isDestroying = false; this.nodes = new VersionedArrayList(); if (prAtt.getPartitionResolver() != null) { this.partitionResolver = prAtt.getPartitionResolver().getClass().getName(); } this.colocatedWith = prAtt.getColocatedWith(); this.isColocationComplete = colocatedWith == null; this.fullPath = path; this.firstDataStoreCreated = prAtt.getLocalMaxMemory() != 0; this.elderFPAs = new LinkedHashSet<FixedPartitionAttributesImpl>(); PartitionListener[] prListeners = prAtt.getPartitionListeners(); if (prListeners != null && prListeners.length != 0) { for (int i = 0; i < prListeners.length; i++) { PartitionListener listener = prListeners[i]; this.partitionListenerClassNames.add(listener.getClass().getName()); } } }
/** * Resets the partition description based on partition attributes, to pick up * product defaults and side-effects. */ private static void resetPartitionDescription(PartitionDescription pd, PartitionAttributes pa) { if (pd.getLocalMaxMemory() != null) { pd.setLocalMaxMemory(new Integer(pa.getLocalMaxMemory())); } // else deferred pd.setRecoveryDelay(new Long(pa.getRecoveryDelay())); pd.setRedundantCopies(new Integer(pa.getRedundantCopies())); pd.setStartupRecoveryDelay(new Long(pa.getStartupRecoveryDelay())); pd.setTotalMaxMemory(new Long(pa.getTotalMaxMemory())); pd.setTotalNumBuckets(new Integer(pa.getTotalNumBuckets())); }
aStr.append(" redundantCopies: " + parAttr.getRedundantCopies() + "\n"); aStr.append(" localProperties: " + parAttr.getLocalProperties() + "\n"); aStr.append(" globalProperties: " + parAttr.getGlobalProperties() + "\n"); aStr.append(" partitonResolver: " + parAttr.getPartitionResolver()+ "\n"); aStr.append(" colocatedWith: " + parAttr.getColocatedWith() + "\n"); aStr.append(" recoveryDelay: " + parAttr.getRecoveryDelay() + "\n"); aStr.append(" startupRecoveryDelay: " + parAttr.getStartupRecoveryDelay() + "\n");
protected void populateSequentiallyAndEvenly() { int totalNumBuckets = aRegion.getPartitionAttributes().getTotalNumBuckets(); int numEntriesPerBucket = MAX_KEYS_TO_BE_POPULATED / totalNumBuckets; for (int bucketId = 0; bucketId < totalNumBuckets; bucketId++) { populateSpecificBucketSpecificSize(bucketId, numEntriesPerBucket); } }
@Override protected boolean usesDiskStore(RegionAttributes ra) { if (ra.getPartitionAttributes().getLocalMaxMemory() == 0) return false; // see bug 42055 return super.usesDiskStore(ra); }
PartitionAttributes pa = regionAttrs.getPartitionAttributes(); assertEquals(pa.getRedundantCopies(), 1); assertNotNull(pa.getPartitionResolver().getClass()); assertEquals(pa.getPartitionResolver(), resolver); List<FixedPartitionAttributesImpl> fixedPartitionsList = pa .getFixedPartitionAttributes(); if (isColocated) { assertNull(fixedPartitionsList); assertNotNull(pa.getColocatedWith()); assertNull(pa.getColocatedWith()); assertEquals(fixedPartitionsList.size(), 4); assertEquals(fixedPartitionsList.containsAll(fpattrsList), true);
/** * Waits for recovery in self vm after reconnect */ protected void waitForSelfRecovery(){ RegionAttributes attr = aRegion.getAttributes(); PartitionAttributes prAttr = attr.getPartitionAttributes(); if(prAttr != null){ List otherVMs = new ArrayList(ClientVmMgr.getOtherClientVmids()); int numPRs = (ConfigPrms.getHadoopConfig() != null) ? 2 : 1; PRObserver.waitForRecovery(prAttr.getRecoveryDelay(), prAttr.getStartupRecoveryDelay(), new Integer(RemoteTestModule.getMyVmid()), otherVMs, 1, numPRs, null, null); } }
/** Return a String describing important attributes of the given region. * * @param aRegion The region to describe. */ private static String getRegionStr(Region aRegion) { StringBuffer aStr = new StringBuffer(); aStr.append(aRegion.getFullPath() + " (size " + aRegion.size() + " dataPolicy " + aRegion.getAttributes().getDataPolicy() + " eviction " + aRegion.getAttributes().getEvictionAttributes()); PartitionAttributes prAttr = aRegion.getAttributes().getPartitionAttributes(); if (prAttr != null) { aStr.append(" localMaxMemory=" + aRegion.getAttributes().getPartitionAttributes().getLocalMaxMemory()); aStr.append(" redundantCopies=" + aRegion.getAttributes().getPartitionAttributes().getRedundantCopies()); if (prAttr.getColocatedWith() != null) { aStr.append(" colocatedWith=" + prAttr.getColocatedWith()); } } RecoveryTestVersionHelper.logDiskStore(aRegion, aStr); aStr.append(")\n"); return aStr.toString(); }
public PartitionResolver getPartitionResolver() { // [SQLFabric] use PartitionAttributes to get the the resolver // since it may change after ALTER TABLE return this.partitionAttributes.getPartitionResolver(); }
/** * Returns true if the underlying region is partitioned and has redundancy. * * @return true if region is partitioned and redundant. */ public final boolean isRedundant() { if (this.regionAttributes.getDataPolicy().withPartitioning()) { return this.regionAttributes.getPartitionAttributes() .getRedundantCopies() > 0; } return false; }
public boolean isRedundancyImpaired() { int numBuckets = this.prRegion.getPartitionAttributes().getTotalNumBuckets(); int targetRedundancy = this.prRegion.getPartitionAttributes().getRedundantCopies(); for (int i =0; i < numBuckets; i++) { int redundancy = this.prRegion.getRegionAdvisor().getBucketRedundancy(i); if (redundancy < targetRedundancy && redundancy != -1 || redundancy > targetRedundancy) { return true; } } return false; }
public Object load(LoaderHelper helper) throws CacheLoaderException { /* checking the attributes set in xml file */ PartitionedRegion pr = (PartitionedRegion) helper.getRegion(); if (pr.getAttributes().getPartitionAttributes().getRedundantCopies() != 1) Assert .fail("Redundancy of the partition region is not 1"); Assert.assertEquals(pr.getAttributes() .getPartitionAttributes().getGlobalProperties().getProperty( PartitionAttributesFactory.GLOBAL_MAX_BUCKETS_PROPERTY), "11"); Assert.assertEquals(pr.getAttributes() .getPartitionAttributes().getLocalMaxMemory(), 200); /* * Returning the same key. This is to check CaccheLoader is invoked or * not */ return helper.getKey(); }
public String getColocatedWith() { // [SQLFabric] use PartitionAttributes to get colocated region // since it may change after ALTER TABLE return this.partitionAttributes.getColocatedWith(); }
public void run2() throws CacheException { final Cache cache; try { CacheXml30Test.lonerDistributedSystem = false; cache = getCache(); } finally { CacheXml30Test.lonerDistributedSystem = true; } Region region = cache.getRegion(regionName); assertNotNull(region); RegionAttributes attrs = region.getAttributes(); assertNotNull(attrs.getPartitionAttributes()); PartitionAttributes pa = attrs.getPartitionAttributes(); // assertNull(pa.getCacheWriter()); assertEquals(pa.getRedundantCopies(), 1); assertEquals(pa.getGlobalProperties().getProperty( PartitionAttributesFactory.GLOBAL_MAX_MEMORY_PROPERTY), "96"); assertEquals(pa.getLocalProperties().getProperty( PartitionAttributesFactory.LOCAL_MAX_MEMORY_PROPERTY), "32"); } };
protected PartitionedRegionBridge(Region<K, V> region) { super(region); this.parRegion = (PartitionedRegion)region; this.prStats = parRegion.getPrStats(); PartitionAttributes<K, V> partAttrs = parRegion.getPartitionAttributes(); this.parRegionMonitor = new MBeanStatsMonitor(PAR_REGION_MONITOR); this.configurePartitionRegionMetrics(); this.configuredRedundancy = partAttrs.getRedundantCopies(); this.partitionAttributesData = RegionMBeanCompositeDataFactory.getPartitionAttributesData(partAttrs); if (partAttrs.getFixedPartitionAttributes() != null) { this.fixedPartitionAttributesTable = RegionMBeanCompositeDataFactory.getFixedPartitionAttributesData(partAttrs); } parRegionMonitor.addStatisticsToMonitor(prStats.getStats()); }
protected static String getRecoveryDelay(PartitionAttributes pa) { return String.valueOf(pa.getRecoveryDelay()); } protected static String getStartupRecoveryDelay(PartitionAttributes pa) {
private void validatePartitionListeners(final PartitionRegionConfig prconf, final PartitionAttributes userPA) { ArrayList<String> prconfList = prconf.getPartitionListenerClassNames(); if (userPA.getPartitionListeners() == null && userPA.getPartitionListeners().length == 0 && prconfList != null) { throw new IllegalStateException( LocalizedStrings.PartitionRegionConfigValidator_INCOMPATIBLE_PARTITION_LISTENER .toLocalizedString(new Object[] { null, prconfList })); } if (userPA.getPartitionListeners() != null && prconfList != null) { ArrayList<String> userPRList = new ArrayList<String>(); for (int i = 0; i < userPA.getPartitionListeners().length; i++) { userPRList.add(userPA.getPartitionListeners()[i].getClass().getName()); } if (userPA.getPartitionListeners().length != prconfList.size()) { throw new IllegalStateException( LocalizedStrings.PartitionRegionConfigValidator_INCOMPATIBLE_PARTITION_LISTENER .toLocalizedString(new Object[] { userPRList, prconfList })); } for (String listener : prconfList) { if (!(userPRList.contains(listener))) { throw new IllegalStateException( LocalizedStrings.PartitionRegionConfigValidator_INCOMPATIBLE_PARTITION_LISTENER .toLocalizedString(new Object[] { userPRList, prconfList })); } } } }
/** * Constructor. */ PartitionRegionConfig(int prId, String path, PartitionAttributes prAtt, Scope sc) { this.prId = prId; this.pAttrs = (PartitionAttributesImpl)prAtt; this.scope = sc; this.isDestroying = false; this.nodes = new VersionedArrayList(); if (prAtt.getPartitionResolver() != null) { this.partitionResolver = prAtt.getPartitionResolver().getClass().getName(); } this.colocatedWith = prAtt.getColocatedWith(); this.isColocationComplete = colocatedWith == null; this.fullPath = path; this.firstDataStoreCreated = prAtt.getLocalMaxMemory() > 0; this.elderFPAs = new LinkedHashSet<FixedPartitionAttributesImpl>(); PartitionListener[] prListeners = prAtt.getPartitionListeners(); if (prListeners != null && prListeners.length != 0) { for (int i = 0; i < prListeners.length; i++) { PartitionListener listener = prListeners[i]; this.partitionListenerClassNames.add(listener.getClass().getName()); } } }