本文整理了Java中akka.actor.Props.create()
方法的一些代码示例,展示了Props.create()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Props.create()
方法的具体详情如下:
包路径:akka.actor.Props
类名称:Props
方法名:create
暂无
代码示例来源:origin: apache/flink
protected ActorRef createSelfActor() {
return actorSystem.actorOf(
Props.create(AkkaAdapter.class, this),
"ResourceManager");
}
代码示例来源:origin: apache/usergrid
private void subscribeToReservations( ActorSystem localSystem ) {
logger.info("Starting ReservationCacheUpdater");
localSystem.actorOf( Props.create( ReservationCacheActor.class ), "subscriber");
}
代码示例来源:origin: ben-manes/caffeine
/** 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());
}
代码示例来源:origin: kaaproject/kaa
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;
}
代码示例来源:origin: apache/usergrid
@Inject
public QueueWriterRouter() {
this.router = getContext().actorOf( FromConfig.getInstance().props(
Props.create( GuiceActorProducer.class, QueueWriter.class )
.withDispatcher("akka.blocking-io-dispatcher")), "router");
}
代码示例来源:origin: apache/usergrid
@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");
}
代码示例来源:origin: kaaproject/kaa
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;
}
代码示例来源:origin: apache/usergrid
@Inject
public QueueSenderRouter() {
this.router = getContext().actorOf( FromConfig.getInstance().props(
Props.create( GuiceActorProducer.class, QueueSender.class )
.withDispatcher("akka.blocking-io-dispatcher")), "router");
}
代码示例来源:origin: apache/usergrid
@Inject
public UniqueValuesRouter() {
router = getContext().actorOf( FromConfig.getInstance().props(
Props.create( GuiceActorProducer.class, UniqueValueActor.class)
.withDispatcher("akka.blocking-io-dispatcher")), "router");
}
代码示例来源:origin: kaaproject/kaa
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;
}
代码示例来源:origin: apache/flink
/**
* 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;
}
}
代码示例来源:origin: kaaproject/kaa
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;
}
代码示例来源:origin: kaaproject/kaa
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;
}
代码示例来源:origin: apache/usergrid
@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" );
}
代码示例来源:origin: apache/usergrid
@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" );
}
代码示例来源:origin: apache/usergrid
@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" );
}
代码示例来源:origin: apache/usergrid
@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 );
}
代码示例来源:origin: apache/flink
/**
* 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();
}
代码示例来源:origin: apache/flink
/**
* 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);
}
}
代码示例来源:origin: apache/flink
@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());
}
}
内容来源于网络,如有侵权,请联系作者删除!