use of org.apache.geode.InvalidValueException in project geode by apache.
the class CacheServerImpl method getAttribFactoryForClientMessagesRegion.
public static AttributesFactory getAttribFactoryForClientMessagesRegion(InternalCache cache, String ePolicy, int capacity, String overflowDir, boolean isDiskStore) throws InvalidValueException, GemFireIOException {
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
if (isDiskStore) {
// overflowDir parameter is actually diskstore name
factory.setDiskStoreName(overflowDir);
// client subscription queue is always overflow to disk, so do async
// see feature request #41479
factory.setDiskSynchronous(true);
} else if (overflowDir == null || overflowDir.equals(ClientSubscriptionConfig.DEFAULT_OVERFLOW_DIRECTORY)) {
factory.setDiskStoreName(null);
// client subscription queue is always overflow to disk, so do async
// see feature request #41479
factory.setDiskSynchronous(true);
} else {
File dir = new File(overflowDir + File.separatorChar + generateNameForClientMsgsRegion(OSProcess.getId()));
// This will delete the overflow directory when virtual machine terminates.
dir.deleteOnExit();
if (!dir.mkdirs() && !dir.isDirectory()) {
throw new GemFireIOException("Could not create client subscription overflow directory: " + dir.getAbsolutePath());
}
File[] dirs = { dir };
DiskStoreFactory dsf = cache.createDiskStoreFactory();
dsf.setAutoCompact(true).setDiskDirsAndSizes(dirs, new int[] { MAX_VALUE }).create("bsi");
factory.setDiskStoreName("bsi");
// backward compatibility, it was sync
factory.setDiskSynchronous(true);
}
factory.setDataPolicy(DataPolicy.NORMAL);
// enable statistics
factory.setStatisticsEnabled(true);
/* setting LIFO related eviction attributes */
if (HARegionQueue.HA_EVICTION_POLICY_ENTRY.equals(ePolicy)) {
factory.setEvictionAttributes(EvictionAttributes.createLIFOEntryAttributes(capacity, EvictionAction.OVERFLOW_TO_DISK));
} else if (HARegionQueue.HA_EVICTION_POLICY_MEMORY.equals(ePolicy)) {
// condition refinement
factory.setEvictionAttributes(EvictionAttributes.createLIFOMemoryAttributes(capacity, EvictionAction.OVERFLOW_TO_DISK));
} else {
// throw invalid eviction policy exception
throw new InvalidValueException(LocalizedStrings.CacheServerImpl__0_INVALID_EVICTION_POLICY.toLocalizedString(ePolicy));
}
return factory;
}
use of org.apache.geode.InvalidValueException in project geode by apache.
the class AbstractDistributionConfig method setAttributeObject.
public void setAttributeObject(String attName, Object attValue, ConfigSource source) {
// TODO: the setters is already checking the parameter type, do we still need to do this?
Class validValueClass = getAttributeType(attName);
if (attValue != null) {
// null is a "valid" value for any class
if (!validValueClass.isInstance(attValue)) {
throw new InvalidValueException(LocalizedStrings.AbstractDistributionConfig_0_VALUE_1_MUST_BE_OF_TYPE_2.toLocalizedString(new Object[] { attName, attValue, validValueClass.getName() }));
}
}
if (attName.startsWith(USERDEFINED_PREFIX_NAME)) {
// Do nothing its user defined property.
return;
}
// accepts int
if (attName.equalsIgnoreCase(LOG_LEVEL) || attName.equalsIgnoreCase(SECURITY_LOG_LEVEL)) {
if (attValue instanceof String) {
attValue = LogLevel.getLogWriterLevel((String) attValue);
}
}
if (attName.startsWith(SECURITY_PREFIX)) {
this.setSecurity(attName, attValue.toString());
}
if (attName.startsWith(SSL_SYSTEM_PROPS_NAME) || attName.startsWith(SYS_PROP_NAME)) {
this.setSSLProperty(attName, attValue.toString());
}
Method setter = setters.get(attName);
if (setter == null) {
// return
if (attName.startsWith(SECURITY_PREFIX) || attName.startsWith(SSL_SYSTEM_PROPS_NAME) || attName.startsWith(SYS_PROP_NAME)) {
getAttSourceMap().put(attName, source);
return;
}
throw new InternalGemFireException(LocalizedStrings.AbstractDistributionConfig_UNHANDLED_ATTRIBUTE_NAME_0.toLocalizedString(attName));
}
Class[] pTypes = setter.getParameterTypes();
if (pTypes.length != 1) {
throw new InternalGemFireException("the attribute setter must have one and only one parametter");
}
checkAttribute(attName, attValue);
try {
setter.invoke(this, attValue);
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
} else {
throw new InternalGemFireException("error invoking " + setter.getName() + " with " + attValue, e);
}
}
getAttSourceMap().put(attName, source);
}
Aggregations