akka.actor.Address类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中akka.actor.Address类的一些代码示例,展示了Address类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address类的具体详情如下:
包路径:akka.actor.Address
类名称:Address

Address介绍

暂无

代码示例

代码示例来源:origin: apache/flink

final String akkaHostname = AkkaUtils.getAddress(actorSystem).host().get();
final int akkaPort = (Integer) AkkaUtils.getAddress(actorSystem).port().get();

代码示例来源:origin: apache/usergrid

@Override
public void preStart() {
  logger.debug("{} role {} address {}:{} starting up, subscribing to cluster events...", name,
    cluster.getSelfRoles().iterator().next(),
    cluster.readView().selfAddress().host(),
    cluster.readView().selfAddress().hostPort());
  cluster.subscribe(getSelf(), ClusterEvent.MemberEvent.class, ClusterEvent.ReachabilityEvent.class);
}

代码示例来源:origin: apache/usergrid

logger.info("Member is Up: {}, hostname: {}", event.member(),  event.member().address().host().get() );
logger.info("Member detected as unreachable: {}", event.member());
String hostname = event.member().address().host().get();

代码示例来源:origin: org.opendaylight.netconf/netconf-topology

@Override
public void preStart(){
  Cluster cluster = Cluster.get(actorSystem);
  for(Member node : cluster.state().getMembers()) {
    if(!node.address().equals(cluster.selfAddress())) {
      final NetconfTopologyPathCreator pathCreator = new NetconfTopologyPathCreator(node.address().toString(), topologyId);
      final String path = pathCreator.withSuffix(nodeId).withSuffix(NetconfTopologyPathCreator.MASTER_SOURCE_PROVIDER).build();
      actorSystem.actorSelection(path).tell(new AnnounceClusteredDeviceSourcesResolverUp(), TypedActor.context().self());
    }
  }
}

代码示例来源:origin: org.opendaylight.usc/usc-channel-impl

private boolean isLocalAddress(Address address) {
  if (cluster.selfAddress().equals(address)) {
    return true;
  } else {
    return false;
  }
}

代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore

StringBuilder getShardManagerActorPathBuilder(Address address) {
  return new StringBuilder().append(address.toString()).append("/user/").append(shardManagerIdentifier);
}

代码示例来源:origin: org.eclipse.ditto/ditto-services-utils-cluster

