}
} else {
RemotePolicyCacheConfiguration partitionConfiguration =
partition.getConstraintsConfiguration();
PolicyCachePartitionConstraints partitionConstraints;
Group baseGroup;
if (builder.isRemote()) {
// The project is remote so use the group associated with the
// remote partition if any, or the remote group.
String location = configuration.getLocation();
baseGroup = policyCache.getRemotePartitionGroup(location);
if (baseGroup == null) {
baseGroup = policyCache.getRemoteGroup();
}
partitionConstraints =
policyCache.getRemotePartitionConstraints();
} else {
baseGroup = policyCache.getLocalGroup();
partitionConstraints =
policyCache.getLocalPartitionConstraints();
}
int partitionSize = partitionConstraints.constrainPartitionSize(
partition.getSize());
if (partitionSize < 1) {
throw new IllegalStateException("Partition size must be >= 1");
}
CacheFactory cacheFactory = CacheFactory.getDefaultInstance();
GroupBuilder groupBuilder = cacheFactory.createGroupBuilder();
groupBuilder.setMaxCount(partitionSize);
Group partitionGroup = baseGroup.addGroup(
configuration.getLocation(), groupBuilder);
// Create the base constraints for the partition. These will
// be used to derive the constraints for the type specific
// partitions.
CacheControlConstraints base =
new CacheControlConstraints(
partitionConstraints.getConstraints(),
partitionConfiguration);
builder.setCacheControlDefaults(base.getDefaultCacheControl());
SeparateCacheControlConstraintsMap constraintsMap =