Search in sources :

Example 1 with OmTransport

use of org.apache.hadoop.ozone.om.protocolPB.OmTransport in project ozone by apache.

the class TestReplicatedFileChecksumHelper method init.

@Before
public void init() throws IOException {
    ConfigurationSource config = new InMemoryConfiguration();
    rpcClient = new RpcClient(config, null) {

        @Override
        protected OmTransport createOmTransport(String omServiceId) throws IOException {
            return new MockOmTransport();
        }

        @NotNull
        @Override
        protected XceiverClientFactory createXceiverClientFactory(List<X509Certificate> x509Certificates) throws IOException {
            return new MockXceiverClientFactory();
        }
    };
    client = new OzoneClient(config, rpcClient);
    store = client.getObjectStore();
}
Also used : ConfigurationSource(org.apache.hadoop.hdds.conf.ConfigurationSource) MockOmTransport(org.apache.hadoop.ozone.client.MockOmTransport) MockOmTransport(org.apache.hadoop.ozone.client.MockOmTransport) OmTransport(org.apache.hadoop.ozone.om.protocolPB.OmTransport) ByteString(org.apache.ratis.thirdparty.com.google.protobuf.ByteString) IOException(java.io.IOException) OzoneClient(org.apache.hadoop.ozone.client.OzoneClient) MockXceiverClientFactory(org.apache.hadoop.ozone.client.MockXceiverClientFactory) XceiverClientFactory(org.apache.hadoop.hdds.scm.XceiverClientFactory) NotNull(org.jetbrains.annotations.NotNull) X509Certificate(java.security.cert.X509Certificate) MockXceiverClientFactory(org.apache.hadoop.ozone.client.MockXceiverClientFactory) InMemoryConfiguration(org.apache.hadoop.hdds.conf.InMemoryConfiguration) RpcClient(org.apache.hadoop.ozone.client.rpc.RpcClient) Before(org.junit.Before)

Example 2 with OmTransport

use of org.apache.hadoop.ozone.om.protocolPB.OmTransport in project ozone by apache.

the class BaseFreonGenerator method createOmClient.

/**
 * Create the OM RPC client to use it for testing.
 */
public OzoneManagerProtocolClientSideTranslatorPB createOmClient(OzoneConfiguration conf, String omServiceID) throws IOException {
    UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
    RPC.setProtocolEngine(conf, OzoneManagerProtocolPB.class, ProtobufRpcEngine.class);
    String clientId = ClientId.randomId().toString();
    if (omServiceID == null) {
        // if only one serviceId is configured, use that
        final String[] configuredServiceIds = conf.getTrimmedStrings(OZONE_OM_SERVICE_IDS_KEY);
        if (configuredServiceIds.length == 1) {
            omServiceID = configuredServiceIds[0];
        }
    }
    OmTransport transport = OmTransportFactory.create(conf, ugi, omServiceID);
    return new OzoneManagerProtocolClientSideTranslatorPB(transport, clientId);
}
Also used : OzoneManagerProtocolClientSideTranslatorPB(org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB) OmTransport(org.apache.hadoop.ozone.om.protocolPB.OmTransport) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Example 3 with OmTransport

use of org.apache.hadoop.ozone.om.protocolPB.OmTransport in project ozone by apache.

the class ReconControllerModule method getOzoneManagerProtocol.

@Provides
OzoneManagerProtocol getOzoneManagerProtocol(final OzoneConfiguration ozoneConfiguration) {
    OzoneManagerProtocol ozoneManagerClient = null;
    try {
        ClientId clientId = ClientId.randomId();
        UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
        String serviceId = getOzoneManagerServiceId(ozoneConfiguration);
        OmTransport transport = OmTransportFactory.create(ozoneConfiguration, ugi, serviceId);
        ozoneManagerClient = new OzoneManagerProtocolClientSideTranslatorPB(transport, clientId.toString());
    } catch (IOException ioEx) {
        LOG.error("Error in provisioning OzoneManagerProtocol ", ioEx);
    }
    return ozoneManagerClient;
}
Also used : OzoneManagerProtocolClientSideTranslatorPB(org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB) OzoneManagerProtocol(org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol) OmTransport(org.apache.hadoop.ozone.om.protocolPB.OmTransport) ClientId(org.apache.ratis.protocol.ClientId) IOException(java.io.IOException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Provides(com.google.inject.Provides)

Example 4 with OmTransport

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

OmTransport (org.apache.hadoop.ozone.om.protocolPB.OmTransport)4 OzoneManagerProtocolClientSideTranslatorPB (org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB)3 IOException (java.io.IOException)2 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)2 Provides (com.google.inject.Provides)1 X509Certificate (java.security.cert.X509Certificate)1 ConfigurationSource (org.apache.hadoop.hdds.conf.ConfigurationSource)1 InMemoryConfiguration (org.apache.hadoop.hdds.conf.InMemoryConfiguration)1 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)1 XceiverClientFactory (org.apache.hadoop.hdds.scm.XceiverClientFactory)1 MockOmTransport (org.apache.hadoop.ozone.client.MockOmTransport)1 MockXceiverClientFactory (org.apache.hadoop.ozone.client.MockXceiverClientFactory)1 OzoneClient (org.apache.hadoop.ozone.client.OzoneClient)1 OzoneClientException (org.apache.hadoop.ozone.client.OzoneClientException)1 RpcClient (org.apache.hadoop.ozone.client.rpc.RpcClient)1 OzoneManagerProtocol (org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol)1 Hadoop3OmTransportFactory (org.apache.hadoop.ozone.om.protocolPB.Hadoop3OmTransportFactory)1 ClientId (org.apache.ratis.protocol.ClientId)1 ByteString (org.apache.ratis.thirdparty.com.google.protobuf.ByteString)1 NotNull (org.jetbrains.annotations.NotNull)1