-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
19 changed files
with
493 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 0 additions & 103 deletions
103
clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiException.java
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
...iasearch-client-java-2/algoliasearch-core/com/algolia/exceptions/AlgoliaApiException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.algolia.exceptions; | ||
|
||
/** Exception thrown in case of API failure such as 4XX, 5XX error. */ | ||
public class AlgoliaApiException extends AlgoliaRuntimeException { | ||
|
||
public int getHttpErrorCode() { | ||
return httpErrorCode; | ||
} | ||
|
||
private final int httpErrorCode; | ||
|
||
public AlgoliaApiException( | ||
String message, | ||
Throwable cause, | ||
int httpErrorCode | ||
) { | ||
super(message, cause); | ||
this.httpErrorCode = httpErrorCode; | ||
} | ||
|
||
public AlgoliaApiException(String message, int httpErrorCode) { | ||
super(message); | ||
this.httpErrorCode = httpErrorCode; | ||
} | ||
|
||
public AlgoliaApiException(Throwable cause, int httpErrorCode) { | ||
super(cause); | ||
this.httpErrorCode = httpErrorCode; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...search-client-java-2/algoliasearch-core/com/algolia/exceptions/AlgoliaRetryException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.algolia.exceptions; | ||
|
||
/** | ||
* Exception thrown when an error occurs during the retry strategy. For example: All hosts are | ||
* unreachable. | ||
*/ | ||
public class AlgoliaRetryException extends AlgoliaRuntimeException { | ||
|
||
public AlgoliaRetryException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public AlgoliaRetryException(String message) { | ||
super(message); | ||
} | ||
|
||
public AlgoliaRetryException(Throwable cause) { | ||
super(cause); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...arch-client-java-2/algoliasearch-core/com/algolia/exceptions/AlgoliaRuntimeException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.algolia.exceptions; | ||
|
||
/** Exception thrown when an error occurs during the Serialization/Deserialization process */ | ||
public class AlgoliaRuntimeException extends RuntimeException { | ||
|
||
public AlgoliaRuntimeException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public AlgoliaRuntimeException(String message) { | ||
super(message); | ||
} | ||
|
||
public AlgoliaRuntimeException(Throwable cause) { | ||
super(cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/Requester.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/Utils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.algolia.utils; | ||
|
||
import java.time.Clock; | ||
import java.time.Instant; | ||
import java.time.OffsetDateTime; | ||
import java.time.ZoneOffset; | ||
import java.time.zone.ZoneRules; | ||
|
||
public class Utils { | ||
|
||
private static final ZoneRules ZONE_RULES_UTC = ZoneOffset.UTC.getRules(); | ||
|
||
/** | ||
* Memory optimization for getZoneRules with the same ZoneOffset (UTC). ZoneRules is immutable and | ||
* threadsafe, but getRules method consumes a lot of memory during load testing. | ||
*/ | ||
public static OffsetDateTime nowUTC() { | ||
final Instant now = Clock.system(ZoneOffset.UTC).instant(); | ||
return OffsetDateTime.ofInstant(now, ZONE_RULES_UTC.getOffset(now)); | ||
} | ||
} |
30 changes: 21 additions & 9 deletions
30
.../algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/echo/EchoRequester.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,46 @@ | ||
package com.algolia.utils.echo; | ||
|
||
import com.algolia.ApiException; | ||
import com.algolia.utils.Requester; | ||
import okhttp3.Request; | ||
|
||
public class EchoRequester implements Requester { | ||
|
||
public CallEcho newCall(Request request) throws ApiException { | ||
private int connectionTimeout, readTimeout, writeTimeout; | ||
|
||
public EchoRequester() { | ||
this.connectionTimeout = 100; | ||
this.readTimeout = 100; | ||
this.writeTimeout = 100; | ||
} | ||
|
||
public CallEcho newCall(Request request) { | ||
return new CallEcho(request); | ||
} | ||
|
||
// NO-OP for now | ||
|
||
public void setDebugging(boolean debugging) {} | ||
|
||
public int getConnectTimeout() { | ||
return 100; | ||
return this.connectionTimeout; | ||
} | ||
|
||
public void setConnectTimeout(int connectionTimeout) {} | ||
public void setConnectTimeout(int connectionTimeout) { | ||
this.connectionTimeout = connectionTimeout; | ||
} | ||
|
||
public int getReadTimeout() { | ||
return 100; | ||
return this.readTimeout; | ||
} | ||
|
||
public void setReadTimeout(int readTimeout) {} | ||
public void setReadTimeout(int readTimeout) { | ||
this.readTimeout = readTimeout; | ||
} | ||
|
||
public int getWriteTimeout() { | ||
return 100; | ||
return this.writeTimeout; | ||
} | ||
|
||
public void setWriteTimeout(int writeTimeout) {} | ||
public void setWriteTimeout(int writeTimeout) { | ||
this.writeTimeout = writeTimeout; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/retry/CallType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.algolia.utils.retry; | ||
|
||
public enum CallType { | ||
READ, | ||
WRITE, | ||
} |
7 changes: 7 additions & 0 deletions
7
.../algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/retry/RetryOutcome.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.algolia.utils.retry; | ||
|
||
public enum RetryOutcome { | ||
SUCCESS, | ||
RETRY, | ||
FAILURE, | ||
} |
Oops, something went wrong.