use of com.linkedin.databus2.core.DatabusException in project databus by linkedin.
the class DbusEventBufferMult method constructFilters.
/**
* Processes all {@link DatabusSubscription} and generates a filter to match events for any of
* those subscriptions.
*/
public DbusFilter constructFilters(Collection<DatabusSubscription> subs) throws DatabusException {
HashMap<PhysicalPartition, PhysicalPartitionDbusFilter> filterMap = null;
for (DatabusSubscription sub : subs) {
PhysicalPartition ppart = sub.getPhysicalPartition();
if (sub.getLogicalSource().isWildcard()) {
if (!ppart.isWildcard()) {
if (null == filterMap)
filterMap = new HashMap<PhysicalPartition, PhysicalPartitionDbusFilter>(10);
filterMap.put(ppart, new PhysicalPartitionDbusFilter(ppart, null));
} else {
LOG.warn("ignoring subscription with both physical partition and logical source wildcards");
}
} else {
PhysicalPartitionDbusFilter ppartFilter = null != filterMap ? filterMap.get(ppart) : null;
LogicalSourceAndPartitionDbusFilter logFilter = null;
if (null == ppartFilter) {
logFilter = new LogicalSourceAndPartitionDbusFilter();
ppartFilter = new PhysicalPartitionDbusFilter(ppart, logFilter);
if (null == filterMap)
filterMap = new HashMap<PhysicalPartition, PhysicalPartitionDbusFilter>(10);
filterMap.put(ppart, ppartFilter);
} else {
logFilter = (LogicalSourceAndPartitionDbusFilter) ppartFilter.getNestedFilter();
}
if (null != logFilter)
logFilter.addSourceCondition(sub.getLogicalPartition());
else
LOG.error("unexpected null filter for logical source");
}
}
if (0 == filterMap.size())
return AllowAllDbusFilter.THE_INSTANCE;
else if (1 == filterMap.size()) {
DbusFilter result = filterMap.entrySet().iterator().next().getValue();
return result;
} else {
ConjunctionDbusFilter result = new ConjunctionDbusFilter();
for (Map.Entry<PhysicalPartition, PhysicalPartitionDbusFilter> filterEntry : filterMap.entrySet()) {
result.addFilter(filterEntry.getValue());
}
return result;
}
}
use of com.linkedin.databus2.core.DatabusException in project databus by linkedin.
the class TestParser method missingScnCheck.
/**
* Missing scn should throw an exception
*/
@Test
public void missingScnCheck() throws Exception {
BasicOperationsCheckCallback callback = new BasicOperationsCheckCallback();
try {
StaxBuilderTest test = new StaxBuilderTest(actualXmlDataDir + "missingscn.xml", service, callback);
test.processXml();
Assert.fail("Test has not detected failure on missing scn");
} catch (DatabusException e) {
LOG.info("Caught databus exception, verifying if it's for missing scn..");
String error = e.getMessage();
String expected = "Unable to find scn for the given dbUpdate, terminating the parser";
Assert.assertEquals(error, expected);
}
}
use of com.linkedin.databus2.core.DatabusException in project databus by linkedin.
the class TestParser method basicOperationsTest.
/**
* Makes sure there are no exceptions is thrown on parsing xml, verify the keys processed.
* @throws DatabusException
* @throws FileNotFoundException
*/
@Test
public void basicOperationsTest() throws Exception {
BasicOperationsCheckCallback callback = new BasicOperationsCheckCallback();
StaxBuilderTest test = new StaxBuilderTest(actualXmlDataDir + "basicprocessing.xml", service, callback);
test.processXml();
}
use of com.linkedin.databus2.core.DatabusException in project databus by linkedin.
the class BootstrapProducerCallback method onStartDataEventSequence.
@Override
public ConsumerCallbackResult onStartDataEventSequence(SCN startScn) {
_srcRm.start();
_totalNumEvents = 0;
ConsumerCallbackResult success = ConsumerCallbackResult.SUCCESS;
try {
if (_oldWindowScn == -1) {
initWindowScn();
}
} catch (SQLException e) {
if (null != _statsCollector)
_statsCollector.registerSQLException();
LOG.error("Got SQLException in startDataEventSequence Hanlder!! Connections will be reset !!", e);
try {
reset();
} catch (DatabusException e2) {
DbusPrettyLogUtils.logExceptionAtError("Unable to reset connection", e2, LOG);
} catch (SQLException sqlEx) {
DbusPrettyLogUtils.logExceptionAtError("Got exception while resetting connections. Stopping Client !!", sqlEx, LOG);
return ConsumerCallbackResult.ERROR_FATAL;
}
success = ConsumerCallbackResult.ERROR;
}
return success;
}
use of com.linkedin.databus2.core.DatabusException in project databus by linkedin.
the class BootstrapHttpServer method initializeBootstrapServerCommandProcessors.
protected void initializeBootstrapServerCommandProcessors() throws DatabusException {
LOG.info("Initializing Bootstrap HTTP Server");
LOG.info("Config=" + _bootstrapServerConfig);
try {
RequestProcessorRegistry processorRegistry = getProcessorRegistry();
processorRegistry.register(ConfigRequestProcessor.COMMAND_NAME, new ConfigRequestProcessor(null, this));
processorRegistry.register(BootstrapRequestProcessor.COMMAND_NAME, new BootstrapRequestProcessor(null, _bootstrapServerConfig, this));
processorRegistry.register(StartSCNRequestProcessor.COMMAND_NAME, new StartSCNRequestProcessor(null, _bootstrapServerConfig, this));
processorRegistry.register(TargetSCNRequestProcessor.COMMAND_NAME, new TargetSCNRequestProcessor(null, _bootstrapServerConfig, this));
processorRegistry.register(ContainerOperationProcessor.COMMAND_NAME, new ContainerOperationProcessor(null, this));
} catch (SQLException sqle) {
throw new DatabusException("command registration failed", sqle);
} catch (InstantiationException e) {
throw new DatabusException("command registration failed", e);
} catch (IllegalAccessException e) {
throw new DatabusException("command registration failed", e);
} catch (ClassNotFoundException e) {
throw new DatabusException("command registration failed", e);
}
LOG.info("Done Initializing Bootstrap HTTP Server");
}
Aggregations