@Override
public Boolean call() throws Exception {
try {
int count = 0;
Store randomPartitonStore =
OrderedLocalMessageStorageManager.this.getOrCreateStore(topic, Partition.RandomPartiton);
// ���ָܻ��ĸ����������Ȼָ�һ��δ֪����������(ԭ����,����������ݵIJ���ʱ���������ھ������)
// ������ͬһ��topic��δ֪�������лָ�������ᵼ�������ظ�����
if (randomPartitonStore.size() > 0) {
// ������ʱ�Ŷ�randomPartitonStoreͬ������
synchronized (randomPartitonStore) {
// ˫�ؼ��
if (randomPartitonStore.size() > 0) {
count = this.innerRecover(randomPartitonStore, recoverer);
log.info("SendRecover topic=" + topic + "@-1--1�ָ���Ϣ" + count + "��");
}
}
}
Store store = OrderedLocalMessageStorageManager.this.getOrCreateStore(topic, partition);
count = this.innerRecover(store, recoverer);
log.info("SendRecover topic=" + name + "�ָ���Ϣ" + count + "��");
}
catch (Throwable e) {
log.error("SendRecover������Ϣ�ָ�ʧ��,topic=" + name, e);
}
finally {
log.info("SendRecoverִ������Ƴ����ͻָ�����,topic=" + name);
OrderedLocalMessageStorageManager.this.topicRecoverTaskMap.remove(name);
}
return true;
}
private int innerRecover(Store store, final MessageRecoverer recoverer) throws IOException, Exception {
Iterator<byte[]> it = store.iterator();
int count = 0;
while (it.hasNext()) {
byte[] key = it.next();
Message msg =
(Message) OrderedLocalMessageStorageManager.this.deserializer.decodeObject(store.get(key));
recoverer.handle(msg);
try {
store.remove(key);
count++;
}
catch (IOException e) {
log.error("SendRecover remove message failed", e);
}