Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 4.7.0 update #186

Merged
merged 37 commits into from
May 3, 2016
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
49fbc0d
Read abi and display
nonelse Mar 10, 2016
3f648c8
Add service examples
nonelse Mar 16, 2016
51720cd
Rename session timer to foreground
nonelse Mar 18, 2016
4aa185a
Send in the background
nonelse Mar 18, 2016
9e3d8a5
Add deeplink listener
nonelse Mar 22, 2016
d23f810
Prevent sdk start due to offline or disable
nonelse Mar 22, 2016
ed74f9d
Update ActivityHandler.java
esamcgv Mar 23, 2016
22effd2
Refactor internal state
nonelse Mar 22, 2016
6b04219
Read files in constructor
nonelse Mar 22, 2016
d15dbd0
Send reftag and deeplink always
nonelse Mar 22, 2016
8cdc3b7
Refactor timer and logs
nonelse Mar 31, 2016
ab223e5
Sdk click handler
nonelse Mar 31, 2016
2b0dcd8
Send queue size
nonelse Mar 31, 2016
395aa60
Add exponential backoff and jitter
nonelse Mar 31, 2016
43f7604
Replace custom inner Thread classes
nonelse Apr 1, 2016
37ea556
Send_at in attribution request
nonelse Apr 4, 2016
0354ad3
Refactor activity timers
nonelse Apr 6, 2016
2c09f2c
Send parameter if buffering is enabled
nonelse Apr 6, 2016
9f01faa
Refactor Boolean
nonelse Apr 6, 2016
fea4c1f
Update handler status and send
nonelse Apr 6, 2016
fa08a61
Reorder timer init
nonelse Apr 11, 2016
40cf37c
Update handler status and resume
nonelse Apr 11, 2016
6ff7223
Decimal format for seconds display
nonelse Apr 18, 2016
9e66481
Refac init
nonelse Apr 26, 2016
2358e4e
Move state check of track event
nonelse Apr 26, 2016
c62e9a8
Log and comment refac
nonelse Apr 26, 2016
0b5b51a
Update README.md
nonelse Apr 29, 2016
894168a
Update Play services version
nonelse Apr 29, 2016
b587336
Edit example app
nonelse Apr 29, 2016
4f3c4d6
Refac launch deeplink
nonelse May 2, 2016
bcc93ec
Refac waiting time
nonelse May 2, 2016
8c5b716
Stop and start timers in background
nonelse May 2, 2016
973b4b6
Delay max wait time click handler
nonelse May 2, 2016
abb93df
Update libraries
nonelse May 3, 2016
0597803
Adjust enable/disable button text in onResume
May 3, 2016
f68a42f
Update tests
nonelse Apr 12, 2016
4ac574c
New version v4.7.0
nonelse May 3, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refac waiting time
nonelse committed May 3, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit bcc93ec8866344f0d97d7a73c5fbaed2a6a2984b
32 changes: 16 additions & 16 deletions Adjust/adjust/src/main/java/com/adjust/sdk/BackoffStrategy.java
Original file line number Diff line number Diff line change
@@ -7,43 +7,43 @@ public enum BackoffStrategy {
LONG_WAIT(1, // min retries
2 * Constants.ONE_MINUTE, // milliseconds multiplier
24 * Constants.ONE_HOUR, // max wait time
50, // min jitter multiplier
100), // max jitter multiplier
0.5, // min jitter multiplier
1.0), // max jitter multiplier

// 0.1-0.2, 0.2-0.4, 0.4-0.8, ... 1m
// 0.1-0.2, 0.2-0.4, 0.4-0.8, ... 1h
SHORT_WAIT(1, // min retries
200, // milliseconds multiplier
Constants.ONE_MINUTE, // max wait time
50, // min jitter multiplier
100), // max jitter multiplier
0.5, // min jitter multiplier
1.0), // max jitter multiplier

TEST_WAIT(1, // min retries
200, // milliseconds multiplier
1000, // max wait time
50, // min jitter multiplier
100), // max jitter multiplier
0.5, // min jitter multiplier
1.0), // max jitter multiplier

NO_WAIT(100, // min retries
1, // milliseconds multiplier
Constants.ONE_SECOND, // max wait time
1, // min jitter multiplier
1); // max jitter multiplier
1.0, // min jitter multiplier
1.0); // max jitter multiplier

int minRetries;
int minRetries; // retries before starting backoff
long milliSecondMultiplier;
long maxWait;
int minJitter;
int maxJitter;
double minRange;
double maxRange;

BackoffStrategy(int minRetries,
long milliSecondMultiplier,
long maxWait,
int minJitter,
int maxJitter) {
double minRange,
double maxRange) {
this.minRetries = minRetries;
this.milliSecondMultiplier = milliSecondMultiplier;
this.maxWait = maxWait;
this.minJitter = minJitter;
this.maxJitter = maxJitter;
this.minRange = minRange;
this.maxRange = maxRange;
}
}
25 changes: 15 additions & 10 deletions Adjust/adjust/src/main/java/com/adjust/sdk/Util.java
Original file line number Diff line number Diff line change
@@ -527,19 +527,24 @@ public static long getWaitingTime(int retries, BackoffStrategy backoffStrategy)
if (retries < backoffStrategy.minRetries) {
return 0;
}
// start with base 0
int base = retries - backoffStrategy.minRetries;
// get the exponential Time from the base: 1, 2, 4, 8, 16, ... * times the multiplier
long exponentialTime = (((long) Math.pow(2, base)) * backoffStrategy.milliSecondMultiplier);
// start with expon 0
int expon = retries - backoffStrategy.minRetries;
// get the exponential Time from the power of 2: 1, 2, 4, 8, 16, ... * times the multiplier
long exponentialTime = ((long) Math.pow(2, expon)) * backoffStrategy.milliSecondMultiplier;
// limit the maximum allowed time to wait
long ceilingTime = Math.min(exponentialTime, backoffStrategy.maxWait);
Random random = new Random();
// add 1 to allow maximum value
int jitterFactorBase = random.nextInt(backoffStrategy.maxJitter - backoffStrategy.minJitter + 1);
int jitterFactorAdjusted = jitterFactorBase + backoffStrategy.minJitter;
double jitterFactor = jitterFactorAdjusted / 100.0;
// get the random range
double randomDouble = randomInRange(backoffStrategy.minRange, backoffStrategy.maxRange);
// apply jitter factor
double waitingTime = ceilingTime * jitterFactor;
double waitingTime = ceilingTime * randomDouble;
return (long)waitingTime;
}

private static double randomInRange(double minRange, double maxRange) {
Random random = new Random();
double range = maxRange - minRange;
double scaled = random.nextDouble() * range;
double shifted = scaled + minRange;
return shifted;
}
}