-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* App_Resiliency_Changes. * Calculate limit one time,TooManyTasks update, renaming . * Concurrency Changes . * Concurrency Changes. * Comment principal name logic. * Concurrency Issue Optimistic Locking & Init Changes. * Fix internal task issue. * maxPctParallelRequestsPerActor to 25. * Review Comments Fix. * Correct Function Description. * Long to long. * Fix QueryTask Add Context. * Review Comments Code Fix.
- Loading branch information
Showing
15 changed files
with
350 additions
and
56 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
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
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
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
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
79 changes: 79 additions & 0 deletions
79
here-naksha-lib-core/src/main/java/com/here/naksha/lib/core/DefaultRequestLimitManager.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,79 @@ | ||
/* | ||
* Copyright (C) 2017-2023 HERE Europe B.V. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* License-Filename: LICENSE | ||
*/ | ||
package com.here.naksha.lib.core; | ||
/** | ||
* The DefaultRequestLimitManager class is an implementation of the IRequestLimitManager interface | ||
* providing default behavior for retrieving request limits. | ||
*/ | ||
public class DefaultRequestLimitManager implements IRequestLimitManager { | ||
private final long instanceLevelLimit; | ||
private final double actorLimitPct; | ||
|
||
/** | ||
* Retrieves the number of available processors. | ||
* | ||
* @return The number of available processors. | ||
*/ | ||
private static long getAvailableProcessors() { | ||
return Runtime.getRuntime().availableProcessors(); | ||
} | ||
|
||
/** | ||
* Constructs a DefaultRequestLimitManager instance with default values. | ||
* The instance-level limit is calculated based on the available processors. | ||
* This function is useful where Hub is not involved | ||
*/ | ||
public DefaultRequestLimitManager() { | ||
this.instanceLevelLimit = 30L * getAvailableProcessors(); | ||
this.actorLimitPct = 25; // 25% | ||
} | ||
|
||
/** | ||
* Constructs a DefaultRequestLimitManager instance with custom values. | ||
* | ||
* @param cpuLevelLimit The limit per CPU level. | ||
* @param actorLimitPct The percentage of actor limit. | ||
*/ | ||
public DefaultRequestLimitManager(int cpuLevelLimit, int actorLimitPct) { | ||
this.instanceLevelLimit = cpuLevelLimit * getAvailableProcessors(); | ||
this.actorLimitPct = actorLimitPct; | ||
} | ||
|
||
/** | ||
* Retrieves the instance-level request limit. | ||
* | ||
* @return The instance-level request limit. | ||
*/ | ||
@Override | ||
public long getInstanceLevelLimit() { | ||
return instanceLevelLimit; | ||
} | ||
|
||
/** | ||
* Retrieves the request limit for a specific actor within the given context. | ||
* The actor-level limit is calculated as a percentage of the instance-level limit. | ||
* | ||
* @param context The NakshaContext representing the context in which the actor operates. | ||
* @return The request limit for the actor within the given context. | ||
*/ | ||
@Override | ||
public long getActorLevelLimit(NakshaContext context) { | ||
return (long) ((instanceLevelLimit * actorLimitPct) / 100); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
here-naksha-lib-core/src/main/java/com/here/naksha/lib/core/IRequestLimitManager.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,39 @@ | ||
/* | ||
* Copyright (C) 2017-2023 HERE Europe B.V. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* License-Filename: LICENSE | ||
*/ | ||
package com.here.naksha.lib.core; | ||
|
||
/** | ||
* The IRequestLimitManager interface defines methods for retrieving request limits | ||
* at different levels - instance level and actor level. | ||
*/ | ||
public interface IRequestLimitManager { | ||
/** | ||
* Retrieves the instance-level request limit. | ||
* | ||
* @return The instance-level request limit. | ||
*/ | ||
long getInstanceLevelLimit(); | ||
/** | ||
* Retrieves the request limit for a specific actor within the given context. | ||
* | ||
* @param context The NakshaContext representing the context in which the actor operates. | ||
* @return The request limit for the actor within the given context. | ||
*/ | ||
long getActorLevelLimit(NakshaContext context); | ||
} |
Oops, something went wrong.