use of com.linkedin.databus.core.util.InvalidConfigException in project databus by linkedin.
the class BackoffTimerStaticConfigBuilder method build.
@Override
public BackoffTimerStaticConfig build() throws InvalidConfigException {
if (0 > _initSleep)
throw new InvalidConfigException("initial sleep must be non-negative:" + _initSleep);
if (0 > _maxSleep)
throw new InvalidConfigException("max sleep must be non-negative: " + _maxSleep);
BackoffTimerStaticConfig newConfig = new BackoffTimerStaticConfig(_initSleep, _maxSleep, _sleepIncFactor, _sleepIncDelta, _maxRetryNum);
//sanity check
long secondSleep = newConfig.calcNextSleep(_initSleep);
if (secondSleep < _initSleep || secondSleep < 0)
throw new InvalidConfigException("sleeps are decreasing!");
return newConfig;
}
use of com.linkedin.databus.core.util.InvalidConfigException in project databus by linkedin.
the class FileMaxSCNHandlerFactory method createHandler.
@Override
public MaxSCNReaderWriter createHandler(String id) throws DatabusException {
FileMaxSCNHandler result;
synchronized (_configBuilder) {
String saveKey = _configBuilder.getKey();
_configBuilder.setKey(saveKey + "_" + id);
FileMaxSCNHandler.StaticConfig config;
try {
config = _configBuilder.build();
} catch (InvalidConfigException ice) {
throw new DatabusException("unable to create sequence number handler: " + ice.getMessage(), ice);
}
try {
result = FileMaxSCNHandler.create(config);
} catch (IOException ioe) {
throw new DatabusException("unable to create sequence number handler: " + ioe.getMessage(), ioe);
}
_configBuilder.setKey(saveKey);
}
return result;
}
use of com.linkedin.databus.core.util.InvalidConfigException in project databus by linkedin.
the class TestDbusKeyCompositeFilter method testDbusKeyRangeFilterErrors.
@Test
public void testDbusKeyRangeFilterErrors() throws Exception {
boolean isException = false;
//Error Case: Range Size is negative
try {
KeyFilterConfigHolder.Config partConf = new KeyFilterConfigHolder.Config();
partConf.setType("RANGE");
KeyRangeFilterConfig.Config rangeConf = new KeyRangeFilterConfig.Config();
rangeConf.setSize(-1);
rangeConf.setPartitions("[0,3-4]");
partConf.setRange(rangeConf);
DbusKeyFilter filter = new DbusKeyFilter(new KeyFilterConfigHolder(partConf.build()));
} catch (InvalidConfigException ice) {
isException = true;
}
assertEquals("Got Exception for invalid Config (Range Size is negative) ", true, isException);
isException = false;
//Error Case: min is greater than max
try {
KeyFilterConfigHolder.Config partConf = new KeyFilterConfigHolder.Config();
partConf.setType("RANGE");
KeyRangeFilterConfig.Config rangeConf = new KeyRangeFilterConfig.Config();
rangeConf.setSize(100);
rangeConf.setPartitions("[0,5-4]");
partConf.setRange(rangeConf);
DbusKeyFilter filter = new DbusKeyFilter(new KeyFilterConfigHolder(partConf.build()));
} catch (InvalidConfigException ice) {
isException = true;
}
assertEquals("Got Exception for invalid Config (min is greater than max) ", true, isException);
isException = false;
//Error Case: min is -ve
try {
KeyFilterConfigHolder.Config partConf = new KeyFilterConfigHolder.Config();
partConf.setType("RANGE");
KeyRangeFilterConfig.Config rangeConf = new KeyRangeFilterConfig.Config();
rangeConf.setSize(100);
rangeConf.setPartitions("[-3,2-4]");
partConf.setRange(rangeConf);
DbusKeyFilter filter = new DbusKeyFilter(new KeyFilterConfigHolder(partConf.build()));
} catch (InvalidConfigException ice) {
isException = true;
}
assertEquals("Got Exception for invalid Config (min is greater than max) ", true, isException);
}
use of com.linkedin.databus.core.util.InvalidConfigException in project databus by linkedin.
the class TestDbusKeyCompositeFilter method testDbusKeyModFilterErrors.
@Test
public void testDbusKeyModFilterErrors() throws Exception {
//Error Config : MaxBucket is more than numBuckets
boolean isException = false;
try {
KeyFilterConfigHolder.Config partConf = new KeyFilterConfigHolder.Config();
partConf.setType("MOD");
KeyModFilterConfig.Config modConf = new KeyModFilterConfig.Config();
modConf.setNumBuckets(5);
//invalid config
modConf.setBuckets("[0,3-9]");
partConf.setMod(modConf);
DbusKeyFilter filter = new DbusKeyFilter(new KeyFilterConfigHolder(partConf.build()));
} catch (InvalidConfigException ie) {
ie.printStackTrace();
isException = true;
}
assertEquals("Got Exception for invalid Config (MaxBucket is more than numBuckets) ", true, isException);
//Error Case : Min Bucket is more than maxBucket
isException = false;
try {
KeyFilterConfigHolder.Config partConf = new KeyFilterConfigHolder.Config();
partConf.setType("MOD");
KeyModFilterConfig.Config modConf = new KeyModFilterConfig.Config();
modConf.setNumBuckets(50);
//invalid config
modConf.setBuckets("[0,9-3]");
partConf.setMod(modConf);
DbusKeyFilter filter = new DbusKeyFilter(new KeyFilterConfigHolder(partConf.build()));
} catch (InvalidConfigException ie) {
ie.printStackTrace();
isException = true;
}
assertEquals("Got Exception for invalid Config (Min Bucket is more than maxBucket) ", true, isException);
//Error Case : numBuckets is negative
isException = false;
try {
KeyFilterConfigHolder.Config partConf = new KeyFilterConfigHolder.Config();
partConf.setType("MOD");
KeyModFilterConfig.Config modConf = new KeyModFilterConfig.Config();
modConf.setNumBuckets(-5);
//invalid config
modConf.setBuckets("[0]");
partConf.setMod(modConf);
DbusKeyFilter filter = new DbusKeyFilter(new KeyFilterConfigHolder(partConf.build()));
} catch (InvalidConfigException ie) {
ie.printStackTrace();
isException = true;
}
assertEquals("Got Exception for invalid Config numBuckets is negative) ", true, isException);
//Error Case : minBucket is negative
isException = false;
try {
KeyFilterConfigHolder.Config partConf = new KeyFilterConfigHolder.Config();
partConf.setType("MOD");
KeyModFilterConfig.Config modConf = new KeyModFilterConfig.Config();
modConf.setNumBuckets(50);
//invalid config
modConf.setBuckets("[-5,1-3]");
partConf.setMod(modConf);
DbusKeyFilter filter = new DbusKeyFilter(new KeyFilterConfigHolder(partConf.build()));
} catch (InvalidConfigException ie) {
ie.printStackTrace();
isException = true;
}
assertEquals("Got Exception for invalid Config (minBucket is negative) ", true, isException);
}
use of com.linkedin.databus.core.util.InvalidConfigException in project databus by linkedin.
the class SchemaRegistryConfigBuilder method build.
@Override
public SchemaRegistryStaticConfig build() throws InvalidConfigException {
RegistryType registryType = null;
try {
registryType = RegistryType.valueOf(_type);
} catch (Exception e) {
throw new InvalidConfigException("invalid schema registry type: " + _type);
}
_fileSystem.setEnabled(SchemaRegistryStaticConfig.RegistryType.FILE_SYSTEM == registryType);
// TODO Add config verification
return new SchemaRegistryStaticConfig(registryType, getFileSystem().build(), getExistingService());
}
Aggregations