Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@
import java.util.List;

import com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.crypto.key.KeyProvider;
import org.apache.hadoop.fs.BlockLocation;
import org.apache.hadoop.fs.FileAlreadyExistsException;
import org.apache.hadoop.fs.FileChecksum;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathIsNotEmptyDirectoryException;
import org.apache.hadoop.fs.SafeModeAction;
import org.apache.hadoop.hdds.annotation.InterfaceAudience;
import org.apache.hadoop.hdds.client.ReplicationConfig;
import org.apache.hadoop.hdds.client.ReplicationFactor;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
Expand Down Expand Up @@ -69,7 +67,6 @@
import org.apache.hadoop.ozone.snapshot.SnapshotDiffReportOzone;
import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenRenewer;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -470,56 +467,6 @@ void setClock(Clock monotonicClock) {
this.clock = monotonicClock;
}

/**
* Ozone Delegation Token Renewer.
*/
@InterfaceAudience.Private
public static class Renewer extends TokenRenewer {

//Ensure that OzoneConfiguration files are loaded before trying to use
// the renewer.
static {
OzoneConfiguration.activate();
}

public Text getKind() {
return OzoneTokenIdentifier.KIND_NAME;
}

@Override
public boolean handleKind(Text kind) {
return getKind().equals(kind);
}

@Override
public boolean isManaged(Token<?> token) throws IOException {
return true;
}

@Override
public long renew(Token<?> token, Configuration conf)
throws IOException, InterruptedException {
Token<OzoneTokenIdentifier> ozoneDt =
(Token<OzoneTokenIdentifier>) token;

OzoneClient ozoneClient =
OzoneClientFactory.getOzoneClient(OzoneConfiguration.of(conf),
ozoneDt);
return ozoneClient.getObjectStore().renewDelegationToken(ozoneDt);
}

@Override
public void cancel(Token<?> token, Configuration conf)
throws IOException, InterruptedException {
Token<OzoneTokenIdentifier> ozoneDt =
(Token<OzoneTokenIdentifier>) token;
OzoneClient ozoneClient =
OzoneClientFactory.getOzoneClient(OzoneConfiguration.of(conf),
ozoneDt);
ozoneClient.getObjectStore().cancelDelegationToken(ozoneDt);
}
}

/**
* Adapter to convert OzoneKey to a safe and simple Key implementation.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

import com.google.common.base.Preconditions;
import org.apache.commons.collections.CollectionUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.crypto.key.KeyProvider;
import org.apache.hadoop.fs.BlockLocation;
import org.apache.hadoop.fs.FileAlreadyExistsException;
Expand All @@ -43,7 +42,6 @@
import org.apache.hadoop.fs.PathIsNotEmptyDirectoryException;
import org.apache.hadoop.fs.SafeModeAction;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.hdds.annotation.InterfaceAudience;
import org.apache.hadoop.hdds.client.ReplicationConfig;
import org.apache.hadoop.hdds.client.ReplicationFactor;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
Expand Down Expand Up @@ -80,7 +78,6 @@
import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenRenewer;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
Expand Down Expand Up @@ -958,55 +955,6 @@ public String getCanonicalServiceName() {
return objectStore.getCanonicalServiceName();
}

/**
* Ozone Delegation Token Renewer.
*/
@InterfaceAudience.Private
public static class Renewer extends TokenRenewer {

//Ensure that OzoneConfiguration files are loaded before trying to use
// the renewer.
static {
OzoneConfiguration.activate();
}

public Text getKind() {
return OzoneTokenIdentifier.KIND_NAME;
}

@Override
public boolean handleKind(Text kind) {
return getKind().equals(kind);
}

@Override
public boolean isManaged(Token<?> token) throws IOException {
return true;
}

@Override
public long renew(Token<?> token, Configuration conf)
throws IOException, InterruptedException {
Token<OzoneTokenIdentifier> ozoneDt =
(Token<OzoneTokenIdentifier>) token;
OzoneClient ozoneClient =
OzoneClientFactory.getOzoneClient(OzoneConfiguration.of(conf),
ozoneDt);
return ozoneClient.getObjectStore().renewDelegationToken(ozoneDt);
}

@Override
public void cancel(Token<?> token, Configuration conf)
throws IOException, InterruptedException {
Token<OzoneTokenIdentifier> ozoneDt =
(Token<OzoneTokenIdentifier>) token;
OzoneClient ozoneClient =
OzoneClientFactory.getOzoneClient(OzoneConfiguration.of(conf),
ozoneDt);
ozoneClient.getObjectStore().cancelDelegationToken(ozoneDt);
}
}

/**
* Adapter to convert OzoneKey to a safe and simple Key implementation.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.hadoop.fs.ozone;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdds.annotation.InterfaceAudience;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.security.OzoneTokenIdentifier;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenRenewer;

import java.io.IOException;

import static org.apache.hadoop.ozone.client.OzoneClientFactory.getOzoneClient;

/**
* Ozone Delegation Token Renewer.
*/
@InterfaceAudience.Private
public class OzoneDelegationTokenRenewer extends TokenRenewer {

//Ensure that OzoneConfiguration files are loaded before trying to use
// the renewer.
static {
OzoneConfiguration.activate();
}

public Text getKind() {
return OzoneTokenIdentifier.KIND_NAME;
}

@Override
public boolean handleKind(Text kind) {
return getKind().equals(kind);
}

@Override
public boolean isManaged(Token<?> token) {
return true;
}

@Override
public long renew(Token<?> token, Configuration conf) throws IOException {
Token<OzoneTokenIdentifier> ozoneDt =
(Token<OzoneTokenIdentifier>) token;
OzoneConfiguration ozoneConf = OzoneConfiguration.of(conf);
try (OzoneClient ozoneClient = getOzoneClient(ozoneConf, ozoneDt)) {
return ozoneClient.getObjectStore().renewDelegationToken(ozoneDt);
}
}

@Override
public void cancel(Token<?> token, Configuration conf)
throws IOException, InterruptedException {
Token<OzoneTokenIdentifier> ozoneDt =
(Token<OzoneTokenIdentifier>) token;
OzoneConfiguration ozoneConf = OzoneConfiguration.of(conf);
try (OzoneClient ozoneClient = getOzoneClient(ozoneConf, ozoneDt)) {
ozoneClient.getObjectStore().cancelDelegationToken(ozoneDt);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@
# limitations under the License.
#

org.apache.hadoop.fs.ozone.BasicOzoneClientAdapterImpl$Renewer
org.apache.hadoop.fs.ozone.BasicRootedOzoneClientAdapterImpl$Renewer
org.apache.hadoop.fs.ozone.OzoneDelegationTokenRenewer
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@
# limitations under the License.
#

org.apache.hadoop.fs.ozone.BasicOzoneClientAdapterImpl$Renewer
org.apache.hadoop.fs.ozone.BasicRootedOzoneClientAdapterImpl$Renewer
org.apache.hadoop.fs.ozone.OzoneDelegationTokenRenewer