protected ActorRef createSelfActor() { return actorSystem.actorOf( Props.create(AkkaAdapter.class, this), "ResourceManager"); }
private void subscribeToReservations( ActorSystem localSystem ) { logger.info("Starting ReservationCacheUpdater"); localSystem.actorOf( Props.create( ReservationCacheActor.class ), "subscriber"); }
/** Returns the actors to broadcast trace events to. */ private List<Routee> makeRoutes() { return Registry.policies(settings).stream().map(policy -> { ActorRef actorRef = context().actorOf(Props.create(PolicyActor.class, policy)); context().watch(actorRef); return new ActorRefRoutee(actorRef); }).collect(toList()); }
private ActorRef getOrCreateTenantActorByTokenId(String tenantId) { ActorRef tenantActor = tenants.get(tenantId); if (tenantActor == null) { tenantActor = context().actorOf( Props.create(new TenantActor.ActorCreator(context, tenantId)) .withDispatcher(CORE_DISPATCHER_NAME), tenantId); tenants.put(tenantId, tenantActor); } return tenantActor; }
@Inject public QueueWriterRouter() { this.router = getContext().actorOf( FromConfig.getInstance().props( Props.create( GuiceActorProducer.class, QueueWriter.class ) .withDispatcher("akka.blocking-io-dispatcher")), "router"); }
@Inject public QueueActorRouter( QueueActorRouterProducer queueActorRouterProducer, QakkaFig qakkaFig ) { this.queueActorRouterProducer = queueActorRouterProducer; this.qakkaFig = qakkaFig; this.routerRef = getContext().actorOf( FromConfig.getInstance().props( Props.create( GuiceActorProducer.class, QueueActor.class) .withDispatcher("akka.blocking-io-dispatcher")), "router"); }
private ActorRef getOrCreateGlobalUserActor(String userId) { String globalUserId = toGlobal(userId); ActorRef userActor = globalUsers.get(globalUserId); if (userActor == null && userId != null) { userActor = context().actorOf( Props.create(new GlobalUserActor.ActorCreator(context, userId, tenantId)) .withDispatcher(USER_DISPATCHER_NAME), globalUserId); LOG.debug("Create global user actor with id {}", userId); globalUsers.put(globalUserId, userActor); context().watch(userActor); } return userActor; }
@Inject public QueueSenderRouter() { this.router = getContext().actorOf( FromConfig.getInstance().props( Props.create( GuiceActorProducer.class, QueueSender.class ) .withDispatcher("akka.blocking-io-dispatcher")), "router"); }
@Inject public UniqueValuesRouter() { router = getContext().actorOf( FromConfig.getInstance().props( Props.create( GuiceActorProducer.class, UniqueValueActor.class) .withDispatcher("akka.blocking-io-dispatcher")), "router"); }
private ActorRef getOrCreateUserActor(String userId) { String localUserId = toLocal(userId); ActorRef userActor = localUsers.get(localUserId); if (userActor == null && userId != null) { userActor = context().actorOf( Props.create(new LocalUserActor.ActorCreator(context, userId, tenantId)) .withDispatcher(USER_DISPATCHER_NAME), localUserId); LOG.debug("Create local user actor with id {}", userId); localUsers.put(localUserId, userActor); context().watch(userActor); } return userActor; }
/** * Creates a new ApplicationClient actor or returns an existing one. May start an ActorSystem. * @return ActorSystem */ public ActorRef get() throws FlinkException { if (applicationClient == null) { // start application client LOG.info("Start application client."); final ActorSystem actorSystem; try { actorSystem = actorSystemLoader.get(); } catch (FlinkException fle) { throw new FlinkException("Could not start the ClusterClient's ActorSystem.", fle); } try { applicationClient = actorSystem.actorOf( Props.create( ApplicationClient.class, flinkConfig, highAvailabilityServices.getJobManagerLeaderRetriever(HighAvailabilityServices.DEFAULT_JOB_ID)), "applicationClient"); } catch (Exception e) { throw new FlinkException("Could not start the ApplicationClient.", e); } } return applicationClient; } }
private ActorRef getOrCreateLogActor(String name) { ActorRef logActor = logsSessions.get(name); if (logActor == null) { logActor = context().actorOf( Props.create(new ApplicationLogActor.ActorCreator(context, appToken)) .withDispatcher(LOG_DISPATCHER_NAME) ); context().watch(logActor); logsSessions.put(logActor.path().name(), logActor); } return logActor; }
private ActorRef getOrCreateUserVerifierActor(String name) { ActorRef userVerifierActor = userVerifierSessions.get(name); if (userVerifierActor == null) { userVerifierActor = context() .actorOf( Props.create(new ApplicationUserVerifierActor.ActorCreator(context, appToken)) .withDispatcher(VERIFIER_DISPATCHER_NAME) ); context().watch(userVerifierActor); userVerifierSessions.put(userVerifierActor.path().name(), userVerifierActor); } return userVerifierActor; }
@Override public void produceRouter(ActorSystem system, String role) { ClusterSingletonManagerSettings settings = ClusterSingletonManagerSettings.create( system ).withRole( "io" ); system.actorOf( ClusterSingletonManager.props( Props.create( GuiceActorProducer.class, QueueActorRouter.class ), PoisonPill.getInstance(), settings ), "queueActorRouter" ); ClusterSingletonProxySettings proxySettings = ClusterSingletonProxySettings.create( system ).withRole( role ); system.actorOf( ClusterSingletonProxy.props( "/user/queueActorRouter", proxySettings ), "queueActorRouterProxy" ); }
@Override public void produceRouter(ActorSystem system, String role) { ClusterSingletonManagerSettings settings = ClusterSingletonManagerSettings.create( system ).withRole( "io" ); system.actorOf( ClusterSingletonManager.props( Props.create( GuiceActorProducer.class, QueueSenderRouter.class ), PoisonPill.getInstance(), settings ), "queueSenderRouter" ); ClusterSingletonProxySettings proxySettings = ClusterSingletonProxySettings.create( system ).withRole( role ); system.actorOf( ClusterSingletonProxy.props( "/user/queueSenderRouter", proxySettings ), "queueSenderRouterProxy" ); }
@Override public void produceRouter(ActorSystem system, String role) { ClusterSingletonManagerSettings settings = ClusterSingletonManagerSettings.create( system ).withRole( "io" ); system.actorOf( ClusterSingletonManager.props( Props.create( GuiceActorProducer.class, QueueWriterRouter.class ), PoisonPill.getInstance(), settings ), "queueWriterRouter" ); ClusterSingletonProxySettings proxySettings = ClusterSingletonProxySettings.create( system ).withRole( role ); system.actorOf( ClusterSingletonProxy.props( "/user/queueWriterRouter", proxySettings ), "queueWriterRouterProxy" ); }
@Override public void produceRouter( ActorSystem system, String role ) { ClusterSingletonManagerSettings settings = ClusterSingletonManagerSettings.create( system ).withRole("io"); system.actorOf( ClusterSingletonManager.props( Props.create( GuiceActorProducer.class, UniqueValuesRouter.class ), PoisonPill.getInstance(), settings ), "uvRouter" ); ClusterSingletonProxySettings proxySettings = ClusterSingletonProxySettings.create( system ).withRole( role ); system.actorOf( ClusterSingletonProxy.props( "/user/uvRouter", proxySettings ), "uvProxy" ); subscribeToReservations( system ); }
/** * This test verifies correct job submission messaging logic and plan translation calls. */ @Test public void shouldSubmitToJobClient() throws Exception { jobManagerSystem.actorOf( Props.create(SuccessReturningActor.class), JobMaster.JOB_MANAGER_NAME); StandaloneClusterClient out = new StandaloneClusterClient(config); out.setDetached(true); JobSubmissionResult result = out.run(program.getPlanWithJars(), 1); assertNotNull(result); program.deleteExtractedLibraries(); }
/** * This test verifies correct that the correct exception is thrown when the job submission fails. */ @Test public void shouldSubmitToJobClientFails() throws Exception { jobManagerSystem.actorOf( Props.create(FailureReturningActor.class), JobMaster.JOB_MANAGER_NAME); StandaloneClusterClient out = new StandaloneClusterClient(config); out.setDetached(true); try { out.run(program.getPlanWithJars(), 1); fail("This should fail with an exception"); } catch (ProgramInvocationException e) { // bam! } catch (Exception e) { fail("wrong exception " + e); } }
@Test public void testGetExecutionPlan() { try { jobManagerSystem.actorOf( Props.create(FailureReturningActor.class), JobMaster.JOB_MANAGER_NAME); PackagedProgram prg = new PackagedProgram(TestOptimizerPlan.class, "/dev/random", "/tmp"); assertNotNull(prg.getPreviewPlan()); Optimizer optimizer = new Optimizer(new DataStatistics(), new DefaultCostEstimator(), config); OptimizedPlan op = (OptimizedPlan) ClusterClient.getOptimizedPlan(optimizer, prg, 1); assertNotNull(op); PlanJSONDumpGenerator dumper = new PlanJSONDumpGenerator(); assertNotNull(dumper.getOptimizerPlanAsJSON(op)); // test HTML escaping PlanJSONDumpGenerator dumper2 = new PlanJSONDumpGenerator(); dumper2.setEncodeForHTML(true); String htmlEscaped = dumper2.getOptimizerPlanAsJSON(op); assertEquals(-1, htmlEscaped.indexOf('\\')); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }