[streaming]Add master and scheduler. (#8044)

This commit is contained in:
Tianyi Chen
2020-04-22 14:43:56 +08:00
committed by GitHub
parent c486b56c58
commit 0204dff1e9
18 changed files with 837 additions and 52 deletions
@@ -1,4 +1,4 @@
package io.ray.streaming.runtime.graph;
package io.ray.streaming.runtime.core.graph;
import com.google.common.collect.Lists;
import io.ray.streaming.api.context.StreamingContext;
@@ -0,0 +1,20 @@
package io.ray.streaming.runtime.master;
import java.util.HashMap;
import org.testng.Assert;
import org.testng.annotations.Test;
public class JobMasterTest {
@Test
public void testCreation() {
JobMaster jobMaster = new JobMaster(new HashMap<>());
Assert.assertNotNull(jobMaster.getRuntimeContext());
Assert.assertNotNull(jobMaster.getConf());
Assert.assertNull(jobMaster.getGraphManager());
Assert.assertNull(jobMaster.getResourceManager());
Assert.assertNull(jobMaster.getJobMasterActor());
Assert.assertFalse(jobMaster.init());
}
}
@@ -0,0 +1,12 @@
package io.ray.streaming.runtime.master.jobscheduler;
import org.testng.annotations.Test;
public class JobSchedulerTest {
@Test
public void testSchedule() {
// TODO (tianyi): need JobWorker Part to do this.
}
}
@@ -1,60 +1,34 @@
package io.ray.streaming.runtime.resourcemanager;
package io.ray.streaming.runtime.master.resourcemanager;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.mockito.MockitoAnnotations;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import io.ray.api.Ray;
import io.ray.api.id.UniqueId;
import io.ray.api.runtimecontext.NodeInfo;
import io.ray.streaming.runtime.BaseUnitTest;
import io.ray.streaming.runtime.config.StreamingConfig;
import io.ray.streaming.runtime.config.global.CommonConfig;
import io.ray.streaming.runtime.master.resourcemanager.ResourceManager;
import io.ray.streaming.runtime.master.resourcemanager.ResourceManagerImpl;
import io.ray.streaming.runtime.core.resource.Container;
import io.ray.streaming.runtime.master.JobRuntimeContext;
import io.ray.streaming.runtime.util.Mockitools;
import io.ray.streaming.runtime.util.RayUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.IObjectFactory;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.ObjectFactory;
import org.testng.annotations.Test;
@PrepareForTest(RayUtils.class)
@PowerMockIgnore({"org.slf4j.*", "javax.xml.*"})
public class ResourceManagerTest {
public class ResourceManagerTest extends BaseUnitTest {
private static final Logger LOG = LoggerFactory.getLogger(ResourceManagerTest.class);
private Object rayAsyncContext;
@ObjectFactory
public IObjectFactory getObjectFactory() {
return new org.powermock.modules.testng.PowerMockObjectFactory();
}
@org.testng.annotations.BeforeClass
public void setUp() {
LOG.warn("Do set up");
MockitoAnnotations.initMocks(this);
}
@org.testng.annotations.AfterClass
public void tearDown() {
LOG.warn("Do tear down");
}
@BeforeMethod
public void mockGscApi() {
public void init() {
// ray init
Ray.init();
rayAsyncContext = Ray.getAsyncContext();
Mockitools.mockGscApi();
}
@Test
@@ -63,7 +37,7 @@ public class ResourceManagerTest {
Assert.assertEquals(nodeInfoMap.size(), 5);
}
@Test
@Test(dependsOnMethods = "testGcsMockedApi")
public void testApi() {
Ray.setAsyncContext(rayAsyncContext);
@@ -1,4 +1,4 @@
package io.ray.streaming.runtime.schedule.strategy;
package io.ray.streaming.runtime.master.resourcemanager.strategy;
import io.ray.api.id.UniqueId;
import io.ray.streaming.jobgraph.JobGraph;
@@ -8,12 +8,11 @@ import io.ray.streaming.runtime.config.types.ResourceAssignStrategyType;
import io.ray.streaming.runtime.core.graph.executiongraph.ExecutionGraph;
import io.ray.streaming.runtime.core.resource.Container;
import io.ray.streaming.runtime.core.resource.ResourceType;
import io.ray.streaming.runtime.graph.ExecutionGraphTest;
import io.ray.streaming.runtime.core.graph.ExecutionGraphTest;
import io.ray.streaming.runtime.master.JobRuntimeContext;
import io.ray.streaming.runtime.master.graphmanager.GraphManager;
import io.ray.streaming.runtime.master.graphmanager.GraphManagerImpl;
import io.ray.streaming.runtime.master.resourcemanager.ResourceAssignmentView;
import io.ray.streaming.runtime.master.resourcemanager.strategy.ResourceAssignStrategy;
import io.ray.streaming.runtime.master.resourcemanager.strategy.impl.PipelineFirstStrategy;
import java.util.ArrayList;
import java.util.HashMap;
@@ -58,14 +57,11 @@ public class PipelineFirstStrategyTest extends BaseUnitTest {
}
@Test
public void testStrategyName() {
Assert
.assertEquals(ResourceAssignStrategyType.PIPELINE_FIRST_STRATEGY.getName(), strategy.getName());
}
@Test
public void testAssignResource() {
public void testResourceAssignment() {
strategy = new PipelineFirstStrategy();
Assert.assertEquals(
ResourceAssignStrategyType.PIPELINE_FIRST_STRATEGY.getName(), strategy.getName());
Map<String, String> jobConf = new HashMap<>();
StreamingConfig streamingConfig = new StreamingConfig(jobConf);
GraphManager graphManager = new GraphManagerImpl(new JobRuntimeContext(streamingConfig));