use of org.apache.ignite.internal.util.GridStringBuilder in project ignite by apache.
the class ServiceDeploymentOutsideBaselineTest method checkDeployFromEachNodes.
/**
* @param persistence If {@code true}, then persistence will be enabled.
* @param staticDeploy If {@code true}, then static deployment will be used instead of a dynamic one.
* @throws Exception If failed.
*/
private void checkDeployFromEachNodes(boolean persistence, boolean staticDeploy) throws Exception {
this.persistence = persistence;
CountDownLatch exeLatch = new CountDownLatch(1);
DummyService.exeLatch(SERVICE_NAME, exeLatch);
Ignite ignite0 = deployServiceFromNewNode(staticDeploy, 0);
if (!staticDeploy) {
IgniteCluster cluster = ignite0.cluster();
cluster.setBaselineTopology(cluster.topologyVersion());
}
assertTrue(exeLatch.await(10, TimeUnit.SECONDS));
IgniteInternalFuture startFut = GridTestUtils.runAsync(() -> {
try {
deployServiceFromNewNode(staticDeploy);
} catch (Exception e) {
fail(e.getMessage());
}
});
try {
startFut.get(10, TimeUnit.SECONDS);
} catch (IgniteFutureTimeoutCheckedException e) {
GridStringBuilder sb = new SB().a("Node can not start out of baseline till ").a(10_000L).a("ms").a(U.nl());
for (Thread t : Thread.getAllStackTraces().keySet()) if (t.getName().startsWith("async-runnable-runner"))
U.printStackTrace(t.getId(), sb);
fail(sb.toString());
}
}
use of org.apache.ignite.internal.util.GridStringBuilder in project ignite by apache.
the class H2IndexingAbstractGeoSelfTest method createDynamicIndex.
/**
* Create dynamic index.
*
* @param cache Cache.
* @param entity Entity.
* @param idx Index.
* @throws Exception If failed.
*/
private void createDynamicIndex(IgniteCache cache, QueryEntity entity, QueryIndex idx) throws Exception {
boolean spatial = idx.getIndexType() == QueryIndexType.GEOSPATIAL;
GridStringBuilder sb = new SB("CREATE ").a(spatial ? "SPATIAL " : "").a("INDEX ").a("\"" + idx.getName() + "\"").a(" ON ").a(QueryUtils.tableName(entity)).a(" (");
boolean first = true;
for (Map.Entry<String, Boolean> fieldEntry : idx.getFields().entrySet()) {
if (first)
first = false;
else
sb.a(", ");
String name = fieldEntry.getKey();
boolean asc = fieldEntry.getValue();
sb.a("\"" + name + "\"").a(" ").a(asc ? "ASC" : "DESC");
}
sb.a(')');
String sql = sb.toString();
cache.query(new SqlFieldsQuery(sql)).getAll();
}
use of org.apache.ignite.internal.util.GridStringBuilder in project ignite by apache.
the class H2DynamicTableSelfTest method doTestCustomNames.
/**
* Test that appending supplied arguments to {@code CREATE TABLE} results in creating new cache that has settings
* as expected
* @param cacheName Cache name, or {@code null} if the name generated by default should be used.
* @param keyTypeName Key type name, or {@code null} if the name generated by default should be used.
* @param valTypeName Value type name, or {@code null} if the name generated by default should be used.
*/
private void doTestCustomNames(String cacheName, String keyTypeName, String valTypeName) {
GridStringBuilder b = new GridStringBuilder("CREATE TABLE \"NameTest\" (id int primary key, x varchar) WITH " + "wrap_key,wrap_value");
assert !F.isEmpty(cacheName) || !F.isEmpty(keyTypeName) || !F.isEmpty(valTypeName);
if (!F.isEmpty(cacheName))
b.a(",\"cache_name=").a(cacheName).a('"');
if (!F.isEmpty(keyTypeName))
b.a(",\"key_type=").a(keyTypeName).a('"');
if (!F.isEmpty(valTypeName))
b.a(",\"value_type=").a(valTypeName).a('"');
String res = b.toString();
if (res.endsWith(","))
res = res.substring(0, res.length() - 1);
execute(client(), res);
String resCacheName = U.firstNotNull(cacheName, cacheName("NameTest"));
IgniteInternalCache<BinaryObject, BinaryObject> cache = client().cachex(resCacheName);
assertNotNull(cache);
CacheConfiguration ccfg = cache.configuration();
assertEquals(1, ccfg.getQueryEntities().size());
QueryEntity e = (QueryEntity) ccfg.getQueryEntities().iterator().next();
if (!F.isEmpty(keyTypeName))
assertEquals(keyTypeName, e.getKeyType());
else
assertTrue(e.getKeyType().startsWith("SQL_PUBLIC"));
if (!F.isEmpty(valTypeName))
assertEquals(valTypeName, e.getValueType());
else
assertTrue(e.getValueType().startsWith("SQL_PUBLIC"));
execute(client(), "INSERT INTO \"NameTest\" (id, x) values (1, 'a')");
List<List<?>> qres = execute(client(), "SELECT id, x from \"NameTest\"");
assertEqualsCollections(Collections.singletonList(Arrays.asList(1, "a")), qres);
BinaryObject key = client().binary().builder(e.getKeyType()).setField("ID", 1).build();
BinaryObject val = (BinaryObject) client().cache(resCacheName).withKeepBinary().get(key);
BinaryObject exVal = client().binary().builder(e.getValueType()).setField("X", "a").build();
assertEquals(exVal, val);
}
use of org.apache.ignite.internal.util.GridStringBuilder in project ignite by apache.
the class H2Utils method indexColumnsSql.
/**
* Generate String represenation of given indexed columns.
*
* @param idxCols Indexed columns.
* @return String represenation of given indexed columns.
*/
public static String indexColumnsSql(IndexColumn[] idxCols) {
GridStringBuilder sb = new SB();
boolean first = true;
for (IndexColumn col : idxCols) {
if (first)
first = false;
else
sb.a(", ");
sb.a(withQuotes(col.columnName)).a(" ").a(col.sortType == SortOrder.ASCENDING ? "ASC" : "DESC");
}
return sb.toString();
}
use of org.apache.ignite.internal.util.GridStringBuilder in project ignite by apache.
the class H2Utils method indexCreateSql.
/**
* Generate {@code CREATE INDEX} SQL statement for given params.
* @param fullTblName Fully qualified table name.
* @param h2Idx H2 index.
* @param ifNotExists Quietly skip index creation if it exists.
* @return Statement string.
*/
public static String indexCreateSql(String fullTblName, GridH2IndexBase h2Idx, boolean ifNotExists) {
boolean spatial = F.eq(SPATIAL_IDX_CLS, h2Idx.getClass().getName());
GridStringBuilder sb = new SB("CREATE ").a(spatial ? "SPATIAL " : "").a("INDEX ").a(ifNotExists ? "IF NOT EXISTS " : "").a(withQuotes(h2Idx.getName())).a(" ON ").a(fullTblName).a(" (");
sb.a(indexColumnsSql(h2Idx.getIndexColumns()));
sb.a(')');
return sb.toString();
}
Aggregations