use of org.h2.util.Cache in project ignite by apache.
the class GridReduceQueryExecutor method stableDataNodes.
/**
* @param isReplicatedOnly If we must only have replicated caches.
* @param topVer Topology version.
* @param cacheIds Participating cache IDs.
* @param parts Partitions.
* @return Data nodes or {@code null} if repartitioning started and we need to retry.
*/
private Map<ClusterNode, IntArray> stableDataNodes(boolean isReplicatedOnly, AffinityTopologyVersion topVer, List<Integer> cacheIds, int[] parts) {
GridCacheContext<?, ?> cctx = cacheContext(cacheIds.get(0));
Map<ClusterNode, IntArray> map = stableDataNodesMap(topVer, cctx, parts);
Set<ClusterNode> nodes = map.keySet();
if (F.isEmpty(map))
throw new CacheException("Failed to find data nodes for cache: " + cctx.name());
for (int i = 1; i < cacheIds.size(); i++) {
GridCacheContext<?, ?> extraCctx = cacheContext(cacheIds.get(i));
String extraCacheName = extraCctx.name();
if (extraCctx.isLocal())
// No consistency guaranties for local caches.
continue;
if (isReplicatedOnly && !extraCctx.isReplicated())
throw new CacheException("Queries running on replicated cache should not contain JOINs " + "with partitioned tables [replicatedCache=" + cctx.name() + ", partitionedCache=" + extraCacheName + "]");
Set<ClusterNode> extraNodes = stableDataNodesMap(topVer, extraCctx, parts).keySet();
if (F.isEmpty(extraNodes))
throw new CacheException("Failed to find data nodes for cache: " + extraCacheName);
boolean disjoint;
if (extraCctx.isReplicated()) {
if (isReplicatedOnly) {
nodes.retainAll(extraNodes);
disjoint = map.isEmpty();
} else
disjoint = !extraNodes.containsAll(nodes);
} else
disjoint = !extraNodes.equals(nodes);
if (disjoint) {
if (isPreloadingActive(cacheIds))
// Retry.
return null;
else
throw new CacheException("Caches have distinct sets of data nodes [cache1=" + cctx.name() + ", cache2=" + extraCacheName + "]");
}
}
return map;
}
use of org.h2.util.Cache in project ignite by apache.
the class H2DynamicTableSelfTest method testCacheSelfDrop.
/**
* Test that attempting to execute {@code DROP TABLE} via API of cache being dropped yields an error.
* @throws Exception if failed.
*/
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public void testCacheSelfDrop() throws Exception {
execute("CREATE TABLE IF NOT EXISTS \"Person\" (\"id\" int, \"city\" varchar," + " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\")) WITH " + "\"template=cache\"");
GridTestUtils.assertThrows(null, new Callable<Object>() {
@Override
public Object call() throws Exception {
client().cache(QueryUtils.createTableCacheName(QueryUtils.DFLT_SCHEMA, "Person")).query(new SqlFieldsQuery("DROP TABLE \"Person\"")).getAll();
return null;
}
}, IgniteSQLException.class, "DROP TABLE cannot be called from the same cache that holds the table " + "being dropped");
execute("DROP TABLE \"Person\"");
}
use of org.h2.util.Cache in project ignite by apache.
the class H2DynamicTableSelfTest method testDataRegion.
/**
* Test data region.
*
* @throws Exception If failed.
*/
@SuppressWarnings({ "ThrowableNotThrown", "unchecked" })
public void testDataRegion() throws Exception {
// Empty region name.
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override
public Void call() throws Exception {
execute("CREATE TABLE TEST_DATA_REGION (name varchar primary key, code int) WITH \"data_region=\"");
return null;
}
}, IgniteSQLException.class, "Parameter value cannot be empty: DATA_REGION");
// Valid region name.
execute("CREATE TABLE TEST_DATA_REGION (name varchar primary key, code int) WITH \"data_region=" + DATA_REGION_NAME + "\"");
CacheConfiguration ccfg = client().cache("SQL_PUBLIC_TEST_DATA_REGION").getConfiguration(CacheConfiguration.class);
assertEquals(DATA_REGION_NAME, ccfg.getDataRegionName());
}
use of org.h2.util.Cache in project h2database by h2database.
the class Parser method parseAlterSequence.
private AlterSequence parseAlterSequence() {
boolean ifExists = readIfExists(false);
String sequenceName = readIdentifierWithSchema();
AlterSequence command = new AlterSequence(session, getSchema());
command.setSequenceName(sequenceName);
command.setIfExists(ifExists);
while (true) {
if (readIf("RESTART")) {
read("WITH");
command.setStartWith(readExpression());
} else if (readIf("INCREMENT")) {
read("BY");
command.setIncrement(readExpression());
} else if (readIf("MINVALUE")) {
command.setMinValue(readExpression());
} else if (readIf("NOMINVALUE")) {
command.setMinValue(null);
} else if (readIf("MAXVALUE")) {
command.setMaxValue(readExpression());
} else if (readIf("NOMAXVALUE")) {
command.setMaxValue(null);
} else if (readIf("CYCLE")) {
command.setCycle(true);
} else if (readIf("NOCYCLE")) {
command.setCycle(false);
} else if (readIf("NO")) {
if (readIf("MINVALUE")) {
command.setMinValue(null);
} else if (readIf("MAXVALUE")) {
command.setMaxValue(null);
} else if (readIf("CYCLE")) {
command.setCycle(false);
} else if (readIf("CACHE")) {
command.setCacheSize(ValueExpression.get(ValueLong.get(1)));
} else {
break;
}
} else if (readIf("CACHE")) {
command.setCacheSize(readExpression());
} else if (readIf("NOCACHE")) {
command.setCacheSize(ValueExpression.get(ValueLong.get(1)));
} else {
break;
}
}
return command;
}
use of org.h2.util.Cache in project h2database by h2database.
the class Parser method parseCreateSequence.
private CreateSequence parseCreateSequence() {
boolean ifNotExists = readIfNotExists();
String sequenceName = readIdentifierWithSchema();
CreateSequence command = new CreateSequence(session, getSchema());
command.setIfNotExists(ifNotExists);
command.setSequenceName(sequenceName);
while (true) {
if (readIf("START")) {
readIf("WITH");
command.setStartWith(readExpression());
} else if (readIf("INCREMENT")) {
readIf("BY");
command.setIncrement(readExpression());
} else if (readIf("MINVALUE")) {
command.setMinValue(readExpression());
} else if (readIf("NOMINVALUE")) {
command.setMinValue(null);
} else if (readIf("MAXVALUE")) {
command.setMaxValue(readExpression());
} else if (readIf("NOMAXVALUE")) {
command.setMaxValue(null);
} else if (readIf("CYCLE")) {
command.setCycle(true);
} else if (readIf("NOCYCLE")) {
command.setCycle(false);
} else if (readIf("NO")) {
if (readIf("MINVALUE")) {
command.setMinValue(null);
} else if (readIf("MAXVALUE")) {
command.setMaxValue(null);
} else if (readIf("CYCLE")) {
command.setCycle(false);
} else if (readIf("CACHE")) {
command.setCacheSize(ValueExpression.get(ValueLong.get(1)));
} else {
break;
}
} else if (readIf("CACHE")) {
command.setCacheSize(readExpression());
} else if (readIf("NOCACHE")) {
command.setCacheSize(ValueExpression.get(ValueLong.get(1)));
} else if (readIf("BELONGS_TO_TABLE")) {
command.setBelongsToTable(true);
} else if (readIf("ORDER")) {
// Oracle compatibility
} else {
break;
}
}
return command;
}
Aggregations