akka.actor.Address.toString()方法的使用及代码示例

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

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

Address.toString介绍

暂无

代码示例

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

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

代码示例来源: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: opendaylight/controller

@Override
public Map<String, String> findRpcByName(final String name) {
  RoutingTable localTable = getLocalData();
  // Get all RPCs from local bucket
  Map<String, String> rpcMap = new HashMap<>(getRpcMemberMapByName(localTable, name, LOCAL_CONSTANT));
  // Get all RPCs from remote bucket
  Map<Address, Bucket<RoutingTable>> buckets = getRemoteBuckets();
  for (Entry<Address, Bucket<RoutingTable>> entry : buckets.entrySet()) {
    RoutingTable table = entry.getValue().getData();
    rpcMap.putAll(getRpcMemberMapByName(table, name, entry.getKey().toString()));
  }
  log.debug("list of RPCs {} searched by name {}", rpcMap, name);
  return rpcMap;
}

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

@Override
public Map<String, String> findRpcByRoute(String routeId) {
  RoutingTable localTable = rpcRegistry.getLocalBucket().getData();
  Map<String, String> rpcMap = new HashMap<>(getRpcMemberMapByRoute(localTable, routeId, LOCAL_CONSTANT));
  Map<Address, Bucket<RoutingTable>> buckets = rpcRegistry.getRemoteBuckets();
  for(Address address : buckets.keySet()) {
    RoutingTable table = buckets.get(address).getData();
    rpcMap.putAll(getRpcMemberMapByRoute(table, routeId, address.toString()));
  }
  if(log.isDebugEnabled()) {
    log.debug("list of RPCs {} searched by route {}", rpcMap, routeId);
  }
  return rpcMap;
}

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

@Override
public Map<String, String> findRpcByName(final String name) {
  RoutingTable localTable = rpcRegistry.getLocalBucket().getData();
  // Get all RPCs from local bucket
  Map<String, String> rpcMap = new HashMap<>(getRpcMemberMapByName(localTable, name, LOCAL_CONSTANT));
  // Get all RPCs from remote bucket
  Map<Address, Bucket<RoutingTable>> buckets = rpcRegistry.getRemoteBuckets();
  for(Address address : buckets.keySet()) {
    RoutingTable table = buckets.get(address).getData();
    rpcMap.putAll(getRpcMemberMapByName(table, name, address.toString()));
  }
  if(log.isDebugEnabled()) {
    log.debug("list of RPCs {} searched by name {}", rpcMap, name);
  }
  return rpcMap;
}

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

private void addPeer(final Address address) {
  if (!clusterMembers.contains(address)) {
    clusterMembers.add(address);
  }
  peers.computeIfAbsent(address, input -> getContext().system()
    .actorSelection(input.toString() + getSelf().path().toStringWithoutAddress()));
}

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

@Override
public ClusterStatus get() {
  final Function<Member, String> mapMemberToString = member -> member.address().toString();
  final Set<Member> unreachable = cluster.state().getUnreachable(); //
  final Set<Member> all =
      StreamSupport.stream(cluster.state().getMembers().spliterator(), false).collect(Collectors.toSet());
  final Set<Member> reachable = all.stream().filter(m -> !unreachable.contains(m)).collect(Collectors.toSet());
  final Set<ClusterRoleStatus> roles = new HashSet<>(cluster.state().getAllRoles().size());
  cluster.state().getAllRoles().forEach(role -> { //
    final Predicate<Member> filterRole = member -> member.getRoles().contains(role);
    roles.add(ClusterRoleStatus.of( //
        role, //
        reachable.stream().filter(filterRole).map(mapMemberToString).collect(Collectors.toSet()), //
        unreachable.stream().filter(filterRole).map(mapMemberToString).collect(Collectors.toSet()), //
        Optional.ofNullable(cluster.state().getRoleLeader(role)).map(Address::toString).orElse(null) //
    ));
  });
  return ClusterStatus.of( //
      reachable.stream().map(mapMemberToString).collect(Collectors.toSet()), //
      unreachable.stream().map(mapMemberToString).collect(Collectors.toSet()), //
      cluster.state().getSeenBy().stream().map(Address::toString).collect(Collectors.toSet()), //
      Optional.ofNullable(cluster.state().getLeader()).map(Address::toString).orElse(null), //
      cluster.getSelfRoles(), //
      roles //
  );
}

