use of org.apache.ignite.hadoop.fs.KerberosHadoopFileSystemFactory in project ignite by apache.
the class HadoopKerberosFileSystemFactoryDelegate method start.
@Override
public void start() throws IgniteException {
super.start();
KerberosHadoopFileSystemFactory proxy0 = (KerberosHadoopFileSystemFactory) proxy;
A.ensure(!F.isEmpty(proxy0.getKeyTab()), "keyTab cannot not be empty.");
A.ensure(!F.isEmpty(proxy0.getKeyTabPrincipal()), "keyTabPrincipal cannot not be empty.");
A.ensure(proxy0.getReloginInterval() >= 0, "reloginInterval cannot not be negative.");
reloginInterval = proxy0.getReloginInterval();
try {
UserGroupInformation.setConfiguration(cfg);
UserGroupInformation.loginUserFromKeytab(proxy0.getKeyTabPrincipal(), proxy0.getKeyTab());
} catch (IOException ioe) {
throw new IgniteException("Failed login from keytab [keyTab=" + proxy0.getKeyTab() + ", keyTabPrincipal=" + proxy0.getKeyTabPrincipal() + ']', ioe);
}
}
use of org.apache.ignite.hadoop.fs.KerberosHadoopFileSystemFactory in project ignite by apache.
the class KerberosHadoopFileSystemFactorySelfTest method testSerialization.
/**
* Checks serializatuion and deserialization of the secure factory.
*
* @throws Exception If failed.
*/
public void testSerialization() throws Exception {
KerberosHadoopFileSystemFactory fac = new KerberosHadoopFileSystemFactory();
checkSerialization(fac);
fac = new KerberosHadoopFileSystemFactory();
fac.setUri("igfs://igfs@localhost:10500/");
fac.setConfigPaths("/a/core-sute.xml", "/b/mapred-site.xml");
fac.setKeyTabPrincipal("foo");
fac.setKeyTab("/etc/krb5.keytab");
fac.setReloginInterval(30 * 60 * 1000L);
checkSerialization(fac);
}
use of org.apache.ignite.hadoop.fs.KerberosHadoopFileSystemFactory in project ignite by apache.
the class KerberosHadoopFileSystemFactorySelfTest method checkParameters.
/**
* Check parameters.
*
* @param keyTab Key tab.
* @param keyTabPrincipal Key tab principal.
* @param reloginInterval Re-login interval.
*/
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
private void checkParameters(String keyTab, String keyTabPrincipal, long reloginInterval) {
final KerberosHadoopFileSystemFactory fac = new KerberosHadoopFileSystemFactory();
fac.setKeyTab(keyTab);
fac.setKeyTabPrincipal(keyTabPrincipal);
fac.setReloginInterval(reloginInterval);
GridTestUtils.assertThrows(null, new Callable<Object>() {
@Override
public Object call() throws Exception {
HadoopFileSystemFactoryDelegate delegate = HadoopDelegateUtils.fileSystemFactoryDelegate(getClass().getClassLoader(), fac);
delegate.start();
return null;
}
}, IllegalArgumentException.class, null);
}
use of org.apache.ignite.hadoop.fs.KerberosHadoopFileSystemFactory in project ignite by apache.
the class KerberosHadoopFileSystemFactorySelfTest method checkSerialization.
/**
* Serializes the factory,
*
* @param fac The facory to check.
* @throws Exception If failed.
*/
private void checkSerialization(KerberosHadoopFileSystemFactory fac) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutput oo = new ObjectOutputStream(baos);
oo.writeObject(fac);
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
KerberosHadoopFileSystemFactory fac2 = (KerberosHadoopFileSystemFactory) in.readObject();
assertEquals(fac.getUri(), fac2.getUri());
Assert.assertArrayEquals(fac.getConfigPaths(), fac2.getConfigPaths());
assertEquals(fac.getKeyTab(), fac2.getKeyTab());
assertEquals(fac.getKeyTabPrincipal(), fac2.getKeyTabPrincipal());
assertEquals(fac.getReloginInterval(), fac2.getReloginInterval());
}
Aggregations