Search in sources :

Example 16 with GridStringBuilder

use of org.apache.ignite.internal.util.GridStringBuilder in project ignite by apache.

the class TransactionMetricsAdapter method composeNodeInfo.

/**
 * @param ids Ids.
 */
private String composeNodeInfo(final Set<UUID> ids) {
    final GridStringBuilder sb = new GridStringBuilder();
    sb.a("[");
    String delim = "";
    for (UUID id : ids) {
        sb.a(delim).a(composeNodeInfo(id));
        delim = ", ";
    }
    sb.a("]");
    return sb.toString();
}
Also used : GridStringBuilder(org.apache.ignite.internal.util.GridStringBuilder) UUID(java.util.UUID)

Example 17 with GridStringBuilder

use of org.apache.ignite.internal.util.GridStringBuilder in project ignite by apache.

the class MavenUtils method downloadArtifact.

/**
 * Downloads and stores in local repository an artifact with given identifier.
 *
 * @param artifact Artifact identifier, must match pattern [groupId:artifactId:version].
 * @throws Exception In case of an error.
 */
private static void downloadArtifact(String artifact) throws Exception {
    X.println("Downloading artifact... Identifier: " + artifact);
    // Default platform independ path for maven settings file.
    Path localProxyMavenSettings = Paths.get(System.getProperty("user.home"), ".m2", "local-proxy.xml");
    String localProxyMavenSettingsFromEnv = System.getenv("LOCAL_PROXY_MAVEN_SETTINGS");
    GridStringBuilder mavenCommandArgs = new SB(" ").a(MAVEN_DEPENDENCY_PLUGIN).a(":get -Dartifact=" + artifact);
    if (!isEmpty(localProxyMavenSettingsFromEnv))
        localProxyMavenSettings = Paths.get(localProxyMavenSettingsFromEnv);
    if (Files.exists(localProxyMavenSettings))
        mavenCommandArgs.a(" -s " + localProxyMavenSettings.toString());
    else {
        Collection<String> repos = new ArrayList<>();
        if (useGgRepo)
            repos.add(GG_MVN_REPO);
        repos.addAll(mavenProjectRepositories());
        if (!repos.isEmpty())
            mavenCommandArgs.a(" -DremoteRepositories=").a(String.join(",", repos));
    }
    exec(buildMvnCommand() + mavenCommandArgs.toString());
    X.println("Download is finished");
}
Also used : Path(java.nio.file.Path) GridStringBuilder(org.apache.ignite.internal.util.GridStringBuilder) ArrayList(java.util.ArrayList) SB(org.apache.ignite.internal.util.typedef.internal.SB)

Example 18 with GridStringBuilder

use of org.apache.ignite.internal.util.GridStringBuilder in project ignite by apache.

the class GridNearTxLocal method completedTransactionDump.

/**
 * Builds dump string for completed transaction.
 *
 * @param state Transaction state.
 * @param systemTimeMillis System time in milliseconds.
 * @param userTimeMillis User time in milliseconds.
 * @param isLong Whether the dumped transaction is long running or not.
 * @return Dump string.
 */
private String completedTransactionDump(TransactionState state, long systemTimeMillis, long userTimeMillis, boolean isLong) {
    long cacheOperationsTimeMillis = U.nanosToMillis(systemTime.get() - prepareTime.get() - commitOrRollbackTime.get());
    GridStringBuilder warning = new GridStringBuilder(isLong ? "Long transaction time dump " : "Transaction time dump ").a("[startTime=").a(IgniteUtils.DEBUG_DATE_FMT.format(Instant.ofEpochMilli(startTime))).a(", totalTime=").a(systemTimeMillis + userTimeMillis).a(", systemTime=").a(systemTimeMillis).a(", userTime=").a(userTimeMillis).a(", cacheOperationsTime=").a(cacheOperationsTimeMillis);
    if (state == COMMITTED) {
        warning.a(", prepareTime=").a(timeMillis(prepareTime)).a(", commitTime=").a(timeMillis(commitOrRollbackTime));
    } else {
        warning.a(", rollbackTime=").a(timeMillis(commitOrRollbackTime));
    }
    warning.a(", tx=").a(this).a("]");
    return warning.toString();
}
Also used : GridStringBuilder(org.apache.ignite.internal.util.GridStringBuilder)

Example 19 with GridStringBuilder

use of org.apache.ignite.internal.util.GridStringBuilder in project ignite by apache.

the class IgniteIndexReaderTest method updateQuery.

/**
 * Performs an update query.
 *
 * @param cache Ignite cache.
 * @param tblName Table name.
 * @param fields List of fields.
 * @param cntr Counter which is used to generate data.
 */
private static void updateQuery(IgniteCache cache, String tblName, List<IgnitePair<String>> fields, int cntr) {
    GridStringBuilder q = new GridStringBuilder().a("update ").a(tblName).a(" set ").a(fields.stream().map(IgniteBiTuple::get1).collect(joining("=?, ", "", "=?"))).a(" where id=?");
    Object[] paramVals = new Object[fields.size() + 1];
    for (int i = 0; i < fields.size() + 1; i++) paramVals[i] = (i % 2 == 0) ? cntr : valueOf(cntr);
    Object id = paramVals[0];
    paramVals[0] = paramVals[paramVals.length - 1];
    paramVals[paramVals.length - 1] = id;
    query(cache, q.toString(), paramVals);
}
Also used : GridStringBuilder(org.apache.ignite.internal.util.GridStringBuilder)

Aggregations

GridStringBuilder (org.apache.ignite.internal.util.GridStringBuilder)19 SB (org.apache.ignite.internal.util.typedef.internal.SB)8 Map (java.util.Map)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 IgniteException (org.apache.ignite.IgniteException)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 UUID (java.util.UUID)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Ignite (org.apache.ignite.Ignite)1 IgniteCluster (org.apache.ignite.IgniteCluster)1 BinaryObject (org.apache.ignite.binary.BinaryObject)1 QueryEntity (org.apache.ignite.cache.QueryEntity)1 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)1