Skip to content

Commit

Permalink
Merge pull request #23 from hynix/master
Browse files Browse the repository at this point in the history
bug fixes
  • Loading branch information
hynix authored Feb 3, 2022
2 parents 52f0c66 + a12c7b1 commit afc3249
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
import java.io.IOException;
import java.net.URI;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.client.api.YarnClient;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.slf4j.Logger;
Expand Down Expand Up @@ -96,6 +94,7 @@ public void kill(Application application) {
client.killApplication(ApplicationId.fromString(id));
} catch (YarnException | IOException e) {
LOG.error("Can't kill Yarn app: {}", application, e);
throw new IllegalStateException(e);
}
});
}
Expand All @@ -120,19 +119,18 @@ public Map<String, String> getSubmitConfiguration(Application application) {
}

private Optional<String> getYarnApplicationId(Application application) {
var allStates = EnumSet.allOf(YarnApplicationState.class);
return Optional.ofNullable(application.getAppId())
.or(() -> {
try {
var request = GetApplicationsRequest.newInstance(Set.of("SPARK"));
var request = GetApplicationsRequest.newInstance();
request.setApplicationTags(Set.of(application.getId()));
return client.getApplications(request).stream()
.max(Comparator.comparing(ApplicationReport::getStartTime))
.map(ApplicationReport::getApplicationId)
.map(ApplicationId::toString);
} catch (YarnException | IOException e) {
LOG.error("Failed to get app id for app: {}", application, e);
return Optional.empty();
throw new IllegalStateException(e);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import io.micronaut.context.annotation.Property;
import io.micronaut.context.annotation.Requires;
import jakarta.inject.Singleton;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.yarn.client.api.YarnClient;
import org.apache.hadoop.yarn.conf.YarnConfiguration;

@Factory
@Requires(beans = YarnProperties.class)
Expand All @@ -19,7 +19,7 @@ public class YarnConfigurationFactory {
@Singleton
public YarnBackend backend(YarnProperties yarnProperties, AppConfiguration conf,
@Property(name = "hadoop.conf.dir") String hadoopConfDir) {
YarnConfiguration yarnConfiguration = new YarnConfiguration();
var yarnConfiguration = new Configuration(false);
yarnConfiguration.addResource(new Path(hadoopConfDir, "core-site.xml"));
yarnConfiguration.addResource(new Path(hadoopConfDir, "yarn-site.xml"));
if (yarnProperties.getKerberosKeytab() != null && yarnProperties.getKerberosPrincipal() != null) {
Expand Down

0 comments on commit afc3249

Please sign in to comment.