List of usage examples for java.lang System lineSeparator
String lineSeparator
To view the source code for java.lang System lineSeparator.
Click Source Link
From source file:com.pearson.eidetic.driver.threads.RefreshAwsAccountVolumes.java
private ConcurrentHashMap<Region, ArrayList<Volume>> processLocalVolumeNoTime( ConcurrentHashMap<Region, ArrayList<Volume>> localVolumeNoTime, Region region) { for (Map.Entry pair : volNoTimeHasTag_.entrySet()) { Boolean contin = (Boolean) pair.getValue(); if (contin) { continue; }/*from w w w . j a v a2s . c o m*/ Volume vol = (Volume) pair.getKey(); try { localVolumeNoTime.get(region).remove(vol); } catch (Exception e) { logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error removing vol from VolumeNoTime_\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } volNoTimeHasTag_.clear(); return localVolumeNoTime; }
From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotVolumeSyncValidator.java
public boolean snapshotDeletion(AmazonEC2Client ec2Client, Volume vol, Integer keep) { if ((keep == null) || (ec2Client == null) || (vol == null)) { return false; }/*from w w w. j a v a2s. c om*/ try { List<Snapshot> del_snapshots = getAllSnapshotsOfVolume(ec2Client, vol, numRetries_, maxApiRequestsPerSecond_, uniqueAwsAccountIdentifier_); List<Snapshot> deletelist = new ArrayList(); List<Snapshot> sortedDeleteList = new ArrayList<>(deletelist); sortSnapshotsByDate(sortedDeleteList); int delta = sortedDeleteList.size() - keep; for (int i : range(0, delta - 1)) { try { deleteSnapshot(ec2Client, sortedDeleteList.get(i), numRetries_, maxApiRequestsPerSecond_, uniqueAwsAccountIdentifier_); } catch (Exception e) { logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error deleting snapshot\", Snapshot_id=\"" + sortedDeleteList.get(i).getSnapshotId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } } catch (Exception e) { logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error in snapshotDeletion\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } return true; }
From source file:com.pearson.eidetic.driver.threads.RefreshAwsAccountVolumes.java
private ConcurrentHashMap<Region, ArrayList<Volume>> processLocalCopyVolumeSnapshots( ConcurrentHashMap<Region, ArrayList<Volume>> localCopyVolumeSnapshots, Region region) { for (Map.Entry pair : volCopyHasTag_.entrySet()) { Boolean contin = (Boolean) pair.getValue(); if (contin) { continue; }/*from ww w .j a v a 2 s . co m*/ Volume vol = (Volume) pair.getKey(); try { localCopyVolumeSnapshots.get(region).remove(vol); } catch (Exception e) { logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error removing vol from CopyVolumeSnapshots_\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } volCopyHasTag_.clear(); return localCopyVolumeSnapshots; }
From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotChecker.java
public boolean snapshotDeletion(AmazonEC2Client ec2Client, Volume vol, String period, Integer keep) { if ((keep == null) || (ec2Client == null) || (vol == null) || (period == null)) { return false; }/*from ww w . j a v a2 s.c o m*/ try { List<Snapshot> del_snapshots = getAllSnapshotsOfVolume(ec2Client, vol, numRetries_, maxApiRequestsPerSecond_, uniqueAwsAccountIdentifier_); List<Snapshot> deletelist = new ArrayList(); for (Snapshot snapshot : del_snapshots) { String desc = snapshot.getDescription(); if ("week".equals(period) && desc.startsWith("week_snapshot")) { deletelist.add(snapshot); } else if ("day".equals(period) && desc.startsWith("day_snapshot")) { deletelist.add(snapshot); } else if ("hour".equals(period) && desc.startsWith("hour_snapshot")) { deletelist.add(snapshot); } else if ("month".equals(period) && desc.startsWith("month_snapshot")) { deletelist.add(snapshot); } } List<Snapshot> sortedDeleteList = new ArrayList<>(deletelist); sortSnapshotsByDate(sortedDeleteList); int delta = sortedDeleteList.size() - keep; for (int i : range(0, delta - 1)) { try { deleteSnapshot(ec2Client, sortedDeleteList.get(i), numRetries_, maxApiRequestsPerSecond_, uniqueAwsAccountIdentifier_); } catch (Exception e) { logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error deleting snapshot\", Snapshot_id=\"" + sortedDeleteList.get(i).getSnapshotId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } } catch (Exception e) { logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error in snapshotDeletion\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } return true; }
From source file:org.apache.ambari.server.serveraction.upgrades.ConfigureAction.java
/** * Aside from the normal execution, this method performs the following logic, with * the stack values set in the table below: * <p>//from w w w . ja va 2 s.co m * <table> * <tr> * <th>Upgrade Path</th> * <th>direction</th> * <th>Stack Actual</th> * <th>Stack Desired</th> * <th>Config Stack</th> * <th>Action</th> * </tr> * <tr> * <td>2.2.x -> 2.2.y</td> * <td>upgrade or downgrade</td> * <td>2.2</td> * <td>2.2</td> * <td>2.2</td> * <td>if value has changed, create a new config object with new value</td> * </tr> * <tr> * <td>2.2 -> 2.3</td> * <td>upgrade</td> * <td>2.2</td> * <td>2.3: set before action is executed</td> * <td>2.3: set before action is executed</td> * <td>new configs are already created; just update with new properties</td> * </tr> * <tr> * <td>2.3 -> 2.2</td> * <td>downgrade</td> * <td>2.2</td> * <td>2.2: set before action is executed</td> * <td>2.2</td> * <td>configs are already managed, results are the same as 2.2.x -> 2.2.y</td> * </tr> * </table> * </p> * * {@inheritDoc} */ @Override public CommandReport execute(ConcurrentMap<String, Object> requestSharedDataContext) throws AmbariException, InterruptedException { Map<String, String> commandParameters = getCommandParameters(); if (null == commandParameters || commandParameters.isEmpty()) { return createCommandReport(0, HostRoleStatus.FAILED, "{}", "", "Unable to change configuration values without command parameters"); } String clusterName = commandParameters.get("clusterName"); // such as hdfs-site or hbase-env String configType = commandParameters.get(ConfigureTask.PARAMETER_CONFIG_TYPE); // extract transfers List<ConfigurationKeyValue> keyValuePairs = Collections.emptyList(); String keyValuePairJson = commandParameters.get(ConfigureTask.PARAMETER_KEY_VALUE_PAIRS); if (null != keyValuePairJson) { keyValuePairs = m_gson.fromJson(keyValuePairJson, new TypeToken<List<ConfigurationKeyValue>>() { }.getType()); } // extract transfers List<Transfer> transfers = Collections.emptyList(); String transferJson = commandParameters.get(ConfigureTask.PARAMETER_TRANSFERS); if (null != transferJson) { transfers = m_gson.fromJson(transferJson, new TypeToken<List<Transfer>>() { }.getType()); } // extract replacements List<Replace> replacements = Collections.emptyList(); String replaceJson = commandParameters.get(ConfigureTask.PARAMETER_REPLACEMENTS); if (null != replaceJson) { replacements = m_gson.fromJson(replaceJson, new TypeToken<List<Replace>>() { }.getType()); } // if there is nothing to do, then skip the task if (keyValuePairs.isEmpty() && transfers.isEmpty() && replacements.isEmpty()) { String message = "cluster={0}, type={1}, transfers={2}, replacements={3}, configurations={4}"; message = MessageFormat.format(message, clusterName, configType, transfers, replacements, keyValuePairs); StringBuilder buffer = new StringBuilder( "Skipping this configuration task since none of the conditions were met and there are no transfers or replacements") .append("\n"); buffer.append(message); return createCommandReport(0, HostRoleStatus.COMPLETED, "{}", buffer.toString(), ""); } // if only 1 of the required properties was null and no transfer properties, // then something went wrong if (null == clusterName || null == configType || (keyValuePairs.isEmpty() && transfers.isEmpty() && replacements.isEmpty())) { String message = "cluster={0}, type={1}, transfers={2}, replacements={3}, configurations={4}"; message = MessageFormat.format(message, clusterName, configType, transfers, replacements, keyValuePairs); return createCommandReport(0, HostRoleStatus.FAILED, "{}", "", message); } Cluster cluster = m_clusters.getCluster(clusterName); Map<String, DesiredConfig> desiredConfigs = cluster.getDesiredConfigs(); DesiredConfig desiredConfig = desiredConfigs.get(configType); Config config = cluster.getConfig(configType, desiredConfig.getTag()); StackId currentStack = cluster.getCurrentStackVersion(); StackId targetStack = cluster.getDesiredStackVersion(); StackId configStack = config.getStackId(); // !!! initial reference values Map<String, String> base = config.getProperties(); Map<String, String> newValues = new HashMap<String, String>(base); boolean changedValues = false; // !!! do transfers first before setting defined values StringBuilder outputBuffer = new StringBuilder(250); for (Transfer transfer : transfers) { switch (transfer.operation) { case COPY: String valueToCopy = null; if (null == transfer.fromType) { // copying from current configuration valueToCopy = base.get(transfer.fromKey); } else { // copying from another configuration Config other = cluster.getDesiredConfigByType(transfer.fromType); if (null != other) { Map<String, String> otherValues = other.getProperties(); if (otherValues.containsKey(transfer.fromKey)) { valueToCopy = otherValues.get(transfer.fromKey); } } } // if the value is null use the default if it exists if (StringUtils.isBlank(valueToCopy) && !StringUtils.isBlank(transfer.defaultValue)) { valueToCopy = transfer.defaultValue; } if (StringUtils.isNotBlank(valueToCopy)) { // possibly coerce the value on copy if (transfer.coerceTo != null) { switch (transfer.coerceTo) { case YAML_ARRAY: { // turn c6401,c6402 into ['c6401',c6402'] String[] splitValues = StringUtils.split(valueToCopy, ','); List<String> quotedValues = new ArrayList<String>(splitValues.length); for (String splitValue : splitValues) { quotedValues.add("'" + StringUtils.trim(splitValue) + "'"); } valueToCopy = "[" + StringUtils.join(quotedValues, ',') + "]"; break; } default: break; } } // at this point we know that we have a changed value changedValues = true; newValues.put(transfer.toKey, valueToCopy); // append standard output outputBuffer.append(MessageFormat.format("Created {0}/{1} = \"{2}\"\n", configType, transfer.toKey, mask(transfer, valueToCopy))); } break; case MOVE: // if the value existed previously, then update the maps with the new // key; otherwise if there is a default value specified, set the new // key with the default if (newValues.containsKey(transfer.fromKey)) { newValues.put(transfer.toKey, newValues.remove(transfer.fromKey)); changedValues = true; // append standard output outputBuffer.append(MessageFormat.format("Renamed {0}/{1} to {2}/{3}\n", configType, transfer.fromKey, configType, transfer.toKey)); } else if (StringUtils.isNotBlank(transfer.defaultValue)) { newValues.put(transfer.toKey, transfer.defaultValue); changedValues = true; // append standard output outputBuffer.append(MessageFormat.format("Created {0}/{1} with default value \"{2}\"\n", configType, transfer.toKey, mask(transfer, transfer.defaultValue))); } break; case DELETE: if ("*".equals(transfer.deleteKey)) { newValues.clear(); // append standard output outputBuffer.append(MessageFormat.format("Deleted all keys from {0}\n", configType)); for (String keeper : transfer.keepKeys) { if (base.containsKey(keeper) && base.get(keeper) != null) { newValues.put(keeper, base.get(keeper)); // append standard output outputBuffer.append( MessageFormat.format("Preserved {0}/{1} after delete\n", configType, keeper)); } } // !!! with preserved edits, find the values that are different from // the stack-defined and keep them - also keep values that exist in // the config but not on the stack if (transfer.preserveEdits) { List<String> edited = findValuesToPreserve(clusterName, config); for (String changed : edited) { newValues.put(changed, base.get(changed)); // append standard output outputBuffer.append( MessageFormat.format("Preserved {0}/{1} after delete\n", configType, changed)); } } changedValues = true; } else { newValues.remove(transfer.deleteKey); changedValues = true; // append standard output outputBuffer.append(MessageFormat.format("Deleted {0}/{1}\n", configType, transfer.deleteKey)); } break; } } // set all key/value pairs if (null != keyValuePairs && !keyValuePairs.isEmpty()) { for (ConfigurationKeyValue keyValuePair : keyValuePairs) { String key = keyValuePair.key; String value = keyValuePair.value; if (null != key) { String oldValue = base.get(key); // !!! values are not changing, so make this a no-op if (null != oldValue && value.equals(oldValue)) { if (currentStack.equals(targetStack) && !changedValues) { outputBuffer.append(MessageFormat.format( "{0}/{1} for cluster {2} would not change, skipping setting", configType, key, clusterName)); // continue because this property is not changing continue; } } // !!! only put a key/value into this map of new configurations if // there was a key, otherwise this will put something like null=null // into the configs which will cause NPEs after upgrade - this is a // byproduct of the configure being able to take a list of transfers // without a key/value to set newValues.put(key, value); final String message; if (StringUtils.isEmpty(value)) { message = MessageFormat.format("{0}/{1} changed to an empty value", configType, key); } else { message = MessageFormat.format("{0}/{1} changed to \"{2}\"\n", configType, key, mask(keyValuePair, value)); } outputBuffer.append(message); } } } // !!! string replacements happen only on the new values. for (Replace replacement : replacements) { // the key might exist but might be null, so we need to check this // condition when replacing a part of the value String toReplace = newValues.get(replacement.key); if (StringUtils.isNotBlank(toReplace)) { if (!toReplace.contains(replacement.find)) { outputBuffer.append(MessageFormat.format("String \"{0}\" was not found in {1}/{2}\n", replacement.find, configType, replacement.key)); } else { String replaced = StringUtils.replace(toReplace, replacement.find, replacement.replaceWith); newValues.put(replacement.key, replaced); outputBuffer.append(MessageFormat.format("Replaced {0}/{1} containing \"{2}\" with \"{3}\"", configType, replacement.key, replacement.find, replacement.replaceWith)); outputBuffer.append(System.lineSeparator()); } } else { outputBuffer.append(MessageFormat.format( "Skipping replacement for {0}/{1} because it does not exist or is empty.", configType, replacement.key)); outputBuffer.append(System.lineSeparator()); } } // !!! check to see if we're going to a new stack and double check the // configs are for the target. Then simply update the new properties instead // of creating a whole new history record since it was already done if (!targetStack.equals(currentStack) && targetStack.equals(configStack)) { config.setProperties(newValues); config.persist(false); return createCommandReport(0, HostRoleStatus.COMPLETED, "{}", outputBuffer.toString(), ""); } // !!! values are different and within the same stack. create a new // config and service config version String serviceVersionNote = "Stack Upgrade"; String auditName = getExecutionCommand().getRoleParams().get(ServerAction.ACTION_USER_NAME); if (auditName == null) { auditName = m_configuration.getAnonymousAuditName(); } m_configHelper.createConfigType(cluster, m_controller, configType, newValues, auditName, serviceVersionNote); String message = "Finished updating configuration ''{0}''"; message = MessageFormat.format(message, configType); return createCommandReport(0, HostRoleStatus.COMPLETED, "{}", message, ""); }
From source file:im.ene.lab.attiq.ui.activities.ProfileActivity.java
@SuppressWarnings("unused") public void onEventMainThread(UserFetchedEvent event) { Log.d(TAG, "onEventMainThread() called with: " + "event = [" + event + "]"); if (event.user != null) { mRealm.beginTransaction();// w ww. j a v a2s . co m mProfile.setProfileImageUrl(event.user.getProfileImageUrl()); StringBuilder description = new StringBuilder(); boolean willBreakLine = false; boolean willSeparate = false; if (!UIUtil.isEmpty(event.user.getName())) { description.append(event.user.getName()); willBreakLine = true; } if (!UIUtil.isEmpty(event.user.getLocation())) { if (willSeparate) { description.append(", "); } if (willBreakLine) { description.append(System.lineSeparator()); } description.append(event.user.getLocation()); } mProfile.setBrief(description.toString()); mProfile.setDescription(event.user.getDescription()); mProfile.setOrganization(event.user.getOrganization()); mProfile.setItemCount(event.user.getItemsCount()); mProfile.setFollowerCount(event.user.getFollowersCount()); mProfile.setFollowingCount(event.user.getFolloweesCount()); mProfile.setWebsite(event.user.getWebsiteUrl()); mProfile.setFacebookName(event.user.getFacebookId()); mProfile.setTwitterName(event.user.getTwitterScreenName()); mProfile.setGithubName(event.user.getGithubLoginName()); mProfile.setLinkedinName(event.user.getLinkedinId()); mRealm.commitTransaction(); } }
From source file:com.puppycrawl.tools.checkstyle.MainTest.java
@Test public void testExistingTargetFilePlainOutputNonexistingProperties() throws Exception { exit.expectSystemExitWithStatus(-1); exit.checkAssertionAfterwards(new Assertion() { @Override//ww w . j ava 2 s . com public void checkAssertion() { assertEquals("Could not find file 'nonexisting.properties'." + System.lineSeparator(), systemOut.getLog()); assertEquals("", systemErr.getLog()); } }); Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/" + "config-classname-prop.xml", "-p", "nonexisting.properties", "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java"); }
From source file:fusion.Fusion.java
private static void getINASameAsLinks(File file) throws FileNotFoundException, IOException, URISyntaxException { try (BufferedReader br = new BufferedReader(new FileReader(file))) { StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { if (line.contains("owl:sameAs")) { sb.append(line);//from ww w. j a v a2 s . com sb.append(System.lineSeparator()); } line = br.readLine(); } String linksString = sb.toString(); String[] linksArray = linksString.split("\n"); for (int i = 0; i < linksArray.length; i++) { String value1 = linksArray[i].substring(0, linksArray[i].indexOf(" owl:sameAs")); String value2 = linksArray[i].substring(linksArray[i].lastIndexOf("owl:sameAs ") + 11, linksArray[i].length() - 1); value1 = StringUtils.removeStart(value1, "<"); value2 = StringUtils.removeStart(value2, "<"); value1 = StringUtils.removeStart(value1, "http://www.ina.fr/thesaurus/pp/"); value2 = StringUtils.removeStart(value2, "http://www.ina.fr/thesaurus/pp/"); value1 = StringUtils.removeStart(value1, "http://fr.dbpedia.org/resource/"); // value2 = StringUtils.removeStart(value2, "http://fr.dbpedia.org/resource/"); // value1 = StringUtils.removeEnd(value1, "."); value2 = StringUtils.removeEnd(value2, "."); value1 = StringUtils.removeEnd(value1, ">"); value2 = StringUtils.removeEnd(value2, ">"); if (!distinctURLs.containsKey(value1.hashCode())) distinctURLs.put(value1.hashCode(), new URI(value1)); if (!distinctURLs.containsKey(value2.hashCode())) distinctURLs.put(value2.hashCode(), new URI(value2)); links.add(new SameAsLink(distinctURLs.get(value1.hashCode()), distinctURLs.get(value2.hashCode()))); // adding same as links } for (Integer name : distinctURLs.keySet()) { Instance instance = new Instance(distinctURLs.get(name), null); if (distinctURLs.get(name).toString().contains("dbpedia")) instance.setSource(sources.get("fr.dbpedia.org")); else instance.setSource(sources.get("www.ina.fr")); instances.put(instance.getUri(), instance); } } }
From source file:org.apache.cassandra.tools.LoaderOptions.java
public static void printUsage(Options options) { String usage = String.format("%s [options] <dir_path>", TOOL_NAME); String header = System.lineSeparator() + "Bulk load the sstables found in the directory <dir_path> to the configured cluster." + "The parent directories of <dir_path> are used as the target keyspace/table name. " + "So for instance, to load an sstable named Standard1-g-1-Data.db into Keyspace1/Standard1, " + "you will need to have the files Standard1-g-1-Data.db and Standard1-g-1-Index.db into a directory /path/to/Keyspace1/Standard1/."; String footer = System.lineSeparator() + "You can provide cassandra.yaml file with -f command line option to set up streaming throughput, client and server encryption options. " + "Only stream_throughput_outbound_megabits_per_sec, server_encryption_options and client_encryption_options are read from yaml. " + "You can override options read from cassandra.yaml with corresponding command line options."; new HelpFormatter().printHelp(usage, header, options, footer); }
From source file:org.jboss.as.test.integration.logging.handlers.SocketHandlerTestCase.java
private static List<JsonObject> executeRequest(final String msg, final Map<String, String> params, final JsonLogServer server, final int expectedMessages) throws IOException, InterruptedException { executeRequest(msg, params);//from w w w . jav a 2 s . c om final List<JsonObject> messages = new ArrayList<>(expectedMessages); for (int i = 0; i < expectedMessages; i++) { final JsonObject foundMessage = server.getLogMessage(DFT_TIMEOUT); if (foundMessage == null) { final String failureMessage = "A log messages was not received within " + DFT_TIMEOUT + " milliseconds." + System.lineSeparator() + "Found the following messages: " + messages; Assert.fail(failureMessage); } messages.add(foundMessage); } return messages; }