Search in sources :

Example 1 with Hadoop3OmTransportFactory

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");
    }
}
Also used : OzoneManagerProtocolClientSideTranslatorPB(org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB) OmTransport(org.apache.hadoop.ozone.om.protocolPB.OmTransport) OzoneClientException(org.apache.hadoop.ozone.client.OzoneClientException) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Hadoop3OmTransportFactory(org.apache.hadoop.ozone.om.protocolPB.Hadoop3OmTransportFactory)

Aggregations

OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)1 OzoneClientException (org.apache.hadoop.ozone.client.OzoneClientException)1 Hadoop3OmTransportFactory (org.apache.hadoop.ozone.om.protocolPB.Hadoop3OmTransportFactory)1 OmTransport (org.apache.hadoop.ozone.om.protocolPB.OmTransport)1 OzoneManagerProtocolClientSideTranslatorPB (org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB)1