/** * Constructs an instance of <code>RegionExistsException</code> with the specified detail message * and cause. * * @param rgn the Region that exists * @param cause the causal Throwable */ public RegionExistsException(Region rgn, Throwable cause) { super(rgn.getFullPath(), cause); this.region = rgn; }
/** * Constructs an instance of <code>RegionExistsException</code> with the specified Region. * * @param rgn the Region that exists */ public RegionExistsException(Region rgn) { super(rgn.getFullPath()); this.region = rgn; }
@Override public int hashCode() { return ((Region) this).getFullPath().hashCode(); } }
@Override public Region getLocalDataSet(Region r) { if (this.colocatedLocalDataMap != null) { return this.colocatedLocalDataMap.get(r.getFullPath()); } else { return null; } }
@Override public boolean include(Region<?, ?> region) { String fullPath = region.getFullPath(); if (included != null) { return included.contains(fullPath); } if (excluded != null) { return !excluded.contains(fullPath); } return true; }
@Override public Collection<Index> getIndexes(Region<?, ?> region) { Collection<Index> indexes = this.indexes.get(region.getFullPath()); return (indexes != null) ? indexes : Collections.emptyList(); }
/** * Writes an instance of Region. A Region is serialized as just a reference to a full path only. * It will be recreated on the other end by calling {@link CacheFactory#getAnyInstance} and then * calling <code>getRegion</code> on it. This method will handle a <code>null</code> value and not * throw a <code>NullPointerException</code>. */ public static void writeRegion(Region<?, ?> rgn, DataOutput out) throws IOException { writeString((rgn != null) ? rgn.getFullPath() : null, out); }
/** * 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 static Set<String> getAllRegionNames(Cache cache) { Set<String> regionNames = new HashSet<>(); Set<Region<?, ?>> rootRegions = cache.rootRegions(); for (Region<?, ?> rootRegion : rootRegions) { regionNames.add(rootRegion.getFullPath().substring(1)); Set<Region<?, ?>> subRegions = rootRegion.subregions(true); for (Region<?, ?> subRegion : subRegions) { regionNames.add(subRegion.getFullPath().substring(1)); } } return regionNames; }
public void beforeRegionDestroyed(Region region) { List<LuceneIndex> indexes = getIndexes(region.getFullPath()); if (!indexes.isEmpty()) { String indexNames = indexes.stream().map(i -> i.getName()).collect(Collectors.joining(",")); throw new IllegalStateException( String.format( "Region %s cannot be destroyed because it defines Lucene index(es) [%s]. Destroy all Lucene indexes before destroying the region.", region.getFullPath(), indexNames)); } }
@Override public Collection<String> getRegionNames() { security.authorize(DATA, READ, ALL, ALL); Set<String> regionNames = new HashSet<>(); cache.rootRegions().forEach(region -> { regionNames.add(region.getFullPath()); region.subregions(true).stream().map(Region::getFullPath).forEach(regionNames::add); }); return regionNames; }
private void saveRegion(Region<?, ?> region, File dir, SnapshotFormat format, SnapshotOptions options) throws IOException { RegionSnapshotService<?, ?> regionSnapshotService = region.getSnapshotService(); String name = "snapshot" + region.getFullPath().replace('/', '-') + RegionSnapshotService.SNAPSHOT_FILE_EXTENSION; File f = new File(dir, name); regionSnapshotService.save(f, format, options); } }
@Override public LuceneIndex getIndex(String indexName, String regionPath) { Region region = cache.getRegion(regionPath); if (region == null) { return null; } return indexMap.get(getUniqueIndexName(indexName, region.getFullPath())); }
public static String getRegionFullPath(String regionName) { final Region r = cache.getRegion(Region.SEPARATOR + regionName); assertNotNull(r); return r.getFullPath(); }
private void doInitializeList(ByteArrayWrapper key, Region r) { r.put("head", 0); r.put("tail", 0); String fullpath = r.getFullPath(); HashMap<Enum<?>, Query> queryList = new HashMap<>(); for (ListQuery lq : ListQuery.values()) { String queryString = lq.getQueryString(fullpath); Query query = this.queryService.newQuery(queryString); queryList.put(lq, query); } this.preparedQueries.put(key, queryList); }
@Before public void setUp() throws Exception { Region<String, String> region1Stub = mock(Region.class); when(region1Stub.getFullPath()).thenReturn(TEST_REGION1); Region<String, String> region2Stub = mock(Region.class); when(region2Stub.getFullPath()).thenReturn(TEST_REGION2); Region<String, String> region3Stub = mock(Region.class); when(region3Stub.getFullPath()).thenReturn(TEST_REGION3); when(cacheStub.rootRegions()).thenReturn(Collections .unmodifiableSet(new HashSet<>(Arrays.asList(region1Stub, region2Stub, region3Stub)))); operationHandler = new GetRegionNamesRequestOperationHandler(); }
@Override public void afterInvalidate(EntryEvent event) { logger.debug("BucketListener: o={}, r={}, k={}, dm={}", event.getOperation(), event.getRegion().getFullPath(), event.getKey(), event.getDistributedMember()); }
@Override public void afterUpdate(EntryEvent event) { EntryEventImpl ee = (EntryEventImpl) event; logger.debug("BucketListener: o={}, r={}, k={}, ov={}, nv={}, dm={}", event.getOperation(), event.getRegion().getFullPath(), event.getKey(), ee.getRawOldValue(), ee.getRawNewValue(), event.getDistributedMember()); }
private static void setupReplicatedRegion(String regionName) { InternalCache cache = ClusterStartupRule.getCache(); RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE); Region dataRegion = regionFactory.create(regionName); assertThat(dataRegion).isNotNull(); assertThat(dataRegion.getFullPath()).contains(regionName); }
private static void setupPartitionedRegion(String regionName) { InternalCache cache = ClusterStartupRule.getCache(); PartitionAttributes partitionAttrs = new PartitionAttributesFactory().setRedundantCopies(2).create(); RegionFactory<Object, Object> partitionRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION); partitionRegionFactory.setPartitionAttributes(partitionAttrs); Region dataParRegion = partitionRegionFactory.create(regionName); assertThat(dataParRegion).isNotNull(); assertThat(dataParRegion.getFullPath()).contains(regionName); }