@Test(expected = IllegalArgumentException.class) public void convert_malform_interval() throws Exception { ServiceProfile<?> original = new ServiceProfile<HadoopScriptHandler>( "testing", QueueHadoopScriptHandler.class, map(new String[] { JobClientProfile.KEY_POLLING_INTERVAL, "?", "1.url", "http: }), new ProfileContext(getClass().getClassLoader(), new VariableResolver(map(new String[] { })))); JobClientProfile.convert(original); }
public static JobClientProfile convert(ServiceProfile<?> profile) { if (profile == null) { throw new IllegalArgumentException("profile must not be null"); } Map<String, String> conf = new HashMap<>(profile.getConfiguration()); conf.remove(ExecutionScriptHandler.KEY_RESOURCE); removeKeyPrefix(conf, ExecutionScriptHandler.KEY_PROP_PREFIX); long timeout = extractLong(profile, conf, KEY_TIMEOUT, DEFAULT_TIMEOUT); if (timeout <= 0) { throw new IllegalArgumentException(MessageFormat.format( "Request time out must be > 0 ({0}.{1}={2})", profile.getPrefix(), KEY_TIMEOUT, timeout)); } long pollingInterval = extractLong(profile, conf, KEY_POLLING_INTERVAL, DEFAULT_POLLING_INTERVAL); if (pollingInterval <= 0) { throw new IllegalArgumentException(MessageFormat.format( "Status polling interval must be > 0 ({0}.{1}={2})", profile.getPrefix(), KEY_TIMEOUT, pollingInterval)); } List<JobClient> clients = extractClients(profile, conf); if (clients.isEmpty()) { throw new IllegalArgumentException(MessageFormat.format( "There must be one or more job clients ({0}.<n>)", profile.getPrefix())); } return new JobClientProfile(profile.getPrefix(), clients, timeout, pollingInterval); }
JobClientProfile { public static JobClientProfile convert(ServiceProfile<?> profile) { if (profile == null) { throw new IllegalArgumentException("profile must not be null"); } Map<String, String> conf = new HashMap<>(profile.getConfiguration()); conf.remove(ExecutionScriptHandler.KEY_RESOURCE); removeKeyPrefix(conf, ExecutionScriptHandler.KEY_PROP_PREFIX); long timeout = extractLong(profile, conf, KEY_TIMEOUT, DEFAULT_TIMEOUT); if (timeout <= 0) { throw new IllegalArgumentException(MessageFormat.format( "Request time out must be > 0 ({0}.{1}={2})", profile.getPrefix(), KEY_TIMEOUT, timeout)); } long pollingInterval = extractLong(profile, conf, KEY_POLLING_INTERVAL, DEFAULT_POLLING_INTERVAL); if (pollingInterval <= 0) { throw new IllegalArgumentException(MessageFormat.format( "Status polling interval must be > 0 ({0}.{1}={2})", profile.getPrefix(), KEY_TIMEOUT, pollingInterval)); } List<JobClient> clients = extractClients(profile, conf); if (clients.isEmpty()) { throw new IllegalArgumentException(MessageFormat.format( "There must be one or more job clients ({0}.<n>)", profile.getPrefix())); } return new JobClientProfile(profile.getPrefix(), clients, timeout, pollingInterval); } }
JobClientProfile { public static JobClientProfile convert(ServiceProfile<?> profile) { if (profile == null) { throw new IllegalArgumentException("profile must not be null"); } Map<String, String> conf = new HashMap<>(profile.getConfiguration()); conf.remove(ExecutionScriptHandler.KEY_RESOURCE); removeKeyPrefix(conf, ExecutionScriptHandler.KEY_PROP_PREFIX); long timeout = extractLong(profile, conf, KEY_TIMEOUT, DEFAULT_TIMEOUT); if (timeout <= 0) { throw new IllegalArgumentException(MessageFormat.format( "Request time out must be > 0 ({0}.{1}={2})", profile.getPrefix(), KEY_TIMEOUT, timeout)); } long pollingInterval = extractLong(profile, conf, KEY_POLLING_INTERVAL, DEFAULT_POLLING_INTERVAL); if (pollingInterval <= 0) { throw new IllegalArgumentException(MessageFormat.format( "Status polling interval must be > 0 ({0}.{1}={2})", profile.getPrefix(), KEY_TIMEOUT, pollingInterval)); } List<JobClient> clients = extractClients(profile, conf); if (clients.isEmpty()) { throw new IllegalArgumentException(MessageFormat.format( "There must be one or more job clients ({0}.<n>)", profile.getPrefix())); } return new JobClientProfile(profile.getPrefix(), clients, timeout, pollingInterval); } JobClientProfile(String prefix, List<? extends JobClient> clients, long timeout, long pollingInterval); }
JobClientProfile { public static JobClientProfile convert(ServiceProfile<?> profile) { if (profile == null) { throw new IllegalArgumentException("profile must not be null"); } Map<String, String> conf = new HashMap<>(profile.getConfiguration()); conf.remove(ExecutionScriptHandler.KEY_RESOURCE); removeKeyPrefix(conf, ExecutionScriptHandler.KEY_PROP_PREFIX); long timeout = extractLong(profile, conf, KEY_TIMEOUT, DEFAULT_TIMEOUT); if (timeout <= 0) { throw new IllegalArgumentException(MessageFormat.format( "Request time out must be > 0 ({0}.{1}={2})", profile.getPrefix(), KEY_TIMEOUT, timeout)); } long pollingInterval = extractLong(profile, conf, KEY_POLLING_INTERVAL, DEFAULT_POLLING_INTERVAL); if (pollingInterval <= 0) { throw new IllegalArgumentException(MessageFormat.format( "Status polling interval must be > 0 ({0}.{1}={2})", profile.getPrefix(), KEY_TIMEOUT, pollingInterval)); } List<JobClient> clients = extractClients(profile, conf); if (clients.isEmpty()) { throw new IllegalArgumentException(MessageFormat.format( "There must be one or more job clients ({0}.<n>)", profile.getPrefix())); } return new JobClientProfile(profile.getPrefix(), clients, timeout, pollingInterval); } JobClientProfile(String prefix, List<? extends JobClient> clients, long timeout, long pollingInterval); String getPrefix(); List<JobClient> getClients(); long getTimeout(); long getPollingInterval(); static JobClientProfile convert(ServiceProfile<?> profile); }
JobClientProfile { public static JobClientProfile convert(ServiceProfile<?> profile) { if (profile == null) { throw new IllegalArgumentException("profile must not be null"); } Map<String, String> conf = new HashMap<>(profile.getConfiguration()); conf.remove(ExecutionScriptHandler.KEY_RESOURCE); removeKeyPrefix(conf, ExecutionScriptHandler.KEY_PROP_PREFIX); long timeout = extractLong(profile, conf, KEY_TIMEOUT, DEFAULT_TIMEOUT); if (timeout <= 0) { throw new IllegalArgumentException(MessageFormat.format( "Request time out must be > 0 ({0}.{1}={2})", profile.getPrefix(), KEY_TIMEOUT, timeout)); } long pollingInterval = extractLong(profile, conf, KEY_POLLING_INTERVAL, DEFAULT_POLLING_INTERVAL); if (pollingInterval <= 0) { throw new IllegalArgumentException(MessageFormat.format( "Status polling interval must be > 0 ({0}.{1}={2})", profile.getPrefix(), KEY_TIMEOUT, pollingInterval)); } List<JobClient> clients = extractClients(profile, conf); if (clients.isEmpty()) { throw new IllegalArgumentException(MessageFormat.format( "There must be one or more job clients ({0}.<n>)", profile.getPrefix())); } return new JobClientProfile(profile.getPrefix(), clients, timeout, pollingInterval); } JobClientProfile(String prefix, List<? extends JobClient> clients, long timeout, long pollingInterval); String getPrefix(); List<JobClient> getClients(); long getTimeout(); long getPollingInterval(); static JobClientProfile convert(ServiceProfile<?> profile);  }