@Override public void validate() { super.validate(); if (namespace == null || namespace.isEmpty()) { throw new IllegalArgumentException("Namespace must be specified"); } if (name == null || name.isEmpty()) { throw new IllegalArgumentException("Application name must be specified"); } getId(); } }
@Override public void execute(Arguments arguments) throws Exception { ApplicationId appId = arguments.getId(); ArtifactSummary artifactSummary = arguments.getArtifact(); if (appExists(appId)) { return; } KerberosPrincipalId ownerPrincipalId = arguments.getOwnerPrincipal() == null ? null : new KerberosPrincipalId(arguments.getOwnerPrincipal()); // if we don't null check, it gets serialized to "null" String configString = arguments.getConfig() == null ? null : GSON.toJson(arguments.getConfig()); try { appLifecycleService.deployApp(appId.getParent(), appId.getApplication(), appId.getVersion(), artifactSummary, configString, x -> { }, ownerPrincipalId, arguments.canUpdateSchedules()); } catch (NotFoundException | UnauthorizedException | InvalidArtifactException e) { // these exceptions are for sure not retry-able. It's hard to tell if the others are, so we just try retrying // up to the default time limit throw e; } catch (DatasetManagementException e) { if (e.getCause() instanceof UnauthorizedException) { throw (UnauthorizedException) e.getCause(); } else { throw new RetryableException(e); } } catch (Exception e) { throw new RetryableException(e); } }
@Override public void execute(Arguments arguments) throws Exception { ApplicationId appId = arguments.getId(); ArtifactSummary artifactSummary = arguments.getArtifact(); if (appExists(appId)) { return; } KerberosPrincipalId ownerPrincipalId = arguments.getOwnerPrincipal() == null ? null : new KerberosPrincipalId(arguments.getOwnerPrincipal()); // if we don't null check, it gets serialized to "null" String configString = arguments.getConfig() == null ? null : GSON.toJson(arguments.getConfig()); try { appLifecycleService.deployApp(appId.getParent(), appId.getApplication(), appId.getVersion(), artifactSummary, configString, x -> { }, ownerPrincipalId, arguments.canUpdateSchedules()); } catch (NotFoundException | UnauthorizedException | InvalidArtifactException e) { // these exceptions are for sure not retry-able. It's hard to tell if the others are, so we just try retrying // up to the default time limit throw e; } catch (DatasetManagementException e) { if (e.getCause() instanceof UnauthorizedException) { throw (UnauthorizedException) e.getCause(); } else { throw new RetryableException(e); } } catch (Exception e) { throw new RetryableException(e); } }
@Test public void testMissingFieldsThrowsException() { ArtifactSummary artifactSummary = new ArtifactSummary("name", "1.0.0"); AppRequest<JsonObject> appRequest = new AppRequest<>(artifactSummary); AppCreator.Arguments arguments = new AppCreator.Arguments(appRequest, null, "app"); try { arguments.validate(); Assert.fail("arguments should have been invalidated."); } catch (IllegalArgumentException e) { // expected } arguments = new AppCreator.Arguments(appRequest, "namespace", null); try { arguments.validate(); Assert.fail("arguments should have been invalidated."); } catch (IllegalArgumentException e) { // expected } }
@Override public void validate() { super.validate(); if (namespace == null || namespace.isEmpty()) { throw new IllegalArgumentException("Namespace must be specified"); } if (name == null || name.isEmpty()) { throw new IllegalArgumentException("Application name must be specified"); } getId(); } }