use of com.twitter.heron.scheduler.TopologySubmissionException in project incubator-heron by apache.
the class AppsV1beta1Controller method submit.
@Override
boolean submit(PackingPlan packingPlan) {
final String topologyName = getTopologyName();
if (!topologyName.equals(topologyName.toLowerCase())) {
throw new TopologySubmissionException("K8S scheduler does not allow upper case topologies.");
}
final Resource containerResource = getContainerResource(packingPlan);
// find the max number of instances in a container so we can open
// enough ports if remote debugging is enabled.
int numberOfInstances = 0;
for (PackingPlan.ContainerPlan containerPlan : packingPlan.getContainers()) {
numberOfInstances = Math.max(numberOfInstances, containerPlan.getInstances().size());
}
final V1beta1StatefulSet statefulSet = createStatefulSet(containerResource, numberOfInstances);
try {
final Response response = client.createNamespacedStatefulSetCall(getNamespace(), statefulSet, null, null, null).execute();
if (!response.isSuccessful()) {
LOG.log(Level.SEVERE, "Error creating topology message: " + response.message());
KubernetesUtils.logResponseBodyIfPresent(LOG, response);
// construct a message based on the k8s api server response
throw new TopologySubmissionException(KubernetesUtils.errorMessageFromResponse(response));
}
} catch (IOException | ApiException e) {
KubernetesUtils.logExceptionWithDetails(LOG, "Error creating topology", e);
throw new TopologySubmissionException(e.getMessage());
}
return true;
}
Aggregations