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

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

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

Address.host介绍

暂无

代码示例

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

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

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

public static ActorSystem startJobClientActorSystem(Configuration config)
    throws IOException {
  LOG.info("Starting JobClient actor system");
  Option<Tuple2<String, Object>> remoting = new Some<>(new Tuple2<String, Object>("", 0));
  // start a remote actor system to listen on an arbitrary port
  ActorSystem system = AkkaUtils.createActorSystem(config, remoting);
  Address address = system.provider().getDefaultAddress();
  String hostAddress = address.host().isDefined() ?
      NetUtils.ipAddressToUrlString(InetAddress.getByName(address.host().get())) :
      "(unknown)";
  int port = address.port().isDefined() ? ((Integer) address.port().get()) : -1;
  LOG.info("Started JobClient actor system at " + hostAddress + ':' + port);
  return system;
}

代码示例来源: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: com.alibaba.blink/flink-runtime

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_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

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);
}

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

public AkkaJobManagerGateway(ActorGateway jobManagerGateway) {
  this.jobManagerGateway = Preconditions.checkNotNull(jobManagerGateway);
  final Option<String> optHostname = jobManagerGateway.actor().path().address().host();
  hostname = optHostname.isDefined() ? optHostname.get() : "localhost";
}

代码示例来源:origin: com.alibaba.blink/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);
}

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

public ActorContext(ActorSystem actorSystem, ActorRef shardManager,
    ClusterWrapper clusterWrapper, Configuration configuration,
    DatastoreContext datastoreContext, PrimaryShardInfoFutureCache primaryShardInfoCache) {
  this.actorSystem = actorSystem;
  this.shardManager = shardManager;
  this.clusterWrapper = clusterWrapper;
  this.configuration = configuration;
  this.datastoreContext = datastoreContext;
  this.dispatchers = new Dispatchers(actorSystem.dispatchers());
  this.primaryShardInfoCache = primaryShardInfoCache;
  this.shardStrategyFactory = new ShardStrategyFactory(configuration);
  setCachedProperties();
  Address selfAddress = clusterWrapper.getSelfAddress();
  if (selfAddress != null && !selfAddress.host().isEmpty()) {
    selfAddressHostPort = selfAddress.host().get() + ":" + selfAddress.port().get();
  } else {
    selfAddressHostPort = null;
  }
}

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

public AkkaJobManagerGateway(ActorGateway jobManagerGateway) {
  this.jobManagerGateway = Preconditions.checkNotNull(jobManagerGateway);
  final Option<String> optHostname = jobManagerGateway.actor().path().address().host();
  hostname = optHostname.isDefined() ? optHostname.get() : "localhost";
}

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

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);
}

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

public AkkaJobManagerGateway(ActorGateway jobManagerGateway) {
  this.jobManagerGateway = Preconditions.checkNotNull(jobManagerGateway);
  final Option<String> optHostname = jobManagerGateway.actor().path().address().host();
  hostname = optHostname.isDefined() ? optHostname.get() : "localhost";
}

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

private void handleMemberUp(final ClusterEvent.MemberUp memberUp) {
  final Member upMember = memberUp.member();
  log.debug("Member is UP: {}", upMember);
  final Address address = upMember.address();
  if (address.host().isDefined()) {
    try {
      final InetAddress inetAddress = InetAddress.getByName(address.host().get());
      log.debug("Found DNS entry '{}' for UP member: '{}'", inetAddress, upMember);
      knownAddresses.put(inetAddress.getHostName(), address);
    } catch (final UnknownHostException ex) {
      log.error(ex, "No DNS entry found for UP member: '{}'", upMember);
    }
  } else {
    log.warning("No host defined in address '{}' for UP member: '{}'", address, upMember);
  }
  scheduleMajorityCheck();
  cluster.sendCurrentClusterState(getSelf());
}

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

