LOG.debug("keytabPath: {}", keytabPath); config.setString(SecurityOptions.KERBEROS_LOGIN_KEYTAB, keytabPath); config.setString(SecurityOptions.KERBEROS_LOGIN_PRINCIPAL, remoteKeytabPrincipal); final String amPortRange = config.getString( YarnConfigOptions.APPLICATION_MASTER_PORT); LOG); ActorRef resourceMaster = actorSystem.actorOf(resourceMasterProps); actorSystem.actorOf( Props.create(ProcessReaper.class, resourceMaster, LOG, ACTOR_DIED_EXIT_CODE), "YARN_Resource_Master_Process_Reaper"); actorSystem.actorOf( Props.create(ProcessReaper.class, jobManager, LOG, ACTOR_DIED_EXIT_CODE), "JobManager_Process_Reaper"); actorSystem.terminate().onComplete( new OnComplete<Terminated>() { public void onComplete(Throwable failure, Terminated result) { Await.ready(actorSystem.whenTerminated(), Duration.Inf()); } catch (InterruptedException | TimeoutException e) { LOG.error("Error shutting down actor system", e);
/** * Inits the actor system. */ @PostConstruct public void initActorSystem() { LOG.info("Initializing Akka system..."); akka = ActorSystem.create(EPS, context.getConfig()); LOG.info("Initializing Akka EPS actor..."); opsActor = akka.actorOf(Props.create( new OperationsServerActor.ActorCreator(context)) .withDispatcher(CORE_DISPATCHER_NAME), EPS); LOG.info("Lookup platform protocols"); Set<String> platformProtocols = PlatformLookup.lookupPlatformProtocols( PlatformLookup.DEFAULT_PROTOCOL_LOOKUP_PACKAGE_NAME); LOG.info("Initializing Akka io router..."); ioRouter = akka.actorOf( new RoundRobinPool(context.getIoWorkerCount()) .withSupervisorStrategy(SupervisionStrategyFactory.createIoRouterStrategy(context)) .props(Props.create(new EncDecActor.ActorCreator(opsActor, context, platformProtocols)) .withDispatcher(IO_DISPATCHER_NAME)), IO_ROUTER_ACTOR_NAME); LOG.info("Initializing Akka event service listener..."); eventListener = new AkkaEventServiceListener(opsActor); context.getEventService().addListener(eventListener); clusterListener = new AkkaClusterServiceListener(opsActor); context.getClusterService().setListener(clusterListener); LOG.info("Initializing Akka system done"); }
Cancellable scheduler = getContext().system().scheduler().schedule( Duration.create( 0, TimeUnit.MILLISECONDS ), Duration.create( qakkaFig.getQueueRefreshMilliseconds(), TimeUnit.MILLISECONDS ), self(), new QueueRefreshRequest( queueName, false ), getContext().dispatcher(), getSelf() ); refreshSchedulersByQueueName.put( queueName, scheduler ); Cancellable scheduler = getContext().system().scheduler().schedule( Duration.create( 0, TimeUnit.SECONDS ), Duration.create( qakkaFig.getQueueTimeoutSeconds() / 2, TimeUnit.SECONDS ), Cancellable scheduler = getContext().system().scheduler().schedule( Duration.create( 0, TimeUnit.MILLISECONDS ), Duration.create( qakkaFig.getShardAllocationCheckFrequencyMillis(), TimeUnit.MILLISECONDS ),
@Override public void close() throws Exception { if (isLoaded()) { actorSystem.terminate(); Await.ready(actorSystem.whenTerminated(), Duration.Inf()); actorSystem = null; } }
Props akkaRpcActorProps = Props.create(AkkaRpcActor.class, rpcEndpoint, terminationFuture); ActorRef actorRef; actorRef = actorSystem.actorOf(akkaRpcActorProps, rpcEndpoint.getEndpointId()); actors.add(actorRef); LOG.info("Starting RPC endpoint for {} at {} .", rpcEndpoint.getClass().getName(), actorRef.path()); final String address = AkkaUtils.getAkkaURL(actorSystem, actorRef); final String hostname; Option<String> host = actorRef.path().address().host(); if (host.isEmpty()) { hostname = "localhost"; } else { hostname = host.get();
/** * Wait and retry. */ public void waitAndRetry() { ContinueToSendToBatchSenderAsstManager continueToSendToBatchSenderAsstManager = new ContinueToSendToBatchSenderAsstManager( processedWorkerCount); logger.debug("NOW WAIT Another " + asstManagerRetryIntervalMillis + " MS. at " + PcDateUtils.getNowDateTimeStrStandard()); getContext() .system() .scheduler() .scheduleOnce( Duration.create(asstManagerRetryIntervalMillis, TimeUnit.MILLISECONDS), getSelf(), continueToSendToBatchSenderAsstManager, getContext().system().dispatcher(), getSelf()); return; }
new JavaTestKit(system) {{ final Deadline deadline = new FiniteDuration(3, TimeUnit.MINUTES).fromNow(); Configuration flinkConfig = new Configuration(); YarnConfiguration yarnConfig = new YarnConfiguration(); SettableLeaderRetrievalService leaderRetrievalService = new SettableLeaderRetrievalService( leader1 = system.actorOf( Props.create( TestingUtils.ForwardingActor.class, getRef(), Option.apply(leaderSessionID) )); resourceManager = system.actorOf( Props.create( TestingYarnFlinkResourceManager.class, flinkConfig, )); leaderRetrievalService.notifyListener(leader1.path().toString(), leaderSessionID); leaderRetrievalService.notifyListener(leader1.path().toString(), leaderSessionID);
public static void main(String... args) throws Exception { final ActorSystem system = ActorSystem.create("example"); final ActorRef persistentActor = system.actorOf(Props.create(ExamplePersistentActor.class), "persistentActor-3-java"); persistentActor.tell("a", null); persistentActor.tell("b", null); persistentActor.tell("snap", null); persistentActor.tell("c", null); persistentActor.tell("d", null); persistentActor.tell("print", null); Thread.sleep(10000); system.terminate(); } }
public AkkaRpcService(final ActorSystem actorSystem, final Time timeout) { this.actorSystem = checkNotNull(actorSystem, "actor system"); this.timeout = checkNotNull(timeout, "timeout"); if (actorSystem.settings().config().hasPath(MAXIMUM_FRAME_SIZE_PATH)) { maximumFramesize = actorSystem.settings().config().getBytes(MAXIMUM_FRAME_SIZE_PATH); } else { // only local communication maximumFramesize = Long.MAX_VALUE; } Address actorSystemAddress = AkkaUtils.getAddress(actorSystem); if (actorSystemAddress.host().isDefined()) { address = actorSystemAddress.host().get(); } else { address = ""; } internalScheduledExecutor = new InternalScheduledExecutorImpl(actorSystem); }
@Override public void downloadAndIndex(String path, IndexWriter writer) { ActorSystem actorSystem = ActorSystem.create(); ActorRef master = actorSystem.actorOf(Props.create(SupervisingActor.class, new IndexerImpl(writer), new ChaosMonkeyPageRetriever(path))); master.tell(path, actorSystem.guardian()); actorSystem.awaitTermination(); }
+ " at " + prepareRequestTimeStr); ActorRef worker = getContext().system().actorOf( Props.create(OperationWorker.class, new TaskRequest(task.getConfig() .getActorMaxOperationTimeoutSec(), maxConcurrency); batchSenderAsstManager = getContext().system().actorOf( Props.create(AssistantExecutionManager.class), "RequestToBatchSenderAsstManager-" + UUID.randomUUID().toString()); batchSenderAsstManager.tell(requestToBatchSenderAsstManager, getSelf()); TimeUnit.SECONDS); timeoutMessageCancellable = getContext() .system() .scheduler() .scheduleOnce(timeOutDuration, getSelf(), ExecutionManagerMsgType.OPERATION_TIMEOUT, getContext().system().dispatcher(), getSelf()); this.responseCount);
public static void main(String[] args) { ActorSystem system = ActorSystem.create(); final ActorRef supervisor = system.actorOf(Supervisor.props(), "supervisor"); for (int i = 0; i < 10; i++) { supervisor.tell(new NonTrustWorthyChild.Command(), ActorRef.noSender()); } System.out.println("ENTER to terminate"); StdIn.readLine(); system.terminate(); } }
void addMessageToRetry(Object message, ActorRef replyTo, String failureMessage) { LOG.debug("{}: Adding message {} to retry", shard.persistenceId(), message); MessageInfo messageInfo = new MessageInfo(message, replyTo, failureMessage); FiniteDuration period = shard.getDatastoreContext().getShardRaftConfig().getElectionTimeOutInterval().$times(2); messageInfo.timer = shard.getContext().system().scheduler().scheduleOnce(period, shard.getSelf(), messageInfo, shard.getContext().dispatcher(), ActorRef.noSender()); messagesToRetry.add(messageInfo); }
@RetryOnFailure(times = 1) public void testCheckpointRecoveryFailure() throws Exception { final Deadline testDeadline = TestTimeOut.fromNow(); final String zooKeeperQuorum = ZooKeeper.getConnectString(); final String fileStateBackendPath = temporaryFolder.newFolder().toString(); fileStateBackendPath); config.setInteger(ConfigConstants.LOCAL_NUMBER_JOB_MANAGER, 2); testActorSystem = AkkaUtils.createActorSystem(new Configuration(), new Some<>(new Tuple2<String, Object>("localhost", 0))); taskManagerSystem = AkkaUtils.createActorSystem( config, Option.apply(new Tuple2<String, Object>("localhost", 0))); TaskManager.startTaskManagerComponentsAndActor( config, leaderListener.waitForNewLeader(testDeadline.timeLeft().toMillis()); ActorRef leaderRef = AkkaUtils.getActorRef( leaderAddress, testActorSystem, testDeadline.timeLeft()); ActorGateway leader = new AkkaActorGateway(leaderRef, leaderId); taskManagerSystem.shutdown(); testActorSystem.shutdown();
final Configuration configuration = new Configuration(); final TestingHighAvailabilityServices highAvailabilityServices = new TestingHighAvailabilityServices(); final ActorSystem actorSystem = AkkaUtils.createDefaultActorSystem(); ActorRef actorRef = null; final UUID leaderId = UUID.randomUUID(); actorRef = actorSystem.actorOf( Props.create( JobClientActorTest.PlainActor.class, leaderId)); final String expectedAddress = AkkaUtils.getAkkaURL(actorSystem, actorRef); actorSystem.shutdown();
ActorSystem system = ActorSystem.create("PiSystem"); final ActorRef listener = system.actorOf(Props.create(Listener.class), "listener"); ActorRef master = system.actorOf(Props.create(Master.class, nrOfWorkers, nrOfMessages, nrOfElements, listener), "master"); master.tell(new Calculate(), ActorRef.noSender());