Search in sources :

Example 1 with ServiceInfo

use of org.apache.hadoop.ozone.om.helpers.ServiceInfo 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 ServiceInfo

use of org.apache.hadoop.ozone.om.helpers.ServiceInfo 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)

Example 3 with ServiceInfo

use of org.apache.hadoop.ozone.om.helpers.ServiceInfo in project ozone by apache.

the class OzoneManagerProtocolClientSideTranslatorPB method getServiceInfo.

@Override
public ServiceInfoEx getServiceInfo() throws IOException {
    ServiceListRequest req = ServiceListRequest.newBuilder().build();
    OMRequest omRequest = createOMRequest(Type.ServiceList).setServiceListRequest(req).build();
    final ServiceListResponse resp = handleError(submitRequest(omRequest)).getServiceListResponse();
    return new ServiceInfoEx(resp.getServiceInfoList().stream().map(ServiceInfo::getFromProtobuf).collect(Collectors.toList()), resp.getCaCertificate(), resp.getCaCertsList());
}
Also used : ServiceInfo(org.apache.hadoop.ozone.om.helpers.ServiceInfo) OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) ServiceListRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ServiceListRequest) ServiceInfoEx(org.apache.hadoop.ozone.om.helpers.ServiceInfoEx) ServiceListResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ServiceListResponse)

Example 4 with ServiceInfo

use of org.apache.hadoop.ozone.om.helpers.ServiceInfo in project ozone by apache.

the class OzoneManagerRequestHandler method getServiceList.

private ServiceListResponse getServiceList(ServiceListRequest request) throws IOException {
    ServiceListResponse.Builder resp = ServiceListResponse.newBuilder();
    ServiceInfoEx serviceInfoEx = impl.getServiceInfo();
    List<OzoneManagerProtocolProtos.ServiceInfo> serviceInfoProtos = new ArrayList<>();
    List<ServiceInfo> serviceInfos = serviceInfoEx.getServiceInfoList();
    for (ServiceInfo info : serviceInfos) {
        serviceInfoProtos.add(info.getProtobuf());
    }
    resp.addAllServiceInfo(serviceInfoProtos);
    if (serviceInfoEx.getCaCertificate() != null) {
        resp.setCaCertificate(serviceInfoEx.getCaCertificate());
    }
    for (String ca : serviceInfoEx.getCaCertPemList()) {
        resp.addCaCerts(ca);
    }
    return resp.build();
}
Also used : ServiceInfo(org.apache.hadoop.ozone.om.helpers.ServiceInfo) ServiceInfoEx(org.apache.hadoop.ozone.om.helpers.ServiceInfoEx) ArrayList(java.util.ArrayList) ServiceListResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ServiceListResponse)

Example 5 with ServiceInfo

use of org.apache.hadoop.ozone.om.helpers.ServiceInfo in project ozone by apache.

the class RpcClient method validateOmVersion.

static boolean validateOmVersion(String expectedVersion, List<ServiceInfo> serviceInfoList) {
    if (expectedVersion == null || expectedVersion.isEmpty()) {
        // Empty strings assumes client is fine with any OM version.
        return true;
    }
    // At min one OM should be present.
    boolean found = false;
    for (ServiceInfo s : serviceInfoList) {
        if (s.getNodeType() == HddsProtos.NodeType.OM) {
            ComparableVersion comparableExpectedVersion = new ComparableVersion(expectedVersion);
            ComparableVersion comparableOMVersion = new ComparableVersion(s.getProtobuf().getOMProtocolVersion());
            if (comparableOMVersion.compareTo(comparableExpectedVersion) < 0) {
                return false;
            } else {
                found = true;
            }
        }
    }
    return found;
}
Also used : ServiceInfo(org.apache.hadoop.ozone.om.helpers.ServiceInfo) ComparableVersion(org.apache.hadoop.util.ComparableVersion)

Aggregations

ServiceInfo (org.apache.hadoop.ozone.om.helpers.ServiceInfo)6 ArrayList (java.util.ArrayList)3 InetSocketAddress (java.net.InetSocketAddress)2 ServiceInfoEx (org.apache.hadoop.ozone.om.helpers.ServiceInfoEx)2 OMRoleInfo (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRoleInfo)2 ServiceListResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ServiceListResponse)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HashMap (java.util.HashMap)1 List (java.util.List)1 OMNodeDetails (org.apache.hadoop.ozone.om.helpers.OMNodeDetails)1 OMRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest)1 ServiceListRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ServiceListRequest)1 ComparableVersion (org.apache.hadoop.util.ComparableVersion)1 HttpResponse (org.apache.http.HttpResponse)1 HttpClient (org.apache.http.client.HttpClient)1 HttpGet (org.apache.http.client.methods.HttpGet)1 Test (org.junit.Test)1