if (address.host().isDefined()) {
  try {
    final InetAddress inetAddress = InetAddress.getByName(address.host().get());
    log.debug("Found DNS entry '{}' for WEAKLY UP member: '{}'", inetAddress, weaklyUpMember);
      unreachableMembers.stream().map(Member::address).filter(a -> a.equals(knownAddress))
          .findFirst().ifPresent(a ->

代码示例来源:origin: org.deeplearning4j/deeplearning4j-scaleout-akka

conf.set(MASTER_URL,getMasterAddress().toString());
conf.set(MASTER_PATH,ActorRefUtils.absPath(masterActor, system));
  String host = a.host().get();

代码示例来源:origin: apache/flink

scala.Option<Object> portOption = AkkaUtils.getAddress(getContext().system()).port();
int actorSystemPort = portOption.isDefined() ? (int) portOption.get() : -1;

代码示例来源:origin: org.apache.flink/flink-runtime_2.11

AkkaInvocationHandler(
    String address,
    String hostname,
    ActorRef rpcEndpoint,
    Time timeout,
    long maximumFramesize,
    @Nullable CompletableFuture<Void> terminationFuture) {
  this.address = Preconditions.checkNotNull(address);
  this.hostname = Preconditions.checkNotNull(hostname);
  this.rpcEndpoint = Preconditions.checkNotNull(rpcEndpoint);
  this.isLocal = this.rpcEndpoint.path().address().hasLocalScope();
  this.timeout = Preconditions.checkNotNull(timeout);
  this.maximumFramesize = maximumFramesize;
  this.terminationFuture = terminationFuture;
}

代码示例来源:origin: keeps/roda

private void processAndAddSeedNode(List<Address> seedNodes, String node) {
 if (StringUtils.isBlank(node)) {
  return;
 }
 try {
  String[] nodeParts = node.split("#", 2);
  seedNodes.add(new Address("akka.tcp", EVENTS_SYSTEM, nodeParts[0], Integer.parseInt(nodeParts[1])));
 } catch (NumberFormatException | IndexOutOfBoundsException e) {
  // do nothing and carry on
 }
}

代码示例来源:origin: org.apache.flink/flink-runtime-web_2.10

@Override
  public BlobCache checkedApply(Object result) throws IOException {
    Option<String> hostOption = jobManager.actor().path().address().host();
    String host = hostOption.isDefined() ? hostOption.get() : "localhost";
    int port = (int) result;
    return new BlobCache(new InetSocketAddress(host, port), config, blobView);
  }
}, executor);

代码示例来源:origin: org.opendaylight.netconf/netconf-topology

public void registerMountPoint(final ActorSystem actorSystem, final ActorContext context) {
  if (remoteSchemaContext == null || netconfSessionPreferences == null) {
    LOG.debug("Master mount point does not have schemas ready yet, delaying registration");
    return;
  }
  Preconditions.checkNotNull(id);
  Preconditions.checkNotNull(remoteSchemaContext, "Device has no remote schema context yet. Probably not fully connected.");
  Preconditions.checkNotNull(netconfSessionPreferences, "Device has no capabilities yet. Probably not fully connected.");
  this.actorSystem = actorSystem;
  final NetconfDeviceNotificationService notificationService = new NetconfDeviceNotificationService();
  LOG.warn("Creating master data broker for device {}", id);
  deviceDataBroker = TypedActor.get(context).typedActorOf(new TypedProps<>(ProxyNetconfDeviceDataBroker.class, new Creator<NetconfDeviceMasterDataBroker>() {
    @Override
    public NetconfDeviceMasterDataBroker create() throws Exception {
      return new NetconfDeviceMasterDataBroker(actorSystem, id, remoteSchemaContext, deviceRpc, netconfSessionPreferences);
    }
  }), MOUNT_POINT);
  LOG.debug("Master data broker registered on path {}", TypedActor.get(actorSystem).getActorRefFor(deviceDataBroker).path());
  salProvider.getMountInstance().onTopologyDeviceConnected(remoteSchemaContext, deviceDataBroker, deviceRpc, notificationService);
  final Cluster cluster = Cluster.get(actorSystem);
  final Iterable<Member> members = cluster.state().getMembers();
  final ActorRef deviceDataBrokerRef = TypedActor.get(actorSystem).getActorRefFor(deviceDataBroker);
  for (final Member member : members) {
    if (!member.address().equals(cluster.selfAddress())) {
      final NetconfTopologyPathCreator pathCreator = new NetconfTopologyPathCreator(member.address().toString(),topologyId);
      final String path = pathCreator.withSuffix(id.getName()).build();
      actorSystem.actorSelection(path).tell(new AnnounceMasterMountPoint(), deviceDataBrokerRef);
    }
  }
}

代码示例来源:origin: org.opendaylight.controller/sal-remoterpc-connector

/**
 * Add member to the local copy of member list if it doesnt already
 * @param member
 */
void receiveMemberUp(Member member) {
  if (selfAddress.equals(member.address())) {
    return; //ignore up notification for self
  }
  if (!clusterMembers.contains(member.address())) {
    clusterMembers.add(member.address());
  }
  if(log.isDebugEnabled()) {
    log.debug("Added member [{}], Active member list [{}]", member.address(), clusterMembers);
  }
}

代码示例来源:origin: opendaylight/controller

@Override
public Map<String, String> findRpcByRoute(final String routeId) {
  RoutingTable localTable = getLocalData();
  Map<String, String> rpcMap = new HashMap<>(getRpcMemberMapByRoute(localTable, routeId, LOCAL_CONSTANT));
  Map<Address, Bucket<RoutingTable>> buckets = getRemoteBuckets();
  for (Entry<Address, Bucket<RoutingTable>> entry : buckets.entrySet()) {
    RoutingTable table = entry.getValue().getData();
    rpcMap.putAll(getRpcMemberMapByRoute(table, routeId, entry.getKey().toString()));
  }
  log.debug("list of RPCs {} searched by route {}", rpcMap, routeId);
  return rpcMap;
}

代码示例来源:origin: org.apache.flink/flink-yarn

scala.Option<Object> portOption = AkkaUtils.getAddress(getContext().system()).port();
int actorSystemPort = portOption.isDefined() ? (int) portOption.get() : -1;

代码示例来源:origin: com.alibaba.blink/flink-runtime

AkkaInvocationHandler(
    String address,
    String hostname,
    ActorRef rpcEndpoint,
    Time timeout,
    long maximumFramesize,
    @Nullable CompletableFuture<Void> terminationFuture) {
  this.address = Preconditions.checkNotNull(address);
  this.hostname = Preconditions.checkNotNull(hostname);
  this.rpcEndpoint = Preconditions.checkNotNull(rpcEndpoint);
  this.isLocal = this.rpcEndpoint.path().address().hasLocalScope();
  this.timeout = Preconditions.checkNotNull(timeout);
  this.maximumFramesize = maximumFramesize;
  this.terminationFuture = terminationFuture;
}

代码示例来源:origin: saturnism/akka-kubernetes-example

public static void main(String[] args) throws IOException {
  ActorSystem actorSystem = ActorSystem.create(CLUSTER_NAME);
  actorSystem.actorOf(SimpleClusterListener.props());
  final ActorMaterializer materializer = ActorMaterializer.create(actorSystem);

  Cluster cluster = Cluster.get(actorSystem);
  List<Address> addresses = Arrays.asList(System.getenv().get("SEED_NODES").split(","))
    .stream()
    .map(ip -> new Address("akka.tcp", CLUSTER_NAME, ip, 2551))
    .collect(Collectors.toList());
  cluster.joinSeedNodes(addresses);
 }
}

代码示例来源:origin: org.apache.flink/flink-runtime_2.11

public LeaderConnectionInfo(String address, UUID leaderSessionID) throws FlinkException {
  this.address = address;
  this.leaderSessionID = leaderSessionID;
  final Address akkaAddress;
  // this only works as long as the address is Akka based
  try {
    akkaAddress = AkkaUtils.getAddressFromAkkaURL(address);
  } catch (MalformedURLException e) {
    throw new FlinkException("Could not extract the hostname from the given address \'" +
      address + "\'.", e);
  }
  if (akkaAddress.host().isDefined()) {
    hostname = akkaAddress.host().get();
  } else {
    hostname = "localhost";
  }
  if (akkaAddress.port().isDefined()) {
    port = (int) akkaAddress.port().get();
  } else {
    port = -1;
  }
}

代码示例来源:origin: org.apache.flink/flink-runtime

private Tuple2<String, String> extractAddressHostname(ActorRef actorRef) {
  final String actorAddress = AkkaUtils.getAkkaURL(actorSystem, actorRef);
  final String hostname;
  Option<String> host = actorRef.path().address().host();
  if (host.isEmpty()) {
    hostname = "localhost";
  } else {
    hostname = host.get();
  }
  return Tuple2.of(actorAddress, hostname);
}

相关文章