congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
GlobalLocker.lockWithNumberOfTries
Code IndexAdd Tabnine to your IDE (free)

How to use
lockWithNumberOfTries
method
in
org.killbill.commons.locker.GlobalLocker

Best Java code snippets using org.killbill.commons.locker.GlobalLocker.lockWithNumberOfTries (Showing top 13 results out of 315)

origin: killbill/killbill

public void clear(final DateTime effectiveDate, final InternalCallContext context) throws OverdueException, OverdueApiException {
  GlobalLock lock = null;
  try {
    lock = locker.lockWithNumberOfTries(LockerType.ACCNT_INV_PAY.toString(), overdueable.getId().toString(), MAX_LOCK_RETRIES);
    clearWithLock(effectiveDate, context);
  } catch (final LockFailedException e) {
    log.warn("Failed to clear overdue for accountId='{}'", overdueable.getId(), e);
  } finally {
    if (lock != null) {
      lock.release();
    }
  }
}
origin: killbill/killbill

public OverdueState refresh(final DateTime effectiveDate, final InternalCallContext context) throws OverdueException, OverdueApiException {
  if (overdueStateSet.size() < 1) { // No configuration available
    return overdueStateSet.getClearState();
  }
  GlobalLock lock = null;
  try {
    lock = locker.lockWithNumberOfTries(LockerType.ACCNT_INV_PAY.toString(), overdueable.getId().toString(), MAX_LOCK_RETRIES);
    return refreshWithLock(effectiveDate, context);
  } catch (final LockFailedException e) {
    log.warn("Failed to process overdue for accountId='{}'", overdueable.getId(), e);
  } finally {
    if (lock != null) {
      lock.release();
    }
  }
  return null;
}
origin: killbill/killbill

  @Test(groups = "slow")
  public void testSimpleLocking() throws IOException, LockFailedException {
    final String lockName = UUID.randomUUID().toString();

    final GlobalLock lock = locker.lockWithNumberOfTries(LockerType.ACCNT_INV_PAY.toString(), lockName, 3);

    dbi.inTransaction(new TransactionCallback<Void>() {
      @Override
      public Void inTransaction(final Handle conn, final TransactionStatus status)
          throws Exception {
        conn.execute("insert into dummy2 (dummy_id) values ('" + UUID.randomUUID().toString() + "')");
        return null;
      }
    });
    Assert.assertEquals(locker.isFree(LockerType.ACCNT_INV_PAY.toString(), lockName), false);

    boolean gotException = false;
    try {
      locker.lockWithNumberOfTries(LockerType.ACCNT_INV_PAY.toString(), lockName, 1);
    } catch (LockFailedException e) {
      gotException = true;
    }
    Assert.assertTrue(gotException);

    lock.release();

    Assert.assertEquals(locker.isFree(LockerType.ACCNT_INV_PAY.toString(), lockName), true);
  }
}
origin: org.kill-bill.billing/killbill-invoice

public Invoice processAccount(final boolean isApiCall,
               final UUID accountId,
               @Nullable final LocalDate targetDate,
               @Nullable final DryRunArguments dryRunArguments,
               final boolean isRescheduled,
               final InternalCallContext context) throws InvoiceApiException {
  boolean parkedAccount = false;
  try {
    parkedAccount = parkedAccountsManager.isParked(context);
    if (parkedAccount && !isApiCall) {
      log.warn("Ignoring invoice generation process for accountId='{}', targetDate='{}', account is parked", accountId.toString(), targetDate);
      return null;
    }
  } catch (final TagApiException e) {
    log.warn("Unable to determine parking state for accountId='{}'", accountId);
  }
  GlobalLock lock = null;
  try {
    lock = locker.lockWithNumberOfTries(LockerType.ACCNT_INV_PAY.toString(), accountId.toString(), invoiceConfig.getMaxGlobalLockRetries());
    return processAccountWithLock(parkedAccount, accountId, targetDate, dryRunArguments, isRescheduled, context);
  } catch (final LockFailedException e) {
    log.warn("Failed to process invoice for accountId='{}', targetDate='{}'", accountId.toString(), targetDate, e);
  } finally {
    if (lock != null) {
      lock.release();
    }
  }
  return null;
}
origin: org.kill-bill.billing/killbill-overdue

public void clear(final DateTime effectiveDate, final InternalCallContext context) throws OverdueException, OverdueApiException {
  GlobalLock lock = null;
  try {
    lock = locker.lockWithNumberOfTries(LockerType.ACCNT_INV_PAY.toString(), overdueable.getId().toString(), MAX_LOCK_RETRIES);
    clearWithLock(effectiveDate, context);
  } catch (final LockFailedException e) {
    log.warn("Failed to clear overdue for accountId='{}'", overdueable.getId(), e);
  } finally {
    if (lock != null) {
      lock.release();
    }
  }
}
origin: org.kill-bill.billing/killbill-invoice

public void processParentInvoiceForAdjustments(final Account childAccount, final UUID childInvoiceId, final InternalCallContext context) throws InvoiceApiException {
  GlobalLock lock = null;
  try {
    lock = locker.lockWithNumberOfTries(LockerType.ACCNT_INV_PAY.toString(), childAccount.getParentAccountId().toString(), invoiceConfig.getMaxGlobalLockRetries());
    processParentInvoiceForAdjustmentsWithLock(childAccount, childInvoiceId, context);
  } catch (final LockFailedException e) {
    log.warn("Failed to process parent invoice for parentAccountId='{}'", childAccount.getParentAccountId().toString(), e);
  } finally {
    if (lock != null) {
      lock.release();
    }
  }
}
origin: org.kill-bill.billing/killbill-invoice

