@Override public PreviewRunner getRunner(ApplicationId preview) throws NotFoundException { Injector injector = appInjectors.getIfPresent(preview); if (injector == null) { throw new NotFoundException(preview); } return injector.getInstance(PreviewRunner.class); }
@POST @Path("/data/datasets/{name}/admin/upgrade") public void upgrade(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("name") String instanceName) { propagateUserId(request); try { DatasetId instanceId = new DatasetId(namespaceId, instanceName); datasetAdminService.upgrade(instanceId); responder.sendJson(HttpResponseStatus.OK, GSON.toJson(new DatasetAdminOpResponse(null, null))); } catch (NotFoundException e) { LOG.debug("Got handler exception", e); responder.sendString(HttpResponseStatus.NOT_FOUND, StringUtils.defaultIfEmpty(e.getMessage(), "")); } catch (Exception e) { LOG.error(getAdminOpErrorMessage("upgrade", instanceName), e); responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR, getAdminOpErrorMessage("upgrade", instanceName)); } }
/** * Tests deploying an application in a non-existing non-default namespace. */ @Test public void testDeployNonExistingNamespace() throws Exception { HttpResponse response = deploy(AllProgramsApp.class, 404, Constants.Gateway.API_VERSION_3_TOKEN, "random"); NotFoundException nfe = new NamespaceNotFoundException(new NamespaceId("random")); Assert.assertEquals(nfe.getMessage(), response.getResponseBodyAsString()); }
@Override public PreviewRunner getRunner(ApplicationId preview) throws NotFoundException { Injector injector = appInjectors.getIfPresent(preview); if (injector == null) { throw new NotFoundException(preview); } return injector.getInstance(PreviewRunner.class); }
@Override public void ensureExists(ProgramRunId runId) throws NotFoundException { if (store.getRun(runId) == null) { throw new NotFoundException(runId); } } }
private RunRecordMeta getRunRecordMeta(ProgramRunId programRunId) throws NotFoundException { RunRecordMeta runRecord = programStore.getRun(programRunId); if (runRecord == null) { throw new NotFoundException(programRunId); } return runRecord; } }
@Override public void ensureExists(InstanceId instanceId) throws NotFoundException { if (!instanceName.equals(instanceId.getInstance())) { throw new NotFoundException(instanceId); } } }
@Override public void ensureExists(InstanceId instanceId) throws NotFoundException { if (!instanceName.equals(instanceId.getInstance())) { throw new NotFoundException(instanceId); } } }
private RunRecordMeta getRunRecordMeta(ProgramRunId programRunId) throws NotFoundException { RunRecordMeta runRecord = programStore.getRun(programRunId); if (runRecord == null) { throw new NotFoundException(programRunId); } return runRecord; } }
private void checkStreamExists(StreamId streamId) throws Exception { if (!streamAdmin.exists(streamId)) { throw new NotFoundException(streamId); } }
@Override public void ensureExists(ProgramRunId runId) throws NotFoundException { if (store.getRun(runId) == null) { throw new NotFoundException(runId); } } }
/** * Validate properties for the specified provisioner. * * @param provisionerName the name of the provisioner to validate * @param properties properties for the specified provisioner * @throws NotFoundException if the provisioner does not exist * @throws IllegalArgumentException if the properties are invalid */ public void validateProperties(String provisionerName, Map<String, String> properties) throws NotFoundException { Provisioner provisioner = provisionerInfo.get().provisioners.get(provisionerName); if (provisioner == null) { throw new NotFoundException(String.format("Provisioner '%s' does not exist", provisionerName)); } provisioner.validateProperties(properties); }
/** * Validate properties for the specified provisioner. * * @param provisionerName the name of the provisioner to validate * @param properties properties for the specified provisioner * @throws NotFoundException if the provisioner does not exist * @throws IllegalArgumentException if the properties are invalid */ public void validateProperties(String provisionerName, Map<String, String> properties) throws NotFoundException { Provisioner provisioner = provisionerInfo.get().provisioners.get(provisionerName); if (provisioner == null) { throw new NotFoundException(String.format("Provisioner '%s' does not exist", provisionerName)); } provisioner.validateProperties(properties); }
@GET @Path("/provisioners/{provisioner-name}") public void getProvisioner(HttpRequest request, HttpResponder responder, @PathParam("provisioner-name") String provisionerName) throws NotFoundException { ProvisionerDetail provisionerDetail = provisioningService.getProvisionerDetail(provisionerName); if (provisionerDetail == null) { throw new NotFoundException(String.format("Provisioner %s not found", provisionerName)); } responder.sendJson(HttpResponseStatus.OK, GSON.toJson(provisionerDetail)); } }
@GET @Path("/provisioners/{provisioner-name}") public void getProvisioner(HttpRequest request, HttpResponder responder, @PathParam("provisioner-name") String provisionerName) throws NotFoundException { ProvisionerDetail provisionerDetail = provisioningService.getProvisionerDetail(provisionerName); if (provisionerDetail == null) { throw new NotFoundException(String.format("Provisioner %s not found", provisionerName)); } responder.sendJson(HttpResponseStatus.OK, GSON.toJson(provisionerDetail)); } }
@GET @Path("/{service-provider}/stats") public void getServiceProviderStats(HttpRequest request, HttpResponder responder, @PathParam("service-provider") String serviceProvider) throws Exception { // we want to fetch stats with the specified service name grouped by the stat type Map<String, Map<String, Object>> stats = getStats(OperationalStatsUtils.SERVICE_NAME_KEY, serviceProvider, OperationalStatsUtils.STAT_TYPE_KEY); if (stats.isEmpty()) { throw new NotFoundException(String.format("Service provider %s not found", serviceProvider)); } // info is only needed in the list API, not in the stats API stats.remove(OperationalStatsUtils.STAT_TYPE_INFO); responder.sendJson(HttpResponseStatus.OK, GSON.toJson(stats)); }
@GET @Path("/{service-provider}/stats") public void getServiceProviderStats(HttpRequest request, HttpResponder responder, @PathParam("service-provider") String serviceProvider) throws Exception { // we want to fetch stats with the specified service name grouped by the stat type Map<String, Map<String, Object>> stats = getStats(OperationalStatsUtils.SERVICE_NAME_KEY, serviceProvider, OperationalStatsUtils.STAT_TYPE_KEY); if (stats.isEmpty()) { throw new NotFoundException(String.format("Service provider %s not found", serviceProvider)); } // info is only needed in the list API, not in the stats API stats.remove(OperationalStatsUtils.STAT_TYPE_INFO); responder.sendJson(HttpResponseStatus.OK, GSON.toJson(stats)); }
/** * Send request to get the status of latest restart instances request for a CDAP system service. */ @Path("/system/services/{service-name}/latest-restart") @GET public void getLatestRestartServiceInstanceStatus(HttpRequest request, HttpResponder responder, @PathParam("service-name") String serviceName) throws Exception { try { responder.sendJson(HttpResponseStatus.OK, GSON.toJson(serviceStore.getLatestRestartInstancesRequest(serviceName))); } catch (IllegalStateException ex) { throw new NotFoundException(String.format("No restart instances request found or %s", serviceName)); } }
/** * Send request to get the status of latest restart instances request for a CDAP system service. */ @Path("/system/services/{service-name}/latest-restart") @GET public void getLatestRestartServiceInstanceStatus(HttpRequest request, HttpResponder responder, @PathParam("service-name") String serviceName) throws Exception { try { responder.sendJson(HttpResponseStatus.OK, GSON.toJson(serviceStore.getLatestRestartInstancesRequest(serviceName))); } catch (IllegalStateException ex) { throw new NotFoundException(String.format("No restart instances request found or %s", serviceName)); } }
@Override public void delete(StreamViewId viewId) throws NotFoundException { ViewSpecification removed; Lock lock = viewsLock.writeLock(); lock.lock(); try { removed = views.remove(viewId, viewId.getParent()); } finally { lock.unlock(); } if (removed == null) { throw new NotFoundException(viewId); } }