MCPcopy Create free account
hub / github.com/apache/mesos / TestScheduler

Class TestScheduler

src/examples/java/V1TestFramework.java:44–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42
43public class V1TestFramework {
44 static class TestScheduler implements Scheduler {
45
46 public TestScheduler(
47 String master,
48 FrameworkInfo framework,
49 ExecutorInfo executor) {
50 this(master, framework, executor, 5);
51 }
52
53 public TestScheduler(
54 String master,
55 FrameworkInfo framework,
56 ExecutorInfo executor,
57 int totalTasks) {
58 this.framework = framework;
59 this.executor = executor;
60 this.totalTasks = totalTasks;
61 this.state = State.DISCONNECTED;
62 }
63
64 // TODO(anand): Synchronize on `state` instead.
65 @Override
66 public synchronized void connected(final Mesos mesos) {
67 System.out.println("Connected");
68
69 state = State.CONNECTED;
70
71 retryTimer = new Timer();
72 retryTimer.schedule(new TimerTask() {
73 @Override
74 public void run() {
75 doReliableRegistration(mesos);
76 }
77 }, 0, 1000); // Repeat every 1 second
78 }
79
80 @Override
81 public synchronized void disconnected(Mesos mesos) {
82 System.out.println("Disconnected");
83
84 state = state.DISCONNECTED;
85 cancelRetryTimer();
86 }
87
88 @Override
89 public synchronized void received(Mesos mesos, Event event) {
90 switch (event.getType()) {
91 case SUBSCRIBED: {
92 frameworkId = event.getSubscribed().getFrameworkId();
93 state = State.SUBSCRIBED;
94
95 System.out.println(
96 "Subscribed with ID " + frameworkId + " to master " +
97 event.getSubscribed().getMasterInfo().getId());
98 break;
99 }
100
101 case OFFERS: {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected