Tabnine Logo
GlobalLock.release
Code IndexAdd Tabnine to your IDE (free)

How to use
release
method
in
org.killbill.commons.locker.GlobalLock

Best Java code snippets using org.killbill.commons.locker.GlobalLock.release (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-invoice

} 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-payment

} finally {
  if (lock != null) {
    lock.release();
origin: org.kill-bill.billing/killbill-payment

} finally {
  if (lock != null) {
    lock.release();
org.killbill.commons.lockerGlobalLockrelease

Popular methods of GlobalLock

    Popular in Java

    • Finding current android device location
    • getSystemService (Context)
    • addToBackStack (FragmentTransaction)
    • scheduleAtFixedRate (ScheduledExecutorService)
    • File (java.io)
      An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
    • FileWriter (java.io)
      A specialized Writer that writes to a file in the file system. All write requests made by calling me
    • Date (java.util)
      A specific moment in time, with millisecond precision. Values typically come from System#currentTime
    • TimeZone (java.util)
      TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
    • UUID (java.util)
      UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
    • SAXParseException (org.xml.sax)
      Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
    • From CI to AI: The AI layer in your organization
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

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