[
https://issues.apache.org/jira/browse/HDFS-6300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14540503#comment-14540503
]
Tsz Wo Nicholas Sze commented on HDFS-6300:
-------------------------------------------
Indeed, we could combine checkAnotherBalancerIsRunning to checkAndMarkRunning
as below. I also adds a comment to explain why doing append.
{code}
private OutputStream checkAndMarkRunning() throws IOException {
try {
if (fs.exists(idPath)) {
// try appending to it so that it will fail fast if another balancer is
running.
IOUtils.closeStream(fs.append(idPath));
fs.delete(idPath, true);
}
final FSDataOutputStream fsout = fs.create(idPath, false);
// mark balancer idPath to be deleted during FileSystem closure
fs.deleteOnExit(idPath);
if (write2IdFile) {
fsout.writeBytes(InetAddress.getLocalHost().getHostName());
fsout.hflush();
}
return fsout;
} catch(RemoteException e) {
if(AlreadyBeingCreatedException.class.getName().equals(e.getClassName())){
return null;
} else {
throw e;
}
}
}
{code}
> Shouldn't allows to run multiple balancer simultaneously
> --------------------------------------------------------
>
> Key: HDFS-6300
> URL: https://issues.apache.org/jira/browse/HDFS-6300
> Project: Hadoop HDFS
> Issue Type: Bug
> Components: balancer & mover
> Reporter: Rakesh R
> Assignee: Rakesh R
> Labels: BB2015-05-RFC
> Attachments: HDFS-6300-001.patch, HDFS-6300-002.patch,
> HDFS-6300-003.patch, HDFS-6300.patch
>
>
> Javadoc of "Balancer.java" says, it will not allow to run second balancer if
> the first one is in progress. But I've noticed multiple can run together and
> balancer.id implementation is not safe guarding.
> {code}
> * <li>Another balancer is running. Exiting...
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)