1

1.ignite如何在集群模式下处理裂脑场景?

2.在putAll的情况下,它是为每个条目命中持久存储还是所有内容都立即存储?

3.如果我们设置批量大小,putAll 如何处理持久存储?

4.如果分区有备份,数据移动的顺序是什么?主要->备份->持久性或主要->备份同时异步进入持久性?

5.如果在持久化存储中进行了更新,必须如何在缓存中反映而不重新加载?(如何处理后端更新)

6.在后端进行更新并反映缓存中的更改,如果我们使用 loadCache 重新加载缓存,缓存中的更改不会更新,或者如果我们直接使用 get() 也不会反映更新。只有在清除缓存一次然后调用 loadcache 或 get api 后才会反映更新。这是重新加载缓存的正确方法吗?

 Person p1 = new Person(1, "Benakaraj", "KS", 11, 26, 1000);
    Person p2 = new Person(2, "Ashwin", "Konale", 13, 26, 10000);
    Connection con = null;
    Statement stmt = null;

    con = ds.getConnection();
    stmt = con.createStatement();
    String sql =
        "create table Person(per_id int,name varchar(20),last_name varchar(20),org_id int,age int,salary REAL,primary key(per_id))";
    stmt.executeUpdate(sql);

    ROCCacheConfiguration<Integer, Person> pesonConfig = new ROCCacheConfiguration<>();
    pesonConfig.setName("bkendupdtCache");
    pesonConfig.setCacheMode(CacheMode.PARTITIONED);
    JdbcType jdbcType = new JdbcType();

    jdbcType.setCacheName("bkendupdtCache");
    jdbcType.setDatabaseSchema("ROC4Test");
    jdbcType.setDatabaseTable("Person");
    jdbcType.setKeyType(Integer.class);
    jdbcType.setValueType(Person.class);
    // Key fields for PERSON.

    Collection<JdbcTypeField> keys = new ArrayList<>();
    keys.add(new JdbcTypeField(Types.INTEGER, "per_id", int.class, "perId"));
    jdbcType.setKeyFields(keys.toArray(new JdbcTypeField[keys.size()]));

    // Value fields for PERSON.
    Collection<JdbcTypeField> vals = new ArrayList<>();
    vals.add(new JdbcTypeField(Types.INTEGER, "per_id", int.class, "perId"));
    vals.add(new JdbcTypeField(Types.VARCHAR, "name", String.class, "name"));
    vals.add(new JdbcTypeField(Types.VARCHAR, "last_name", String.class, "lastName"));
    vals.add(new JdbcTypeField(Types.INTEGER, "org_id", int.class, "orgId"));
    vals.add(new JdbcTypeField(Types.INTEGER, "age", int.class, "age"));
    vals.add(new JdbcTypeField(Types.FLOAT, "salary", Float.class, "salary"));
    jdbcType.setValueFields(vals.toArray(new JdbcTypeField[vals.size()]));

    Collection<JdbcType> jdbcTypes = new ArrayList<>();

    jdbcTypes.add(jdbcType);

    CacheJdbcPojoStoreFactory<Integer, Organization> cacheJdbcdPojoStorefactory4 =
        context.getBean(CacheJdbcPojoStoreFactory.class);
    cacheJdbcdPojoStorefactory4.setTypes(jdbcTypes.toArray(new JdbcType[jdbcTypes.size()]));

    pesonConfig.setCacheStoreFactory((Factory<? extends CacheStore<Integer, Person>>) cacheJdbcdPojoStorefactory4);
    pesonConfig.setReadThrough(true);
    pesonConfig.setWriteThrough(true);
    ROCCache<Integer, Person> personCache2 = rocCachemanager.createCache(pesonConfig);
    personCache2.put(1, p1);
    personCache2.put(2, p2);
    assertEquals(personCache2.get(2).getName(), "Ashwin");
    sql = assertEquals(personCache2.get(2).getName(), "Abhi");

"update Person set name='Abhi' where per_id=2";
        stmt.execute(sql);

        //fails and asks for assertion with the stale value
        personCache.loadcache(null);
        assertEquals(personCache2.get(2).getName(), "Abhi");

        //works fine
        personCache2.clear(2);
        assertEquals(personCache2.get(2).getName(), "Abhi");

        //works fine
        personCache2.clear();
        personCache2.loadcache(null);
        assertEquals(personCache2.get(2).getName(), "Abhi");

        sql = "drop table Person";
        stmt.executeUpdate(sql);
        con.close();
        stmt.close();
        rocCachemanager.destroyCache("bkendupdtCache");
4

1 回答 1

1
  1. 默认情况下,您将获得两个永远不会再相互连接的独立集群(否则可能会出现数据不一致)。您将不得不手动停止其中一个集群并在网络恢复后重新启动。但是,自动解析可以作为插件实现。例如,GridGain 开箱即用地提供此功能:https ://gridgain.readme.io/docs/network-segmentation

  2. Ignites 尝试尽可能减少持久性存储调用。loadAll如果您的存储支持批量读写,那么在实现,writeAllremoveAll方法时利用这一点是个好主意。

  3. 批量更新操作将根据节点映射拆分批次。批处理的每个部分将立即保存在相应的主节点上。

  4. 存储与主节点自动更新(如果写入存储失败,缓存不会更新,反之亦然)。默认情况下,备份在后台异步更新。

  5. 如果可能,您应该避免这种情况,并将 Ignite 视为主数据存储,在后端有一个可选存储(即始终通过 Ignite API 访问数据)。没有简单的方法可以将数据库更新传播到 Ignite。

  6. 您可以使用方法使条目无效clear/clearAll,或使用方法重新加载它们loadAll。另一种选择是使用过期:https ://apacheignite.readme.io/docs/expiry-policies

于 2016-03-18T02:30:25.023 回答