├── .gitignore
├── .mvn
└── maven.config
├── LICENSE
├── Readme.md
├── actor4j-core-runtime-base
├── .gitignore
├── LICENSE
├── pom.xml
└── src
│ └── main
│ └── java
│ └── io
│ └── actor4j
│ └── core
│ └── runtime
│ ├── AbstractActorExecutionUnitPool.java
│ ├── AbstractActorExecutionUnitPoolHandler.java
│ ├── ActorExecutionUnit.java
│ ├── ActorExecutionUnitPool.java
│ ├── ActorExecutionUnitPoolHandler.java
│ ├── ActorExecutorServiceImpl.java
│ ├── ActorSystemImpl.java
│ ├── ActorTimerExecutorService.java
│ ├── BaseActorCell.java
│ ├── BaseActorMessageDispatcher.java
│ ├── DefaultActorExecutionUnitPoolHandler.java
│ ├── DefaultActorStrategyOnFailure.java
│ ├── DefaultPodReplicationControllerRunnable.java
│ ├── DefaultThreadFactory.java
│ ├── DefaultWatchdogRunnable.java
│ ├── InternalActorExecutorService.java
│ ├── InternalActorRuntimeSystem.java
│ ├── PodActorCell.java
│ ├── PseudoActorCell.java
│ ├── ResourceActorCell.java
│ ├── annotations
│ └── concurrent
│ │ ├── Readonly.java
│ │ ├── ThreadLocalAccess.java
│ │ └── ThreadSafeAccess.java
│ ├── balancing
│ ├── ActorLoadBalancingAfterStart.java
│ └── ActorLoadBalancingBeforeStart.java
│ ├── persistence
│ └── ActorPersistenceServiceImpl.java
│ ├── pods
│ ├── DefaultPodReplicationController.java
│ └── PodDeployment.java
│ ├── protocols
│ ├── RecoverProtocol.java
│ ├── RestartProtocol.java
│ ├── StopProtocol.java
│ └── StopUserSpaceProtocol.java
│ └── utils
│ └── ProcessingTimeStatistics.java
├── actor4j-core-runtime-classic
├── .gitignore
├── LICENSE
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── io
│ │ └── actor4j
│ │ └── core
│ │ ├── ActorRuntime.java
│ │ ├── ActorServiceRuntime.java
│ │ ├── ClassicActorRuntime.java
│ │ ├── ClassicActorServiceRuntime.java
│ │ └── runtime
│ │ └── classic
│ │ ├── ActorMessageDispatcherCallback.java
│ │ ├── ActorRunnable.java
│ │ ├── ActorRunnableMetrics.java
│ │ ├── ActorRunnablePool.java
│ │ ├── ClassicActorCell.java
│ │ ├── ClassicDefaultActorExecutorService.java
│ │ ├── ClassicDefaultActorMessageDispatcher.java
│ │ ├── ClassicDefaultActorSystemImpl.java
│ │ ├── ClassicInternalActorCell.java
│ │ ├── ClassicInternalActorExecutorService.java
│ │ ├── ClassicPodActorCell.java
│ │ ├── DefaultActorRunnable.java
│ │ └── utils
│ │ └── ClassicForkJoinWorkerThread.java
│ └── test
│ └── java
│ └── io
│ └── actor4j
│ └── core
│ └── features
│ ├── ActorFeature.java
│ ├── ActorGroupMemberFeature.java
│ ├── AllFeaturesTest.java
│ ├── AskPatternFeature.java
│ ├── AwaitFeature.java
│ ├── BehaviourFeature.java
│ ├── CacheFeature.java
│ ├── CacheHandlerFeature.java
│ ├── CommPatternFeature.java
│ ├── ConcurrentPseudoActorFeature.java
│ ├── ConfigFeature.java
│ ├── EmbeddedActorFeature.java
│ ├── FaultToleranceFeature.java
│ ├── HandlerFeature.java
│ ├── LifeCycleFeature.java
│ ├── MatcherFeature.java
│ ├── OptionalFeature.java
│ ├── PodFeature.java
│ ├── PrimarySecondaryActorFeature.java
│ ├── PseudoActorFeature.java
│ ├── ResourceActorFeature.java
│ ├── ServiceDiscoveyFeature.java
│ ├── StatelessActorFeature.java
│ └── pod
│ ├── ExampleReplicationWithActorPod.java
│ ├── ExampleReplicationWithFunctionPod.java
│ ├── ExampleReplicationWithRemoteActorPodWithRequest.java
│ ├── ExampleReplicationWithRemoteFunctionImpl.java
│ ├── ExampleReplicationWithRemoteFunctionPod.java
│ ├── ExampleShardingWithActorPod.java
│ └── HelloActor.java
├── actor4j-core-runtime-extended
├── .gitignore
├── LICENSE
├── doc
│ └── Readme.txt
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── io
│ │ └── actor4j
│ │ └── core
│ │ ├── XActorRuntime.java
│ │ ├── XActorService.java
│ │ ├── XActorServiceRuntime.java
│ │ ├── XActorSystem.java
│ │ ├── actors
│ │ ├── ActorWithRxStash.java
│ │ ├── ConcurrentPseudoActorWithRx.java
│ │ ├── PseudoActorWithRx.java
│ │ └── XActor.java
│ │ ├── config
│ │ ├── XActorServiceConfig.java
│ │ └── XActorSystemConfig.java
│ │ ├── logging
│ │ └── XActorLogger.java
│ │ ├── runtime
│ │ └── extended
│ │ │ ├── BoundedActorThread.java
│ │ │ ├── UnboundedActorThread.java
│ │ │ ├── XDefaultActorSystemImpl.java
│ │ │ └── di
│ │ │ ├── ConstructorInjector.java
│ │ │ ├── DIMapEntry.java
│ │ │ └── DefaultDIContainer.java
│ │ └── utils
│ │ ├── ActorMessageFlowable.java
│ │ └── Utils.java
│ └── resources
│ └── log4j2.properties
├── actor4j-core-runtime-loom
├── .gitignore
├── LICENSE
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── io
│ │ └── actor4j
│ │ └── core
│ │ ├── ActorRuntime.java
│ │ ├── ActorServiceRuntime.java
│ │ ├── VirtualActorRuntime.java
│ │ ├── VirtualActorServiceRuntime.java
│ │ └── runtime
│ │ └── loom
│ │ ├── DefaultVirtualActorExecutorService.java
│ │ ├── DefaultVirtualActorMessageDispatcher.java
│ │ ├── DefaultVirtualActorRunnable.java
│ │ ├── DefaultVirtualActorRunnablePoolHandler.java
│ │ ├── DefaultVirtualActorSystemImpl.java
│ │ ├── InternalVirtualActorExecutorService.java
│ │ ├── VirtualActorRunnable.java
│ │ ├── VirtualActorRunnableMetrics.java
│ │ ├── VirtualActorRunnablePool.java
│ │ ├── VirtualActorRunnablePoolHandler.java
│ │ ├── VirtualActorRunnablePoolHandlerFactory.java
│ │ ├── VirtualBaseActorCell.java
│ │ ├── VirtualInternalActorCell.java
│ │ └── VirtualPodActorCell.java
│ └── test
│ └── java
│ └── io
│ └── actor4j
│ └── core
│ └── features
│ ├── ActorFeature.java
│ ├── ActorGroupMemberFeature.java
│ ├── AllFeaturesTest.java
│ ├── AskPatternFeature.java
│ ├── AwaitFeature.java
│ ├── BehaviourFeature.java
│ ├── CacheFeature.java
│ ├── CacheHandlerFeature.java
│ ├── CommPatternFeature.java
│ ├── ConcurrentPseudoActorFeature.java
│ ├── ConfigFeature.java
│ ├── EmbeddedActorFeature.java
│ ├── FaultToleranceFeature.java
│ ├── HandlerFeature.java
│ ├── LifeCycleFeature.java
│ ├── MatcherFeature.java
│ ├── OptionalFeature.java
│ ├── PodFeature.java
│ ├── PrimarySecondaryActorFeature.java
│ ├── PseudoActorFeature.java
│ ├── ResourceActorFeature.java
│ ├── ServiceDiscoveyFeature.java
│ ├── StatelessActorFeature.java
│ ├── WatchdogFeature.java
│ └── pod
│ ├── ExampleReplicationWithActorPod.java
│ ├── ExampleReplicationWithFunctionPod.java
│ ├── ExampleReplicationWithRemoteActorPodWithRequest.java
│ ├── ExampleReplicationWithRemoteFunctionImpl.java
│ ├── ExampleReplicationWithRemoteFunctionPod.java
│ ├── ExampleShardingWithActorPod.java
│ └── HelloActor.java
├── actor4j-core-runtime
├── .gitignore
├── LICENSE
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── io
│ │ └── actor4j
│ │ └── core
│ │ ├── ActorRuntime.java
│ │ ├── ActorServiceRuntime.java
│ │ └── runtime
│ │ ├── ActorThread.java
│ │ ├── ActorThreadFactory.java
│ │ ├── ActorThreadPool.java
│ │ ├── ActorThreadPoolHandler.java
│ │ ├── DefaultActorExecutorService.java
│ │ ├── DefaultActorMessageDispatcher.java
│ │ ├── DefaultActorSystemImpl.java
│ │ ├── DefaultActorThread.java
│ │ ├── DefaultActorThreadFactory.java
│ │ ├── DefaultInternalActorExecutorService.java
│ │ ├── DefaultInternalActorRuntimeSystem.java
│ │ └── DefaultUnboundedActorThread.java
│ └── test
│ └── java
│ └── io
│ └── actor4j
│ └── core
│ └── features
│ ├── ActorFeature.java
│ ├── ActorGroupMemberFeature.java
│ ├── AllFeaturesTest.java
│ ├── AskPatternFeature.java
│ ├── AwaitFeature.java
│ ├── BehaviourFeature.java
│ ├── CacheFeature.java
│ ├── CacheHandlerFeature.java
│ ├── CommPatternFeature.java
│ ├── ConcurrentPseudoActorFeature.java
│ ├── ConfigFeature.java
│ ├── EmbeddedActorFeature.java
│ ├── EmbeddedActorLifeCycleFeature.java
│ ├── FaultToleranceFeature.java
│ ├── HandlerFeature.java
│ ├── LifeCycleFeature.java
│ ├── MatcherFeature.java
│ ├── OptionalFeature.java
│ ├── PodFeature.java
│ ├── PrimarySecondaryActorFeature.java
│ ├── PseudoActorFeature.java
│ ├── ResourceActorFeature.java
│ ├── ServiceDiscoveyFeature.java
│ ├── StatelessActorFeature.java
│ ├── UnsafeFeature.java
│ ├── WatchdogFeature.java
│ └── pod
│ ├── ExampleReplicationWithActorPod.java
│ ├── ExampleReplicationWithFunctionPod.java
│ ├── ExampleReplicationWithRemoteActorPodWithRequest.java
│ ├── ExampleReplicationWithRemoteFunctionImpl.java
│ ├── ExampleReplicationWithRemoteFunctionPod.java
│ ├── ExampleShardingWithActorPod.java
│ └── HelloActor.java
├── actor4j-core-sdk
├── .gitignore
├── LICENSE
├── pom.xml
└── src
│ └── main
│ └── java
│ └── io
│ └── actor4j
│ └── core
│ ├── ActorCell.java
│ ├── ActorPodService.java
│ ├── ActorService.java
│ ├── ActorSystem.java
│ ├── ActorSystemFactory.java
│ ├── EmbeddedActorCell.java
│ ├── actors
│ ├── Actor.java
│ ├── ActorDistributedGroupMember.java
│ ├── ActorGroupMember.java
│ ├── ActorIgnoreDistributedGroupMember.java
│ ├── ActorRef.java
│ ├── ActorRegionMember.java
│ ├── ActorVersionNumber.java
│ ├── ActorWithBothGroups.java
│ ├── ActorWithCache.java
│ ├── ActorWithDistributedGroup.java
│ ├── ActorWithGroup.java
│ ├── ConcurrentPseudoActor.java
│ ├── EmbeddedActor.java
│ ├── EmbeddedActorRef.java
│ ├── EmbeddedHandlerActor.java
│ ├── EmbeddedHostActor.java
│ ├── PersistenceId.java
│ ├── PersistentActor.java
│ ├── PrimaryActor.java
│ ├── PseudoActor.java
│ ├── PseudoActorRef.java
│ ├── ResourceActor.java
│ ├── SecondaryActor.java
│ └── StatelessActor.java
│ ├── config
│ ├── ActorServiceConfig.java
│ └── ActorSystemConfig.java
│ ├── exceptions
│ ├── ActorInitializationException.java
│ ├── ActorKilledException.java
│ ├── ActorResourceException.java
│ └── ActorSystemConfigException.java
│ ├── function
│ ├── Procedure.java
│ ├── QuadConsumer.java
│ ├── QuintConsumer.java
│ ├── SextConsumer.java
│ ├── TriConsumer.java
│ └── TriFunction.java
│ ├── id
│ ├── ActorId.java
│ ├── GlobalId.java
│ └── RedirectId.java
│ ├── immutable
│ ├── ImmutableCollection.java
│ ├── ImmutableList.java
│ ├── ImmutableMap.java
│ ├── ImmutableObject.java
│ └── ImmutableSet.java
│ ├── json
│ ├── JsonArray.java
│ ├── JsonObject.java
│ ├── ObjectMapper.java
│ └── api
│ │ ├── JsonFactoryService.java
│ │ └── ObjectMapperService.java
│ ├── logging
│ ├── ActorLogger.java
│ └── LoggerFactory.java
│ ├── messages
│ ├── ActorMessage.java
│ ├── ActorMessageUtils.java
│ ├── ActorReservedTag.java
│ ├── DefaultActorMessage.java
│ ├── DefaultPodActorMessage.java
│ └── PodActorMessage.java
│ ├── mutable
│ └── MutableObject.java
│ ├── persistence
│ ├── ActorPersistenceDTO.java
│ └── drivers
│ │ ├── PersistenceDriver.java
│ │ └── PersistenceImpl.java
│ ├── pods
│ ├── ActorPod.java
│ ├── DefaultActorPod.java
│ ├── DefaultRemoteActorPod.java
│ ├── Pod.java
│ ├── PodConfiguration.java
│ ├── PodContext.java
│ ├── PodFactory.java
│ ├── RemotePodMessage.java
│ ├── RemotePodMessageDTO.java
│ ├── Shard.java
│ ├── SystemPod.java
│ ├── actors
│ │ ├── DefaultPodActor.java
│ │ ├── DefaultShardPodActor.java
│ │ ├── EmbeddedHandlerPodActor.java
│ │ ├── HandlerPodActor.java
│ │ ├── HandlerPodActorFactory.java
│ │ ├── PodActor.java
│ │ ├── PodChildActor.java
│ │ ├── RemoteHandlerPodActor.java
│ │ ├── ShardProxyPodActor.java
│ │ └── ShardProxyPodActorFactory.java
│ ├── api
│ │ ├── Caching.java
│ │ ├── Database.java
│ │ └── Host.java
│ ├── functions
│ │ ├── FunctionPod.java
│ │ ├── PodFunction.java
│ │ ├── PodRemoteFunction.java
│ │ └── RemoteFunctionPod.java
│ └── utils
│ │ ├── PodActorMessageProxyHandler.java
│ │ ├── PodRequestMethod.java
│ │ ├── PodRequestParam.java
│ │ └── PodStatus.java
│ ├── runtime
│ ├── ActorExecutorService.java
│ ├── ActorGlobalSettings.java
│ ├── ActorMessageDispatcher.java
│ ├── ActorStrategyOnFailure.java
│ ├── ActorSystemError.java
│ ├── ActorThreadMode.java
│ ├── InternalActorCell.java
│ ├── InternalActorSystem.java
│ ├── InternalPodActorCell.java
│ ├── InternalPseudoActorCell.java
│ ├── PodReplicationControllerRunnable.java
│ ├── PodReplicationControllerRunnableFactory.java
│ ├── PseudoActorCellFactory.java
│ ├── WatchdogRunnable.java
│ ├── WatchdogRunnableFactory.java
│ ├── di
│ │ ├── DIContainer.java
│ │ ├── DefaultDIContainer.java
│ │ └── FactoryInjector.java
│ ├── embedded
│ │ ├── ActorEmbeddedRouter.java
│ │ ├── BaseEmbeddedActorCell.java
│ │ ├── DefaultEmbeddedActorStrategyOnFailure.java
│ │ ├── EmbeddedActorStrategyOnFailure.java
│ │ ├── EmbeddedHostActorImpl.java
│ │ ├── InternalEmbeddedActorCell.java
│ │ └── protocol
│ │ │ ├── RestartProtocol.java
│ │ │ └── StopProtocol.java
│ ├── fault
│ │ └── tolerance
│ │ │ ├── ErrorHandler.java
│ │ │ ├── FaultTolerance.java
│ │ │ ├── FaultToleranceManager.java
│ │ │ └── FaultToleranceMethod.java
│ ├── persistence
│ │ ├── ActorPersistenceService.java
│ │ └── actor
│ │ │ └── PersistenceServiceActor.java
│ ├── pods
│ │ ├── PodReplicationController.java
│ │ ├── PodReplicationTuple.java
│ │ └── PodSystemConfiguration.java
│ ├── protocols
│ │ └── ActorProtocolTag.java
│ └── service
│ │ └── loader
│ │ └── ServiceLoader.java
│ ├── serializer
│ └── api
│ │ └── SerializerService.java
│ ├── service
│ ├── discovery
│ │ ├── Service.java
│ │ ├── ServiceDiscoveryActor.java
│ │ └── ServiceDiscoveryManager.java
│ └── support
│ │ ├── PodSupportService.java
│ │ └── SupportService.java
│ ├── supervisor
│ ├── DefaultSupervisorStrategy.java
│ ├── OneForAllSupervisorStrategy.java
│ ├── OneForOneSupervisorStrategy.java
│ ├── SupervisorStrategy.java
│ └── SupervisorStrategyDirective.java
│ └── utils
│ ├── ActorCacheHandler.java
│ ├── ActorFactory.java
│ ├── ActorGroup.java
│ ├── ActorGroupList.java
│ ├── ActorGroupSet.java
│ ├── ActorMessageHandler.java
│ ├── ActorMessageMatcher.java
│ ├── ActorMessageMatcherHandler.java
│ ├── ActorMessageProxyHandler.java
│ ├── ActorOptional.java
│ ├── ActorTimer.java
│ ├── ActorUtils.java
│ ├── AskPattern.java
│ ├── Cache.java
│ ├── CacheAsMap.java
│ ├── CacheLRU.java
│ ├── CacheVolatileLRU.java
│ ├── CircuitBreaker.java
│ ├── CommPattern.java
│ ├── ConcurrentActorGroupQueue.java
│ ├── ConcurrentActorGroupSet.java
│ ├── DeepCopyable.java
│ ├── EmbeddedActorFactory.java
│ ├── GenericType.java
│ ├── HubPattern.java
│ ├── Pair.java
│ ├── PodActorFactory.java
│ ├── Range.java
│ ├── ReadOnlyCache.java
│ ├── Shareable.java
│ └── Triple.java
├── doc
├── actor4j.asta
├── actor4j.tags.md
├── actor4j.yuml.me
└── images
│ ├── analyzer.png
│ ├── cd_left_right.png
│ ├── cd_top_down.png
│ ├── class diagram.png
│ ├── lifecycle1.png
│ ├── lifecycle1_v2.png
│ ├── lifecycle2.png
│ ├── promo.png
│ ├── rest api.png
│ └── supervision.png
└── pom.xml
/.mvn/maven.config:
--------------------------------------------------------------------------------
1 | -Drevision=2.4.0
--------------------------------------------------------------------------------
/actor4j-core-runtime-base/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-base/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | io.actor4j
5 | actor4j-core
6 | ${revision}
7 |
8 | actor4j-core-runtime-base
9 | jar
10 |
11 | ${project.groupId}:${project.artifactId}
12 | Actor4j is an actor-oriented Java framework.
13 | https://github.com/relvaner/actor4j-core
14 | 2015
15 |
16 |
17 |
18 | The Apache License, Version 2.0
19 | http://www.apache.org/licenses/LICENSE-2.0.txt
20 | repo
21 |
22 |
23 |
24 |
25 |
26 | David A. Bauer
27 | relvaner.github@gmail.com
28 |
29 |
30 |
31 |
32 |
33 | io.actor4j
34 | actor4j-core-sdk
35 | ${revision}
36 |
37 |
38 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-base/src/main/java/io/actor4j/core/runtime/ActorExecutionUnitPoolHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime;
17 |
18 | import io.actor4j.core.messages.ActorMessage;
19 |
20 | public interface ActorExecutionUnitPoolHandler {
21 | public void postPersistence(ActorMessage> message);
22 |
23 | public void registerCell(InternalActorCell cell);
24 | public void unregisterCell(InternalActorCell cell);
25 | public boolean isRegisteredCell(InternalActorCell cell);
26 | }
27 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-base/src/main/java/io/actor4j/core/runtime/DefaultActorExecutionUnitPoolHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime;
17 |
18 | import java.util.List;
19 | import java.util.Map;
20 |
21 | public interface DefaultActorExecutionUnitPoolHandler extends ActorExecutionUnitPoolHandler {
22 | public Map getExecutionUnitMap();
23 | public List getExecutionUnitList();
24 |
25 | public void beforeStart(List executionUnitList);
26 | }
27 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-base/src/main/java/io/actor4j/core/runtime/DefaultPodReplicationControllerRunnable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime;
17 |
18 | import static io.actor4j.core.logging.ActorLogger.*;
19 |
20 | public class DefaultPodReplicationControllerRunnable extends PodReplicationControllerRunnable {
21 | public DefaultPodReplicationControllerRunnable(InternalActorSystem system) {
22 | super(system);
23 | }
24 |
25 | @Override
26 | public void onRun() {
27 | horizontalPodAutoscaler();
28 | }
29 |
30 | public void horizontalPodAutoscaler() {
31 | systemLogger().log(DEBUG, String.format("[REPLICATION][AUTOSCALER] sync"));
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-base/src/main/java/io/actor4j/core/runtime/InternalActorExecutorService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime;
17 |
18 | public interface InternalActorExecutorService extends ActorExecutorService {
19 | public ActorExecutionUnitPool getExecutionUnitPool();
20 | }
21 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-base/src/main/java/io/actor4j/core/runtime/InternalActorRuntimeSystem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime;
17 |
18 | import io.actor4j.core.id.ActorId;
19 | import io.actor4j.core.runtime.di.DIContainer;
20 |
21 | public interface InternalActorRuntimeSystem extends InternalActorSystem {
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-base/src/main/java/io/actor4j/core/runtime/PodActorCell.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime;
17 |
18 | import static io.actor4j.core.logging.ActorLogger.*;
19 |
20 | import java.util.concurrent.atomic.AtomicReference;
21 |
22 | import io.actor4j.core.actors.Actor;
23 | import io.actor4j.core.pods.PodContext;
24 |
25 | public class PodActorCell extends BaseActorCell implements InternalPodActorCell {
26 | protected final AtomicReference contextReference;
27 |
28 | public PodActorCell(InternalActorSystem system, Actor actor) {
29 | super(system, actor);
30 |
31 | this.contextReference = new AtomicReference<>();
32 | }
33 |
34 | @Override
35 | public boolean isPod() {
36 | return true;
37 | }
38 |
39 | @Override
40 | public PodContext getContext() {
41 | return contextReference.get();
42 | }
43 |
44 | @Override
45 | public void setContext(PodContext context) {
46 | contextReference.set(context);
47 | }
48 |
49 | @Override
50 | public void preStart() {
51 | systemLogger().log(INFO, String.format("[REPLICATION] PodActor (%s, %s) starting", getContext().domain(), getId()));
52 | super.preStart();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-base/src/main/java/io/actor4j/core/runtime/annotations/concurrent/Readonly.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2019, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.annotations.concurrent;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | @Retention(RetentionPolicy.SOURCE)
24 | @Target({ElementType.FIELD})
25 | public @interface Readonly {
26 | }
--------------------------------------------------------------------------------
/actor4j-core-runtime-base/src/main/java/io/actor4j/core/runtime/annotations/concurrent/ThreadLocalAccess.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2025, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.annotations.concurrent;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | @Retention(RetentionPolicy.SOURCE)
24 | @Target({ElementType.FIELD})
25 | public @interface ThreadLocalAccess {
26 | String reason() default "";
27 | }
--------------------------------------------------------------------------------
/actor4j-core-runtime-base/src/main/java/io/actor4j/core/runtime/annotations/concurrent/ThreadSafeAccess.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2025, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.annotations.concurrent;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | @Retention(RetentionPolicy.SOURCE)
24 | @Target({ElementType.FIELD})
25 | public @interface ThreadSafeAccess {
26 | String reason() default "";
27 | }
--------------------------------------------------------------------------------
/actor4j-core-runtime-base/src/main/java/io/actor4j/core/runtime/protocols/RecoverProtocol.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.protocols;
17 |
18 | import io.actor4j.core.actors.PersistentActor;
19 | import io.actor4j.core.messages.ActorMessage;
20 | import io.actor4j.core.runtime.InternalActorCell;
21 | import io.actor4j.core.runtime.InternalActorSystem;
22 | import io.actor4j.core.runtime.persistence.actor.PersistenceServiceActor;
23 |
24 | public final class RecoverProtocol {
25 | public static void apply(final InternalActorCell cell) {
26 | if (cell.getSystem().getConfig().persistenceMode() && cell.getActor() instanceof PersistentActor) {
27 | cell.setActive(false);
28 | ((InternalActorSystem)cell.getSystem()).getMessageDispatcher().postPersistence(
29 | ActorMessage.create(((PersistentActor,?>)cell.getActor()).persistenceId().toString(), PersistenceServiceActor.RECOVER, cell.getId(), null));
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-classic/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-classic/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 |
6 | io.actor4j
7 | actor4j-core
8 | ${revision}
9 |
10 | actor4j-core-runtime-classic
11 | jar
12 |
13 | ${project.groupId}:${project.artifactId}
14 | Actor4j is an actor-oriented Java framework.
15 | https://github.com/relvaner/actor4j-core
16 | 2015
17 |
18 |
19 |
20 | The Apache License, Version 2.0
21 | http://www.apache.org/licenses/LICENSE-2.0.txt
22 | repo
23 |
24 |
25 |
26 |
27 |
28 | David A. Bauer
29 | relvaner.github@gmail.com
30 |
31 |
32 |
33 |
34 |
35 | io.actor4j
36 | actor4j-core-runtime-base
37 | ${revision}
38 |
39 |
40 |
41 | org.junit.vintage
42 | junit-vintage-engine
43 | ${junit.version}
44 | test
45 |
46 |
47 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-classic/src/main/java/io/actor4j/core/ActorRuntime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2025, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core;
17 |
18 | import io.actor4j.core.config.ActorSystemConfig;
19 |
20 | public class ActorRuntime {
21 | public static ActorSystemFactory factory() {
22 | return ClassicActorRuntime.factory();
23 | }
24 |
25 | public static ActorSystem create() {
26 | return ClassicActorRuntime.create();
27 | }
28 |
29 | public static ActorSystem create(String name) {
30 | return ClassicActorRuntime.create(name);
31 | }
32 |
33 | public static ActorSystem create(ActorSystemConfig config) {
34 | return ClassicActorRuntime.create(config);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-classic/src/main/java/io/actor4j/core/ActorServiceRuntime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2025, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core;
17 |
18 | import io.actor4j.core.config.ActorSystemConfig;
19 |
20 | public class ActorServiceRuntime {
21 | public static ActorSystemFactory factory() {
22 | return ClassicActorServiceRuntime.factory();
23 | }
24 |
25 | public static ActorService create() {
26 | return ClassicActorServiceRuntime.create();
27 | }
28 |
29 | public static ActorService create(String name) {
30 | return ClassicActorServiceRuntime.create(name);
31 | }
32 |
33 | public static ActorService create(ActorSystemConfig config) {
34 | return ClassicActorServiceRuntime.create(config);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-classic/src/main/java/io/actor4j/core/ClassicActorRuntime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core;
17 |
18 | import io.actor4j.core.config.ActorSystemConfig;
19 | import io.actor4j.core.runtime.classic.ClassicDefaultActorSystemImpl;
20 |
21 | public class ClassicActorRuntime {
22 | public static ActorSystemFactory factory() {
23 | return (c) -> new ClassicDefaultActorSystemImpl(ActorSystemConfig.builder(c).watchdogEnabled(false).build());
24 | }
25 |
26 | public static ActorSystem create() {
27 | return create(ActorSystemConfig.create());
28 | }
29 |
30 | public static ActorSystem create(String name) {
31 | return create(ActorSystemConfig.builder().name(name).build());
32 | }
33 |
34 | public static ActorSystem create(ActorSystemConfig config) {
35 | return factory().apply(config);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-classic/src/main/java/io/actor4j/core/ClassicActorServiceRuntime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core;
17 |
18 | import io.actor4j.core.config.ActorServiceConfig;
19 | import io.actor4j.core.config.ActorSystemConfig;
20 | import io.actor4j.core.runtime.classic.ClassicDefaultActorSystemImpl;
21 |
22 | public class ClassicActorServiceRuntime {
23 | public static ActorSystemFactory factory() {
24 | return (c) -> new ClassicDefaultActorSystemImpl(ActorServiceConfig.builder(c).watchdogEnabled(false).build());
25 | }
26 |
27 | public static ActorService create() {
28 | return create(ActorServiceConfig.create());
29 | }
30 |
31 | public static ActorService create(String name) {
32 | return create(ActorServiceConfig.builder().name(name).build());
33 | }
34 |
35 | public static ActorService create(ActorSystemConfig config) {
36 | return (ActorService)factory().apply(config!=null ? config : ActorServiceConfig.create());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-classic/src/main/java/io/actor4j/core/runtime/classic/ActorMessageDispatcherCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2024, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.classic;
17 |
18 | public interface ActorMessageDispatcherCallback {
19 | public void dispatchFromThread(ClassicInternalActorCell cell);
20 | }
21 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-classic/src/main/java/io/actor4j/core/runtime/classic/ActorRunnableMetrics.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2025, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.classic;
17 |
18 | import java.util.Queue;
19 | import java.util.concurrent.ConcurrentLinkedQueue;
20 | import java.util.concurrent.atomic.AtomicInteger;
21 | import java.util.concurrent.atomic.AtomicLong;
22 |
23 | public final class ActorRunnableMetrics {
24 | protected final long threadId;
25 |
26 | protected final AtomicLong counter;
27 | // protected final AtomicBoolean load;
28 |
29 | protected final AtomicInteger processingTimeSampleCount;
30 | protected final Queue processingTimeSamples;
31 |
32 | protected final AtomicInteger cellsProcessingTimeSampleCount;
33 |
34 | public ActorRunnableMetrics(long threadId) {
35 | super();
36 | this.threadId = threadId;
37 |
38 | // load = new AtomicBoolean(false);
39 | counter = new AtomicLong(0);
40 |
41 | processingTimeSampleCount = new AtomicInteger(0);
42 | processingTimeSamples = new ConcurrentLinkedQueue<>();
43 |
44 | cellsProcessingTimeSampleCount = new AtomicInteger(0);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-classic/src/main/java/io/actor4j/core/runtime/classic/ClassicDefaultActorExecutorService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.classic;
17 |
18 | import io.actor4j.core.runtime.ActorExecutorServiceImpl;
19 | import io.actor4j.core.runtime.ActorExecutionUnitPool;
20 | import io.actor4j.core.runtime.InternalActorRuntimeSystem;
21 |
22 | public class ClassicDefaultActorExecutorService extends ActorExecutorServiceImpl implements ClassicInternalActorExecutorService {
23 | public ClassicDefaultActorExecutorService(InternalActorRuntimeSystem system) {
24 | super(system);
25 | }
26 |
27 | @Override
28 | public ActorExecutionUnitPool createExecutionUnitPool() {
29 | return new ActorRunnablePool(system);
30 | }
31 |
32 | @Override
33 | public ActorRunnablePool getRunnablePool() {
34 | return (ActorRunnablePool)executionUnitPool;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-classic/src/main/java/io/actor4j/core/runtime/classic/ClassicInternalActorCell.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.classic;
17 |
18 | import java.util.Queue;
19 | import java.util.concurrent.atomic.AtomicBoolean;
20 |
21 | import io.actor4j.core.messages.ActorMessage;
22 | import io.actor4j.core.runtime.InternalActorCell;
23 |
24 | public interface ClassicInternalActorCell extends InternalActorCell {
25 | public Queue> directiveQueue();
26 | public Queue> outerQueue();
27 |
28 | public default boolean hasMessage() {
29 | return
30 | !directiveQueue().isEmpty() ||
31 | !outerQueue().isEmpty();
32 | }
33 |
34 | public AtomicBoolean isScheduled();
35 | public boolean aquireAsScheduled();
36 | }
37 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-classic/src/main/java/io/actor4j/core/runtime/classic/ClassicInternalActorExecutorService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.classic;
17 |
18 | import io.actor4j.core.runtime.ActorExecutorService;
19 |
20 | public interface ClassicInternalActorExecutorService extends ActorExecutorService {
21 | public ActorRunnablePool getRunnablePool();
22 | }
23 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-classic/src/main/java/io/actor4j/core/runtime/classic/DefaultActorRunnable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.classic;
17 |
18 | import io.actor4j.core.messages.ActorMessage;
19 | import io.actor4j.core.runtime.InternalActorSystem;
20 |
21 | public class DefaultActorRunnable extends ActorRunnable {
22 | public DefaultActorRunnable(InternalActorSystem system) {
23 | super(system);
24 | }
25 |
26 | @Override
27 | public void onRun(ClassicInternalActorCell cell) {
28 | int hasDirective = 0;
29 | int hasNextOuter = 0;
30 |
31 | ActorMessage> msg = null;
32 | for (; (msg=cell.directiveQueue().poll())!=null; hasDirective++)
33 | faultToleranceMethod(msg, cell);
34 |
35 | for (; hasNextOuter metricsMap) {
26 | super(pool);
27 |
28 | metricsMap.put(threadId(), new ActorRunnableMetrics(threadId()));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-extended/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-extended/doc/Readme.txt:
--------------------------------------------------------------------------------
1 | Alternative to MpscLinkedQueue -> org.agrona.concurrent.ManyToOneConcurrentLinkedQueue
--------------------------------------------------------------------------------
/actor4j-core-runtime-extended/src/main/java/io/actor4j/core/XActorRuntime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2024, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core;
17 |
18 | import io.actor4j.core.config.XActorSystemConfig;
19 | import io.actor4j.core.runtime.extended.XDefaultActorSystemImpl;
20 |
21 | public class XActorRuntime {
22 | public static ActorSystemFactory factory() {
23 | return (c) -> new XDefaultActorSystemImpl((XActorSystemConfig)c);
24 | }
25 |
26 | public static ActorSystem create() {
27 | return create(XActorSystemConfig.create());
28 | }
29 |
30 | public static ActorSystem create(String name) {
31 | return create(XActorSystemConfig.builder().name(name).build());
32 | }
33 |
34 | public static ActorSystem create(XActorSystemConfig config) {
35 | return factory().apply(config);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-extended/src/main/java/io/actor4j/core/XActorServiceRuntime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2024, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core;
17 |
18 | import io.actor4j.core.config.XActorServiceConfig;
19 | import io.actor4j.core.runtime.extended.XDefaultActorSystemImpl;
20 |
21 | public class XActorServiceRuntime {
22 | public static ActorSystemFactory factory() {
23 | return (c) -> new XDefaultActorSystemImpl((XActorServiceConfig)c);
24 | }
25 |
26 | public static ActorSystem create() {
27 | return create(XActorServiceConfig.create());
28 | }
29 |
30 | public static ActorSystem create(String name) {
31 | return create(XActorServiceConfig.builder().name(name).build());
32 | }
33 |
34 | public static ActorSystem create(XActorServiceConfig config) {
35 | return factory().apply(config);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-extended/src/main/java/io/actor4j/core/XActorSystem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core;
17 |
18 | import io.actor4j.core.config.ActorSystemConfig;
19 | import io.actor4j.core.config.XActorSystemConfig;
20 | import io.actor4j.core.runtime.extended.XDefaultActorSystemImpl;
21 |
22 | public interface XActorSystem extends ActorSystem {
23 | public static XActorSystem create() {
24 | return create(XActorSystemConfig.builder().build());
25 | }
26 |
27 | public static XActorSystem create(String name) {
28 | return create(XActorSystemConfig.builder().name(name).build());
29 | }
30 |
31 | public static XActorSystem create(XActorSystemConfig config) {
32 | return new XDefaultActorSystemImpl(config);
33 | }
34 |
35 | @Deprecated
36 | @Override
37 | public default boolean setConfig(ActorSystemConfig config) {
38 | return false;
39 | }
40 |
41 | public boolean setConfig(XActorSystemConfig config);
42 |
43 | // public List addActor(int instances, Class extends Actor> clazz, Object... args) throws ActorInitializationException;
44 | // public ActorId addActor(Class extends Actor> clazz, Object... args) throws ActorInitializationException;
45 | }
46 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-extended/src/main/java/io/actor4j/core/actors/ActorWithRxStash.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2024, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.actors;
17 |
18 | import java.util.LinkedList;
19 |
20 | import io.actor4j.core.messages.ActorMessage;
21 | import io.actor4j.core.utils.ActorMessageFlowable;
22 | import io.reactivex.rxjava3.core.Flowable;
23 |
24 | public abstract class ActorWithRxStash extends Actor {
25 | protected Flowable> rxStash;
26 |
27 | public ActorWithRxStash() {
28 | this(null);
29 | }
30 |
31 | public ActorWithRxStash(String name) {
32 | super(name);
33 |
34 | stash = new LinkedList<>();
35 | rxStash = ActorMessageFlowable.getMessages(stash);
36 | }
37 |
38 | public ActorMessage> unstash() {
39 | return stash.poll();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-extended/src/main/java/io/actor4j/core/actors/ConcurrentPseudoActorWithRx.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2024, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.actors;
17 |
18 | import io.actor4j.core.ActorSystem;
19 | import io.actor4j.core.messages.ActorMessage;
20 | import io.actor4j.core.utils.ActorMessageFlowable;
21 | import io.reactivex.rxjava3.core.Flowable;
22 |
23 | public abstract class ConcurrentPseudoActorWithRx extends ConcurrentPseudoActor {
24 | public ConcurrentPseudoActorWithRx(String name, ActorSystem system) {
25 | this(name, system, false);
26 | }
27 |
28 | public ConcurrentPseudoActorWithRx(ActorSystem system, boolean blocking) {
29 | this(null, system, blocking);
30 | }
31 |
32 | public ConcurrentPseudoActorWithRx(String name, ActorSystem system, boolean blocking) {
33 | super();
34 |
35 | actor = new PseudoActorWithRx(name, system, blocking) {
36 | @Override
37 | public void receive(ActorMessage> message) {
38 | ConcurrentPseudoActorWithRx.this.receive(message);
39 | }
40 | };
41 | }
42 |
43 | public Flowable> runWithRx() {
44 | return ActorMessageFlowable.getMessages(getOuterQueue());
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-extended/src/main/java/io/actor4j/core/logging/XActorLogger.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2019, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.logging;
17 |
18 | import org.slf4j.Logger;
19 | import org.slf4j.LoggerFactory;
20 |
21 | public class XActorLogger {
22 | public static Logger logger;
23 |
24 | static {
25 | logger = LoggerFactory.getLogger(XActorLogger.class);
26 | }
27 |
28 | public static Logger logger() {
29 | return logger;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-extended/src/main/java/io/actor4j/core/runtime/extended/di/ConstructorInjector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.extended.di;
17 |
18 | public class ConstructorInjector {
19 | protected Object[] params;
20 |
21 | public ConstructorInjector() {
22 | super();
23 | }
24 |
25 | public Object[] getParams() {
26 | return params;
27 | }
28 |
29 | public void setParams(Object[] params) {
30 | this.params = params;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-extended/src/main/java/io/actor4j/core/runtime/extended/di/DIMapEntry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.extended.di;
17 |
18 | import io.actor4j.core.runtime.di.FactoryInjector;
19 |
20 | public class DIMapEntry {
21 | protected Class> base;
22 | protected ConstructorInjector constructorInjector;
23 | protected FactoryInjector> factoryInjector;
24 |
25 | public DIMapEntry() {
26 | constructorInjector = new ConstructorInjector();
27 | }
28 |
29 | public Class> getBase() {
30 | return base;
31 | }
32 |
33 | public void setBase(Class> base) {
34 | this.base = base;
35 | }
36 |
37 | public ConstructorInjector getConstructorInjector() {
38 | return constructorInjector;
39 | }
40 |
41 | public void setConstructorInjector(ConstructorInjector constructorInjector) {
42 | this.constructorInjector = constructorInjector;
43 | }
44 |
45 | public FactoryInjector> getFactoryInjector() {
46 | return factoryInjector;
47 | }
48 |
49 | public void setFactoryInjector(FactoryInjector> factoryInjector) {
50 | this.factoryInjector = factoryInjector;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-extended/src/main/java/io/actor4j/core/utils/Utils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.utils;
17 |
18 | import java.util.HashMap;
19 | import java.util.Map;
20 |
21 | public final class Utils {
22 | private static Map, Class>> PRIMITIVE_MAPPERS;
23 |
24 | public static boolean isPrimitive(Class> type) {
25 | return type.isPrimitive();
26 | }
27 |
28 | public static Class> getPrimitiveWrapper(Class> type) {
29 | return PRIMITIVE_MAPPERS.get(type);
30 | }
31 |
32 | static {
33 | PRIMITIVE_MAPPERS = new HashMap<>();
34 | PRIMITIVE_MAPPERS.put(byte.class, Byte.class);
35 | PRIMITIVE_MAPPERS.put(short.class, Short.class);
36 | PRIMITIVE_MAPPERS.put(int.class, Integer.class);
37 | PRIMITIVE_MAPPERS.put(long.class, Long.class);
38 | PRIMITIVE_MAPPERS.put(float.class, Float.class);
39 | PRIMITIVE_MAPPERS.put(double.class, Double.class);
40 | PRIMITIVE_MAPPERS.put(char.class, Character.class);
41 | PRIMITIVE_MAPPERS.put(String.class, String.class);
42 | PRIMITIVE_MAPPERS.put(boolean.class, Boolean.class);
43 | PRIMITIVE_MAPPERS.put(Void.class, Void.class);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-extended/src/main/resources/log4j2.properties:
--------------------------------------------------------------------------------
1 | appender.system.type = Console
2 | appender.system.name = system
3 | appender.system.layout.type = PatternLayout
4 | appender.system.layout.pattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss.SSS} [SYSTEM] [%t] %-40C -> %L [MESSAGE] %m%n
5 |
6 | appender.user.type = Console
7 | appender.user.name = user
8 | appender.user.layout.type = PatternLayout
9 | appender.user.layout.pattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss.SSS} [USER ] [%t] %-40C -> %L [MESSAGE] %m%n
10 |
11 | rootLogger.level = error
12 | rootLogger.appenderRef.rootLogger.ref = system
13 |
14 | logger.user.name = io.actor4j.core.logging
15 | logger.user.level = error
16 | logger.user.additivity = false
17 | logger.user.appenderRef.user.ref = user
--------------------------------------------------------------------------------
/actor4j-core-runtime-loom/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-loom/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 |
6 | io.actor4j
7 | actor4j-core
8 | ${revision}
9 |
10 | actor4j-core-runtime-loom
11 | jar
12 |
13 | ${project.groupId}:${project.artifactId}
14 | Actor4j is an actor-oriented Java framework.
15 | https://github.com/relvaner/actor4j-core
16 | 2015
17 |
18 |
19 |
20 | The Apache License, Version 2.0
21 | http://www.apache.org/licenses/LICENSE-2.0.txt
22 | repo
23 |
24 |
25 |
26 |
27 |
28 | David A. Bauer
29 | relvaner.github@gmail.com
30 |
31 |
32 |
33 |
34 |
35 | io.actor4j
36 | actor4j-core-runtime-base
37 | ${revision}
38 |
39 |
40 |
41 | org.junit.vintage
42 | junit-vintage-engine
43 | ${junit.version}
44 | test
45 |
46 |
47 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-loom/src/main/java/io/actor4j/core/ActorRuntime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2025, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core;
17 |
18 | import io.actor4j.core.config.ActorSystemConfig;
19 |
20 | public class ActorRuntime {
21 | public static ActorSystemFactory factory() {
22 | return VirtualActorRuntime.factory();
23 | }
24 |
25 | public static ActorSystem create() {
26 | return VirtualActorRuntime.create();
27 | }
28 |
29 | public static ActorSystem create(String name) {
30 | return VirtualActorRuntime.create(name);
31 | }
32 |
33 | public static ActorSystem create(ActorSystemConfig config) {
34 | return VirtualActorRuntime.create(config);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-loom/src/main/java/io/actor4j/core/ActorServiceRuntime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core;
17 |
18 | import io.actor4j.core.config.ActorSystemConfig;
19 |
20 | public class ActorServiceRuntime {
21 | public static ActorSystemFactory factory() {
22 | return VirtualActorServiceRuntime.factory();
23 | }
24 |
25 | public static ActorService create() {
26 | return VirtualActorServiceRuntime.create();
27 | }
28 |
29 | public static ActorService create(String name) {
30 | return VirtualActorServiceRuntime.create(name);
31 | }
32 |
33 | public static ActorService create(ActorSystemConfig config) {
34 | return VirtualActorServiceRuntime.create(config);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-loom/src/main/java/io/actor4j/core/VirtualActorRuntime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core;
17 |
18 | import io.actor4j.core.config.ActorSystemConfig;
19 | import io.actor4j.core.runtime.loom.DefaultVirtualActorSystemImpl;
20 |
21 | public class VirtualActorRuntime {
22 | public static ActorSystemFactory factory() {
23 | return (config) -> new DefaultVirtualActorSystemImpl(ActorSystemConfig.builder(config).watchdogEnabled(false).build());
24 | }
25 |
26 | public static ActorSystem create() {
27 | return create(ActorSystemConfig.create());
28 | }
29 |
30 | public static ActorSystem create(String name) {
31 | return create(ActorSystemConfig.builder().name(name).build());
32 | }
33 |
34 | public static ActorSystem create(ActorSystemConfig config) {
35 | return factory().apply(config);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-loom/src/main/java/io/actor4j/core/VirtualActorServiceRuntime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core;
17 |
18 | import io.actor4j.core.config.ActorServiceConfig;
19 | import io.actor4j.core.config.ActorSystemConfig;
20 | import io.actor4j.core.runtime.loom.DefaultVirtualActorSystemImpl;
21 |
22 | public class VirtualActorServiceRuntime {
23 | public static ActorSystemFactory factory() {
24 | return (config) -> new DefaultVirtualActorSystemImpl(ActorServiceConfig.builder(config).watchdogEnabled(false).build());
25 | }
26 |
27 | public static ActorService create() {
28 | return create(ActorServiceConfig.create());
29 | }
30 |
31 | public static ActorService create(String name) {
32 | return create(ActorServiceConfig.builder().name(name).build());
33 | }
34 |
35 | public static ActorService create(ActorSystemConfig config) {
36 | return (ActorService)factory().apply(config!=null ? config : ActorServiceConfig.create());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-loom/src/main/java/io/actor4j/core/runtime/loom/DefaultVirtualActorRunnablePoolHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.loom;
17 |
18 | import io.actor4j.core.runtime.InternalActorCell;
19 | import io.actor4j.core.runtime.InternalActorSystem;
20 |
21 | public class DefaultVirtualActorRunnablePoolHandler extends VirtualActorRunnablePoolHandler {
22 | public DefaultVirtualActorRunnablePoolHandler(InternalActorSystem system, VirtualActorRunnablePool virtualActorRunnablePool) {
23 | super(system, virtualActorRunnablePool);
24 | }
25 |
26 | @Override
27 | public VirtualActorRunnable createVirtualActorRunnable(InternalActorSystem system, InternalActorCell cell, Runnable onTermination) {
28 | return new DefaultVirtualActorRunnable(system, cell, onTermination);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-loom/src/main/java/io/actor4j/core/runtime/loom/InternalVirtualActorExecutorService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.loom;
17 |
18 | import io.actor4j.core.runtime.ActorExecutorService;
19 |
20 | public interface InternalVirtualActorExecutorService extends ActorExecutorService {
21 | public VirtualActorRunnablePool getVirtualActorResourceRunnablePool();
22 | public VirtualActorRunnablePool getVirtualActorRunnablePool();
23 | }
24 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-loom/src/main/java/io/actor4j/core/runtime/loom/VirtualActorRunnableMetrics.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2025, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.loom;
17 |
18 | import java.util.Queue;
19 | import java.util.concurrent.ConcurrentLinkedQueue;
20 | import java.util.concurrent.atomic.AtomicInteger;
21 | import java.util.concurrent.atomic.AtomicLong;
22 |
23 | public final class VirtualActorRunnableMetrics {
24 | protected final AtomicLong counter;
25 | // protected final AtomicBoolean load;
26 |
27 | protected final AtomicInteger processingTimeSampleCount;
28 | protected final Queue processingTimeSamples;
29 |
30 | protected final AtomicInteger cellsProcessingTimeSampleCount;
31 |
32 | static {
33 |
34 | }
35 |
36 | public VirtualActorRunnableMetrics() {
37 | super();
38 |
39 | // load = new AtomicBoolean(false);
40 | counter = new AtomicLong(0);
41 |
42 | processingTimeSampleCount = new AtomicInteger(0);
43 | processingTimeSamples = new ConcurrentLinkedQueue<>();
44 |
45 | cellsProcessingTimeSampleCount = new AtomicInteger(0);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-loom/src/main/java/io/actor4j/core/runtime/loom/VirtualActorRunnablePoolHandlerFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.loom;
17 |
18 | import java.util.function.Function;
19 |
20 | public interface VirtualActorRunnablePoolHandlerFactory extends Function {
21 | }
22 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-loom/src/main/java/io/actor4j/core/runtime/loom/VirtualBaseActorCell.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2025, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.loom;
17 |
18 | import io.actor4j.core.actors.Actor;
19 | import io.actor4j.core.runtime.BaseActorCell;
20 | import io.actor4j.core.runtime.InternalActorSystem;
21 |
22 | public class VirtualBaseActorCell extends BaseActorCell implements VirtualInternalActorCell {
23 | protected VirtualActorRunnable virtualRunnable;
24 |
25 | public VirtualBaseActorCell(InternalActorSystem system, Actor actor) {
26 | super(system, actor);
27 | }
28 |
29 | public VirtualActorRunnable getVirtualRunnable() {
30 | return virtualRunnable;
31 | }
32 |
33 | public void setVirtualRunnable(VirtualActorRunnable virtualRunnable) {
34 | this.virtualRunnable = virtualRunnable;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-loom/src/main/java/io/actor4j/core/runtime/loom/VirtualInternalActorCell.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2025, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.loom;
17 |
18 | public interface VirtualInternalActorCell {
19 | public VirtualActorRunnable getVirtualRunnable();
20 | public void setVirtualRunnable(VirtualActorRunnable virtualRunnable);
21 | }
22 |
--------------------------------------------------------------------------------
/actor4j-core-runtime-loom/src/main/java/io/actor4j/core/runtime/loom/VirtualPodActorCell.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2025, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime.loom;
17 |
18 | import io.actor4j.core.actors.Actor;
19 | import io.actor4j.core.runtime.InternalActorSystem;
20 | import io.actor4j.core.runtime.PodActorCell;
21 |
22 | public class VirtualPodActorCell extends PodActorCell implements VirtualInternalActorCell {
23 | protected VirtualActorRunnable virtualRunnable;
24 |
25 | public VirtualPodActorCell(InternalActorSystem system, Actor actor) {
26 | super(system, actor);
27 | }
28 |
29 | public VirtualActorRunnable getVirtualRunnable() {
30 | return virtualRunnable;
31 | }
32 |
33 | public void setVirtualRunnable(VirtualActorRunnable virtualRunnable) {
34 | this.virtualRunnable = virtualRunnable;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/actor4j-core-runtime/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/actor4j-core-runtime/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 |
6 | io.actor4j
7 | actor4j-core
8 | ${revision}
9 |
10 | actor4j-core-runtime
11 | jar
12 |
13 | ${project.groupId}:${project.artifactId}
14 | Actor4j is an actor-oriented Java framework.
15 | https://github.com/relvaner/actor4j-core
16 | 2015
17 |
18 |
19 |
20 | The Apache License, Version 2.0
21 | http://www.apache.org/licenses/LICENSE-2.0.txt
22 | repo
23 |
24 |
25 |
26 |
27 |
28 | David A. Bauer
29 | relvaner.github@gmail.com
30 |
31 |
32 |
33 |
34 |
35 | io.actor4j
36 | actor4j-core-runtime-base
37 | ${revision}
38 |
39 |
40 |
41 | org.junit.vintage
42 | junit-vintage-engine
43 | ${junit.version}
44 | test
45 |
46 |
47 |
--------------------------------------------------------------------------------
/actor4j-core-runtime/src/main/java/io/actor4j/core/ActorRuntime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core;
17 |
18 | import io.actor4j.core.config.ActorSystemConfig;
19 | import io.actor4j.core.runtime.DefaultActorSystemImpl;
20 |
21 | public class ActorRuntime {
22 | public static ActorSystemFactory factory() {
23 | return (c) -> new DefaultActorSystemImpl(c);
24 | }
25 |
26 | public static ActorSystem create() {
27 | return create(ActorSystemConfig.create());
28 | }
29 |
30 | public static ActorSystem create(String name) {
31 | return create(ActorSystemConfig.builder().name(name).build());
32 | }
33 |
34 | public static ActorSystem create(ActorSystemConfig config) {
35 | return factory().apply(config);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/actor4j-core-runtime/src/main/java/io/actor4j/core/ActorServiceRuntime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core;
17 |
18 | import io.actor4j.core.config.ActorServiceConfig;
19 | import io.actor4j.core.config.ActorSystemConfig;
20 | import io.actor4j.core.runtime.DefaultActorSystemImpl;
21 |
22 | public class ActorServiceRuntime {
23 | public static ActorSystemFactory factory() {
24 | return (c) -> new DefaultActorSystemImpl(c);
25 | }
26 |
27 | public static ActorService create() {
28 | return create(ActorServiceConfig.create());
29 | }
30 |
31 | public static ActorService create(String name) {
32 | return create(ActorServiceConfig.builder().name(name).build());
33 | }
34 |
35 | public static ActorService create(ActorSystemConfig config) {
36 | return (ActorService)factory().apply(config!=null ? config : ActorServiceConfig.create());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/actor4j-core-runtime/src/main/java/io/actor4j/core/runtime/ActorThreadFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime;
17 |
18 | import io.actor4j.core.function.TriFunction;
19 |
20 | public interface ActorThreadFactory extends TriFunction {
21 | }
22 |
--------------------------------------------------------------------------------
/actor4j-core-runtime/src/main/java/io/actor4j/core/runtime/DefaultActorExecutorService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime;
17 |
18 | public class DefaultActorExecutorService extends ActorExecutorServiceImpl implements DefaultInternalActorExecutorService {
19 | public DefaultActorExecutorService(InternalActorRuntimeSystem system) {
20 | super(system);
21 | }
22 |
23 | public ActorExecutionUnitPool createExecutionUnitPool() {
24 | return new ActorThreadPool((DefaultInternalActorRuntimeSystem)system);
25 | }
26 |
27 | @Override
28 | public ActorThreadPool getThreadPool() {
29 | return (ActorThreadPool)executionUnitPool;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/actor4j-core-runtime/src/main/java/io/actor4j/core/runtime/DefaultActorThreadFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime;
17 |
18 | public class DefaultActorThreadFactory extends DefaultThreadFactory {
19 |
20 | public DefaultActorThreadFactory(String name) {
21 | super(name);
22 | }
23 |
24 | public ActorThread newThread(DefaultInternalActorRuntimeSystem system) {
25 | ActorThread t = system.getActorThreadFactory().apply(group, name + "-worker-thread-" + index.getAndIncrement(), system);
26 |
27 | if (t.isDaemon())
28 | t.setDaemon(false);
29 | if (t.getPriority() != Thread.MAX_PRIORITY)
30 | t.setPriority(Thread.MAX_PRIORITY);
31 |
32 | return t;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/actor4j-core-runtime/src/main/java/io/actor4j/core/runtime/DefaultInternalActorExecutorService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime;
17 |
18 | public interface DefaultInternalActorExecutorService extends InternalActorExecutorService {
19 | public ActorThreadPool getThreadPool();
20 | }
21 |
--------------------------------------------------------------------------------
/actor4j-core-runtime/src/main/java/io/actor4j/core/runtime/DefaultInternalActorRuntimeSystem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime;
17 |
18 | public interface DefaultInternalActorRuntimeSystem extends InternalActorRuntimeSystem {
19 | public ActorThreadFactory getActorThreadFactory();
20 | }
21 |
--------------------------------------------------------------------------------
/actor4j-core-runtime/src/main/java/io/actor4j/core/runtime/DefaultUnboundedActorThread.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.runtime;
17 |
18 | import java.util.ArrayDeque;
19 | import java.util.LinkedList;
20 | import java.util.concurrent.ConcurrentLinkedQueue;
21 | import java.util.concurrent.PriorityBlockingQueue;
22 |
23 | public class DefaultUnboundedActorThread extends DefaultActorThread {
24 | public DefaultUnboundedActorThread(ThreadGroup group, String name, InternalActorSystem system) {
25 | super(group, name, system);
26 | }
27 |
28 | @Override
29 | public void configQueues() {
30 | directiveQueue = new ConcurrentLinkedQueue<>(); /* unbounded */
31 | priorityQueue = new PriorityBlockingQueue<>(queueSize); /* unbounded */
32 |
33 | serverQueueL2 = new ConcurrentLinkedQueue<>(); /* unbounded */
34 | serverQueueL1 = new ArrayDeque<>(bufferQueueSize); /* unbounded */
35 |
36 | outerQueueL2 = new ConcurrentLinkedQueue<>(); /* unbounded */
37 | outerQueueL1 = new ArrayDeque<>(bufferQueueSize); /* unbounded */
38 |
39 | innerQueue = new LinkedList<>(); /* unbounded */
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | io.actor4j
5 | actor4j-core
6 | ${revision}
7 |
8 | actor4j-core-sdk
9 | jar
10 |
11 | ${project.groupId}:${project.artifactId}
12 | Actor4j is an actor-oriented Java framework.
13 | https://github.com/relvaner/actor4j-core
14 | 2015
15 |
16 |
17 |
18 | The Apache License, Version 2.0
19 | http://www.apache.org/licenses/LICENSE-2.0.txt
20 | repo
21 |
22 |
23 |
24 |
25 |
26 | David A. Bauer
27 | relvaner.github@gmail.com
28 |
29 |
30 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/ActorPodService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.actor4j.core;
18 |
19 | import io.actor4j.core.id.ActorId;
20 | import io.actor4j.core.pods.PodContext;
21 | import io.actor4j.core.utils.PodActorFactory;
22 |
23 | public interface ActorPodService {
24 | public ActorId addPodActor(PodActorFactory factory, PodContext context);
25 | }
26 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/ActorSystemFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2019, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core;
17 |
18 | import java.util.function.Function;
19 |
20 | import io.actor4j.core.config.ActorSystemConfig;
21 |
22 | public interface ActorSystemFactory extends Function{
23 | }
24 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/EmbeddedActorCell.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core;
17 |
18 | import java.util.UUID;
19 | import java.util.function.Predicate;
20 |
21 | import io.actor4j.core.actors.ActorRef;
22 | import io.actor4j.core.id.ActorId;
23 | import io.actor4j.core.messages.ActorMessage;
24 |
25 | public interface EmbeddedActorCell extends ActorId {
26 | public ActorRef host();
27 |
28 | public ActorId localId();
29 | public UUID globalId();
30 |
31 | public ActorId getId();
32 | public ActorId getParent();
33 |
34 | public void become(Predicate> behaviour, boolean replace);
35 | public void unbecome();
36 | public void unbecomeAll();
37 |
38 | public void send(ActorMessage> message);
39 |
40 | public void preStart();
41 | public void restart(Exception reason);
42 | public void stop();
43 | }
44 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/actors/ActorDistributedGroupMember.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.actors;
17 |
18 | import java.util.UUID;
19 |
20 | public interface ActorDistributedGroupMember {
21 | public UUID getDistributedGroupId();
22 | }
23 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/actors/ActorGroupMember.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.actors;
17 |
18 | import java.util.UUID;
19 |
20 | public interface ActorGroupMember {
21 | public UUID getGroupId();
22 | }
23 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/actors/ActorIgnoreDistributedGroupMember.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.actors;
17 |
18 | public interface ActorIgnoreDistributedGroupMember {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/actors/ActorRegionMember.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2024, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.actors;
17 |
18 | import java.util.UUID;
19 |
20 | public interface ActorRegionMember extends ActorGroupMember {
21 | public default UUID getRegionId() {
22 | return getGroupId();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/actors/ActorVersionNumber.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.actors;
17 |
18 | public interface ActorVersionNumber {
19 | public String versionNumber();
20 | }
21 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/actors/ActorWithBothGroups.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.actors;
17 |
18 | import io.actor4j.core.utils.ActorGroup;
19 |
20 | public abstract class ActorWithBothGroups extends ActorWithDistributedGroup implements ActorGroupMember {
21 | public ActorWithBothGroups(ActorGroup group) {
22 | super(group);
23 | }
24 |
25 | public ActorWithBothGroups(String name, ActorGroup group) {
26 | super(name, group);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/actors/ActorWithDistributedGroup.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.actors;
17 |
18 | import java.util.UUID;
19 |
20 | import io.actor4j.core.utils.ActorGroup;
21 |
22 | public abstract class ActorWithDistributedGroup extends Actor implements ActorDistributedGroupMember {
23 | protected UUID distributedGroupId;
24 |
25 | public ActorWithDistributedGroup(ActorGroup group) {
26 | this(null, group);
27 | }
28 |
29 | public ActorWithDistributedGroup(String name, ActorGroup group) {
30 | super(name);
31 |
32 | distributedGroupId = group.getId();
33 | }
34 |
35 | @Override
36 | public UUID getDistributedGroupId() {
37 | return distributedGroupId;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/actors/ActorWithGroup.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.actors;
17 |
18 | import java.util.UUID;
19 |
20 | import io.actor4j.core.utils.ActorGroup;
21 |
22 | public abstract class ActorWithGroup extends Actor implements ActorGroupMember {
23 | protected UUID groupId;
24 |
25 | public ActorWithGroup(ActorGroup group) {
26 | this(null, group);
27 | }
28 |
29 | public ActorWithGroup(String name, ActorGroup group) {
30 | super(name);
31 |
32 | groupId = group.getId();
33 | }
34 |
35 | @Override
36 | public UUID getGroupId() {
37 | return groupId;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/actors/EmbeddedActorRef.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.actors;
17 |
18 | import io.actor4j.core.id.ActorId;
19 | import io.actor4j.core.messages.ActorMessage;
20 |
21 | public interface EmbeddedActorRef {
22 | public ActorRef host();
23 |
24 | public String getName();
25 | public ActorId getId();
26 | public ActorId self();
27 | public ActorId getParent();
28 |
29 | public void send(ActorMessage> message);
30 | public void send(ActorMessage> message, ActorId dest);
31 | public void tell(T value, int tag, ActorId dest);
32 | public void forward(ActorMessage> message, ActorId dest);
33 | }
34 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/actors/PersistenceId.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.actors;
17 |
18 | import java.util.UUID;
19 |
20 | public interface PersistenceId {
21 | public UUID persistenceId();
22 | }
23 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/actors/PersistentActor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.actors;
17 |
18 | import static io.actor4j.core.runtime.protocols.ActorProtocolTag.INTERNAL_RECOVER;
19 |
20 | import java.util.function.Consumer;
21 |
22 | import io.actor4j.core.json.JsonObject;
23 |
24 | public abstract class PersistentActor extends Actor implements PersistenceId {
25 | public static final int RECOVER = INTERNAL_RECOVER;
26 |
27 | public PersistentActor() {
28 | super();
29 | }
30 |
31 | public PersistentActor(String name) {
32 | super(name);
33 | }
34 |
35 | @SuppressWarnings("unchecked")
36 | public void persist(Consumer onSuccess, Consumer onFailure, E... events) {
37 | cell.persist(onSuccess, onFailure, events);
38 | }
39 |
40 | public void saveSnapshot(Consumer onSuccess, Consumer onFailure, S state) {
41 | cell.saveSnapshot(onSuccess, onFailure, state);
42 | }
43 |
44 | public void recover(JsonObject value) {
45 | // empty
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/actors/ResourceActor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.actors;
17 |
18 | public abstract class ResourceActor extends Actor {
19 | protected final boolean stateful;
20 | protected final boolean bulk;
21 |
22 | public ResourceActor() {
23 | this(null, false, false);
24 | }
25 |
26 | public ResourceActor(String name) {
27 | this(name, false, false);
28 | }
29 |
30 | public ResourceActor(boolean stateful) {
31 | this(null, stateful, false);
32 | }
33 |
34 | public ResourceActor(String name, boolean stateful) {
35 | this(name, stateful, false);
36 | }
37 |
38 | public ResourceActor(String name, boolean stateful, boolean bulk) {
39 | super(name);
40 | this.stateful = stateful;
41 | this.bulk = bulk;
42 | }
43 |
44 | public boolean isStateful() {
45 | return stateful;
46 | }
47 |
48 | public boolean isBulk() {
49 | return bulk;
50 | }
51 |
52 | public void before() {
53 | // empty
54 | }
55 |
56 | public void after() {
57 | // empty
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/actors/SecondaryActor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.actors;
17 |
18 | import static io.actor4j.core.actors.ActorWithCache.SUBSCRIBE_SECONDARY;
19 |
20 | import io.actor4j.core.id.ActorId;
21 | import io.actor4j.core.messages.ActorMessage;
22 | import io.actor4j.core.utils.ActorGroup;
23 |
24 | public abstract class SecondaryActor extends ActorWithDistributedGroup {
25 | protected /*final*/ ActorId primary;
26 |
27 | public SecondaryActor(ActorGroup group, ActorId primary) {
28 | this(null, group, primary);
29 | }
30 |
31 | public SecondaryActor(String name, ActorGroup group, ActorId primary) {
32 | super(name, group);
33 | this.primary = primary;
34 | }
35 |
36 | public void publish(ActorMessage> message) {
37 | send(message, primary);
38 | }
39 |
40 | public void publish(T value, int tag) {
41 | tell(value, tag, primary);
42 | }
43 |
44 | public void subscribeAsSecondary() {
45 | tell(null, SUBSCRIBE_SECONDARY, primary);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/actors/StatelessActor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.actors;
17 |
18 | import io.actor4j.core.utils.ActorGroup;
19 |
20 | public abstract class StatelessActor extends ActorWithDistributedGroup {
21 |
22 | public StatelessActor(ActorGroup group) {
23 | super(group);
24 | }
25 |
26 | public StatelessActor(String name, ActorGroup group) {
27 | super(name, group);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/config/ActorServiceConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.config;
17 |
18 | public class ActorServiceConfig extends ActorSystemConfig {
19 | public static abstract class Builder extends ActorSystemConfig.Builder {
20 | public Builder() {
21 | super();
22 | serverMode();
23 | }
24 |
25 | public Builder(T config) {
26 | super(config);
27 | serverMode();
28 | }
29 | }
30 |
31 | public ActorServiceConfig(Builder> builder) {
32 | super(builder);
33 | }
34 |
35 | public static ActorServiceConfig create() {
36 | return new ActorServiceConfig(builder());
37 | }
38 |
39 | public static Builder> builder() {
40 | return new Builder() {
41 | @Override
42 | public ActorServiceConfig build() {
43 | return new ActorServiceConfig(this);
44 | }
45 | };
46 | }
47 |
48 | public static Builder> builder(ActorServiceConfig config) {
49 | return new Builder(config) {
50 | @Override
51 | public ActorServiceConfig build() {
52 | return new ActorServiceConfig(this);
53 | }
54 | };
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/exceptions/ActorInitializationException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.exceptions;
17 |
18 | public class ActorInitializationException extends RuntimeException {
19 | protected static final long serialVersionUID = -6130654059639276742L;
20 |
21 | public ActorInitializationException() {
22 | super("actor initialization failed");
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/exceptions/ActorKilledException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.exceptions;
17 |
18 | public class ActorKilledException extends RuntimeException {
19 | protected static final long serialVersionUID = 5887686326593649655L;
20 |
21 | public ActorKilledException() {
22 | super("actor was killed");
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/exceptions/ActorResourceException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.exceptions;
17 |
18 | public class ActorResourceException extends RuntimeException {
19 | protected static final long serialVersionUID = 8954823248417031086L;
20 | }
21 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/exceptions/ActorSystemConfigException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.exceptions;
17 |
18 | public class ActorSystemConfigException extends RuntimeException {
19 | protected static final long serialVersionUID = -4944921391208119874L;
20 |
21 | public ActorSystemConfigException() {
22 | super("wrong configuration class");
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/function/Procedure.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.function;
17 |
18 | @FunctionalInterface
19 | public interface Procedure {
20 | public void apply();
21 | }
22 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/function/QuadConsumer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.function;
17 |
18 | import java.util.Objects;
19 |
20 | @FunctionalInterface
21 | public interface QuadConsumer {
22 | void accept(T t, U u, V v, W w);
23 |
24 | default QuadConsumer andThen(QuadConsumer super T, ? super U, ? super V, ? super W> after) {
25 | Objects.requireNonNull(after);
26 |
27 | return (t, u, v, w) -> {
28 | accept(t, u, v, w);
29 | after.accept(t, u, v, w);
30 | };
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/function/QuintConsumer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.function;
17 |
18 | import java.util.Objects;
19 |
20 | @FunctionalInterface
21 | public interface QuintConsumer {
22 | void accept(T t, U u, V v, W w, X x);
23 |
24 | default QuintConsumer andThen(QuintConsumer super T, ? super U, ? super V, ? super W, ? super X> after) {
25 | Objects.requireNonNull(after);
26 |
27 | return (t, u, v, w, x) -> {
28 | accept(t, u, v, w, x);
29 | after.accept(t, u, v, w, x);
30 | };
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/function/SextConsumer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.function;
17 |
18 | import java.util.Objects;
19 |
20 | @FunctionalInterface
21 | public interface SextConsumer {
22 | void accept(T t, U u, V v, W w, X x, Y y);
23 |
24 | default SextConsumer andThen(SextConsumer super T, ? super U, ? super V, ? super W, ? super X, ? super Y> after) {
25 | Objects.requireNonNull(after);
26 |
27 | return (t, u, v, w, x, y) -> {
28 | accept(t, u, v, w, x, y);
29 | after.accept(t, u, v, w, x, y);
30 | };
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/function/TriConsumer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.function;
17 |
18 | import java.util.Objects;
19 |
20 | @FunctionalInterface
21 | public interface TriConsumer {
22 | void accept(T t, U u, V v);
23 |
24 | default TriConsumer andThen(TriConsumer super T, ? super U, ? super V> after) {
25 | Objects.requireNonNull(after);
26 |
27 | return (t, u, v) -> {
28 | accept(t, u, v);
29 | after.accept(t, u, v);
30 | };
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/function/TriFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.function;
17 |
18 | import java.util.Objects;
19 | import java.util.function.Function;
20 |
21 | @FunctionalInterface
22 | public interface TriFunction {
23 | R apply(T t, U u, V v);
24 |
25 | default TriFunction andThen(Function super R, ? extends W> after) {
26 | Objects.requireNonNull(after);
27 | return (T t, U u, V v) -> after.apply(apply(t, u, v));
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/id/ActorId.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2025, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.id;
17 |
18 | import java.util.UUID;
19 |
20 | import io.actor4j.core.utils.Shareable;
21 |
22 | public interface ActorId extends Shareable {
23 | public ActorId localId();
24 | public UUID globalId();
25 |
26 | public static ActorId none() {
27 | return new ActorId() {
28 | @Override
29 | public ActorId localId() {
30 | return null;
31 | }
32 |
33 | @Override
34 | public UUID globalId() {
35 | return null;
36 | }
37 |
38 | };
39 | }
40 |
41 | public static ActorId of(UUID globalId) {
42 | return GlobalId.of(globalId);
43 | }
44 |
45 | public static ActorId ofRedirect() {
46 | return RedirectId.of();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/id/GlobalId.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2025, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.id;
17 |
18 | import java.util.UUID;
19 |
20 | public record GlobalId(ActorId localId, UUID globalId) implements ActorId {
21 | public static final UUID UUID_ZERO = UUID.fromString("00000000-0000-0000-0000-000000000000");
22 |
23 | public GlobalId(UUID globalId) {
24 | this(null, globalId);
25 | }
26 |
27 | public static ActorId of(String globalId) {
28 | UUID uuid = UUID_ZERO;
29 | try {
30 | uuid = UUID.fromString(globalId);
31 | }
32 | catch (IllegalArgumentException e) {
33 | e.printStackTrace();
34 | }
35 |
36 | return new GlobalId(uuid);
37 | }
38 |
39 | public static ActorId of(UUID globalId) {
40 | return new GlobalId(globalId);
41 | }
42 |
43 | public static ActorId random() {
44 | return new GlobalId(UUID.randomUUID());
45 | }
46 |
47 | public static ActorId zero() {
48 | return new GlobalId(UUID_ZERO);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/id/RedirectId.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2025, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.id;
17 |
18 | import java.util.UUID;
19 |
20 | public record RedirectId(ActorId localId, UUID globalId) implements ActorId {
21 | public RedirectId() {
22 | this(null, null);
23 | }
24 |
25 |
26 | public static ActorId of() {
27 | return new RedirectId();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/immutable/ImmutableCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2022, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.immutable;
17 |
18 | import io.actor4j.core.utils.Shareable;
19 |
20 | public interface ImmutableCollection extends Shareable {
21 | public C get();
22 | }
23 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/immutable/ImmutableList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.immutable;
17 |
18 | import java.util.Collections;
19 | import java.util.List;
20 |
21 | public class ImmutableList implements ImmutableCollection> {
22 | protected final List list;
23 |
24 | public ImmutableList() {
25 | super();
26 |
27 | this.list = Collections.emptyList();
28 | }
29 |
30 | public ImmutableList(List list) {
31 | super();
32 |
33 | this.list = Collections.unmodifiableList(list);
34 | }
35 |
36 | @Override
37 | public List get() {
38 | return list;
39 | }
40 |
41 | public static ImmutableList of() {
42 | return new ImmutableList<>();
43 | }
44 |
45 | public static ImmutableList of(List list) {
46 | return new ImmutableList<>(list);
47 | }
48 |
49 | @Override
50 | public String toString() {
51 | return "ImmutableList [list=" + list + "]";
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/actor4j-core-sdk/src/main/java/io/actor4j/core/immutable/ImmutableMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020, David A. Bauer. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.actor4j.core.immutable;
17 |
18 | import java.util.Collections;
19 | import java.util.Map;
20 |
21 | public class ImmutableMap implements ImmutableCollection