Skip to content
Open
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 @@ -24,7 +24,6 @@
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.URI;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -118,14 +117,11 @@ public int run(String[] args) throws Exception {
SecurityUtil.login(conf, DFS_NAMENODE_KEYTAB_FILE_KEY,
DFS_NAMENODE_KERBEROS_PRINCIPAL_KEY, myAddr.getHostName());

return SecurityUtil.doAsLoginUserOrFatal(new PrivilegedAction<Integer>() {
@Override
public Integer run() {
try {
return doRun();
} catch (IOException e) {
throw new RuntimeException(e);
}
return SecurityUtil.doAsLoginUserOrFatal(() -> {
try {
return doRun();
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.io.IOException;
import java.net.InetSocketAddress;
import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -299,28 +298,23 @@ public void catchupDuringFailover() throws IOException {
// Important to do tailing as the login user, in case the shared
// edits storage is implemented by a JournalManager that depends
// on security credentials to access the logs (eg QuorumJournalManager).
SecurityUtil.doAsLoginUser(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
long editsTailed = 0;
// Fully tail the journal to the end
do {
long startTime = timer.monotonicNow();
try {
NameNode.getNameNodeMetrics().addEditLogTailInterval(
startTime - lastLoadTimeMs);
// It is already under the name system lock and the checkpointer
// thread is already stopped. No need to acquire any other lock.
editsTailed = doTailEdits();
} catch (InterruptedException e) {
throw new IOException(e);
} finally {
NameNode.getNameNodeMetrics().addEditLogTailTime(
timer.monotonicNow() - startTime);
}
} while(editsTailed > 0);
return null;
}
SecurityUtil.doAsLoginUser((PrivilegedExceptionAction<Void>) () -> {
long editsTailed = 0;
// Fully tail the journal to the end
do {
long startTime = timer.monotonicNow();
try {
NameNode.getNameNodeMetrics().addEditLogTailInterval(startTime - lastLoadTimeMs);
// It is already under the name system lock and the checkpointer
// thread is already stopped. No need to acquire any other lock.
editsTailed = doTailEdits();
} catch (InterruptedException e) {
throw new IOException(e);
} finally {
NameNode.getNameNodeMetrics().addEditLogTailTime(timer.monotonicNow() - startTime);
}
} while(editsTailed > 0);
return null;
});
}

Expand Down Expand Up @@ -482,14 +476,10 @@ private void setShouldRun(boolean shouldRun) {

@Override
public void run() {
SecurityUtil.doAsLoginUserOrFatal(
new PrivilegedAction<Object>() {
@Override
public Object run() {
doWork();
return null;
}
});
SecurityUtil.doAsLoginUserOrFatal(() -> {
doWork();
return null;
});
}

private void doWork() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -269,17 +268,11 @@ private void doCheckpoint() throws InterruptedException, IOException {
boolean shouldUpload = receiverEntry.isPrimary() ||
secsSinceLastUpload >= checkpointConf.getQuietPeriod();
if (shouldUpload) {
Future<TransferFsImage.TransferResult> upload =
executor.submit(new Callable<TransferFsImage.TransferResult>() {
@Override
public TransferFsImage.TransferResult call()
throws IOException, InterruptedException {
CheckpointFaultInjector.getInstance().duringUploadInProgess();
return TransferFsImage.uploadImageFromStorage(activeNNAddress,
conf, namesystem.getFSImage().getStorage(), imageType, txid,
canceler);
}
});
Future<TransferFsImage.TransferResult> upload = executor.submit(() -> {
CheckpointFaultInjector.getInstance().duringUploadInProgess();
return TransferFsImage.uploadImageFromStorage(activeNNAddress, conf,
namesystem.getFSImage().getStorage(), imageType, txid, canceler);
});
uploads.put(addressString, upload);
}
}
Expand Down Expand Up @@ -397,14 +390,10 @@ private void setShouldRun(boolean shouldRun) {
public void run() {
// We have to make sure we're logged in as far as JAAS
// is concerned, in order to use kerberized SSL properly.
SecurityUtil.doAsLoginUserOrFatal(
new PrivilegedAction<Object>() {
@Override
public Object run() {
doWork();
return null;
}
});
SecurityUtil.doAsLoginUserOrFatal(() -> {
doWork();
return null;
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ public static void init(int interval, int maxSkipLevels, Logger log) {
DirectoryDiffListFactory.maxLevels = maxSkipLevels;

if (maxLevels > 0) {
constructor = c -> new DiffListBySkipList(c);
constructor = DiffListBySkipList::new;
log.info("SkipList is enabled with skipInterval=" + skipInterval
+ ", maxLevels=" + maxLevels);
} else {
constructor = c -> new DiffListByArrayList<>(c);
constructor = DiffListByArrayList::new;
log.info("SkipList is disabled");
}
}

private static volatile IntFunction<DiffList<DirectoryDiff>> constructor
= c -> new DiffListByArrayList<>(c);
private static volatile IntFunction<DiffList<DirectoryDiff>> constructor =
DiffListByArrayList::new;

private static volatile int skipInterval;
private static volatile int maxLevels;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,43 +601,37 @@ public void dumpTreeRecursively(INodeDirectory snapshotRoot, PrintWriter out,
out.print(", #snapshot=");
out.println(n);

INodeDirectory.dumpTreeRecursively(out, prefix,
new Iterable<SnapshotAndINode>() {
@Override
public Iterator<SnapshotAndINode> iterator() {
return new Iterator<SnapshotAndINode>() {
final Iterator<DirectoryDiff> i = getDiffs().iterator();
private DirectoryDiff next = findNext();

private DirectoryDiff findNext() {
for(; i.hasNext(); ) {
final DirectoryDiff diff = i.next();
if (diff.isSnapshotRoot()) {
return diff;
}
}
return null;
INodeDirectory.dumpTreeRecursively(out, prefix, () -> new Iterator<SnapshotAndINode>() {
final private Iterator<DirectoryDiff> diffIterator = getDiffs().iterator();
private DirectoryDiff next = findNext();

private DirectoryDiff findNext() {
while (diffIterator.hasNext()) {
final DirectoryDiff diff = diffIterator.next();
if (diff.isSnapshotRoot()) {
return diff;
}
}
return null;
}

@Override
public boolean hasNext() {
return next != null;
}
@Override
public boolean hasNext() {
return next != null;
}

@Override
public SnapshotAndINode next() {
final SnapshotAndINode pair = new SnapshotAndINode(next
.getSnapshotId(), getSnapshotById(next.getSnapshotId())
.getRoot());
next = findNext();
return pair;
}
@Override
public SnapshotAndINode next() {
final SnapshotAndINode pair = new SnapshotAndINode(next
.getSnapshotId(), getSnapshotById(next.getSnapshotId())
.getRoot());
next = findNext();
return pair;
}

@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
@Override
public void remove() {
throw new UnsupportedOperationException();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -320,12 +318,7 @@ private List<INode> loadDeletedList(final List<INodeReference> refList,
addToDeletedList(deletedRef, dir);
}

Collections.sort(dlist, new Comparator<INode>() {
@Override
public int compare(INode n1, INode n2) {
return n1.compareTo(n2.getLocalNameBytes());
}
});
dlist.sort((n1, n2) -> n1.compareTo(n2.getLocalNameBytes()));
return dlist;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,8 @@ public int compare(Snapshot left, Snapshot right) {
* Compare snapshot with IDs, where null indicates the current status thus
* is greater than any non-null ID.
*/
public static final Comparator<Integer> ID_INTEGER_COMPARATOR
= new Comparator<Integer>() {
@Override
public int compare(Integer left, Integer right) {
// Snapshot.CURRENT_STATE_ID means the current state, thus should be the
// largest
return left - right;
}
};
public static final Comparator<Integer> ID_INTEGER_COMPARATOR =
Comparator.comparingInt(left -> left);

/**
* Find the latest snapshot that 1) covers the given inode (which means the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,10 @@ public Status getStatus(Phase phase) {
public Counter getCounter(Phase phase, Step step) {
if (!isComplete(phase)) {
final StepTracking tracking = lazyInitStep(phase, step);
return new Counter() {
@Override
public void increment() {
tracking.count.incrementAndGet();
}
};
return () -> tracking.count.incrementAndGet();
} else {
return new Counter() {
@Override
public void increment() {
// no-op, because startup has completed
}
return () -> {
// no-op, because startup has completed
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public boolean add(User user) {

@Override
public boolean addAll(Collection<? extends User> users) {
users.forEach(user -> add(user));
users.forEach(this::add);
return true;
}

Expand Down
Loading