use of io.fabric8.knative.serving.v1.Service in project fabric8 by jboss-fuse.
the class SimulateAction method doExecute.
@Override
protected void doExecute(Service service) throws Exception {
Patch patch = service.getPatch(patchId);
if (patch == null) {
throw new PatchException("Patch '" + patchId + "' not found");
}
if (patch.isInstalled()) {
throw new PatchException("Patch '" + patchId + "' is already installed");
}
PatchResult result = service.install(patch, true);
// display(result);
}
use of io.fabric8.knative.serving.v1.Service in project fabric8 by jboss-fuse.
the class FabricTestSupport method destroyChildContainer.
private void destroyChildContainer(FabricService fabricService, CuratorFramework curator, String name) throws InterruptedException {
try {
// Wait for zookeeper service to become available.
Thread.sleep(DEFAULT_WAIT);
// We need this because getContainer will create a container object if container doesn't exists.
if (ZooKeeperUtils.exists(curator, ZkPath.CONTAINER.getPath(name)) != null) {
Container container = fabricService.getContainer(name);
// We want to go through container destroy method so that cleanup methods are properly invoked.
container.destroy();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
use of io.fabric8.knative.serving.v1.Service in project fabric8 by jboss-fuse.
the class ShowAction method doExecute.
@Override
protected void doExecute(Service service) throws Exception {
Patch patch = patchManagement.loadPatch(new PatchDetailsRequest(patchId, bundles, files, diff));
if (patch == null) {
throw new PatchException("Patch '" + patchId + "' not found");
}
System.out.println(String.format("Patch ID: %s", patch.getPatchData().getId()));
if (patch.getManagedPatch() != null) {
System.out.println(String.format("Patch Commit ID: %s", patch.getManagedPatch().getCommitId()));
}
if (bundles) {
System.out.println(String.format("#### %d Bundles%s", patch.getPatchData().getBundles().size(), patch.getPatchData().getBundles().size() == 0 ? "" : ":"));
iterate(patch.getPatchData().getBundles());
}
if (files) {
ManagedPatch details = patch.getManagedPatch();
System.out.println(String.format("#### %d Files added%s", details.getFilesAdded().size(), details.getFilesAdded().size() == 0 ? "" : ":"));
iterate(details.getFilesAdded());
System.out.println(String.format("#### %d Files modified%s", details.getFilesModified().size(), details.getFilesModified().size() == 0 ? "" : ":"));
iterate(details.getFilesModified());
System.out.println(String.format("#### %d Files removed%s", details.getFilesRemoved().size(), details.getFilesRemoved().size() == 0 ? "" : ":"));
iterate(details.getFilesRemoved());
}
if (diff) {
System.out.println("#### Patch changes:\n" + patch.getManagedPatch().getUnifiedDiff());
}
}
use of io.fabric8.knative.serving.v1.Service in project fabric8 by jboss-fuse.
the class HttpGatewayHandler method handle.
@Override
public void handle(HttpServerRequest request) {
long callStart = System.nanoTime();
LOG.debug("Proxying request: {} {}", request.method(), request.uri());
// lets map the request URI to map to the service URI and then the renaming URI
// using mapping rules...
Map<String, MappedServices> mappingRules = httpGateway.getMappedServices();
try {
if (isMappingIndexRequest(request)) {
// lets return the JSON of all the results
doReturnIndex(request, mappingRules);
} else {
doRouteRequest(mappingRules, request);
}
CallDetailRecord cdr = new CallDetailRecord(System.nanoTime() - callStart, null);
httpGateway.addCallDetailRecord(cdr);
} catch (Throwable e) {
LOG.error("Caught: " + e, e);
CallDetailRecord cdr = new CallDetailRecord(System.nanoTime() - callStart, new Date() + ":" + e.getMessage());
httpGateway.addCallDetailRecord(cdr);
request.response().setStatusCode(404);
StringWriter buffer = new StringWriter();
e.printStackTrace(new PrintWriter(buffer));
request.response().setStatusMessage("Error: " + e + "\nStack Trace: " + buffer);
request.response().close();
}
}
use of io.fabric8.knative.serving.v1.Service in project halyard by spinnaker.
the class LocalDebianServiceProvider method getInstallCommand.
@Override
public String getInstallCommand(DeploymentDetails deploymentDetails, GenerateService.ResolvedConfiguration resolvedConfiguration, Map<String, String> installCommands) {
Map<String, Object> bindings = new HashMap<>();
List<SpinnakerService.Type> serviceTypes = new ArrayList<>(installCommands.keySet()).stream().map(SpinnakerService.Type::fromCanonicalName).collect(Collectors.toList());
List<String> upstartNames = getLocalServices(serviceTypes).stream().filter(i -> resolvedConfiguration.getServiceSettings(i.getService()).getEnabled()).map(i -> ((LocalDebianService) i).getUpstartServiceName()).filter(Objects::nonNull).collect(Collectors.toList());
List<String> systemdServiceConfigs = upstartNames.stream().map(n -> n + ".service").collect(Collectors.toList());
List<String> serviceInstalls = serviceTypes.stream().map(t -> installCommands.get(t.getCanonicalName())).collect(Collectors.toList());
TemplatedResource resource = new StringReplaceJarResource("/debian/init.sh");
bindings.put("services", Strings.join(upstartNames, " "));
bindings.put("systemd-service-configs", Strings.join(systemdServiceConfigs, " "));
String upstartInit = resource.setBindings(bindings).toString();
BillOfMaterials.ArtifactSources artifactSources = artifactService.getArtifactSources(deploymentDetails.getDeploymentName());
resource = new StringReplaceJarResource("/debian/install.sh");
bindings = new HashMap<>();
bindings.put("prepare-environment", "true");
bindings.put("install-redis", "true");
bindings.put("debian-repository", artifactSourcesConfig.mergeWithBomSources(artifactSources).getDebianRepository());
bindings.put("install-commands", String.join("\n", serviceInstalls));
bindings.put("service-action", "restart");
bindings.put("upstart-init", upstartInit);
return resource.setBindings(bindings).toString();
}
Aggregations