@Override public boolean cancel() { if (this.done.compareAndSet(false, true)) { return this.future.cancel(false); } return false; }
@Override public void run() { this.store.doneTasks++; try { if (this.done.compareAndSet(false, true)) { this.topicStore.addMessage(context, message); // apply any acks we have synchronized (this.subscriptionKeys) { for (String key : this.subscriptionKeys) { this.topicStore.doAcknowledge(context, key, this.message.getMessageId(), null); } } removeTopicTask(this.topicStore, this.message.getMessageId()); this.future.complete(); } else if (cancelledTaskModMetric > 0 && this.store.canceledTasks++ % cancelledTaskModMetric == 0) { System.err.println(this.store.dest.getName() + " cancelled: " + (this.store.canceledTasks / this.store.doneTasks) * 100); this.store.canceledTasks = this.store.doneTasks = 0; } } catch (Throwable t) { this.future.setException(t); removeTopicTask(this.topicStore, this.message.getMessageId()); } } }
if (ack.isInTransaction() || !task.cancel()) { try { task.future.get(); } catch (InterruptedException e) { throw new InterruptedIOException(e.toString());
if (ack.isInTransaction() || !task.cancel()) { try { task.future.get(); } catch (InterruptedException e) { throw new InterruptedIOException(e.toString());
if (ack.isInTransaction() || !task.cancel()) { try { task.future.get(); } catch (InterruptedException e) { throw new InterruptedIOException(e.toString());
if (ack.isInTransaction() || !task.cancel()) { try { task.future.get(); } catch (InterruptedException e) { throw new InterruptedIOException(e.toString());
@Override public void removeAsyncMessage(ConnectionContext context, MessageAck ack) throws IOException { if (isConcurrentStoreAndDispatchQueues()) { AsyncJobKey key = new AsyncJobKey(ack.getLastMessageId(), getDestination()); StoreQueueTask task = null; synchronized (asyncTaskMap) { task = (StoreQueueTask) asyncTaskMap.get(key); } if (task != null) { if (!task.cancel()) { try { task.future.get(); } catch (InterruptedException e) { throw new InterruptedIOException(e.toString()); } catch (Exception ignored) { LOG.debug("removeAsync: cannot cancel, waiting for add resulted in ex", ignored); } removeMessage(context, ack); } else { synchronized (asyncTaskMap) { asyncTaskMap.remove(key); } } } else { removeMessage(context, ack); } } else { removeMessage(context, ack); } }
@Override public void run() { this.store.doneTasks++; try { if (this.done.compareAndSet(false, true)) { this.topicStore.addMessage(context, message); // apply any acks we have synchronized (this.subscriptionKeys) { for (String key : this.subscriptionKeys) { this.topicStore.doAcknowledge(context, key, this.message.getMessageId(), null); } } removeTopicTask(this.topicStore, this.message.getMessageId()); this.future.complete(); } else if (cancelledTaskModMetric > 0 && this.store.canceledTasks++ % cancelledTaskModMetric == 0) { System.err.println(this.store.dest.getName() + " cancelled: " + (this.store.canceledTasks / this.store.doneTasks) * 100); this.store.canceledTasks = this.store.doneTasks = 0; } } catch (Exception e) { this.future.setException(e); } finally { releaseLocks(); } } }
@Override public void run() { this.store.doneTasks++; try { if (this.done.compareAndSet(false, true)) { this.topicStore.addMessage(context, message); // apply any acks we have synchronized (this.subscriptionKeys) { for (String key : this.subscriptionKeys) { this.topicStore.doAcknowledge(context, key, this.message.getMessageId(), null); } } removeTopicTask(this.topicStore, this.message.getMessageId()); this.future.complete(); } else if (cancelledTaskModMetric > 0 && this.store.canceledTasks++ % cancelledTaskModMetric == 0) { System.err.println(this.store.dest.getName() + " cancelled: " + (this.store.canceledTasks / this.store.doneTasks) * 100); this.store.canceledTasks = this.store.doneTasks = 0; } } catch (Throwable t) { this.future.setException(t); removeTopicTask(this.topicStore, this.message.getMessageId()); } } }
@Override public void run() { this.store.doneTasks++; try { if (this.done.compareAndSet(false, true)) { this.topicStore.addMessage(context, message); // apply any acks we have synchronized (this.subscriptionKeys) { for (String key : this.subscriptionKeys) { this.topicStore.doAcknowledge(context, key, this.message.getMessageId(), null); } } removeTopicTask(this.topicStore, this.message.getMessageId()); this.future.complete(); } else if (cancelledTaskModMetric > 0 && this.store.canceledTasks++ % cancelledTaskModMetric == 0) { System.err.println(this.store.dest.getName() + " cancelled: " + (this.store.canceledTasks / this.store.doneTasks) * 100); this.store.canceledTasks = this.store.doneTasks = 0; } } catch (Throwable t) { this.future.setException(t); removeTopicTask(this.topicStore, this.message.getMessageId()); } } }
@Override public void run() { this.store.doneTasks++; try { if (this.done.compareAndSet(false, true)) { this.topicStore.addMessage(context, message); // apply any acks we have synchronized (this.subscriptionKeys) { for (String key : this.subscriptionKeys) { this.topicStore.doAcknowledge(context, key, this.message.getMessageId(), null); } } removeTopicTask(this.topicStore, this.message.getMessageId()); this.future.complete(); } else if (cancelledTaskModMetric > 0 && this.store.canceledTasks++ % cancelledTaskModMetric == 0) { System.err.println(this.store.dest.getName() + " cancelled: " + (this.store.canceledTasks / this.store.doneTasks) * 100); this.store.canceledTasks = this.store.doneTasks = 0; } } catch (Throwable t) { this.future.setException(t); removeTopicTask(this.topicStore, this.message.getMessageId()); } } }
@Override public void run() { this.store.doneTasks++; try { if (this.done.compareAndSet(false, true)) { this.store.addMessage(context, message); removeQueueTask(this.store, this.message.getMessageId()); this.future.complete(); } else if (cancelledTaskModMetric > 0 && (++this.store.canceledTasks) % cancelledTaskModMetric == 0) { System.err.println(this.store.dest.getName() + " cancelled: " + (this.store.canceledTasks / this.store.doneTasks) * 100); this.store.canceledTasks = this.store.doneTasks = 0; } } catch (Throwable t) { this.future.setException(t); removeQueueTask(this.store, this.message.getMessageId()); } }
public void run() { this.store.doneTasks++; try { if (this.done.compareAndSet(false, true)) { this.store.addMessage(context, message); removeQueueTask(this.store, this.message.getMessageId()); this.future.complete(); } else if (cancelledTaskModMetric > 0 && this.store.canceledTasks++ % cancelledTaskModMetric == 0) { System.err.println(this.store.dest.getName() + " cancelled: " + (this.store.canceledTasks / this.store.doneTasks) * 100); this.store.canceledTasks = this.store.doneTasks = 0; } } catch (Exception e) { this.future.setException(e); } finally { releaseLocks(); } }
@Override public void run() { this.store.doneTasks++; try { if (this.done.compareAndSet(false, true)) { this.store.addMessage(context, message); removeQueueTask(this.store, this.message.getMessageId()); this.future.complete(); } else if (cancelledTaskModMetric > 0 && (++this.store.canceledTasks) % cancelledTaskModMetric == 0) { System.err.println(this.store.dest.getName() + " cancelled: " + (this.store.canceledTasks / this.store.doneTasks) * 100); this.store.canceledTasks = this.store.doneTasks = 0; } } catch (Throwable t) { this.future.setException(t); removeQueueTask(this.store, this.message.getMessageId()); } }
@Override public void run() { this.store.doneTasks++; try { if (this.done.compareAndSet(false, true)) { this.store.addMessage(context, message); removeQueueTask(this.store, this.message.getMessageId()); this.future.complete(); } else if (cancelledTaskModMetric > 0 && (++this.store.canceledTasks) % cancelledTaskModMetric == 0) { System.err.println(this.store.dest.getName() + " cancelled: " + (this.store.canceledTasks / this.store.doneTasks) * 100); this.store.canceledTasks = this.store.doneTasks = 0; } } catch (Throwable t) { this.future.setException(t); removeQueueTask(this.store, this.message.getMessageId()); } }
public boolean cancel() { releaseLocks(); if (this.done.compareAndSet(false, true)) { return this.future.cancel(false); } return false; }
public StoreQueueTask(KahaDBMessageStore store, ConnectionContext context, Message message) { this.store = store; this.context = context; this.message = message; this.future = new InnerFutureTask(this); }
@Override public void done() { fireListener(); }
@Override public void done() { fireListener(); }
@Override public void addListener(Runnable listener) { this.listenerRef.set(listener); if (isDone()) { fireListener(); } }