Search in sources :

Example 1 with RegionMetadata

use of org.apache.geode.spark.connector.internal.RegionMetadata in project geode by apache.

the class RetrieveRegionMetadataFunction method execute.

@Override
public void execute(FunctionContext context) {
    LocalRegion region = (LocalRegion) ((InternalRegionFunctionContext) context).getDataSet();
    String regionPath = region.getFullPath();
    boolean isPartitioned = region.getDataPolicy().withPartitioning();
    String kTypeName = getTypeClassName(region.getAttributes().getKeyConstraint());
    String vTypeName = getTypeClassName(region.getAttributes().getValueConstraint());
    RegionMetadata metadata;
    if (!isPartitioned) {
        metadata = new RegionMetadata(regionPath, false, 0, null, kTypeName, vTypeName);
    } else {
        PartitionedRegion pregion = (PartitionedRegion) region;
        int totalBuckets = pregion.getAttributes().getPartitionAttributes().getTotalNumBuckets();
        Map<Integer, List<BucketServerLocation66>> bucketMap = pregion.getRegionAdvisor().getAllClientBucketProfiles();
        HashMap<ServerLocation, HashSet<Integer>> serverMap = bucketServerMap2ServerBucketSetMap(bucketMap);
        metadata = new RegionMetadata(regionPath, true, totalBuckets, serverMap, kTypeName, vTypeName);
    }
    ResultSender<RegionMetadata> sender = context.getResultSender();
    sender.lastResult(metadata);
}
Also used : ServerLocation(org.apache.geode.distributed.internal.ServerLocation) RegionMetadata(org.apache.geode.spark.connector.internal.RegionMetadata) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) List(java.util.List) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 List (java.util.List)1 ServerLocation (org.apache.geode.distributed.internal.ServerLocation)1 LocalRegion (org.apache.geode.internal.cache.LocalRegion)1 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)1 RegionMetadata (org.apache.geode.spark.connector.internal.RegionMetadata)1