Search in sources :

Example 1 with KerberosHadoopFileSystemFactory

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);
    }
}
Also used : IgniteException(org.apache.ignite.IgniteException) IOException(java.io.IOException) KerberosHadoopFileSystemFactory(org.apache.ignite.hadoop.fs.KerberosHadoopFileSystemFactory)

Example 2 with KerberosHadoopFileSystemFactory

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);
}
Also used : KerberosHadoopFileSystemFactory(org.apache.ignite.hadoop.fs.KerberosHadoopFileSystemFactory)

Example 3 with KerberosHadoopFileSystemFactory

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);
}
Also used : HadoopFileSystemFactoryDelegate(org.apache.ignite.internal.processors.hadoop.delegate.HadoopFileSystemFactoryDelegate) KerberosHadoopFileSystemFactory(org.apache.ignite.hadoop.fs.KerberosHadoopFileSystemFactory)

Example 4 with KerberosHadoopFileSystemFactory

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());
}
Also used : ObjectOutput(java.io.ObjectOutput) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectInput(java.io.ObjectInput) ObjectOutputStream(java.io.ObjectOutputStream) KerberosHadoopFileSystemFactory(org.apache.ignite.hadoop.fs.KerberosHadoopFileSystemFactory) ObjectInputStream(java.io.ObjectInputStream)

Aggregations

KerberosHadoopFileSystemFactory (org.apache.ignite.hadoop.fs.KerberosHadoopFileSystemFactory)4 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ObjectInput (java.io.ObjectInput)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutput (java.io.ObjectOutput)1 ObjectOutputStream (java.io.ObjectOutputStream)1 IgniteException (org.apache.ignite.IgniteException)1 HadoopFileSystemFactoryDelegate (org.apache.ignite.internal.processors.hadoop.delegate.HadoopFileSystemFactoryDelegate)1