use of org.apache.hadoop.ozone.om.protocolPB.Hadoop3OmTransportFactory in project ozone by apache.
the class OMAdmin method createOmClient.
public OzoneManagerProtocolClientSideTranslatorPB createOmClient(String omServiceID, String omHost, boolean forceHA) throws Exception {
OzoneConfiguration conf = parent.getOzoneConf();
if (omHost != null && !omHost.isEmpty()) {
omServiceID = null;
conf.set(OZONE_OM_ADDRESS_KEY, omHost);
} else if (omServiceID == null || omServiceID.isEmpty()) {
omServiceID = getTheOnlyConfiguredOmServiceIdOrThrow();
}
RPC.setProtocolEngine(conf, OzoneManagerProtocolPB.class, ProtobufRpcEngine.class);
String clientId = ClientId.randomId().toString();
if (!forceHA || (forceHA && OmUtils.isOmHAServiceId(conf, omServiceID))) {
OmTransport omTransport = new Hadoop3OmTransportFactory().createOmTransport(conf, parent.getUser(), omServiceID);
return new OzoneManagerProtocolClientSideTranslatorPB(omTransport, clientId);
} else {
throw new OzoneClientException("This command works only on OzoneManager" + " HA cluster. Service ID specified does not match" + " with " + OZONE_OM_SERVICE_IDS_KEY + " defined in the " + "configuration. Configured " + OZONE_OM_SERVICE_IDS_KEY + " are " + conf.getTrimmedStringCollection(OZONE_OM_SERVICE_IDS_KEY) + "\n");
}
}
Aggregations