public AkkaRpcService(final ActorSystem actorSystem, final Time timeout) {
  this.actorSystem = checkNotNull(actorSystem, "actor system");
  this.timeout = checkNotNull(timeout, "timeout");
  if (actorSystem.settings().config().hasPath(MAXIMUM_FRAME_SIZE_PATH)) {
    maximumFramesize = actorSystem.settings().config().getBytes(MAXIMUM_FRAME_SIZE_PATH);
  } else {
    // only local communication
    maximumFramesize = Long.MAX_VALUE;
  }
  Address actorSystemAddress = AkkaUtils.getAddress(actorSystem);
  if (actorSystemAddress.host().isDefined()) {
    address = actorSystemAddress.host().get();
  } else {
    address = "";
  }
  internalScheduledExecutor = new InternalScheduledExecutorImpl(actorSystem);
}

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

public AkkaRpcService(final ActorSystem actorSystem, final Time timeout) {
  this.actorSystem = checkNotNull(actorSystem, "actor system");
  this.timeout = checkNotNull(timeout, "timeout");
  if (actorSystem.settings().config().hasPath(MAXIMUM_FRAME_SIZE_PATH)) {
    maximumFramesize = actorSystem.settings().config().getBytes(MAXIMUM_FRAME_SIZE_PATH);
  } else {
    // only local communication
    maximumFramesize = Long.MAX_VALUE;
  }
  Address actorSystemAddress = AkkaUtils.getAddress(actorSystem);
  if (actorSystemAddress.host().isDefined()) {
    address = actorSystemAddress.host().get();
  } else {
    address = "";
  }
  if (actorSystemAddress.port().isDefined()) {
    port = (Integer) actorSystemAddress.port().get();
  } else {
    port = -1;
  }
  internalScheduledExecutor = new ActorSystemScheduledExecutorAdapter(actorSystem);
  terminationFuture = new CompletableFuture<>();
  stopped = false;
}

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

public AkkaRpcService(final ActorSystem actorSystem, final Time timeout) {
  this.actorSystem = checkNotNull(actorSystem, "actor system");
  this.timeout = checkNotNull(timeout, "timeout");
  if (actorSystem.settings().config().hasPath(MAXIMUM_FRAME_SIZE_PATH)) {
    maximumFramesize = actorSystem.settings().config().getBytes(MAXIMUM_FRAME_SIZE_PATH);
  } else {
    // only local communication
    maximumFramesize = Long.MAX_VALUE;
  }
  Address actorSystemAddress = AkkaUtils.getAddress(actorSystem);
  if (actorSystemAddress.host().isDefined()) {
    address = actorSystemAddress.host().get();
  } else {
    address = "";
  }
  if (actorSystemAddress.port().isDefined()) {
    port = (Integer) actorSystemAddress.port().get();
  } else {
    port = -1;
  }
  internalScheduledExecutor = new ActorSystemScheduledExecutorAdapter(actorSystem);
  terminationFuture = new CompletableFuture<>();
  stopped = false;
}

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

public AkkaRpcService(final ActorSystem actorSystem, final Time timeout) {
  this.actorSystem = checkNotNull(actorSystem, "actor system");
  this.timeout = checkNotNull(timeout, "timeout");
  if (actorSystem.settings().config().hasPath(MAXIMUM_FRAME_SIZE_PATH)) {
    maximumFramesize = actorSystem.settings().config().getBytes(MAXIMUM_FRAME_SIZE_PATH);
  } else {
    // only local communication
    maximumFramesize = Long.MAX_VALUE;
  }
  Address actorSystemAddress = AkkaUtils.getAddress(actorSystem);
  if (actorSystemAddress.host().isDefined()) {
    address = actorSystemAddress.host().get();
  } else {
    address = "";
  }
  if (actorSystemAddress.port().isDefined()) {
    port = (Integer) actorSystemAddress.port().get();
  } else {
    port = -1;
  }
  internalScheduledExecutor = new ActorSystemScheduledExecutorAdapter(actorSystem);
  terminationFuture = new CompletableFuture<>();
  stopped = false;
}

相关文章