ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [05/11] ignite git commit: IGNITE-3202: Renames.
Date Mon, 30 May 2016 16:05:15 GMT
IGNITE-3202: Renames.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/eaab1b06
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/eaab1b06
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/eaab1b06

Branch: refs/heads/ignite-3202
Commit: eaab1b066f4718007e7aad30579263d870c2681e
Parents: 4c01505
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Mon May 30 11:02:59 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Mon May 30 11:02:59 2016 +0300

----------------------------------------------------------------------
 .../hadoop/fs/BasicHadoopFileSystemFactory.java |  40 +++---
 .../fs/CachingHadoopFileSystemFactory.java      |   2 +-
 .../fs/KerberosHadoopFileSystemFactory.java     |   4 +-
 .../ignite/hadoop/util/BasicUserNameMapper.java |  77 +++++++++++
 .../hadoop/util/ConstantUserNameConverter.java  |  64 ---------
 .../hadoop/util/ConstantUserNameMapper.java     |  64 +++++++++
 .../hadoop/util/KerberosUserNameConverter.java  | 137 -------------------
 .../hadoop/util/KerberosUserNameMapper.java     | 137 +++++++++++++++++++
 .../hadoop/util/MappingUserNameConverter.java   |  77 -----------
 .../ignite/hadoop/util/UserNameConverter.java   |  37 -----
 .../ignite/hadoop/util/UserNameMapper.java      |  37 +++++
 11 files changed, 338 insertions(+), 338 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/eaab1b06/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java
index a1651e9..d37db8e 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java
@@ -21,8 +21,8 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.hadoop.fs.v1.IgniteHadoopFileSystem;
-import org.apache.ignite.hadoop.util.KerberosUserNameConverter;
-import org.apache.ignite.hadoop.util.UserNameConverter;
+import org.apache.ignite.hadoop.util.KerberosUserNameMapper;
+import org.apache.ignite.hadoop.util.UserNameMapper;
 import org.apache.ignite.internal.processors.hadoop.HadoopUtils;
 import org.apache.ignite.internal.processors.igfs.IgfsUtils;
 import org.apache.ignite.internal.util.typedef.internal.U;
@@ -53,8 +53,8 @@ public class BasicHadoopFileSystemFactory implements HadoopFileSystemFactory,
Ex
     /** File system config paths. */
     private String[] cfgPaths;
 
-    /** User name converter. */
-    private UserNameConverter usrNameConverter;
+    /** User name mapper. */
+    private UserNameMapper usrNameMapper;
 
     /** Configuration of the secondary filesystem, never null. */
     protected transient Configuration cfg;
@@ -73,10 +73,10 @@ public class BasicHadoopFileSystemFactory implements HadoopFileSystemFactory,
Ex
     @Override public final FileSystem get(String name) throws IOException {
         String name0 = IgfsUtils.fixUserName(name);
 
-        if (usrNameConverter != null)
-            name0 = usrNameConverter.convert(name0);
+        if (usrNameMapper != null)
+            name0 = usrNameMapper.map(name0);
 
-        // If converter returned null, we will use current user, so we "fix" user name again.
+        // If mapper returned null, we will use current user, so we "fix" user name again.
         name0 = IgfsUtils.fixUserName(name0);
 
         return getWithConvertedName0(name0);
@@ -89,7 +89,7 @@ public class BasicHadoopFileSystemFactory implements HadoopFileSystemFactory,
Ex
      * @return File system.
      * @throws IOException If failed.
      */
-    protected FileSystem getWithConvertedName(String usrName) throws IOException {
+    protected FileSystem getWithMappedName(String usrName) throws IOException {
         return getWithConvertedName0(usrName);
     }
 
@@ -193,29 +193,29 @@ public class BasicHadoopFileSystemFactory implements HadoopFileSystemFactory,
Ex
     }
 
     /**
-     * Get optional user name converter.
+     * Get optional user name mapper.
      * <p>
      * When IGFS is invoked from Hadoop, user name is passed along the way to ensure that
request will be performed
      * with proper user context. User name is passed in a simple form and doesn't contain
any extended information,
-     * such as host, domain or Kerberos realm. You may use name converter to translate plain
user name to full user
+     * such as host, domain or Kerberos realm. You may use name mapper to translate plain
user name to full user
      * name required by security engine of the underlying file system.
      * <p>
-     * For example you may want to use {@link KerberosUserNameConverter} to user name from
{@code "johndoe"} to
+     * For example you may want to use {@link KerberosUserNameMapper} to user name from {@code
"johndoe"} to
      * {@code "johndoe@YOUR.REALM.COM"}.
      *
-     * @return User name converter.
+     * @return User name mapper.
      */
-    @Nullable public UserNameConverter getUserNameConverter() {
-        return usrNameConverter;
+    @Nullable public UserNameMapper getUserNameConverter() {
+        return usrNameMapper;
     }
 
     /**
-     * Set optional user name converter. See {@link #getUserNameConverter()} for more information.
+     * Set optional user name mapper. See {@link #getUserNameConverter()} for more information.
      *
-     * @param usrNameConverter User name converter.
+     * @param usrNameConverter User name mapper.
      */
-    public void setUserNameConverter(@Nullable UserNameConverter usrNameConverter) {
-        this.usrNameConverter = usrNameConverter;
+    public void setUserNameConverter(@Nullable UserNameMapper usrNameConverter) {
+        this.usrNameMapper = usrNameConverter;
     }
 
     /** {@inheritDoc} */
@@ -271,7 +271,7 @@ public class BasicHadoopFileSystemFactory implements HadoopFileSystemFactory,
Ex
         else
             out.writeInt(-1);
 
-        out.writeObject(usrNameConverter);
+        out.writeObject(usrNameMapper);
     }
 
     /** {@inheritDoc} */
@@ -287,6 +287,6 @@ public class BasicHadoopFileSystemFactory implements HadoopFileSystemFactory,
Ex
                 cfgPaths[i] = U.readString(in);
         }
 
-        usrNameConverter = (UserNameConverter) in.readObject();
+        usrNameMapper = (UserNameMapper) in.readObject();
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaab1b06/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/CachingHadoopFileSystemFactory.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/CachingHadoopFileSystemFactory.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/CachingHadoopFileSystemFactory.java
index 33a0018..8995feb 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/CachingHadoopFileSystemFactory.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/CachingHadoopFileSystemFactory.java
@@ -60,7 +60,7 @@ public class CachingHadoopFileSystemFactory extends BasicHadoopFileSystemFactory
     }
 
     /** {@inheritDoc} */
