List of usage examples for java.util Set toString
public String toString()
From source file:com.kelveden.rastajax.core.ResourceClassLoader.java
private Parameter loadMethodParameter(final Class<?> clazz, final Method method, final int parameterIndex) { final String logPrefix = " |---"; final Set<Annotation> annotations = JaxRsAnnotationScraper.scrapeJaxRsAnnotationsFrom(clazz, method, parameterIndex);// www . j a va 2 s. com LOGGER.debug("{} Found parameter annotations {}.", logPrefix, annotations.toString()); final Class<?> type = method.getParameterTypes()[parameterIndex]; try { return buildParameterFromJaxRsAnnotations(annotations, type); } catch (IllegalAccessException e) { throw new ResourceClassLoadingException(String.format( "Could not load resource method parameter at index %s on method '%s' on class '%s'", parameterIndex, method.getName(), clazz.getName()), e); } catch (InvocationTargetException e) { throw new ResourceClassLoadingException(String.format( "Could not load resource method parameter at index %s on method '%s' on class '%s'", parameterIndex, method.getName(), clazz.getName()), e); } catch (NoSuchMethodException e) { throw new ResourceClassLoadingException(String.format( "Could not load resource method parameter at index %s on method '%s' on class '%s'", parameterIndex, method.getName(), clazz.getName()), e); } }
From source file:org.apache.hive.ptest.execution.conf.TestParser.java
private List<TestBatch> parseTests() { Context unitContext = new Context(context.getSubProperties(Joiner.on(".").join("unitTests", ""))); Set<String> excluded = Sets.newHashSet(TEST_SPLITTER.split(unitContext.getString("exclude", ""))); Set<String> isolated = Sets.newHashSet(TEST_SPLITTER.split(unitContext.getString("isolate", ""))); Set<String> included = Sets.newHashSet(TEST_SPLITTER.split(unitContext.getString("include", ""))); if (!included.isEmpty() && !excluded.isEmpty()) { throw new IllegalArgumentException( String.format("Included and excluded mutally exclusive." + " Included = %s, excluded = %s", included.toString(), excluded.toString())); }/*from w w w. jav a 2 s .c om*/ List<File> unitTestsDirs = Lists.newArrayList(); for (String unitTestDir : TEST_SPLITTER .split(checkNotNull(unitContext.getString("directories"), "directories"))) { File unitTestParent = new File(sourceDirectory, unitTestDir); if (unitTestParent.isDirectory()) { unitTestsDirs.add(unitTestParent); } else { logger.warn("Unit test directory " + unitTestParent + " does not exist."); } } List<TestBatch> result = Lists.newArrayList(); for (QFileTestBatch test : parseQFileTests()) { result.add(test); excluded.add(test.getDriver()); } for (File unitTestDir : unitTestsDirs) { for (File classFile : FileUtils.listFiles(unitTestDir, new String[] { "class" }, true)) { String className = classFile.getName(); logger.debug("In " + unitTestDir + ", found " + className); if (className.startsWith("Test") && !className.contains("$")) { String testName = className.replaceAll("\\.class$", ""); if (excluded.contains(testName)) { logger.info("Exlcuding unit test " + testName); } else if (included.isEmpty() || included.contains(testName)) { if (isolated.contains(testName)) { logger.info("Executing isolated unit test " + testName); result.add(new UnitTestBatch(testCasePropertyName, testName, false)); } else { logger.info("Executing parallel unit test " + testName); result.add(new UnitTestBatch(testCasePropertyName, testName, true)); } } } } } return result; }
From source file:org.cloudifysource.esc.installer.filetransfer.VfsFileTransfer.java
@Override public void copyFiles(final InstallationDetails details, final Set<String> excludedFiles, final List<File> additionalFiles, final long endTimeMillis) throws TimeoutException, InstallerException { logger.fine("Copying files to: " + host + " from local dir: " + localDir.getName().getPath() + " excluding " + excludedFiles.toString()); try {/*w ww . jav a2 s.co m*/ if (remoteDir.exists()) { FileType type = remoteDir.getType(); if (!type.equals(FileType.FOLDER)) { throw new InstallerException("The remote location: " + remoteDir.getName().getFriendlyURI() + " exists but is not a directory"); } if (deleteRemoteDirectoryContents) { logger.info("Deleting contents of remote directory: " + remoteDir.getName().getFriendlyURI()); remoteDir.delete(new FileDepthSelector(1, Integer.MAX_VALUE)); } FileObject[] children = remoteDir.getChildren(); if (children.length > 0) { throw new InstallerException( "The remote directory: " + remoteDir.getName().getFriendlyURI() + " is not empty"); } } remoteDir.copyFrom(localDir, new FileSelector() { @Override public boolean includeFile(final FileSelectInfo fileInfo) throws Exception { if (excludedFiles.contains(fileInfo.getFile().getName().getBaseName())) { logger.fine(fileInfo.getFile().getName().getBaseName() + " excluded"); return false; } final FileObject remoteFile = fileSystemManager.resolveFile(remoteDir, localDir.getName().getRelativeName(fileInfo.getFile().getName())); if (!remoteFile.exists()) { logger.fine(fileInfo.getFile().getName().getBaseName() + " missing on server"); return true; } if (fileInfo.getFile().getType() == FileType.FILE) { final long remoteSize = remoteFile.getContent().getSize(); final long localSize = fileInfo.getFile().getContent().getSize(); final boolean res = localSize != remoteSize; if (res) { logger.fine(fileInfo.getFile().getName().getBaseName() + " different on server"); } return res; } return false; } @Override public boolean traverseDescendents(final FileSelectInfo fileInfo) throws Exception { return true; } }); for (final File file : additionalFiles) { logger.fine("copying file: " + file.getAbsolutePath() + " to remote directory"); final FileObject fileObject = fileSystemManager.resolveFile("file:" + file.getAbsolutePath()); final FileObject remoteFile = remoteDir.resolveFile(file.getName()); remoteFile.copyFrom(fileObject, new AllFileSelector()); } logger.fine("Copying files to: " + host + " completed."); } catch (final FileSystemException e) { throw new InstallerException("Failed to copy files to remote host " + host + ": " + e.getMessage(), e); } checkTimeout(endTimeMillis); }
From source file:at.rocworks.oa4j.logger.dbs.NoSQLJDBC.java
@Override public boolean dpGetPeriod(Date t1, Date t2, Dp dp, Set<String> configs, DpGetPeriodResult result) { JDebug.out.log(Level.INFO, "dpGetPeriod: {0}-{1} {2} {3}", new Object[] { t1, t2, dp.toString(), configs.toString() }); try {//from w w w . j av a 2 s. c o m Connection conn = dataSourceQuery.getConnection(); if (conn != null) { // select columns ArrayList<Dp> dps = createDpConfigAttrList(dp, configs); if (dps.isEmpty()) { JDebug.out.warning("dpGetPeriod without any valid config."); return false; } StringBuilder columns = new StringBuilder(); dps.forEach((Dp x) -> { String c = attrMap.get(x.getAttribute()); if (c != null) columns.append(c).append(","); }); // add the timestamp columns.append("ts AS TS"); // datapoint element_id Object tag = this.getTagOfDp(dp); if (tag == null) { JDebug.out.log(Level.SEVERE, "dpGetPeriod with invalid datapoint {0}", new Object[] { dp.toString() }); return false; } // build sql statement String sql = String.format(this.sqlSelectStmt, columns); // query data int records = 0; JDebug.out.log(Level.FINE, "dpGetPeriod SQL={0}", sql); try (PreparedStatement stmt = conn.prepareStatement(sql)) { // tag if (tag instanceof Long) stmt.setLong(1, (Long) tag); else if (tag instanceof String) { stmt.setString(1, (String) tag); } // timerange stmt.setTimestamp(2, new java.sql.Timestamp(t1.getTime()), cal); stmt.setTimestamp(3, new java.sql.Timestamp(t2.getTime()), cal); // execute //stmt.setFetchSize(1000); ResultSet rs = stmt.executeQuery(); //ResultSetMetaData md = rs.getMetaData(); Date ts; Object value; while (rs.next()) { records++; int c = 0; ts = rs.getTimestamp("TS", cal); for (int i = 0; i < dps.size(); i++) { switch (dps.get(i).getAttribute()) { case Value: // value_number value = rs.getObject(++c); if (value != null) result.addValue(dps.get(i), ts, value); // value_string value = rs.getObject(++c); if (value != null) result.addValue(dps.get(i), ts, value); // value_timestamp value = rs.getObject(++c); if (value != null) result.addValue(dps.get(i), ts, value); break; case Status: value = rs.getObject(++c); result.addVariable(dps.get(i), ts, new Bit32Var(value)); break; case Status64: value = rs.getObject(++c); result.addVariable(dps.get(i), ts, new Bit64Var(value)); break; case Manager: case User: value = rs.getObject(++c); result.addValue(dps.get(i), ts, value); break; case Stime: value = ts; result.addValue(dps.get(i), ts, value); break; default: c++; JDebug.out.log(Level.SEVERE, "unhandeled config {0}", dps.get(i).getAttribute()); } } } } JDebug.out.log(Level.FINE, "dpGetPeriod: {0} records", records); conn.close(); return true; } else { JDebug.StackTrace(Level.SEVERE, "no connection!"); } } catch (Exception ex) { JDebug.StackTrace(Level.SEVERE, ex); } return false; }
From source file:com.abixen.platform.service.businessintelligence.multivisualisation.application.service.database.AbstractDatabaseService.java
private String buildQueryForChartData(DatabaseDataSource databaseDataSource, Set<String> chartColumnsSet, ResultSetMetaData resultSetMetaData, ChartConfigurationForm chartConfigurationForm, Integer limit) throws SQLException { StringBuilder outerSelect = new StringBuilder("SELECT "); outerSelect.append("subQueryResult." + chartColumnsSet.toString().substring(1, chartColumnsSet.toString().length() - 1)); outerSelect.append(" FROM ("); outerSelect//from ww w.j av a 2s . c om .append(buildQueryForDataSourceData(databaseDataSource, chartColumnsSet, resultSetMetaData, limit)); outerSelect.append(") subQueryResult WHERE "); outerSelect .append(jsonFilterService.convertJsonToJpql(chartConfigurationForm.getFilter(), resultSetMetaData)); return outerSelect.toString(); }
From source file:com.kelveden.rastajax.core.ResourceClassLoader.java
public ResourceClass loadResourceClassFrom(final Class<?> candidateResourceClass) { LOGGER.debug(StringUtils.repeat("-", UNDERLINE_LENGTH)); LOGGER.debug("Attempting to load class {} as a JAX-RS resource class...", candidateResourceClass.getName()); LOGGER.debug(StringUtils.repeat("-", UNDERLINE_LENGTH)); final Set<Annotation> resourceAnnotations = JaxRsAnnotationScraper .scrapeJaxRsAnnotationsFrom(candidateResourceClass); LOGGER.debug("Found class annotations {}.", resourceAnnotations.toString()); String uriTemplate = null;//w w w .j av a 2 s .c o m String[] produces = null; String[] consumes = null; for (Annotation annotation : resourceAnnotations) { if (annotation.annotationType() == Path.class) { uriTemplate = ((Path) annotation).value(); LOGGER.debug("Class URI template is '{}'.", uriTemplate); } else if (annotation.annotationType() == Produces.class) { produces = ((Produces) annotation).value(); LOGGER.debug("Class produces: {}.", StringUtils.join(produces, ",")); } else if (annotation.annotationType() == Consumes.class) { consumes = ((Consumes) annotation).value(); LOGGER.debug("Class consumes: {}.", StringUtils.join(consumes, ",")); } } LOGGER.debug("Finding resource methods..."); final List<ResourceClassMethod> methodsOnResource = loadMethods(candidateResourceClass); LOGGER.debug("Found {} resource methods.", methodsOnResource.size()); if (methodsOnResource.size() == 0) { LOGGER.debug("Class is NOT a resource class."); return null; } LOGGER.debug("Class is a resource class."); LOGGER.debug("Finding fields..."); final List<Parameter> fields = loadClassFields(candidateResourceClass); LOGGER.debug("Found {} fields.", fields.size()); LOGGER.debug("Finding properties..."); final List<Parameter> properties = loadClassProperties(candidateResourceClass); LOGGER.debug("Found {} properties.", properties.size()); fields.addAll(properties); return new ResourceClass(candidateResourceClass, uriTemplate, methodsOnResource, arrayAsList(consumes), arrayAsList(produces), fields); }
From source file:org.jasig.portlet.survey.security.uportal.UPortalSecurityFilter.java
private void populateAuthorites(final RenderRequest req, final String principal) { // But the user's access has not yet been established... final Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>(); boolean isSurveyAdmin = req.isUserInRole("survey-admin"); if (isSurveyAdmin) { authorities.add(new SimpleGrantedAuthority(ROLE_ADMIN)); }/*from ww w. j av a2 s .co m*/ boolean isSurveyUser = req.isUserInRole("survey-user"); if (isSurveyUser) { authorities.add(new SimpleGrantedAuthority(ROLE_USER)); } logger.debug("Setting up GrantedAutorities for user '{}' -- {}", principal, authorities.toString()); final UPortalUserDetails userDetails = new UPortalUserDetails(principal, Collections.unmodifiableSet(authorities)); // Add UserDetails to Session final PortletSession session = req.getPortletSession(); session.setAttribute(AUTHENTICATION_TOKEN_KEY, userDetails, PortletSession.APPLICATION_SCOPE); }
From source file:org.apache.ambari.server.utils.TestStageUtils.java
@Test @Ignore//from w w w.j a v a 2 s . c o m public void testGetClusterHostInfo() throws AmbariException, UnknownHostException { Clusters fsm = injector.getInstance(Clusters.class); String h0 = "h0"; List<String> hostList = new ArrayList<String>(); hostList.add("h1"); hostList.add("h2"); hostList.add("h3"); hostList.add("h4"); hostList.add("h5"); hostList.add("h6"); hostList.add("h7"); hostList.add("h8"); hostList.add("h9"); hostList.add("h10"); mockStaticPartial(StageUtils.class, "getHostName"); expect(StageUtils.getHostName()).andReturn(h0).anyTimes(); replayAll(); List<Integer> pingPorts = Arrays.asList(StageUtils.DEFAULT_PING_PORT, StageUtils.DEFAULT_PING_PORT, StageUtils.DEFAULT_PING_PORT, 8671, 8671, null, 8672, 8672, null, 8673); fsm.addCluster("c1"); fsm.getCluster("c1").setDesiredStackVersion(new StackId(STACK_ID)); int index = 0; for (String host : hostList) { fsm.addHost(host); Map<String, String> hostAttributes = new HashMap<String, String>(); hostAttributes.put("os_family", "redhat"); hostAttributes.put("os_release_version", "5.9"); fsm.getHost(host).setHostAttributes(hostAttributes); fsm.getHost(host).setCurrentPingPort(pingPorts.get(index)); fsm.getHost(host).persist(); fsm.mapHostToCluster(host, "c1"); index++; } //Add HDFS service Map<String, List<Integer>> hdfsTopology = new HashMap<String, List<Integer>>(); hdfsTopology.put("NAMENODE", Collections.singletonList(0)); hdfsTopology.put("SECONDARY_NAMENODE", Collections.singletonList(1)); List<Integer> datanodeIndexes = Arrays.asList(0, 1, 2, 3, 5, 7, 8, 9); hdfsTopology.put("DATANODE", new ArrayList<Integer>(datanodeIndexes)); addService(fsm.getCluster("c1"), hostList, hdfsTopology, "HDFS", injector); //Add HBASE service Map<String, List<Integer>> hbaseTopology = new HashMap<String, List<Integer>>(); hbaseTopology.put("HBASE_MASTER", Collections.singletonList(5)); List<Integer> regionServiceIndexes = Arrays.asList(1, 3, 5, 8, 9); hbaseTopology.put("HBASE_REGIONSERVER", regionServiceIndexes); addService(fsm.getCluster("c1"), hostList, hbaseTopology, "HBASE", injector); //Add MAPREDUCE service Map<String, List<Integer>> mrTopology = new HashMap<String, List<Integer>>(); mrTopology.put("JOBTRACKER", Collections.singletonList(5)); List<Integer> taskTrackerIndexes = Arrays.asList(1, 2, 3, 4, 5, 7, 9); mrTopology.put("TASKTRACKER", taskTrackerIndexes); addService(fsm.getCluster("c1"), hostList, mrTopology, "MAPREDUCE", injector); //Add NONAME service Map<String, List<Integer>> nonameTopology = new HashMap<String, List<Integer>>(); nonameTopology.put("NONAME_SERVER", Collections.singletonList(7)); addService(fsm.getCluster("c1"), hostList, nonameTopology, "NONAME", injector); fsm.getCluster("c1").getService("MAPREDUCE").getServiceComponent("TASKTRACKER") .getServiceComponentHost("h2").setComponentAdminState(HostComponentAdminState.DECOMMISSIONED); fsm.getCluster("c1").getService("MAPREDUCE").getServiceComponent("TASKTRACKER") .getServiceComponentHost("h3").setComponentAdminState(HostComponentAdminState.DECOMMISSIONED); //Get cluster host info Map<String, Set<String>> info = StageUtils.getClusterHostInfo(fsm.getHostsForCluster("c1"), fsm.getCluster("c1")); //All hosts present in cluster host info Set<String> allHosts = info.get(HOSTS_LIST); ArrayList<String> allHostsList = new ArrayList<String>(allHosts); assertEquals(fsm.getHosts().size(), allHosts.size()); for (Host host : fsm.getHosts()) { assertTrue(allHosts.contains(host.getHostName())); } //Check HDFS topology compression Map<String, String> hdfsMapping = new HashMap<String, String>(); hdfsMapping.put("DATANODE", "slave_hosts"); hdfsMapping.put("NAMENODE", "namenode_host"); hdfsMapping.put("SECONDARY_NAMENODE", "snamenode_host"); checkServiceCompression(info, hdfsMapping, hdfsTopology, hostList); //Check HBASE topology compression Map<String, String> hbaseMapping = new HashMap<String, String>(); hbaseMapping.put("HBASE_MASTER", "hbase_master_hosts"); hbaseMapping.put("HBASE_REGIONSERVER", "hbase_rs_hosts"); checkServiceCompression(info, hbaseMapping, hbaseTopology, hostList); //Check MAPREDUCE topology compression Map<String, String> mrMapping = new HashMap<String, String>(); mrMapping.put("JOBTRACKER", "jtnode_host"); mrMapping.put("TASKTRACKER", "mapred_tt_hosts"); checkServiceCompression(info, mrMapping, mrTopology, hostList); Set<String> actualPingPorts = info.get("all_ping_ports"); if (pingPorts.contains(null)) { assertEquals(new HashSet<Integer>(pingPorts).size(), actualPingPorts.size() + 1); } else { assertEquals(new HashSet<Integer>(pingPorts).size(), actualPingPorts.size()); } List<Integer> pingPortsActual = getRangeMappedDecompressedSet(actualPingPorts); List<Integer> reindexedPorts = getReindexedList(pingPortsActual, new ArrayList<String>(allHosts), hostList); //Treat null values while (pingPorts.contains(null)) { int indexOfNull = pingPorts.indexOf(null); pingPorts.set(indexOfNull, StageUtils.DEFAULT_PING_PORT); } assertEquals(pingPorts, reindexedPorts); // check for no-name in the list assertTrue(info.containsKey("noname_server_hosts")); assertTrue(info.containsKey("decom_tt_hosts")); Set<String> decommissionedHosts = info.get("decom_tt_hosts"); assertEquals(2, decommissionedHosts.toString().split(",").length); // check server hostname field assertTrue(info.containsKey(StageUtils.AMBARI_SERVER_HOST)); Set<String> serverHost = info.get(StageUtils.AMBARI_SERVER_HOST); assertEquals(1, serverHost.size()); assertEquals(h0, serverHost.iterator().next()); }
From source file:org.apache.jackrabbit.oak.spi.blob.AbstractBlobStoreTest.java
@Test public void delete() throws Exception { Set<String> ids = createArtifacts(); store.deleteChunks(Lists.newArrayList(ids), 0); Iterator<String> iter = store.getAllChunkIds(0); Set<String> ret = Sets.newHashSet(); while (iter.hasNext()) { ret.add(iter.next());/*from w ww . j av a2 s. co m*/ } assertTrue(ret.toString(), ret.isEmpty()); }
From source file:de.zib.vold.client.VolDClient.java
/** * Refresh a set of keys.//from w w w . ja v a 2 s. c o m * * @param source The source of the keys. * @param set The set keys to refresh. * @param timeStamp The timeStamp of this operation */ public Map<String, String> refresh(String source, Set<Key> set, final long timeStamp) { // guard { log.trace("Refresh: " + set.toString()); checkState(); if (null == set) { throw new IllegalArgumentException("null is no valid argument!"); } } // build greatest common scope String commonscope; { List<String> scopes = new ArrayList<String>(set.size()); for (Key k : set) { scopes.add(k.get_scope()); } commonscope = getGreatestCommonPrefix(scopes); } // build request body Set<Key> keys = new HashSet<Key>(); { for (Key entry : set) { // remove common prefix from scope final String scope = entry.get_scope().substring(commonscope.length()); final String type = entry.get_type(); final String keyname = entry.get_keyname(); keys.add(new Key(scope, type, keyname)); } } // build variable map String url; { url = buildURL(commonscope, keys); log.debug("REFRESH URL: " + url); } // get response from Server ResponseEntity<Map> responseEntity; { HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.add("TIMESTAMP", String.valueOf(timeStamp)); HttpEntity<Map<String, String>> requestEntity = new HttpEntity<Map<String, String>>(null, requestHeaders); responseEntity = rest.exchange(url, HttpMethod.POST, requestEntity, Map.class); //Object obj = rest.postForEntity( url, null, HashMap.class ); } return responseEntity.getBody(); }