代码示例来源:origin: eclipse/ditto

@Override
public ClusterStatus get() {
  final Function<Member, String> mapMemberToString = member -> member.address().toString();
  final Set<Member> unreachable = cluster.state().getUnreachable(); //
  final Set<Member> all =
      StreamSupport.stream(cluster.state().getMembers().spliterator(), false).collect(Collectors.toSet());
  final Set<Member> reachable = all.stream().filter(m -> !unreachable.contains(m)).collect(Collectors.toSet());
  final Set<ClusterRoleStatus> roles = new HashSet<>(cluster.state().getAllRoles().size());
  cluster.state().getAllRoles().forEach(role -> { //
    final Predicate<Member> filterRole = member -> member.getRoles().contains(role);
    roles.add(ClusterRoleStatus.of( //
        role, //
        reachable.stream().filter(filterRole).map(mapMemberToString).collect(Collectors.toSet()), //
        unreachable.stream().filter(filterRole).map(mapMemberToString).collect(Collectors.toSet()), //
        Optional.ofNullable(cluster.state().getRoleLeader(role)).map(Address::toString).orElse(null) //
    ));
  });
  return ClusterStatus.of( //
      reachable.stream().map(mapMemberToString).collect(Collectors.toSet()), //
      unreachable.stream().map(mapMemberToString).collect(Collectors.toSet()), //
      cluster.state().getSeenBy().stream().map(Address::toString).collect(Collectors.toSet()), //
      Optional.ofNullable(cluster.state().getLeader()).map(Address::toString).orElse(null), //
      cluster.getSelfRoles(), //
      roles //
  );
}

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

/**
 * Returns the absolute path of the given actor given the system
 * @param self the actor to getFromOrigin the absolute path for
 * @param system the actor's system
 * @return the absolute path of the given actor
 */
public static String absPath(ActorRef self,ActorSystem system) {
  String address = Cluster.get(system).selfAddress().toString();
  List<String> path2 = new ArrayList<String>();
  scala.collection.immutable.Iterable<String> elements = self.path().elements();
  scala.collection.Iterator<String> iter = elements.iterator();
  while(iter.hasNext())
    path2.add(iter.next());
  String absPath = "/" + org.apache.commons.lang3.StringUtils.join(path2, "/");
  return address + absPath + "/";
  
  
}

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

private void updateActorListFromCluster() {
  List<String> actorList = new ArrayList<String>();
  ActorSelection remoteActorSelection = null;
  scala.collection.immutable.List<Address> seedNodeList = cluster.settings().SeedNodes().toList();
  for (Address address : JavaConversions.seqAsJavaList(seedNodeList)) {
    if (isLocalAddress(address)) {
      continue;
    }
    actorList.add(address.toString());
  }
  for (String path : actorList) {
    if (!isLocalActor(path)) {
      path = path + communicator.path().toStringWithoutAddress();
      remoteActorSelection = actorSystem.actorSelection(path);
      if (remoteActorSelection != null) {
        remoteActors.add(remoteActorSelection);
      } else {
        LOG.error("Failed to get actor selection for " + path);
      }
    }
  }
}

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

/**
 * process member down event for cluster
 *
 * @param member
 *            the member of cluster
 * @return always true,currently not false
 */
public boolean clusterMemberDown(Member member) {
  if (isLocalAddress(member.address())) {
    return true;
  }
  for (ActorSelection actorSelection : remoteActors) {
    LOG.info("clusterMemberDown: actorSelection is " + actorSelection.pathString() + ",member is "
        + member.address());
    if (actorSelection.pathString().contains(member.address().toString())) {
      remoteActors.remove(actorSelection);
      String actorPath = member.address() + communicator.path().toStringWithoutAddress();
      // remove all remote channels related with the specified cluster
      // member
      deviceTable.removeAll(actorPath);
      LOG.info("Succed to remove the remote actor when Member(" + member.address()
          + ") is down or unreachable.");
      return true;
    }
  }
  LOG.info("Failed to remove the remote actor when Member(" + member.address() + ") is down or unreachable.");
  return false;
}

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