-    @Override public FileSystem getWithConvertedName(String name) throws IOException {
+    @Override public FileSystem getWithMappedName(String name) throws IOException {
         return cache.getOrCreate(name);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaab1b06/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactory.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactory.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactory.java
index 8b454a2..bbfbc59 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactory.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactory.java
@@ -68,10 +68,10 @@ public class KerberosHadoopFileSystemFactory extends BasicHadoopFileSystemFactor
     }
 
     /** {@inheritDoc} */
-    @Override public FileSystem getWithConvertedName(String name) throws IOException {
+    @Override public FileSystem getWithMappedName(String name) throws IOException {
         reloginIfNeeded();
 
-        return super.getWithConvertedName(name);
+        return super.getWithMappedName(name);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaab1b06/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/BasicUserNameMapper.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/BasicUserNameMapper.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/BasicUserNameMapper.java
new file mode 100644
index 0000000..95f43bb
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/BasicUserNameMapper.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.hadoop.util;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lifecycle.LifecycleAware;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Map;
+
+/**
+ * Name mapper which maps one user name to another based on predefined dictionary.
+ */
+public class BasicUserNameMapper implements UserNameMapper, LifecycleAware {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Mappings. */
+    private Map<String, String> mappings;
+
+    /** {@inheritDoc} */
+    @Nullable @Override public String map(String name) {
+        assert mappings != null;
+
+        return mappings.get(name);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void start() throws IgniteException {
+        if (mappings == null)
+            throw new IgniteException("Mappings cannot be null.");
+    }
+
+    /** {@inheritDoc} */
+    @Override public void stop() throws IgniteException {
+        // No-op.
+    }
+
+    /**
+     * Get mappings.
+     *
+     * @return Mappings.
+     */
+    public Map<String, String> getMappings() {
+        return mappings;
+    }
+
+    /**
+     * Set mappings.
+     *
+     * @param mappings Mappings.
+     */
+    public void setMappings(Map<String, String> mappings) {
+        this.mappings = mappings;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(BasicUserNameMapper.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaab1b06/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/ConstantUserNameConverter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/ConstantUserNameConverter.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/ConstantUserNameConverter.java
deleted file mode 100644
index b410c00..0000000
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/ConstantUserNameConverter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.hadoop.util;
-
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Constant user name converter. Performs all file system requests with the same user name.
- * <p>
- * If {@code null} is set as a name, name of the current process owner will be used.
- */
-public class ConstantUserNameConverter implements UserNameConverter {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** User name. */
-    private String usrName;
-
-    /** {@inheritDoc} */
-    @Nullable @Override public String convert(String name) {
-        return usrName;
-    }
-
-    /**
-     * Get user name to be user for all file system requests.
-     * <p>
-     * When set to {@code null}, name of the current process owner will be used.
-     *
-     * @return User name.
-     */
-    public String getUserName() {
-        return usrName;
-    }
-
-    /**
-     * Set user name. See {@link #getUserName()} for more information.
-     *
-     * @param usrName User name.
-     */
-    public void setUserName(@Nullable String usrName) {
-        this.usrName = usrName;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(ConstantUserNameConverter.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaab1b06/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/ConstantUserNameMapper.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/ConstantUserNameMapper.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/ConstantUserNameMapper.java
new file mode 100644
index 0000000..6576596
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/ConstantUserNameMapper.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.hadoop.util;
+
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Constant user name mapper. Performs all file system requests with the same user name.
+ * <p>
+ * If {@code null} is set as a name, name of the current process owner will be used.
+ */
+public class ConstantUserNameMapper implements UserNameMapper {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** User name. */
+    private String usrName;
+
+    /** {@inheritDoc} */
+    @Nullable @Override public String map(String name) {
+        return usrName;
+    }
+
+    /**
+     * Get user name to be user for all file system requests.
+     * <p>
+     * When set to {@code null}, name of the current process owner will be used.
+     *
+     * @return User name.
+     */
+    public String getUserName() {
+        return usrName;
+    }
+
+    /**
+     * Set user name. See {@link #getUserName()} for more information.
+     *
+     * @param usrName User name.
+     */
+    public void setUserName(@Nullable String usrName) {
+        this.usrName = usrName;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(ConstantUserNameMapper.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaab1b06/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/KerberosUserNameConverter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/KerberosUserNameConverter.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/KerberosUserNameConverter.java
deleted file mode 100644
index ef0a8ce..0000000
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/KerberosUserNameConverter.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.hadoop.util;
-
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lifecycle.LifecycleAware;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Kerberos user name converter. Use it when you need to map simple user name to Kerberos
principal.
- * E.g. from {@code johndoe} to {@code johndoe@YOUR.REALM.COM} or {@code johndoe/admin@YOUR.REALM.COM}.
- */
-public class KerberosUserNameConverter implements UserNameConverter, LifecycleAware {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** Instance. */
-    private String instance;
-
-    /** Realm. */
-    private String realm;
-
-    /** State. */
-    private volatile State state;
-
-    /** {@inheritDoc} */
-    @Nullable @Override public String convert(String name) {
-        assert state != null;
-
-        switch (state) {
-            case NAME:
-                return name;
-
-            case NAME_REALM:
-                return name + '@' + realm;
-
-            case NAME_INSTANCE:
-                return name + '/' + instance;
-
-            default:
-                assert state == State.NAME_INSTANCE_REALM;
-
-                return name + '/' + instance + '@' + realm;
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void start() throws IgniteException {
-        if (realm.startsWith("@"))
-            throw new IgniteException("Realm should not start with '@' character: " + realm);
-
-        if (!F.isEmpty(instance))
-            state = F.isEmpty(realm) ? State.NAME_INSTANCE : State.NAME_INSTANCE_REALM;
-        else
-            state = F.isEmpty(realm) ? State.NAME : State.NAME_REALM;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void stop() throws IgniteException {
-        // No-op.
-    }
-
-    /**
-     * Get Kerberos instance (optional).
-     *
-     * @return Instance.
-     */
-    @Nullable public String getInstance() {
-        return instance;
-    }
-
-    /**
-     * Set Kerberos instance (optional).
-     *
-     * @param instance Kerberos instance.
-     */
-    public void setInstance(@Nullable String instance) {
-        this.instance = instance;
-    }
-
-    /**
-     * Get Kerberos realm (optional).
-     *
-     * @return Kerberos realm.
-     */
-    @Nullable public String getRealm() {
-        return realm;
-    }
-
-    /**
-     * Set Kerberos realm (optional).
-     *
-     * @param realm Kerberos realm.
-     */
-    public void setRealm(@Nullable String realm) {
-        this.realm = realm;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(KerberosUserNameConverter.class, this);
-    }
-
-    /**
-     * State enumeration.
-     */
-    private enum State {
-        /** Name only. */
-        NAME,
-
-        /** Name and realm. */
-        NAME_REALM,
-
-        /** Name and host. */
-        NAME_INSTANCE,
-
-        /** Name, host and realm. */
-        NAME_INSTANCE_REALM,
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaab1b06/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/KerberosUserNameMapper.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/KerberosUserNameMapper.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/KerberosUserNameMapper.java
new file mode 100644
index 0000000..b250be8
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/KerberosUserNameMapper.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.hadoop.util;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lifecycle.LifecycleAware;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Kerberos user name mapper. Use it when you need to map simple user name to Kerberos principal.
+ * E.g. from {@code johndoe} to {@code johndoe@YOUR.REALM.COM} or {@code johndoe/admin@YOUR.REALM.COM}.
+ */
+public class KerberosUserNameMapper implements UserNameMapper, LifecycleAware {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Instance. */
+    private String instance;
+
+    /** Realm. */
+    private String realm;
+
+    /** State. */
+    private volatile State state;
+
+    /** {@inheritDoc} */
+    @Nullable @Override public String map(String name) {
+        assert state != null;
+
+        switch (state) {
+            case NAME:
+                return name;
+
+            case NAME_REALM:
+                return name + '@' + realm;
+
+            case NAME_INSTANCE:
+                return name + '/' + instance;
+
+            default:
+                assert state == State.NAME_INSTANCE_REALM;
+
+                return name + '/' + instance + '@' + realm;
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void start() throws IgniteException {
+        if (realm.startsWith("@"))
+            throw new IgniteException("Realm should not start with '@' character: " + realm);
+
+        if (!F.isEmpty(instance))
+            state = F.isEmpty(realm) ? State.NAME_INSTANCE : State.NAME_INSTANCE_REALM;
+        else
+            state = F.isEmpty(realm) ? State.NAME : State.NAME_REALM;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void stop() throws IgniteException {
+        // No-op.
+    }
+
+    /**
+     * Get Kerberos instance (optional).
+     *
+     * @return Instance.
+     */
+    @Nullable public String getInstance() {
+        return instance;
+    }
+
+    /**
+     * Set Kerberos instance (optional).
+     *
+     * @param instance Kerberos instance.
+     */
+    public void setInstance(@Nullable String instance) {
+        this.instance = instance;
+    }
+
+    /**
+     * Get Kerberos realm (optional).
+     *
+     * @return Kerberos realm.
+     */
+    @Nullable public String getRealm() {
+        return realm;
+    }
+
+    /**
+     * Set Kerberos realm (optional).
+     *
+     * @param realm Kerberos realm.
+     */
+    public void setRealm(@Nullable String realm) {
+        this.realm = realm;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(KerberosUserNameMapper.class, this);
+    }
+
+    /**
+     * State enumeration.
+     */
+    private enum State {
+        /** Name only. */
+        NAME,
+
+        /** Name and realm. */
+        NAME_REALM,
+
+        /** Name and host. */
+        NAME_INSTANCE,
+
+        /** Name, host and realm. */
+        NAME_INSTANCE_REALM,
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaab1b06/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/MappingUserNameConverter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/MappingUserNameConverter.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/MappingUserNameConverter.java
deleted file mode 100644
index cadd483..0000000
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/MappingUserNameConverter.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.hadoop.util;
-
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lifecycle.LifecycleAware;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Map;
-
-/**
- * Name converter which simply maps one user name to another based on predefined dictionary.
- */
-public class MappingUserNameConverter implements UserNameConverter, LifecycleAware {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** Mappings. */
-    private Map<String, String> mappings;
-
-    /** {@inheritDoc} */
-    @Nullable @Override public String convert(String name) {
-        assert mappings != null;
-
-        return mappings.get(name);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void start() throws IgniteException {
-        if (mappings == null)
-            throw new IgniteException("Mappings cannot be null.");
-    }
-
-    /** {@inheritDoc} */
-    @Override public void stop() throws IgniteException {
-        // No-op.
-    }
-
-    /**
-     * Get mappings.
-     *
-     * @return Mappings.
-     */
-    public Map<String, String> getMappings() {
-        return mappings;
-    }
-
-    /**
-     * Set mappings.
-     *
-     * @param mappings Mappings.
-     */
-    public void setMappings(Map<String, String> mappings) {
-        this.mappings = mappings;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(MappingUserNameConverter.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaab1b06/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/UserNameConverter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/UserNameConverter.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/UserNameConverter.java
deleted file mode 100644
index dac464d..0000000
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/UserNameConverter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.hadoop.util;
-
-import org.apache.ignite.hadoop.fs.HadoopFileSystemFactory;
-import org.jetbrains.annotations.Nullable;
-
-import java.io.Serializable;
-
-/**
- * Hadoop file system name converter. Used by {@link HadoopFileSystemFactory} implementation
to pass proper user names
- * to the underlying Hadoop file system.
- */
-public interface UserNameConverter extends Serializable {
-    /**
-     * Convert user name.
-     *
-     * @param name User name.
-     * @return Converted user name.
-     */
-    @Nullable public String convert(String name);
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaab1b06/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/UserNameMapper.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/UserNameMapper.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/UserNameMapper.java
new file mode 100644
index 0000000..26dc4b2
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/UserNameMapper.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.hadoop.util;
+
+import org.apache.ignite.hadoop.fs.HadoopFileSystemFactory;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.Serializable;
+
+/**
+ * Hadoop file system name mapper. Used by {@link HadoopFileSystemFactory} implementation
to pass proper user names
+ * to the underlying Hadoop file system.
+ */
+public interface UserNameMapper extends Serializable {
+    /**
+     * Map user name.
+     *
+     * @param name User name.
+     * @return Mapped user name.
+     */
+    @Nullable public String map(String name);
+}


Mime
View raw message