使用MapStore的HazelCast和DB2集成

时间:2018-09-27 17:28:55

标签: hazelcast hazelcast-imap

我试图通过执行存储过程,使用MapStore(和MapLoader)将数据从DB2加载到HazelCast。我能够从DB2检索数据,但是当它尝试将数据加载到HazelCast中时,出现了以下异常

  

java.util.concurrent.ExecutionException:   java.util.concurrent.ExecutionException:   java.lang.IllegalStateException:MapLoader加载的项目属于一个   在不同的分区   com.hazelcast.util.executor.CompletableFutureTask.run(CompletableFutureTask.java:69)     在   com.hazelcast.util.executor.CachedExecutorServiceDelegate $ Worker.run(CachedExecutorServiceDelegate.java:227)     在java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源)     在java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知来源)     在java.lang.Thread.run(未知源)在   com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:64)     在   com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:80)   引起原因:java.util.concurrent.ExecutionException:   java.lang.IllegalStateException:MapLoader加载的项目属于一个   在不同的分区   com.hazelcast.spi.impl.operationservice.impl.InvocationFuture.resolveAndThrowIfException(InvocationFuture.java:92)     在   com.hazelcast.spi.impl.AbstractInvocationFuture.get(AbstractInvocationFuture.java:162)     在   com.hazelcast.map.impl.recordstore.BasicRecordStoreLoader.loadValuesInternal(BasicRecordStoreLoader.java:141)     在   com.hazelcast.map.impl.recordstore.BasicRecordStoreLoader.access $ 100(BasicRecordStoreLoader.java:52)     在   com.hazelcast.map.impl.recordstore.BasicRecordStoreLoader $ GivenKeysLoaderTask.call(BasicRecordStoreLoader.java:109)     在   com.hazelcast.util.executor.CompletableFutureTask.run(CompletableFutureTask.java:67)     ... 6更多原因:java.lang.IllegalStateException:MapLoader   加载的项目属于另一个分区,位于   com.hazelcast.map.impl.recordstore.DefaultRecordStore.isKeyAndValueLoadable(DefaultRecordStore.java:1031)     在   com.hazelcast.map.impl.recordstore.DefaultRecordStore.putFromLoadInternal(DefaultRecordStore.java:987)     在   com.hazelcast.map.impl.recordstore.DefaultRecordStore.putFromLoad(DefaultRecordStore.java:978)     在   com.hazelcast.map.impl.operation.PutFromLoadAllOperation.run(PutFromLoadAllOperation.java:74)     在com.hazelcast.spi.Operation.call(Operation.java:148)处   com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.call(OperationRunnerImpl.java:202)     在   com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:191)     在   com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:120)     在   com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.run(OperationThread.java:100)     来自------(-来源:未知)   com.hazelcast.spi.impl.operationservice.impl.InvocationFuture.resolve(InvocationFuture.java:127)     在   com.hazelcast.spi.impl.operationservice.impl.InvocationFuture.resolveAndThrowIfException(InvocationFuture.java:79)     ...还有11个

如果有人通过执行“存储过程”将HazelCast和DB2与MapStore集成。

谢谢, 拉姆

2 个答案:

答案 0 :(得分:1)

@katteriamma,问题是PutFromLoadAllOperation操作。 loadAll方法的签名为Map<K,V> loadAll(Collection<K> keys)

您的情况是您的loadAll方法返回了不属于调用者分区的额外键/值对。您需要确保仅返回Collection<K> keys的键值映射,仅此而已。无论如何,将为每个分区调用loadAll方法。因此,您需要确保存储过程仅返回给定键的数据,或者需要过滤额外的键值对。

答案 1 :(得分:0)

我遇到了像你一样的问题。在我的情况下,loadAllKeys()返回了一组键,loadAll()方法使用这些键将数据从数据存储区加载到映射中。将数据加载到地图中时,loadAll()方法可操纵原始键。因此,map.keySet()不等于loadAllKeys()。这导致了异常MapLoader loaded an item belongs to a different partition

为解决此问题,我确保map.keySet()的输出等于loadAllKeys()