/**
 * Gets bucket versions from bucket store and sends to the supplied address
 *
 * @param remoteActorSystemAddress remote gossiper to send to
 */
void getLocalStatusAndSendTo(Address remoteActorSystemAddress){
  //Get local status from bucket store and send to remote
  Future<Object> futureReply =
      Patterns.ask(getContext().parent(), new GetBucketVersions(), config.getAskDuration());
  //Find gossiper on remote system
  ActorSelection remoteRef = getContext().system().actorSelection(
      remoteActorSystemAddress.toString() + getSelf().path().toStringWithoutAddress());
  if(log.isTraceEnabled()) {
    log.trace("Sending bucket versions to [{}]", remoteRef);
  }
  futureReply.map(getMapperToSendLocalStatus(remoteRef), getContext().dispatcher());
}

代码示例来源: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.netconf/netconf-topology

@Override
public void onDeviceFailed(Throwable throwable) {
  // we need to notify the higher level that something happened, get a current status from all other nodes, and aggregate a new result
  // no need to remove mountpoint, we should receive onRoleChanged callback after unregistering from election that unregisters the mountpoint
  LOG.warn("Netconf node {} failed with {}", nodeId, throwable);
  connected = false;
  String reason = (throwable != null && throwable.getMessage() != null) ? throwable.getMessage() : UNKNOWN_REASON;
  currentOperationalNode = new NodeBuilder().setNodeId(new NodeId(nodeId))
      .addAugmentation(NetconfNode.class,
          new NetconfNodeBuilder()
              .setConnectionStatus(ConnectionStatus.UnableToConnect)
              .setAvailableCapabilities(new AvailableCapabilitiesBuilder().setAvailableCapability(new ArrayList<String>()).build())
              .setUnavailableCapabilities(new UnavailableCapabilitiesBuilder().setUnavailableCapability(new ArrayList<UnavailableCapability>()).build())
              .setClusteredConnectionStatus(
                  new ClusteredConnectionStatusBuilder()
                      .setNodeStatus(
                          Collections.singletonList(
                              new NodeStatusBuilder()
                                  .setNode(clusterExtension.selfAddress().toString())
                                  .setStatus(Status.Failed)
                                  .build()))
                      .build())
              .setConnectedMessage(reason)
              .build()).build();
  topologyManager.notifyNodeStatusChange(new NodeId(nodeId));
}

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

@Nonnull @Override public Node getFailedState(@Nonnull final NodeId nodeId,
                       @Nullable final Node configNode) {
  final NetconfNode netconfNode = configNode == null ? currentOperationalNode.getAugmentation(NetconfNode.class) : configNode.getAugmentation(NetconfNode.class);
  final Node failedNode = new NodeBuilder()
      .setNodeId(nodeId)
      .addAugmentation(NetconfNode.class,
          new NetconfNodeBuilder()
              .setHost(netconfNode.getHost())
              .setPort(netconfNode.getPort())
              .setConnectionStatus(ConnectionStatus.UnableToConnect)
              .setAvailableCapabilities(new AvailableCapabilitiesBuilder().setAvailableCapability(new ArrayList<String>()).build())
              .setUnavailableCapabilities(new UnavailableCapabilitiesBuilder().setUnavailableCapability(new ArrayList<UnavailableCapability>()).build())
              .setClusteredConnectionStatus(
                  new ClusteredConnectionStatusBuilder()
                      .setNodeStatus(
                          Collections.singletonList(
                              new NodeStatusBuilder()
                                  .setNode(clusterExtension.selfAddress().toString())
                                  .setStatus(Status.Failed)
                                  .build()))
                      .build())
              .build())
      .build();
  if (currentOperationalNode == null) {
    currentOperationalNode = failedNode;
  }
  return failedNode;
}

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

