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); } } } }
private final void itemDownloaded() { report(getLabel(), () -> concatReportMessage("item processor for item: ", itemId, " from parcel: ", parcelId, " :: itemDownloaded, state ", processingState, " itemState: ", getState()), DatagramAdapter.VerboseLevel.BASE); if(processingState.canContinue()) { synchronized (cache) { cache.put(item, getResult()); } synchronized (mutex) { //save item in disk cache ledger.putItem(record, item, Instant.now().plus(config.getMaxDiskCacheAge())); } if(item instanceof Contract) { if(((Contract)item).isLimitedForTestnet()) { markContractTest((Contract) item); } } if(!processingState.isProcessedToConsensus()) { processingState = ItemProcessingState.DOWNLOADED; } if(isCheckingForce) { checkItem(); } downloadedEvent.fire(); } }
cache.update(itemId, getResult());
notification.getItemId(), null, ip.getResult(), ip.needsVoteFrom(from), notType)
cache.update(itemId, getResult());
notificationType = ParcelNotification.ParcelNotificationType.PAYLOAD; notification = new ParcelNotification(myInfo, itemId, parcelId, getResult(), true, notificationType); List<NodeInfo> nodes = network.allNodes(); for(NodeInfo node : nodes) {
} else if (itemObject instanceof ItemProcessor) { itemResult = ((ItemProcessor) itemObject).getResult(); } else {
/** * Check the state of the item. This method does not start elections and can be safely called from a client. * * @param itemId item to check * * @return last known state */ public @NonNull ItemResult checkItem(HashId itemId) { report(getLabel(), () -> concatReportMessage("check item processor state for item: ", itemId), DatagramAdapter.VerboseLevel.BASE); Object x = checkItemInternal(itemId); //ItemResult ir = (x instanceof ItemResult) ? (ItemResult) x : ((ItemProcessor) x).getResult(); ItemResult ir = ItemResult.UNDEFINED; if (x instanceof ItemResult) ir = (ItemResult)x; else if (x instanceof ItemProcessor) ir = ((ItemProcessor)x).getResult(); else if (x instanceof ResyncProcessor) ir = ((ResyncProcessor)x).getResult(); final ItemResult irFinal = ir; report(getLabel(), () -> concatReportMessage("item state for: ", itemId, "is ", irFinal.state), DatagramAdapter.VerboseLevel.BASE); ItemInformer.Record record = informer.takeFor(itemId); if (record != null) ir.errors = record.errorRecords; ir.isTestnet = ledger.isTestnet(itemId); return ir; }
ItemResult ir = (x instanceof ItemResult) ? (ItemResult) x : ((ItemProcessor) x).getResult(); report(getLabel(), () -> concatReportMessage("item processor for: ", item.getId(), " was created, state is ", ir.state),
/** * If the item is being electing, block until the item been processed with the consensus. Otherwise * returns state immediately. * * @param itemId item to check or wait for * @param millisToWait is time to wait in milliseconds * @return item state * @throws TimeoutException for timeout * @throws InterruptedException for unexpected interrupt */ public ItemResult waitItem(HashId itemId, long millisToWait) throws TimeoutException, InterruptedException { Object x = null; x = checkItemInternal(itemId); if (x instanceof ItemProcessor) { if(!((ItemProcessor) x).isDone()) { ((ItemProcessor) x).doneEvent.await(millisToWait); } return ((ItemProcessor) x).getResult(); } else if (x instanceof ResyncProcessor) { return ((ResyncProcessor) x).getResult(); } return (ItemResult) x; }
private final void broadcastMyState() { report(getLabel(), () -> concatReportMessage("item processor for item: ", itemId, " from parcel: ", parcelId, " :: broadcastMyState, state ", processingState, " itemState: ", getState()), DatagramAdapter.VerboseLevel.BASE); if(processingState.canContinue()) { 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); network.broadcast(myInfo, notification); } }
public ItemResult getPayloadResult() { if(payloadResult != null) return payloadResult; if(payloadProcessor != null) return payloadProcessor.getResult(); return ItemResult.UNDEFINED; }
public ItemResult getPaymentResult() { if(paymentResult != null) return paymentResult; if(paymentProcessor != null) return paymentProcessor.getResult(); return ItemResult.UNDEFINED; }