Skip to content

Commit

Permalink
Merge pull request #1030 from microsoft/update_backoff_message
Browse files Browse the repository at this point in the history
Update logic for logging backoff message
  • Loading branch information
littleaj authored Aug 26, 2019
2 parents 241e467 + b71aca6 commit aee547d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ public void backoff() {
* Clear the current thread state and and reset the back off counter.
*/
public void clearBackoff() {
policyState.setCurrentState(TransmissionPolicy.UNBLOCKED);
if (policyState.setCurrentState(TransmissionPolicy.UNBLOCKED)) {
InternalLogger.INSTANCE.trace("Backoff has been reset.");
}
backoffManager.onDoneSending();
// InternalLogger.INSTANCE.info("Backoff has been reset.");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@

package com.microsoft.applicationinsights.internal.channel.common;

import java.util.concurrent.atomic.AtomicReference;

/**
* Created by gupele on 6/29/2015.
*/
final class TransmissionPolicyState implements TransmissionPolicyStateFetcher, TransmissionPolicyStateSetter {
private volatile TransmissionPolicy currentState = TransmissionPolicy.UNBLOCKED;
private AtomicReference<TransmissionPolicy> currentState = new AtomicReference<>(TransmissionPolicy.UNBLOCKED);

@Override
public TransmissionPolicy getCurrentState() {
return currentState;
return currentState.get();
}

@Override
public void setCurrentState(TransmissionPolicy currentState) {
this.currentState = currentState;
public boolean setCurrentState(TransmissionPolicy newState) {
return this.currentState.getAndSet(newState) != newState;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@
* Created by gupele on 6/29/2015.
*/
interface TransmissionPolicyStateSetter {
void setCurrentState(TransmissionPolicy currentState);
/**
* Sets the current TransmissionPolicy state.
* @param newState The new value for current state
* @return true if the state changed (newState != currentState); false otherwise.
*/
boolean setCurrentState(TransmissionPolicy newState);
}

0 comments on commit aee547d

Please sign in to comment.