Search in sources :

Example 1 with OMRoleInfo

use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRoleInfo in project ozone by apache.

the class RpcClient method getOmRoleInfos.

@Override
public List<OMRoleInfo> getOmRoleInfos() throws IOException {
    List<ServiceInfo> serviceList = ozoneManagerClient.getServiceList();
    List<OMRoleInfo> roleInfos = new ArrayList<>();
    for (ServiceInfo serviceInfo : serviceList) {
        if (serviceInfo.getNodeType().equals(HddsProtos.NodeType.OM)) {
            OMRoleInfo omRoleInfo = serviceInfo.getOmRoleInfo();
            if (omRoleInfo != null) {
                roleInfos.add(omRoleInfo);
            }
        }
    }
    return roleInfos;
}
Also used : ServiceInfo(org.apache.hadoop.ozone.om.helpers.ServiceInfo) OMRoleInfo(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRoleInfo) ArrayList(java.util.ArrayList)

Example 2 with OMRoleInfo

use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRoleInfo in project ozone by apache.

the class OzoneManager method getServiceList.

@Override
public List<ServiceInfo> getServiceList() throws IOException {
    // When we implement multi-home this call has to be handled properly.
    List<ServiceInfo> services = new ArrayList<>();
    ServiceInfo.Builder omServiceInfoBuilder = ServiceInfo.newBuilder().setNodeType(HddsProtos.NodeType.OM).setHostname(omRpcAddress.getHostName()).setOmClientProtocolVersion(OZONE_OM_CLIENT_PROTOCOL_VERSION).addServicePort(ServicePort.newBuilder().setType(ServicePort.Type.RPC).setValue(omRpcAddress.getPort()).build());
    if (httpServer != null && httpServer.getHttpAddress() != null) {
        omServiceInfoBuilder.addServicePort(ServicePort.newBuilder().setType(ServicePort.Type.HTTP).setValue(httpServer.getHttpAddress().getPort()).build());
    }
    if (httpServer != null && httpServer.getHttpsAddress() != null) {
        omServiceInfoBuilder.addServicePort(ServicePort.newBuilder().setType(ServicePort.Type.HTTPS).setValue(httpServer.getHttpsAddress().getPort()).build());
    }
    // Since this OM is processing the request, we can assume it to be the
    // leader OM
    OMRoleInfo omRole = OMRoleInfo.newBuilder().setNodeId(getOMNodeId()).setServerRole(RaftPeerRole.LEADER.name()).build();
    omServiceInfoBuilder.setOmRoleInfo(omRole);
    if (isRatisEnabled) {
        if (omRatisServer != null) {
            omServiceInfoBuilder.addServicePort(ServicePort.newBuilder().setType(ServicePort.Type.RATIS).setValue(omNodeDetails.getRatisPort()).build());
        }
        for (OMNodeDetails peerNode : peerNodesMap.values()) {
            ServiceInfo.Builder peerOmServiceInfoBuilder = ServiceInfo.newBuilder().setNodeType(HddsProtos.NodeType.OM).setHostname(peerNode.getHostName()).setOmClientProtocolVersion(OZONE_OM_CLIENT_PROTOCOL_VERSION).addServicePort(ServicePort.newBuilder().setType(ServicePort.Type.RPC).setValue(peerNode.getRpcPort()).build());
            OMRoleInfo peerOmRole = OMRoleInfo.newBuilder().setNodeId(peerNode.getNodeId()).setServerRole(RaftPeerRole.FOLLOWER.name()).build();
            peerOmServiceInfoBuilder.setOmRoleInfo(peerOmRole);
            services.add(peerOmServiceInfoBuilder.build());
        }
    }
    services.add(omServiceInfoBuilder.build());
    // For client we have to return SCM with container protocol port,
    // not block protocol. This is information is being not used by
    // RpcClient, but for compatibility leaving as it is and also making sure
    // that this works for SCM HA.
    Collection<InetSocketAddress> scmAddresses = getScmAddressForClients(configuration);
    for (InetSocketAddress scmAddr : scmAddresses) {
        ServiceInfo.Builder scmServiceInfoBuilder = ServiceInfo.newBuilder().setNodeType(HddsProtos.NodeType.SCM).setHostname(scmAddr.getHostName()).addServicePort(ServicePort.newBuilder().setType(ServicePort.Type.RPC).setValue(scmAddr.getPort()).build());
        services.add(scmServiceInfoBuilder.build());
    }
    metrics.incNumGetServiceLists();
    // metrics.incNumGetServiceListFails()
    return services;
}
Also used : ServiceInfo(org.apache.hadoop.ozone.om.helpers.ServiceInfo) OMRoleInfo(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRoleInfo) OMNodeDetails(org.apache.hadoop.ozone.om.helpers.OMNodeDetails) InetSocketAddress(java.net.InetSocketAddress) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 ServiceInfo (org.apache.hadoop.ozone.om.helpers.ServiceInfo)2 OMRoleInfo (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRoleInfo)2 InetSocketAddress (java.net.InetSocketAddress)1 OMNodeDetails (org.apache.hadoop.ozone.om.helpers.OMNodeDetails)1