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