@Nullable
  @Override
  public Node apply(NetconfDeviceCapabilities input) {
    // build state data
    return new NodeBuilder()
        .setNodeId(nodeId)
        .addAugmentation(NetconfNode.class,
            new NetconfNodeBuilder()
                .setConnectionStatus(ConnectionStatus.Connected)
                .setClusteredConnectionStatus(
                    new ClusteredConnectionStatusBuilder()
                        .setNodeStatus(
                            Collections.singletonList(
                                new NodeStatusBuilder()
                                    .setNode(clusterExtension.selfAddress().toString())
                                    .setStatus(Status.Connected)
                                    .build()))
                        .build())
                .setHost(netconfNode.getHost())
                .setPort(netconfNode.getPort())
                .setAvailableCapabilities(new AvailableCapabilitiesBuilder().setAvailableCapability(new ArrayList<String>()).build())
                .setUnavailableCapabilities(new UnavailableCapabilitiesBuilder().setUnavailableCapability(new ArrayList<UnavailableCapability>()).build())
                .build())
        .build();
  }
});

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

@Nullable
  @Override
  public Node apply(NetconfDeviceCapabilities input) {
    // build state data
    currentOperationalNode = new NodeBuilder().setNodeId(nodeId)
        .addAugmentation(NetconfNode.class,
            new NetconfNodeBuilder()
                .setConnectionStatus(ConnectionStatus.Connected)
                .setClusteredConnectionStatus(
                    new ClusteredConnectionStatusBuilder()
                        .setNodeStatus(
                            Collections.singletonList(
                                new NodeStatusBuilder()
                                    .setNode(clusterExtension.selfAddress().toString())
                                    .setStatus(Status.Connected)
                                    .build()))
                        .build())
                .setHost(netconfNode.getHost())
                .setPort(netconfNode.getPort())
                .setAvailableCapabilities(new AvailableCapabilitiesBuilder().setAvailableCapability(new ArrayList<String>()).build())
                .setUnavailableCapabilities(new UnavailableCapabilitiesBuilder().setUnavailableCapability(new ArrayList<UnavailableCapability>()).build())
                .build()).build();
    return currentOperationalNode;
  }
});

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

public void unregisterMountPoint() {
  salProvider.getMountInstance().onTopologyDeviceDisconnected();
  if (deviceDataBroker != null) {
    LOG.debug("Stopping master data broker for device {}", id.getName());
    for (final Member member : Cluster.get(actorSystem).state().getMembers()) {
      if (member.address().equals(Cluster.get(actorSystem).selfAddress())) {
        continue;
      }
      final NetconfTopologyPathCreator pathCreator = new NetconfTopologyPathCreator(member.address().toString(), topologyId);
      final String path = pathCreator.withSuffix(id.getName()).build();
      actorSystem.actorSelection(path).tell(new AnnounceMasterMountPointDown(), null);
    }
    TypedActor.get(actorSystem).stop(deviceDataBroker);
    deviceDataBroker = null;
  }
}

代码示例来源: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.netconf/netconf-topology

@Override
  public void preStart() {
    Cluster cluster = Cluster.get(actorSystem);
    cluster.join(cluster.selfAddress());
    LOG.debug("Notifying members master schema source provider is up.");
    for(Member node : cluster.state().getMembers()) {
      final NetconfTopologyPathCreator pathCreator = new NetconfTopologyPathCreator(node.address().toString(),topologyId);
      final String path = pathCreator.withSuffix(nodeId).withSuffix(NetconfTopologyPathCreator.CLUSTERED_DEVICE_SOURCES_RESOLVER).build();
      if(node.address().equals(cluster.selfAddress())) {
        actorSystem.actorSelection(path).tell(new AnnounceMasterOnSameNodeUp(), TypedActor.context().self());
        actorSystem.actorSelection(path).tell(PoisonPill.getInstance(), TypedActor.context().self());
      } else {
        //TODO extract string constant to util class
        actorSystem.actorSelection(path).tell(new AnnounceMasterSourceProviderUp(), TypedActor.context().self());
      }
    }
  }
}

相关文章