Skip to content

Commit

Permalink
Add separate modules for NodeSelector implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
dain committed Sep 9, 2019
1 parent 565d2a3 commit 6ef45e5
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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 io.prestosql.execution.scheduler;

import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Scopes;

public class TopologyAwareNodeSelectorModule
implements Module
{
@Override
public void configure(Binder binder)
{
binder.bind(NetworkTopology.class).to(FlatNetworkTopology.class).in(Scopes.SINGLETON);
binder.bind(TopologyAwareNodeSelectorFactory.class).in(Scopes.SINGLETON);
binder.bind(NodeSelectorFactory.class).to(TopologyAwareNodeSelectorFactory.class).in(Scopes.SINGLETON);
binder.bind(NodeSchedulerExporter.class).in(Scopes.SINGLETON);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Licensed 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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 io.prestosql.execution.scheduler;

import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Scopes;

public class UniformNodeSelectorModule
implements Module
{
@Override
public void configure(Binder binder)
{
binder.bind(NodeSelectorFactory.class).to(UniformNodeSelectorFactory.class).in(Scopes.SINGLETON);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,10 @@
import io.prestosql.execution.TaskStatus;
import io.prestosql.execution.executor.MultilevelSplitQueue;
import io.prestosql.execution.executor.TaskExecutor;
import io.prestosql.execution.scheduler.FlatNetworkTopology;
import io.prestosql.execution.scheduler.NetworkTopology;
import io.prestosql.execution.scheduler.NodeScheduler;
import io.prestosql.execution.scheduler.NodeSchedulerConfig;
import io.prestosql.execution.scheduler.NodeSchedulerExporter;
import io.prestosql.execution.scheduler.NodeSelectorFactory;
import io.prestosql.execution.scheduler.UniformNodeSelectorFactory;
import io.prestosql.execution.scheduler.TopologyAwareNodeSelectorFactory;
import io.prestosql.execution.scheduler.TopologyAwareNodeSelectorModule;
import io.prestosql.execution.scheduler.UniformNodeSelectorModule;
import io.prestosql.index.IndexManager;
import io.prestosql.memory.LocalMemoryManager;
import io.prestosql.memory.LocalMemoryManagerExporter;
Expand Down Expand Up @@ -249,16 +245,11 @@ protected void setup(Binder binder)
install(installModuleIf(
NodeSchedulerConfig.class,
config -> UNIFORM == config.getNodeSchedulerPolicy(),
moduleBinder -> moduleBinder.bind(NodeSelectorFactory.class).to(UniformNodeSelectorFactory.class).in(Scopes.SINGLETON)));
new UniformNodeSelectorModule()));
install(installModuleIf(
NodeSchedulerConfig.class,
config -> TOPOLOGY == config.getNodeSchedulerPolicy(),
moduleBinder -> {
moduleBinder.bind(NetworkTopology.class).to(FlatNetworkTopology.class).in(Scopes.SINGLETON);
moduleBinder.bind(TopologyAwareNodeSelectorFactory.class).in(Scopes.SINGLETON);
moduleBinder.bind(NodeSelectorFactory.class).to(TopologyAwareNodeSelectorFactory.class).in(Scopes.SINGLETON);
binder.bind(NodeSchedulerExporter.class).in(Scopes.SINGLETON);
}));
new TopologyAwareNodeSelectorModule()));

// task execution
jaxrsBinder(binder).bind(TaskResource.class);
Expand Down

0 comments on commit 6ef45e5

Please sign in to comment.