CreateRegionFunction implements Function, Declarable, DataSerializable { void compareRegionAttributes(RegionAttributes existingRegionAttributes, RegionAttributes requestedRegionAttributes) { EvictionAttributes evictionAttributes = existingRegionAttributes.getEvictionAttributes(); RegionAttributesCreation existingRACreation = new RegionAttributesCreation(existingRegionAttributes, false); RegionAttributesCreation requestedAttributesCreation = new RegionAttributesCreation(requestedRegionAttributes, false); if (existingRegionAttributes.getDataPolicy().withPersistence() || (evictionAttributes != null && evictionAttributes.getAction() == EvictionAction.OVERFLOW_TO_DISK)) { if (requestedRegionAttributes.getDiskStoreName() == null && existingRegionAttributes.getDiskStoreName() == null) { existingRACreation.setDiskStoreName("DEFAULT"); requestedAttributesCreation.setDiskStoreName("DEFAULT"); } } existingRACreation.sameAs(requestedAttributesCreation); } CreateRegionFunction(); @Override @SuppressWarnings("unchecked") void execute(FunctionContext context); @Override Collection<ResourcePermission> getRequiredPermissions(String regionName); @Override String getId(); @Override boolean optimizeForWrite(); @Override boolean isHA(); @Override boolean hasResult(); @Override void toData(DataOutput out); @Override void fromData(DataInput in); static final String ID; }
@Test public void regionComparisonMustBeSuccessfulWhenDiskStoreNamesForBothAreNullAndDiskPropertiesAreDifferent() { final CreateRegionFunction createRegionFunction = mock(CreateRegionFunction.class); doCallRealMethod().when(createRegionFunction).compareRegionAttributes(any(), any()); final RegionAttributes existingRegionAttributes = getRegionAttributesWithModifiedDiskDirSize(new int[] {1}); final RegionAttributes requestedRegionAttributes = getRegionAttributesWithModifiedDiskDirSize(new int[] {2}); createRegionFunction.compareRegionAttributes(existingRegionAttributes, requestedRegionAttributes); final RegionAttributes existingRegionAttributes2 = getRegionAttributesWithModifiedDiskDirs(null); final RegionAttributes requestedRegionAttributes2 = getRegionAttributesWithModifiedDiskDirs(new File[] {}); createRegionFunction.compareRegionAttributes(existingRegionAttributes2, requestedRegionAttributes2); }