public void processParentInvoiceForInvoiceGeneration(final Account childAccount, final UUID childInvoiceId, final InternalCallContext context) throws InvoiceApiException {
  GlobalLock lock = null;
  try {
    lock = locker.lockWithNumberOfTries(LockerType.ACCNT_INV_PAY.toString(), childAccount.getParentAccountId().toString(), invoiceConfig.getMaxGlobalLockRetries());
    processParentInvoiceForInvoiceGenerationWithLock(childAccount, childInvoiceId, context);
  } catch (final LockFailedException e) {
    log.warn("Failed to process parent invoice for parentAccountId='{}'", childAccount.getParentAccountId().toString(), e);
  } finally {
    if (lock != null) {
      lock.release();
    }
  }
}
origin: org.kill-bill.billing/killbill-overdue

public OverdueState refresh(final DateTime effectiveDate, final InternalCallContext context) throws OverdueException, OverdueApiException {
  if (overdueStateSet.size() < 1) { // No configuration available
    return overdueStateSet.getClearState();
  }
  GlobalLock lock = null;
  try {
    lock = locker.lockWithNumberOfTries(LockerType.ACCNT_INV_PAY.toString(), overdueable.getId().toString(), MAX_LOCK_RETRIES);
    return refreshWithLock(effectiveDate, context);
  } catch (final LockFailedException e) {
    log.warn("Failed to process overdue for accountId='{}'", overdueable.getId(), e);
  } finally {
    if (lock != null) {
      lock.release();
    }
  }
  return null;
}
origin: org.kill-bill.billing/killbill-invoice

public void processSubscriptionStartRequestedDate(final RequestedSubscriptionInternalEvent transition, final InternalCallContext context) {
  final long dryRunNotificationTime = invoiceConfig.getDryRunNotificationSchedule(context).getMillis();
  final boolean isInvoiceNotificationEnabled = dryRunNotificationTime > 0;
  if (!isInvoiceNotificationEnabled) {
    return;
  }
  final UUID accountId;
  try {
    accountId = subscriptionApi.getAccountIdFromSubscriptionId(transition.getSubscriptionId(), context);
  } catch (final SubscriptionBaseApiException e) {
    log.warn("Failed handling SubscriptionBase change.",
         new InvoiceApiException(ErrorCode.INVOICE_NO_ACCOUNT_ID_FOR_SUBSCRIPTION_ID, transition.getSubscriptionId().toString()));
    return;
  }
  GlobalLock lock = null;
  try {
    lock = locker.lockWithNumberOfTries(LockerType.ACCNT_INV_PAY.toString(), accountId.toString(), invoiceConfig.getMaxGlobalLockRetries());
    processSubscriptionStartRequestedDateWithLock(accountId, transition, context);
  } catch (final LockFailedException e) {
    log.warn("Failed to process RequestedSubscriptionInternalEvent for accountId='{}'", accountId.toString(), e);
  } finally {
    if (lock != null) {
      lock.release();
    }
  }
}
origin: org.kill-bill.billing/killbill-util

  @Test(groups = "slow")
  public void testSimpleLocking() throws IOException, LockFailedException {
    final String lockName = UUID.randomUUID().toString();

    final GlobalLock lock = locker.lockWithNumberOfTries(LockerType.ACCNT_INV_PAY.toString(), lockName, 3);

    dbi.inTransaction(new TransactionCallback<Void>() {
      @Override
      public Void inTransaction(final Handle conn, final TransactionStatus status)
          throws Exception {
        conn.execute("insert into dummy2 (dummy_id) values ('" + UUID.randomUUID().toString() + "')");
        return null;
      }
    });
    Assert.assertEquals(locker.isFree(LockerType.ACCNT_INV_PAY.toString(), lockName), false);

    boolean gotException = false;
    try {
      locker.lockWithNumberOfTries(LockerType.ACCNT_INV_PAY.toString(), lockName, 1);
    } catch (LockFailedException e) {
      gotException = true;
    }
    Assert.assertTrue(gotException);

    lock.release();

    Assert.assertEquals(locker.isFree(LockerType.ACCNT_INV_PAY.toString(), lockName), true);
  }
}
origin: org.kill-bill.billing/killbill-invoice

Iterable<DefaultInvoice> invoicesForPlugins = null;
try {
  lock = locker.lockWithNumberOfTries(LockerType.ACCNT_INV_PAY.toString(), accountId.toString(), invoiceConfig.getMaxGlobalLockRetries());
origin: org.kill-bill.billing/killbill-payment

lock = locker.lockWithNumberOfTries(LockerType.ACCNT_INV_PAY.toString(), account.getId().toString(), paymentConfig.getMaxGlobalLockRetries());
origin: org.kill-bill.billing/killbill-payment

try {
  lock = locker.lockWithNumberOfTries(LockerType.ACCNT_INV_PAY.toString(), account.getId().toString(), 1);
org.killbill.commons.lockerGlobalLockerlockWithNumberOfTries

Popular methods of GlobalLocker

  • isFree

Popular in Java

  • Running tasks concurrently on multiple threads
  • setContentView (Activity)
  • onRequestPermissionsResult (Fragment)
  • putExtra (Intent)
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Permission (java.security)
    Legacy security code; do not use.
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • JOptionPane (javax.swing)
  • Top 17 Plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now