You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/09/16 12:44:05 UTC
ignite git commit: IGNITE-3916: Moved name mapper to common module.
Repository: ignite
Updated Branches:
refs/heads/ignite-3916 b74894579 -> 551528005
IGNITE-3916: Moved name mapper to common module.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/55152800
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/55152800
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/55152800
Branch: refs/heads/ignite-3916
Commit: 55152800537c57096a667627feaaea342266589b
Parents: b748945
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Sep 16 15:43:37 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Sep 16 15:43:37 2016 +0300
----------------------------------------------------------------------
modules/hadoop-impl/pom.xml | 13 +-
.../ignite/hadoop/util/BasicUserNameMapper.java | 112 ---------------
.../hadoop/util/ChainedUserNameMapper.java | 94 -------------
.../hadoop/util/KerberosUserNameMapper.java | 137 -------------------
.../ignite/hadoop/util/UserNameMapper.java | 37 -----
.../apache/ignite/hadoop/util/package-info.java | 22 ---
.../org/apache/ignite/hadoop/package-info.java | 22 +++
.../ignite/hadoop/util/BasicUserNameMapper.java | 112 +++++++++++++++
.../hadoop/util/ChainedUserNameMapper.java | 94 +++++++++++++
.../hadoop/util/KerberosUserNameMapper.java | 137 +++++++++++++++++++
.../ignite/hadoop/util/UserNameMapper.java | 35 +++++
.../apache/ignite/hadoop/util/package-info.java | 22 +++
12 files changed, 428 insertions(+), 409 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/55152800/modules/hadoop-impl/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hadoop-impl/pom.xml b/modules/hadoop-impl/pom.xml
index 5b25cda..c728483 100644
--- a/modules/hadoop-impl/pom.xml
+++ b/modules/hadoop-impl/pom.xml
@@ -48,6 +48,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-log4j</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-all</artifactId>
<version>4.2</version>
@@ -122,13 +128,6 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-hadoop</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/ignite/blob/55152800/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/BasicUserNameMapper.java
----------------------------------------------------------------------
diff --git a/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/BasicUserNameMapper.java b/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/BasicUserNameMapper.java
deleted file mode 100644
index c34808a..0000000
--- a/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/BasicUserNameMapper.java
+++ /dev/null
@@ -1,112 +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;
-
-import java.util.Map;
-
-/**
- * Name mapper which maps one user name to another based on predefined dictionary. If name is not found in the
- * dictionary, or dictionary is not defined, either passed user name or some default value could be returned.
- */
-public class BasicUserNameMapper implements UserNameMapper {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Mappings. */
- private Map<String, String> mappings;
-
- /** Whether to use default user name. */
- private boolean useDfltUsrName;;
-
- /** Default user name. */
- private String dfltUsrName;
-
- /** {@inheritDoc} */
- @Nullable @Override public String map(String name) {
- String res = mappings != null ? mappings.get(name) : null;
-
- return res != null ? res : useDfltUsrName ? dfltUsrName : name;
- }
-
- /**
- * Get mappings.
- *
- * @return Mappings.
- */
- @Nullable public Map<String, String> getMappings() {
- return mappings;
- }
-
- /**
- * Set mappings.
- *
- * @param mappings Mappings.
- */
- public void setMappings(@Nullable Map<String, String> mappings) {
- this.mappings = mappings;
- }
-
- /**
- * Get whether to use default user name when there is no mapping for current user name.
- *
- * @return Whether to use default user name.
- */
- public boolean isUseDefaultUserName() {
- return useDfltUsrName;
- }
-
- /**
- * Set whether to use default user name when there is no mapping for current user name.
- *
- * @param useDfltUsrName Whether to use default user name.
- */
- public void setUseDefaultUserName(boolean useDfltUsrName) {
- this.useDfltUsrName = useDfltUsrName;
- }
-
- /**
- * Get default user name (optional).
- * <p>
- * This user name will be used if provided mappings doesn't contain mapping for the given user name and
- * {#isUseDefaultUserName} is set to {@code true}.
- * <p>
- * Defaults to {@code null}.
- *
- * @return Default user name.
- */
- @Nullable public String getDefaultUserName() {
- return dfltUsrName;
- }
-
- /**
- * Set default user name (optional). See {@link #getDefaultUserName()} for more information.
- *
- * @param dfltUsrName Default user name.
- */
- public void setDefaultUserName(@Nullable String dfltUsrName) {
- this.dfltUsrName = dfltUsrName;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(BasicUserNameMapper.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/55152800/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/ChainedUserNameMapper.java
----------------------------------------------------------------------
diff --git a/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/ChainedUserNameMapper.java b/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/ChainedUserNameMapper.java
deleted file mode 100644
index 7635e25..0000000
--- a/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/ChainedUserNameMapper.java
+++ /dev/null
@@ -1,94 +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.Arrays;
-
-/**
- * Chained user name mapper. Delegate name conversion to child mappers.
- */
-public class ChainedUserNameMapper implements UserNameMapper, LifecycleAware {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Child mappers. */
- private UserNameMapper[] mappers;
-
- /** {@inheritDoc} */
- @Nullable @Override public String map(String name) {
- for (UserNameMapper mapper : mappers)
- name = mapper.map(name);
-
- return name;
- }
-
- /** {@inheritDoc} */
- @Override public void start() throws IgniteException {
- if (mappers == null)
- throw new IgniteException("Mappers cannot be null.");
-
- for (int i = 0; i < mappers.length; i++) {
- if (mappers[i] == null)
- throw new IgniteException("Mapper cannot be null [index=" + i + ']');
- }
-
- for (UserNameMapper mapper : mappers) {
- if (mapper instanceof LifecycleAware)
- ((LifecycleAware)mapper).start();
- }
- }
-
- /** {@inheritDoc} */
- @Override public void stop() throws IgniteException {
- assert mappers != null;
-
- for (UserNameMapper mapper : mappers) {
- if (mapper instanceof LifecycleAware)
- ((LifecycleAware)mapper).stop();
- }
- }
-
- /**
- * Get child mappers.
- *
- * @return Child mappers.
- */
- public UserNameMapper[] getMappers() {
- return mappers;
- }
-
- /**
- * Set child mappers.
- *
- * @param mappers Child mappers.
- */
- public void setMappers(UserNameMapper... mappers) {
- this.mappers = mappers;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(ChainedUserNameMapper.class, this,
- "mappers", mappers != null ? Arrays.toString(mappers) : null);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/55152800/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/KerberosUserNameMapper.java
----------------------------------------------------------------------
diff --git a/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/KerberosUserNameMapper.java b/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/KerberosUserNameMapper.java
deleted file mode 100644
index 433fb82..0000000
--- a/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/KerberosUserNameMapper.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.processors.igfs.IgfsUtils;
-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;
-
- name = IgfsUtils.fixUserName(name);
-
- 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 (!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/55152800/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/UserNameMapper.java
----------------------------------------------------------------------
diff --git a/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/UserNameMapper.java b/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/UserNameMapper.java
deleted file mode 100644
index 26dc4b2..0000000
--- a/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/UserNameMapper.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 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);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/55152800/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/package-info.java b/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/package-info.java
deleted file mode 100644
index d84c0ba..0000000
--- a/modules/hadoop-impl/src/main/java/org/apache/ignite/hadoop/util/package-info.java
+++ /dev/null
@@ -1,22 +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 description. -->
- * Ignite Hadoop Accelerator utility classes.
- */
-package org.apache.ignite.hadoop.util;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/55152800/modules/hadoop/src/main/java/org/apache/ignite/hadoop/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/package-info.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/package-info.java
new file mode 100644
index 0000000..8a5ae34
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * Ignite Hadoop Accelerator API.
+ */
+package org.apache.ignite.hadoop;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/55152800/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..c34808a
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/BasicUserNameMapper.java
@@ -0,0 +1,112 @@
+/*
+ * 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;
+
+import java.util.Map;
+
+/**
+ * Name mapper which maps one user name to another based on predefined dictionary. If name is not found in the
+ * dictionary, or dictionary is not defined, either passed user name or some default value could be returned.
+ */
+public class BasicUserNameMapper implements UserNameMapper {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Mappings. */
+ private Map<String, String> mappings;
+
+ /** Whether to use default user name. */
+ private boolean useDfltUsrName;;
+
+ /** Default user name. */
+ private String dfltUsrName;
+
+ /** {@inheritDoc} */
+ @Nullable @Override public String map(String name) {
+ String res = mappings != null ? mappings.get(name) : null;
+
+ return res != null ? res : useDfltUsrName ? dfltUsrName : name;
+ }
+
+ /**
+ * Get mappings.
+ *
+ * @return Mappings.
+ */
+ @Nullable public Map<String, String> getMappings() {
+ return mappings;
+ }
+
+ /**
+ * Set mappings.
+ *
+ * @param mappings Mappings.
+ */
+ public void setMappings(@Nullable Map<String, String> mappings) {
+ this.mappings = mappings;
+ }
+
+ /**
+ * Get whether to use default user name when there is no mapping for current user name.
+ *
+ * @return Whether to use default user name.
+ */
+ public boolean isUseDefaultUserName() {
+ return useDfltUsrName;
+ }
+
+ /**
+ * Set whether to use default user name when there is no mapping for current user name.
+ *
+ * @param useDfltUsrName Whether to use default user name.
+ */
+ public void setUseDefaultUserName(boolean useDfltUsrName) {
+ this.useDfltUsrName = useDfltUsrName;
+ }
+
+ /**
+ * Get default user name (optional).
+ * <p>
+ * This user name will be used if provided mappings doesn't contain mapping for the given user name and
+ * {#isUseDefaultUserName} is set to {@code true}.
+ * <p>
+ * Defaults to {@code null}.
+ *
+ * @return Default user name.
+ */
+ @Nullable public String getDefaultUserName() {
+ return dfltUsrName;
+ }
+
+ /**
+ * Set default user name (optional). See {@link #getDefaultUserName()} for more information.
+ *
+ * @param dfltUsrName Default user name.
+ */
+ public void setDefaultUserName(@Nullable String dfltUsrName) {
+ this.dfltUsrName = dfltUsrName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(BasicUserNameMapper.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/55152800/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/ChainedUserNameMapper.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/ChainedUserNameMapper.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/ChainedUserNameMapper.java
new file mode 100644
index 0000000..7635e25
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/ChainedUserNameMapper.java
@@ -0,0 +1,94 @@
+/*
+ * 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.Arrays;
+
+/**
+ * Chained user name mapper. Delegate name conversion to child mappers.
+ */
+public class ChainedUserNameMapper implements UserNameMapper, LifecycleAware {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Child mappers. */
+ private UserNameMapper[] mappers;
+
+ /** {@inheritDoc} */
+ @Nullable @Override public String map(String name) {
+ for (UserNameMapper mapper : mappers)
+ name = mapper.map(name);
+
+ return name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void start() throws IgniteException {
+ if (mappers == null)
+ throw new IgniteException("Mappers cannot be null.");
+
+ for (int i = 0; i < mappers.length; i++) {
+ if (mappers[i] == null)
+ throw new IgniteException("Mapper cannot be null [index=" + i + ']');
+ }
+
+ for (UserNameMapper mapper : mappers) {
+ if (mapper instanceof LifecycleAware)
+ ((LifecycleAware)mapper).start();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void stop() throws IgniteException {
+ assert mappers != null;
+
+ for (UserNameMapper mapper : mappers) {
+ if (mapper instanceof LifecycleAware)
+ ((LifecycleAware)mapper).stop();
+ }
+ }
+
+ /**
+ * Get child mappers.
+ *
+ * @return Child mappers.
+ */
+ public UserNameMapper[] getMappers() {
+ return mappers;
+ }
+
+ /**
+ * Set child mappers.
+ *
+ * @param mappers Child mappers.
+ */
+ public void setMappers(UserNameMapper... mappers) {
+ this.mappers = mappers;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(ChainedUserNameMapper.class, this,
+ "mappers", mappers != null ? Arrays.toString(mappers) : null);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/55152800/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..433fb82
--- /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.processors.igfs.IgfsUtils;
+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;
+
+ name = IgfsUtils.fixUserName(name);
+
+ 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 (!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/55152800/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..12669aa
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/UserNameMapper.java
@@ -0,0 +1,35 @@
+/*
+ * 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.jetbrains.annotations.Nullable;
+
+import java.io.Serializable;
+
+/**
+ * Hadoop file system name mapper. Ensures that correct user name is passed 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);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/55152800/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/package-info.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/package-info.java
new file mode 100644
index 0000000..d84c0ba
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * Ignite Hadoop Accelerator utility classes.
+ */
+package org.apache.ignite.hadoop.util;
\ No newline at end of file