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