Search in sources :

Example 6 with InvalidConfigException

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;
}
Also used : InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException)

Example 7 with InvalidConfigException

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;
}
Also used : DatabusException(com.linkedin.databus2.core.DatabusException) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) IOException(java.io.IOException)

Example 8 with InvalidConfigException

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);
}
Also used : KeyFilterConfigHolder(com.linkedin.databus2.core.filter.KeyFilterConfigHolder) KeyRangeFilterConfig(com.linkedin.databus2.core.filter.KeyRangeFilterConfig) KeyModFilterConfig(com.linkedin.databus2.core.filter.KeyModFilterConfig) KeyRangeFilterConfig(com.linkedin.databus2.core.filter.KeyRangeFilterConfig) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) DbusKeyFilter(com.linkedin.databus2.core.filter.DbusKeyFilter) Test(org.testng.annotations.Test)

Example 9 with InvalidConfigException

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);
}
Also used : KeyFilterConfigHolder(com.linkedin.databus2.core.filter.KeyFilterConfigHolder) KeyModFilterConfig(com.linkedin.databus2.core.filter.KeyModFilterConfig) KeyRangeFilterConfig(com.linkedin.databus2.core.filter.KeyRangeFilterConfig) KeyModFilterConfig(com.linkedin.databus2.core.filter.KeyModFilterConfig) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) DbusKeyFilter(com.linkedin.databus2.core.filter.DbusKeyFilter) Test(org.testng.annotations.Test)

Example 10 with InvalidConfigException

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());
}
Also used : RegistryType(com.linkedin.databus2.schemas.SchemaRegistryStaticConfig.RegistryType) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException)

Aggregations

InvalidConfigException (com.linkedin.databus.core.util.InvalidConfigException)29 DatabusException (com.linkedin.databus2.core.DatabusException)7 IOException (java.io.IOException)7 DbusEventBuffer (com.linkedin.databus.core.DbusEventBuffer)6 NoSuchSchemaException (com.linkedin.databus2.schemas.NoSuchSchemaException)6 ArrayList (java.util.ArrayList)6 DbusEventV2Factory (com.linkedin.databus.core.DbusEventV2Factory)5 SimpleObjectCaptureHandler (com.linkedin.databus2.test.container.SimpleObjectCaptureHandler)5 SimpleTestServerConnection (com.linkedin.databus2.test.container.SimpleTestServerConnection)5 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)5 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)5 HttpServerCodec (org.jboss.netty.handler.codec.http.HttpServerCodec)5 LoggingHandler (org.jboss.netty.handler.logging.LoggingHandler)5 Log4JLoggerFactory (org.jboss.netty.logging.Log4JLoggerFactory)5 BeforeClass (org.testng.annotations.BeforeClass)5 DatabusHttpClientImpl (com.linkedin.databus.client.DatabusHttpClientImpl)4 UnsupportedKeyException (com.linkedin.databus.core.UnsupportedKeyException)4 OracleTriggerMonitoredSourceInfo (com.linkedin.databus2.producers.db.OracleTriggerMonitoredSourceInfo)4 Test (org.testng.annotations.Test)4 Checkpoint (com.linkedin.databus.core.Checkpoint)3