@Override public void run() throws Exception { LOG.info("Validating transaction service configuration."); int defaultTxTimeout = getConfiguredInteger(TxConstants.Manager.CFG_TX_TIMEOUT, "Default transaction timeout"); int maxTxTimeout = getConfiguredInteger(TxConstants.Manager.CFG_TX_MAX_TIMEOUT, "Transaction timeout limit"); if (defaultTxTimeout > maxTxTimeout) { throw new IllegalArgumentException(String.format( "Default transaction timeout (%s) of %d seconds must not exceed the transaction timeout limit (%s) of %d", TxConstants.Manager.CFG_TX_TIMEOUT, defaultTxTimeout, TxConstants.Manager.CFG_TX_MAX_TIMEOUT, maxTxTimeout)); } LOG.info("Transaction service configuration successfully validated."); }
@Override public void run() throws Exception { LOG.info("Validating transaction service configuration."); int defaultTxTimeout = getConfiguredInteger(TxConstants.Manager.CFG_TX_TIMEOUT, "Default transaction timeout"); int maxTxTimeout = getConfiguredInteger(TxConstants.Manager.CFG_TX_MAX_TIMEOUT, "Transaction timeout limit"); if (defaultTxTimeout > maxTxTimeout) { throw new IllegalArgumentException(String.format( "Default transaction timeout (%s) of %d seconds must not exceed the transaction timeout limit (%s) of %d", TxConstants.Manager.CFG_TX_TIMEOUT, defaultTxTimeout, TxConstants.Manager.CFG_TX_MAX_TIMEOUT, maxTxTimeout)); } LOG.info("Transaction service configuration successfully validated."); }
private int getConfiguredInteger(String propertyName, String description) { try { return getConfiguredInteger(propertyName); } catch (NullPointerException e) { throw new IllegalArgumentException(String.format("%s (%s) is not configured.", description, propertyName)); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("%s (%s) is not a number.", description, propertyName), e); } }
private int getConfiguredInteger(String propertyName, String description) { try { return getConfiguredInteger(propertyName); } catch (NullPointerException e) { throw new IllegalArgumentException(String.format("%s (%s) is not configured.", description, propertyName)); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("%s (%s) is not a number.", description, propertyName), e); } }