@Override public WorkerNetAddress getAddress() { return new WorkerNetAddress() .setHost(NetworkAddressUtils.getConnectHost(ServiceType.WORKER_RPC, ServerConfiguration.global())) .setRpcPort(mRpcAddress.getPort()) .setDataPort(getDataLocalPort()) .setDomainSocketPath(getDataDomainSocketPath()) .setWebPort(mWebServer.getLocalPort()) .setTieredIdentity(mTieredIdentitiy); }
/** * Converts a proto type to a wire type. * * @param workerNetPAddress the proto type to convert * @return the converted wire type */ public static WorkerNetAddress fromProto(alluxio.grpc.WorkerNetAddress workerNetPAddress) { WorkerNetAddress workerNetAddress = new WorkerNetAddress(); workerNetAddress.setHost(workerNetPAddress.getHost()); workerNetAddress.setRpcPort(workerNetPAddress.getRpcPort()); workerNetAddress.setDataPort(workerNetPAddress.getDataPort()); workerNetAddress.setWebPort(workerNetPAddress.getWebPort()); workerNetAddress.setDomainSocketPath(workerNetPAddress.getDomainSocketPath()); workerNetAddress.setTieredIdentity(fromProto(workerNetPAddress.getTieredIdentity())); return workerNetAddress; }
/** * Creates a new instance of {@link WorkerNetAddress} from thrift representation. * * @param address the thrift net address * @return the instance */ public static WorkerNetAddress fromThrift(alluxio.thrift.WorkerNetAddress address) { TieredIdentity tieredIdentity = TieredIdentity.fromThrift(address.getTieredIdentity()); if (tieredIdentity == null) { // This means the worker is pre-1.7.0. We handle this in post-1.7.0 clients by filling out // the tiered identity using the hostname field. tieredIdentity = new TieredIdentity( Arrays.asList(new LocalityTier(Constants.LOCALITY_NODE, address.getHost()))); } return new WorkerNetAddress() .setDataPort(address.getDataPort()) .setDomainSocketPath(address.getDomainSocketPath()) .setHost(address.getHost()) .setRpcPort(address.getRpcPort()) .setTieredIdentity(tieredIdentity) .setWebPort(address.getWebPort()); }