use of org.apache.ignite.internal.util.GridStringBuilder in project ignite by apache.
the class AbstractSchemaSelfTest method dynamicIndexCreate.
/**
* Synchronously create index.
*
* @param node Ignite node.
* @param cacheName Cache name.
* @param tblName Table name.
* @param idx Index.
* @param ifNotExists When set to true operation will fail if index already exists.
* @param parallel Parallelism level.
* @throws Exception If failed.
*/
void dynamicIndexCreate(Ignite node, String cacheName, String tblName, QueryIndex idx, boolean ifNotExists, int parallel) throws Exception {
GridStringBuilder sql = new SB("CREATE INDEX ").a(ifNotExists ? "IF NOT EXISTS " : "").a(idx.getName()).a(" ON ").a(tblName).a(" (");
boolean first = true;
for (Map.Entry<String, Boolean> fieldEntry : idx.getFields().entrySet()) {
if (first)
first = false;
else
sql.a(", ");
String name = fieldEntry.getKey();
boolean asc = fieldEntry.getValue();
sql.a(name).a(" ").a(asc ? "ASC" : "DESC");
}
sql.a(')');
if (idx.getInlineSize() != QueryIndex.DFLT_INLINE_SIZE)
sql.a(" INLINE_SIZE ").a(idx.getInlineSize());
if (parallel != 0)
sql.a(" PARALLEL ").a(parallel);
executeSql(node, cacheName, sql.toString());
}
use of org.apache.ignite.internal.util.GridStringBuilder in project ignite by apache.
the class AbstractSchemaSelfTest method dynamicIndexCreate.
/**
* Synchronously create index.
*
* @param node Ignite node.
* @param cacheName Cache name.
* @param tblName Table name.
* @param idx Index.
* @param ifNotExists When set to true operation will fail if index already exists.
* @throws Exception If failed.
*/
protected void dynamicIndexCreate(Ignite node, String cacheName, String tblName, QueryIndex idx, boolean ifNotExists) throws Exception {
GridStringBuilder sql = new SB("CREATE INDEX ").a(ifNotExists ? "IF NOT EXISTS " : "").a(idx.getName()).a(" ON ").a(tblName).a(" (");
boolean first = true;
for (Map.Entry<String, Boolean> fieldEntry : idx.getFields().entrySet()) {
if (first)
first = false;
else
sql.a(", ");
String name = fieldEntry.getKey();
boolean asc = fieldEntry.getValue();
sql.a(name).a(" ").a(asc ? "ASC" : "DESC");
}
sql.a(')');
executeSql(node, cacheName, sql.toString());
}
use of org.apache.ignite.internal.util.GridStringBuilder in project ignite by apache.
the class CLIArgumentParser method usage.
/**
* Returns usage description.
*
* @return Usage.
*/
public String usage() {
GridStringBuilder sb = new GridStringBuilder("Usage: ");
for (CLIArgument arg : argConfiguration.values()) sb.a(argNameForUsage(arg)).a(" ");
for (CLIArgument arg : argConfiguration.values()) {
Object dfltVal = null;
try {
dfltVal = arg.defaultValueSupplier().apply(this);
} catch (Exception ignored) {
/* No op. */
}
sb.a("\n\n").a(arg.name()).a(": ").a(arg.usage());
if (arg.optional())
sb.a(" Default value: ").a(dfltVal);
}
return sb.toString();
}
use of org.apache.ignite.internal.util.GridStringBuilder in project ignite by apache.
the class PageIO method printPage.
/**
* @param addr Address.
*/
public static String printPage(long addr, int pageSize) {
GridStringBuilder sb = new GridStringBuilder("Header [\n\ttype=");
try {
PageIO io = getPageIO(addr);
sb.a(getType(addr)).a(" (").a(io.getClass().getSimpleName()).a("),\n\tver=").a(getVersion(addr)).a(",\n\tcrc=").a(getCrc(addr)).a(",\n\t").a(PageIdUtils.toDetailString(getPageId(addr))).a("\n],\n");
if (getCompressionType(addr) != 0) {
sb.a("CompressedPage[\n\tcompressionType=").a(getCompressionType(addr)).a(",\n\tcompressedSize=").a(getCompressedSize(addr)).a(",\n\tcompactedSize=").a(getCompactedSize(addr)).a("\n]");
} else
io.printPage(addr, pageSize, sb);
} catch (IgniteCheckedException e) {
sb.a("Failed to print page: ").a(e.getMessage());
}
return sb.toString();
}
use of org.apache.ignite.internal.util.GridStringBuilder in project ignite by apache.
the class GridCachePartitionExchangeManager method longRunningTransactionWarning.
/**
* Builds warning string for long running transaction.
*
* @param tx Transaction.
* @param curTime Current timestamp.
* @return Warning string.
*/
private static String longRunningTransactionWarning(IgniteInternalTx tx, long curTime) {
GridStringBuilder warning = new GridStringBuilder().a(">>> Transaction [startTime=").a(formatTime(tx.startTime())).a(", curTime=").a(formatTime(curTime));
if (tx instanceof GridNearTxLocal) {
GridNearTxLocal nearTxLoc = (GridNearTxLocal) tx;
long sysTimeCurr = nearTxLoc.systemTimeCurrent();
// in some cases totalTimeMillis can be less than systemTimeMillis, as they are calculated with different precision
long userTime = Math.max(curTime - nearTxLoc.startTime() - sysTimeCurr, 0);
warning.a(", systemTime=").a(sysTimeCurr).a(", userTime=").a(userTime);
}
warning.a(", tx=").a(tx).a("]");
return warning.toString();
}
Aggregations