public NetServerSpecFactoryBean configure(URI uri) { setHost(null != uri.getHost() ? uri.getHost() : "0.0.0.0"); setPort(uri.getPort() > 0 ? uri.getPort() : 3000); setFraming(null != uri.getPath() ? uri.getPath().substring(1) : "linefeed"); this.delegateCodec = StandardCodecs.STRING_CODEC; if (null != uri.getQuery()) { String[] params = StringUtils.split(uri.getQuery(), "&"); if (null == params) { params = new String[] {uri.getQuery()}; } for (String pair : params) { String[] parts = StringUtils.split(pair, "="); if (parts.length > 1) { if ("codec".equals(parts[0])) { setCodec(parts[1]); } else if ("dispatcher".equals(parts[0])) { setDispatcher(parts[1]); } else if ("lengthFieldLength".equals(parts[0])) { setLengthFieldLength(Integer.parseInt(parts[1])); } } } } return this; }
@VisibleForTesting String[] splitAtColon(String description) { String[] parts = StringUtils.split(description, ":"); for (int i = 0; parts != null && i < parts.length; i++) { if (parts[i] != null) { parts[i] = parts[i].trim(); } } return parts; }
@SuppressWarnings("rawtypes") public Object[] proxy(Class beanClass, String beanName, BeanFactory beanFactory) { if (classNamesMapping == null || classNamesMapping.isEmpty()) { LOGGER.warn("Class name custom proxy matcher closed due to classNames property is null."); return null; } List<Object> interceptors = new LinkedList<Object>(); Set<Map.Entry<String, String>> entrySet = classNamesMapping.entrySet(); for (Map.Entry<String, String> entry : entrySet) { if (StringUtils.isEmpty(entry.getValue())) { continue; } String[] beanNameMappings = StringUtils.split(entry.getKey(), ","); String[] interceptorBeanNames = StringUtils.split(entry.getValue(), ","); List<Object> beans = getInterceptors(beanNameMappings, interceptorBeanNames, beanClass, beanFactory); if (beans != null) { interceptors.addAll(beans); } } return null; }
private List<RedisNode> createSentinels(Sentinel sentinel) { List<RedisNode> sentinels = new ArrayList<RedisNode>(); String nodes = sentinel.getNodes(); for (String node : StringUtils.commaDelimitedListToStringArray(nodes)) { try { String[] parts = StringUtils.split(node, ":"); Assert.state(parts.length == 2, "Must be defined as 'host:port'"); sentinels.add(new RedisNode(parts[0], Integer.valueOf(parts[1]))); } catch (RuntimeException ex) { throw new IllegalStateException( "Invalid redis sentinel " + "property '" + node + "'", ex); } } return sentinels; }
@Test public void testAppInstallSubmit() throws Exception { String ID = "foo-1"; String BASE = "/apps/"; setYarnClient(buildYarnClient()); String[] installAppArgs = new String[] { "--spring.hadoop.fsUri=" + getConfiguration().get("fs.defaultFS"), "--spring.hadoop.resourceManagerAddress=" + getConfiguration().get("yarn.resourcemanager.address"), "--spring.yarn.client.files[0]=file:build/libs/test-install-submit-appmaster-2.0.0.BUILD-SNAPSHOT.jar", "--spring.yarn.client.files[1]=file:build/libs/test-install-submit-container-2.0.0.BUILD-SNAPSHOT.jar" }; Properties appProperties = new Properties(); appProperties.setProperty("spring.yarn.applicationDir", BASE + ID + "/"); YarnPushApplication installApp = new YarnPushApplication(); installApp.applicationVersion(ID); installApp.applicationBaseDir(BASE); installApp.configFile("application.properties", appProperties); installApp.run(installAppArgs); listFiles(); catFile(BASE + ID + "/application.properties"); String rm = getConfiguration().get("yarn.resourcemanager.address"); String[] split = StringUtils.split(rm, ":"); String[] submitAppArgs = new String[] { "--spring.yarn.applicationDir=" + BASE + ID + "/", "--spring.hadoop.fsUri=" + getConfiguration().get("fs.defaultFS"), "--spring.hadoop.resourceManagerHost=" + split[0], "--spring.hadoop.resourceManagerAddress=" + getConfiguration().get("yarn.resourcemanager.address"), "--spring.hadoop.resourceManagerSchedulerAddress=" + getConfiguration().get("yarn.resourcemanager.scheduler.address") }; YarnSubmitApplication submitApp = new YarnSubmitApplication(); submitApp.applicationVersion(ID); submitApp.applicationBaseDir(BASE); ApplicationId applicationId = submitApp.run(submitAppArgs); YarnApplicationState state = waitState(applicationId, 2, TimeUnit.MINUTES, YarnApplicationState.FINISHED); assertThat(state, is(YarnApplicationState.FINISHED)); List<Resource> resources = ContainerLogUtils.queryContainerLogs(getYarnCluster(), applicationId); assertThat(resources, notNullValue()); assertThat(resources.size(), is(6)); for (Resource res : resources) { File file = res.getFile(); String content = ContainerLogUtils.getFileContent(file); if (file.getName().endsWith("stdout")) { assertThat(file.length(), greaterThan(0l)); if (file.getName().equals("Container.stdout")) { assertThat(content, containsString("Hello from ActivatorPojo")); } } else if (file.getName().endsWith("stderr")) { assertThat("stderr file is not empty: " + content, file.length(), is(0l)); } } }