- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我从 Apache Ignite 开始,我正在关注 Apache 网站上的 Ignite 教程。我在下面遇到异常。看来我造成了两个不同的数据集,我无法同步它们或选择一个而不是另一个。
当我首先从命令行启动 Ignite 然后在类方法更新它之前编码时会发生这种情况。然后测试代码启动新节点。我假设它们会同步。
代码:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.Iterator;
import java.util.List;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteException;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.query.FieldsQueryCursor;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.junit.BeforeClass;
import org.junit.Test;
public class IgniteTest
{
@BeforeClass
public static void beforeClass() throws Exception
{
// Register JDBC driver.
Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
// Open JDBC connection.
Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1/");
// Create database tables.
try (Statement stmt = conn.createStatement()) {
// Drop existing tables
stmt.execute("DROP TABLE IF EXISTS Person");
stmt.execute("DROP TABLE IF EXISTS City");
// Create table based on REPLICATED template.
stmt.executeUpdate("CREATE TABLE City (" +
" id LONG PRIMARY KEY, name VARCHAR) " +
" WITH \"template=replicated\"");
// Create table based on PARTITIONED template with one backup.
stmt.executeUpdate("CREATE TABLE Person (" +
" id LONG, name VARCHAR, city_id LONG, " +
" PRIMARY KEY (id, city_id)) " +
" WITH \"backups=1, affinityKey=city_id\"");
// Create an index on the City table.
stmt.executeUpdate("CREATE INDEX idx_city_name ON City (name)");
// Create an index on the Person table.
stmt.executeUpdate("CREATE INDEX idx_person_name ON Person (name)");
}
}
@Test
public void test_01_HelloWorld() throws Exception
{
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml"))
{
// Put values in cache.
IgniteCache<Integer, String> cache = ignite.getOrCreateCache("myCache");
cache.put(1, "Hello");
cache.put(2, "World!");
// Get values from cache
// Broadcast 'Hello World' on all the nodes in the cluster.
ignite.compute().broadcast(() -> System.out.println(cache.get(1) + " " + cache.get(2)));
}
}
@Test
public void test_ignite() throws Exception
{
// Connecting to the cluster.
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml"))
{
// Getting a reference to an underlying cache created for City table above.
IgniteCache<Long, City> cityCache = ignite.cache("SQL_PUBLIC_CITY");
// Getting a reference to an underlying cache created for Person table above.
IgniteCache<PersonKey, Person> personCache = ignite.cache("SQL_PUBLIC_PERSON");
// Inserting entries into City.
SqlFieldsQuery query = new SqlFieldsQuery(
"INSERT INTO City (id, name) VALUES (?, ?)");
cityCache.query(query.setArgs(1, "Forest Hill")).getAll();
cityCache.query(query.setArgs(2, "Denver")).getAll();
cityCache.query(query.setArgs(3, "St. Petersburg")).getAll();
// Inserting entries into Person.
query = new SqlFieldsQuery(
"INSERT INTO Person (id, name, city_id) VALUES (?, ?, ?)");
personCache.query(query.setArgs(1, "John Doe", 3)).getAll();
personCache.query(query.setArgs(2, "Jane Roe", 2)).getAll();
personCache.query(query.setArgs(3, "Mary Major", 1)).getAll();
personCache.query(query.setArgs(4, "Richard Miles", 2)).getAll();
// next example
// Querying data from the cluster using a distributed JOIN.
SqlFieldsQuery query2 = new SqlFieldsQuery("SELECT p.name, c.name " +
" FROM Person p, City c WHERE p.city_id = c.id");
FieldsQueryCursor<List<?>> cursor = cityCache.query(query2);
Iterator<List<?>> iterator = cursor.iterator();
while (iterator.hasNext()) {
List<?> row = iterator.next();
System.out.println(row.get(0) + ", " + row.get(1));
}
}
}
public static void main(String[] args) throws IgniteException
{
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml"))
{
// Put values in cache.
IgniteCache<Integer, String> cache = ignite.getOrCreateCache("myCache");
cache.put(1, "Hello");
cache.put(2, "World!");
// Get values from cache
// Broadcast 'Hello World' on all the nodes in the cluster.
ignite.compute().broadcast(() -> System.out.println(cache.get(1) + " " + cache.get(2)));
}
}
}
class City
{
private long id;
private String name;
}
class Person
{
private long id;
private String name;
private long city_id;
}
class PersonKey
{
}
异常(exception):
javax.cache.CacheException: Caches have distinct sets of data nodes [cache1=SQL_PUBLIC_CITY, cache2=SQL_PUBLIC_PERSON]
at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.stableDataNodes(GridReduceQueryExecutor.java:499)
at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.nodesForPartitions(GridReduceQueryExecutor.java:1486)
at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.query(GridReduceQueryExecutor.java:591)
at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing$8.iterator(IgniteH2Indexing.java:1339)
at org.apache.ignite.internal.processors.cache.QueryCursorImpl.iterator(QueryCursorImpl.java:95)
at org.lhasalimited.ecosystem.business.statestore.ignite.impl.IgniteTest.test_ignite(IgniteTest.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
*emphasized text* at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
最佳答案
我确实遇到了这个错误并通过添加修复了它
Ignition.setClientMode(true);
在调用 Ignition.start();
之前
关于java - Apache Ignite 异常 : Caches have distinct sets of data nodes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49300556/
我有一个包含电子邮件、IP、州、城市、时间戳、ID 列的表 我需要按州分组计算电子邮件和 IP 的不同位置 所以当我运行 MYSQL 查询时, select State, City ,count(di
我试过 select distinct ID from DB.TABLE; 它返回所有记录中的唯一 ID。 select distinct * from DB.TABLE; 它将通过比较所有列
我正在尝试在 Postgresql 中编写一个查询,该查询提取一组有序数据并按不同的字段对其进行过滤。我还需要从同一表行中提取其他几个字段,但需要将它们排除在不同的评估之外。示例: SELECT
我有一个使用以下语句创建的 Postgres 表。该表由另一个服务的数据转储填充。 CREATE TABLE data_table ( date date DEFAULT NULL,
我在一个名为 products 的表中有 4 列 id|p_name| p_img | 1 | Xs | xsmax.png | 2 | Xs | xr.png |
当它的状态仅为"is"时,我想从“num”中选择不同的值,而不是立即包括“否”? 表: +--------+-----+--------+ | id | num | status | +---
全部!今天我有一个棘手的问题要给你,我想使用 select DISTINCT 语句来选择一个需要不同的行,但也在同一个语句中(或者我尝试过的方式?)一个没有的行't/不能区分。我想要的结果是每个类名中
我有一个正在使用 Distinct() 的 linq 查询。如果我只是调用 Distinct() 而没有转换为列表,那么它不会返回不同的列表 - 它仍然包含重复项。 但是,如果我转换为 List 并然
说到性能,我应该使用 .ToList().Distinct() 还是 .Distinct().ToList() ? 两种扩展方法是否生成相同的 SQL 查询? 看起来第二种方法应该表现更好,但这是真的
如何在不支持 SQL Server 2008R2 的 SQL 实现中重写包含标准 IS DISTINCT FROM 和 IS NOT DISTINCT FROM 运算符的表达式? 最佳答案 IS DI
有一张 table (在 HIVE) 示例 - meanalytics.key2_master_ids 该表有 6 列(cmpgn_id、offr_id、exec_id、creatv_id、cmpl_
SELECT * FROM `amc_info` WHERE department =' ( SELECT DISTINCT department ) into outfile = 'Differe
如何在Elasticsearch中计算“不同的平均值”?我有一些这样的非规范化数据: { "record_id" : "100", "cost" : 42 } { "record_id" : "200
关注这个question我有... ID SKU PRODUCT ======================= 1 FOO-23 Orange 2 BAR
我有这个 mysql 查询: SELECT DISTINCT post.postId,hash,previewUrl,lastRetrieved FROM post INNER JOIN (tag a
http://sqlfiddle.com/#!2/37dd94/17 如果我执行 SELECT DISTINCT,我得到的结果与只执行 SELECT 的结果相同。 在查询结果中,您将看到两个包含 Di
我有一列包含空条目,例如此列中的可能值为 None, 1, 2, 3 当我使用 session.query(func.count(distinct(Entry.col))).scalar() 计算列中
这是否可能从表列中选择不同的行并计算单个查询中每个不同字段的重复行 $sql = "SELECT DISTINCT location and COUNT(DISTINCT location)
我在 MySQL 数据库中有一个包含 1100 万行的表。其中一列是个人身份证号码。人们在表中被多次列出,我想知道有多少个唯一的个人 ID 号码。然后创建一个包含这些唯一数字的表格。当我计算列中不同的
我刚刚注意到我的 Informix SQL 列(在同一个表中)的某些 上有些奇怪。当我执行此查询时 SELECT DISTINCT colName FROM myTable 例如,我得到 40 行。但
我是一名优秀的程序员,十分优秀!