This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Coordinator { | |
void registerKernel(Kernel kernel); | |
KernelId getAvailableKernel(); | |
void scheduleTask(KernelId kernelId, Task task, TaskCompletedListener taskCompletedListener); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface TaskProvider { | |
boolean hasTask(); | |
Task getTask(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Master { | |
Coordinator coordinator; | |
TaskProvider taskProvider; | |
ResultCollector resultCollector; | |
public void run() { | |
while(taskProvider.hasTasks()) { | |
Task task = taskProvider.getTask(); | |
KernelId kernelId = coordinator.getAvailableKernel(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface TaskCompletedListener { | |
void onTaskCompleted(KernelId kernelId, Result result); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Kernel { | |
KernelId getId(); | |
void processTask(Task task, ComputationResultHandler handler); | |
} | |
interface ComputationResultHandler { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface ResultCollector extends TaskCompletedListener { | |
Report getReport(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class KernelNode { | |
private ZNode core; | |
private ZNode input; | |
private ZNode output; | |
public boolean isAvailable() { | |
return core.hasChild("indicator"); | |
} | |
public void lock() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ZookeeperCoordinator implements Coordinator { | |
private static final Logger LOG = LoggerFactory.getLogger(ZookeeperCoordinator.class); | |
private final Zoo zoo; | |
private final String root; | |
public ZookeeperCoordinator(Zoo zoo, String root) { | |
this.zoo = zoo; | |
this.root = root; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root | |
|-- kernel1 | |
| |-- input | |
| |-- output | |
| `-- indicator | |
| | |
|-- kernel2 | |
| |-- input | |
| `-- output | |
| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snippet onurl | |
app.${1:type}('${2:url}', (res, req) -> | |
${3:body} | |
) |
OlderNewer