@Inject public BackgroundDBChunkWriter(final TimelineDao timelineDAO, final MeterConfig config, final InternalCallContextFactory internalCallContextFactory) { this(timelineDAO, config, config.getPerformForegroundWrites(), internalCallContextFactory); }
@Inject public DefaultPaymentProviderPluginRegistry(final PaymentConfig config) { this.defaultPlugin = config.getDefaultPaymentProvider(); }
private DateTime getNextRetryDate(final int retryAttempt) { if (retryAttempt > config.getPluginFailureRetryMaxAttempts()) { return null; } int nbSec = config.getPluginFailureRetryStart(); int remainingAttempts = retryAttempt; while (--remainingAttempts > 0) { nbSec = nbSec * config.getPluginFailureRetryMultiplier(); } return clock.getUTCNow().plusSeconds(nbSec); } }
private int getMaxRetrySizeForFailureType(final FailureType failureType) { if (failureType == FailureType.PAYMENT_FAILURE) { return paymentConfig.getPaymentRetryDays().size(); } else { return paymentConfig.getPluginFailureRetryMaxAttempts(); } } }
@Test(groups = "fast") public void testFailedPaymentWithLastRetrySuccess() throws Exception { testSchedulesRetryInternal(paymentConfig.getPaymentRetryDays().size(), FailureType.PAYMENT_FAILURE); }
@Test(groups = "fast") public void testFailedPpluginWithLastRetrySuccess() throws Exception { testSchedulesRetryInternal(paymentConfig.getPluginFailureRetryMaxAttempts(), FailureType.PLUGIN_EXCEPTION); }
private synchronized void purgeFilesAndAccumulators(final DateTime purgeAccumulatorsIfBefore, final DateTime purgeFilesIfBefore) { purgeOldSourcesAndAccumulators(purgeAccumulatorsIfBefore); final Replayer replayer = new Replayer(config.getSpoolDir()); replayer.purgeOldFiles(purgeFilesIfBefore); }
public void startPurgeThread() { purgeThread.scheduleWithFixedDelay(new Runnable() { @Override public void run() { purgeFilesAndAccumulators(); } }, config.getTimelineLength().getMillis(), config.getTimelineLength().getMillis(), TimeUnit.MILLISECONDS); }
private void discardBackingBuffer() { if (config.storeSamplesLocallyTemporary()) { backingBuffer.discard(); } }
@Inject public TimelineEventHandler(final MeterConfig config, final TimelineDao timelineDAO, final TimelineCoder timelineCoder, final SampleCoder sampleCoder, final BackgroundDBChunkWriter backgroundWriter, final FileBackedBuffer fileBackedBuffer) { this.config = config; this.timelineDAO = timelineDAO; this.timelineCoder = timelineCoder; this.sampleCoder = sampleCoder; this.backgroundWriter = backgroundWriter; this.backingBuffer = fileBackedBuffer; this.shutdownSaveMode = ShutdownSaveMode.fromString(config.getShutdownSaveMode()); }
public void runAggregationThread() { aggregatorThread.scheduleWithFixedDelay(new Runnable() { @Override public void run() { getAndProcessTimelineAggregationCandidates(); } }, config.getAggregationInterval().getMillis(), config.getAggregationInterval().getMillis(), TimeUnit.MILLISECONDS); }
public void runBackgroundWriteThread() { if (!performForegroundWrites) { backgroundWriteThread.scheduleWithFixedDelay(new Runnable() { @Override public void run() { maybePerformBackgroundWrites(); } }, config.getBackgroundWriteCheckInterval().getMillis(), config.getBackgroundWriteCheckInterval().getMillis(), TimeUnit.MILLISECONDS); } }
@Override public IniRealm get() { try { return new IniRealm(securityConfig.getShiroResourcePath()); } catch (ConfigurationException e) { log.warn("Unable to configure RBAC", e); return new IniRealm(); } } }
protected void installInvoiceNotifier() { if (config.isEmailNotificationsEnabled()) { bind(InvoiceNotifier.class).to(EmailInvoiceNotifier.class).asEagerSingleton(); } else { bind(InvoiceNotifier.class).to(NullInvoiceNotifier.class).asEagerSingleton(); } }
@LifecycleHandlerType(LifecycleLevel.LOAD_CATALOG) public synchronized void loadCatalog() throws ServiceException { if (!isInitialized) { try { final String url = config.getCatalogURI(); catalog = loader.load(url); isInitialized = true; } catch (Exception e) { throw new ServiceException(e); } } }
@Override public JDBCSessionDao get() { final JDBCSessionDao jdbcSessionDao = new JDBCSessionDao(dbi); if (sessionManager instanceof DefaultSessionManager) { final DefaultSessionManager defaultSessionManager = (DefaultSessionManager) sessionManager; defaultSessionManager.setSessionDAO(jdbcSessionDao); defaultSessionManager.setGlobalSessionTimeout(rbacConfig.getGlobalSessionTimeout().getMillis()); } return jdbcSessionDao; } }
@Test(groups = "fast") public void testAbortedPayment() throws Exception { testSchedulesRetryInternal(paymentConfig.getPaymentRetryDays().size() + 1, FailureType.PAYMENT_FAILURE); }
@Test(groups = "fast") public void testAbortedPlugin() throws Exception { testSchedulesRetryInternal(paymentConfig.getPluginFailureRetryMaxAttempts() + 1, FailureType.PLUGIN_EXCEPTION); }
public TimelineSourceEventAccumulator getOrAddSourceEventAccumulator(final int sourceId, final int categoryId, final DateTime firstSampleTime) { return this.getOrAddSourceEventAccumulator(sourceId, categoryId, firstSampleTime, (int) config.getTimelineLength().getMillis()); }
private void moveClockForFailureType(final FailureType failureType, final int curFailure) { if (failureType == FailureType.PAYMENT_FAILURE) { final int nbDays = paymentConfig.getPaymentRetryDays().get(curFailure); clock.addDays(nbDays + 1); } else { clock.addDays(1); } }