private void forceRemoveSelf() { processors.remove(itemId); stopDownloader(); stopPoller(); stopConsensusReceivedChecker(); // fire all event to release possible listeners downloadedEvent.fire(); pollingReadyEvent.fire(); doneEvent.fire(); removedEvent.fire(); }
private final void sendStartPollingNotification() { if(processingState.canContinue()) { if (!processingState.isProcessedToConsensus()) { synchronized (mutex) { if (isPollingExpired()) { // cancel by timeout expired processingState = ItemProcessingState.GOT_CONSENSUS; stopPoller(); stopDownloader(); rollbackChanges(ItemState.UNDEFINED); return; } } // at this point we should requery the nodes that did not yet answered us Notification notification; ParcelNotification.ParcelNotificationType notificationType; if(item.shouldBeU()) { notificationType = ParcelNotification.ParcelNotificationType.PAYMENT; } else { notificationType = ParcelNotification.ParcelNotificationType.PAYLOAD; } notification = new ParcelNotification(myInfo, itemId, parcelId, getResult(), true, notificationType); List<NodeInfo> nodes = network.allNodes(); for(NodeInfo node : nodes) { if (!positiveNodes.contains(node) && !negativeNodes.contains(node)) network.deliver(node, notification); } } } }
/** * Emergency break all processes and remove self. */ private void emergencyBreak() { report(getLabel(), () -> concatReportMessage("item processor for item: ", itemId, " from parcel: ", parcelId, " :: emergencyBreak, state ", processingState, " itemState: ", getState()), DatagramAdapter.VerboseLevel.BASE); boolean doRollback = !processingState.isDone(); processingState = ItemProcessingState.EMERGENCY_BREAK; stopDownloader(); stopPoller(); stopConsensusReceivedChecker(); for(ResyncingItem ri : resyncingItems.values()) { if(!ri.isCommitFinished()) { ri.closeByTimeout(); } } if(doRollback) rollbackChanges(stateWas); else close(); processingState = ItemProcessingState.FINISHED; }
private void close() { report(getLabel(), () -> concatReportMessage("item processor for item: ", itemId, " from parcel: ", parcelId, " :: close, state ", processingState, " itemState: ", getState()), DatagramAdapter.VerboseLevel.BASE); if(processingState.canContinue()) processingState = ItemProcessingState.DONE; stopPoller(); // fire all event to release possible listeners downloadedEvent.fire(); pollingReadyEvent.fire(); doneEvent.fire(); if(processingState.canContinue()) { checkIfAllReceivedConsensus(); if (processingState == ItemProcessingState.DONE) { pulseSendNewConsensus(); } else { removeSelf(); } } else { removeSelf(); } }