Skip to content

Commit

Permalink
Removes dependencies on Play to load classes (linkedin#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
shkhrgpt authored and akshayrai committed Jan 5, 2017
1 parent 42a9be7 commit e0c5935
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 4 additions & 5 deletions app/com/linkedin/drelephant/ElephantContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.log4j.Logger;
import org.w3c.dom.Document;
import play.api.Play;
import play.api.templates.Html;


Expand Down Expand Up @@ -117,7 +116,7 @@ private void loadAggregators() {
_aggregatorConfData = new AggregatorConfiguration(document.getDocumentElement()).getAggregatorsConfigurationData();
for (AggregatorConfigurationData data : _aggregatorConfData) {
try {
Class<?> aggregatorClass = Play.current().classloader().loadClass(data.getClassName());
Class<?> aggregatorClass = Class.forName(data.getClassName());
Object instance = aggregatorClass.getConstructor(AggregatorConfigurationData.class).newInstance(data);
if (!(instance instanceof HadoopMetricsAggregator)) {
throw new IllegalArgumentException(
Expand Down Expand Up @@ -155,7 +154,7 @@ private void loadFetchers() {
_fetchersConfData = new FetcherConfiguration(document.getDocumentElement()).getFetchersConfigurationData();
for (FetcherConfigurationData data : _fetchersConfData) {
try {
Class<?> fetcherClass = Play.current().classloader().loadClass(data.getClassName());
Class<?> fetcherClass = Class.forName(data.getClassName());
Object instance = fetcherClass.getConstructor(FetcherConfigurationData.class).newInstance(data);
if (!(instance instanceof ElephantFetcher)) {
throw new IllegalArgumentException(
Expand Down Expand Up @@ -195,7 +194,7 @@ private void loadHeuristics() {

// Load all the heuristic classes
try {
Class<?> heuristicClass = Play.current().classloader().loadClass(data.getClassName());
Class<?> heuristicClass = Class.forName(data.getClassName());

Object instance = heuristicClass.getConstructor(HeuristicConfigurationData.class).newInstance(data);
if (!(instance instanceof Heuristic)) {
Expand Down Expand Up @@ -228,7 +227,7 @@ private void loadHeuristics() {

// Load all the heuristic views
try {
Class<?> viewClass = Play.current().classloader().loadClass(data.getViewName());
Class<?> viewClass = Class.forName(data.getViewName());

Method render = viewClass.getDeclaredMethod("render");
Html page = (Html) render.invoke(null);
Expand Down
3 changes: 1 addition & 2 deletions app/com/linkedin/drelephant/util/InfoExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.w3c.dom.Document;

import models.AppResult;
import play.api.Play;

import com.linkedin.drelephant.mapreduce.data.MapReduceApplicationData;

Expand Down Expand Up @@ -69,7 +68,7 @@ public static Scheduler getSchedulerInstance(String appId, Properties properties
if (properties != null) {
for (SchedulerConfigurationData data : _configuredSchedulers) {
try {
Class<?> schedulerClass = Play.current().classloader().loadClass(data.getClassName());
Class<?> schedulerClass = Class.forName(data.getClassName());
Object instance = schedulerClass.getConstructor(String.class, Properties.class, SchedulerConfigurationData.class).newInstance(appId, properties, data);
if (!(instance instanceof Scheduler)) {
throw new IllegalArgumentException(
Expand Down

0 comments on commit e0c5935

Please sign in to comment.