Sha256: fee92ed86a93ba144098dc26bf6a34b6ce7d55f27379518f971eadfdbf98dad3
Contents?: true
Size: 1.88 KB
Versions: 2
Compression:
Stored size: 1.88 KB
Contents
package com.game_machine.core; import akka.actor.ActorSelection; import akka.actor.ActorSystem; import akka.actor.Address; import akka.cluster.Cluster; import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; public class ActorUtil { public static void joinCluster(String protocol, String name, String host, int port) { ActorSystem system = GameMachineLoader.getActorSystem(); Address address = new Address(protocol,name,host,port); Cluster.get(system).join(address); } public static ActorSelection getSelectionByClass(Class<?> klass) { return GameMachineLoader.getActorSystem().actorSelection("/user/"+ klass.getSimpleName()); } public static ActorSelection findDistributed(String name, String id) { String server = Hashring.getHashring("servers").nodeFor(id); String actorName = Hashring.getHashring(name).nodeFor(id); return GameMachineLoader.getActorSystem().actorSelection(server+"/user/"+ actorName); } public static ActorSelection getSelectionByName(String name) { return GameMachineLoader.getActorSystem().actorSelection("/user/"+ name); } public static ActorSystem createSystem(String name) { return ActorSystem.create(name); } public static ActorSystem createSystem(String name, String hostname, String port) { if (hostname == null || port == null) { return createSystem(name); } String remoteConfig = name + ".akka.remote.netty.tcp.port=\"" + port + "\"\n" + name + ".akka.remote.netty.tcp.hostname=\"" + hostname + "\""; Config customConfig = ConfigFactory.parseString(remoteConfig).getConfig(name).withFallback(ConfigFactory.load()); return ActorSystem.create(name, customConfig); } public static ActorSystem createSystem(String name, String remoteConfig) { Config customConfig = ConfigFactory.parseString(remoteConfig).getConfig(name).withFallback(ConfigFactory.load()); return ActorSystem.create(name, customConfig); } }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
game_machine-1.0.4 | java/project/src/main/java/com/game_machine/core/ActorUtil.java |
game_machine-1.0.2 | java/project/src/main/java/com/game_machine/core/ActorUtil.java |