Called after agent has switched a shard. Alert poster needs an update
        in this case, bacause otherwise its posting to lobby instead of the
        shard exchange.
771500
def _fix_alert_poster(self, state, shard):
        '''
        
        '''
        recp = recipient.Broadcast(AlertPoster.protocol_id, shard)
        state.alerter.update_recipients(recp)
512755
def _update_descriptor(self, state, allocation):
        ''''''
        if state.descriptor.shard is None or state.descriptor.shard == 'lobby':
            own_shard = state.agent.get_shard_id()
            state.descriptor.shard = own_shard
        state.descriptor.resources = allocation.alloc
        f = fiber.succeed(state.descriptor)
        f.add_callback(state.agent.save_document)
        f.add_callback(self._store_descriptor)
        return f
1363656
def _do_failover_or_switchover(obj, action, cluster_name, master, candidate, force, scheduled=None):
    

    dcs = get_dcs(obj, cluster_name)
    cluster = dcs.get_cluster()

    if action == 'switchover' and cluster.leader is None:
        raise PatroniCtlException('This cluster has no master')

    if master is None:
        if force or action == 'failover':
            master = cluster.leader and cluster.leader.name
        else:
            master = click.prompt('Master', type=str, default=cluster.leader.member.name)

    if master is not None and cluster.leader and cluster.leader.member.name != master:
        raise PatroniCtlException('Member {0} is not the leader of cluster {1}'.format(master, cluster_name))

    # excluding members with nofailover tag
    candidate_names = [str(m.name) for m in cluster.members if m.name != master and not m.nofailover]
    # We sort the names for consistent output to the client
    candidate_names.sort()

    if not candidate_names:
        raise PatroniCtlException('No candidates found to {0} to'.format(action))

    if candidate is None and not force:
        candidate = click.prompt('Candidate ' + str(candidate_names), type=str, default='')

    if action == 'failover' and not candidate:
        raise PatroniCtlException('Failover could be performed only to a specific candidate')

    if candidate == master:
        raise PatroniCtlException(action.title() + ' target and source are the same.')

    if candidate and candidate not in candidate_names:
        raise PatroniCtlException('Member {0} does not exist in cluster {1}'.format(candidate, cluster_name))

    scheduled_at_str = None
    scheduled_at = None

    if action == 'switchover':
        if scheduled is None and not force:
            scheduled = click.prompt('When should the switchover take place (e.g. 2015-10-01T14:30) ',
                                     type=str, default='now')

        scheduled_at = parse_scheduled(scheduled)
        if scheduled_at:
            if cluster.is_paused():
                raise PatroniCtlException("Can't schedule switchover in the paused state")
            scheduled_at_str = scheduled_at.isoformat()

    failover_value = {'leader': master, 'candidate': candidate, 'scheduled_at': scheduled_at_str}

    logging.debug(failover_value)

    # By now we have established that the leader exists and the candidate exists
    click.echo('Current cluster topology')
    output_members(dcs.get_cluster(), cluster_name)

    if not force:
        demote_msg = ', demoting current master ' + master if master else ''

        if not click.confirm('Are you sure you want to {0} cluster {1}{2}?'.format(action, cluster_name, demote_msg)):
            raise PatroniCtlException('Aborting ' + action)

    r = None
    try:
        member = cluster.leader.member if cluster.leader else cluster.get_member(candidate, False)

        r = request_patroni(member, 'post', action, failover_value, auth_header(obj))

        # probably old patroni, which doesn't support switchover yet
        if r.status_code == 501 and action == 'switchover' and 'Server does not support this operation' in r.text:
            r = request_patroni(member, 'post', 'failover', failover_value, auth_header(obj))

        if r.status_code in (200, 202):
            logging.debug(r)
            cluster = dcs.get_cluster()
            logging.debug(cluster)
            click.echo('{0} {1}'.format(timestamp(), r.text))
        else:
            click.echo('{0} failed, details: {1}, {2}'.format(action.title(), r.status_code, r.text))
            return
    except Exception:
        logging.exception(r)
        logging.warning('Failing over to DCS')
        click.echo('{0} Could not {1} using Patroni api, falling back to DCS'.format(timestamp(), action))
        dcs.manual_failover(master, candidate, scheduled_at=scheduled_at)

    output_members(cluster, cluster_name)
530743
protected void pushChangesToCoordinator(ChangesItem changesItem) throws SecurityException, RPCException
   {
      if (!changesItem.isEmpty())
      {
         rpcService.executeCommandOnCoordinator(applyPersistedChangesTask, true, changesItem);
      }
   }
886577
private void onBusHaltChanged(BusItineraryHalt halt) {
		if (halt.getContainer() == this) {
			final boolean oldValidity = !ListUtil.contains(this.invalidHalts, INVALID_HALT_COMPARATOR, halt);
			final boolean currentValidity = halt.isValidPrimitive();
			if (oldValidity != currentValidity) {
				if (currentValidity) {
					ListUtil.remove(this.invalidHalts, INVALID_HALT_COMPARATOR, halt);
					ListUtil.addIfAbsent(this.validHalts, VALID_HALT_COMPARATOR, halt);
				} else {
					this.validHalts.remove(halt);
					ListUtil.addIfAbsent(this.invalidHalts, INVALID_HALT_COMPARATOR, halt);
				}
				checkPrimitiveValidity();
			}
		}
	}
56256
public void notifyNewLeaderOfTxnDoneIfNeeded() {
        //return quickly to avoid performance hit
        if (m_newLeaderHSID == Long.MIN_VALUE ) {
            return;
        }

        SpScheduler scheduler = (SpScheduler)m_scheduler;
        if (!scheduler.txnDoneBeforeCheckPoint()) {
            return;
        }

        MigratePartitionLeaderMessage message = new MigratePartitionLeaderMessage(m_hsId, m_newLeaderHSID);
        send(message.getNewLeaderHSID(), message);

        //reset status on the old partition leader
        m_migratePartitionLeaderStatus = MigratePartitionLeaderStatus.NONE;
        m_repairLog.setLeaderState(false);
        tmLog.info("MigratePartitionLeader previous leader " + CoreUtils.hsIdToString(m_hsId) + " notifies new leader " +
                CoreUtils.hsIdToString(m_newLeaderHSID) + " transactions are drained." + " status:" + m_migratePartitionLeaderStatus);
        m_newLeaderHSID = Long.MIN_VALUE;
    }
378726
public void notifyOfCatalogUpdate() {
        m_catalogContext.set(VoltDB.instance().getCatalogContext());
        /*
         * Update snapshot daemon settings.
         *
         * Don't do it if the system is still initializing (CL replay),
         * because snapshot daemon may call @SnapshotScan on activation and
         * it will mess replaying txns up.
         */
        if (VoltDB.instance().getMode() != OperationMode.INITIALIZING) {
            mayActivateSnapshotDaemon();

            //add a notification to client right away
            StoredProcedureInvocation spi = new StoredProcedureInvocation();
            spi.setProcName("@SystemCatalog");
            spi.setParams("PROCEDURES");
            spi.setClientHandle(ASYNC_PROC_HANDLE);
            notifyClients(m_currentProcValues,m_currentProcSupplier,
                           spi, OpsSelector.SYSTEMCATALOG);
        }
    }
686063
def _notice_broker_or_pool(obj):
    
    if isinstance(obj, mitogen.core.Broker):
        _brokers[obj] = True
    else:
        _pools[obj] = True
948134
function(error) {
        if (error) {
          return callback(error);
        }
        probe.off('change', monitor.probeChange);
        monitor.set({probeId:null});
        monitor.probe = monitor.probeChange = null;
        return callback(null, reason);
      }
650282
void notifyStateTransition(Execution execution, ExecutionState newState, Throwable error) {
		// only forward this notification if the execution is still the current execution
		// otherwise we have an outdated execution
		if (currentExecution == execution) {
			getExecutionGraph().notifyExecutionChange(execution, newState, error);
		}
	}
1273447
async function _handleChangeAndPush(event, doc, timestamp) {
  // Update the resource content and set dirty
  // TODO: Remove one of these steps since it does encryption twice
  // in the case where the resource does not exist yet
  const resource = await getOrCreateResourceForDoc(doc);

  const updatedResource = await store.updateResource(resource, {
    name: doc.name || 'n/a',
    lastEdited: timestamp,
    lastEditedBy: session.getAccountId(),
    encContent: await encryptDoc(resource.resourceGroupId, doc),
    removed: event === db.CHANGE_REMOVE,
    dirty: true,
  });

  // Debounce pushing of dirty resources
  logger.debug(`Queue ${event} ${updatedResource.id}`);
}
403611
private boolean updateShardedObjectMove(DBObject dbObj) {
        DBObject currDBObj = SpiderService.instance().getObject(m_tableDef, dbObj.getObjectID());
        m_logger.debug("Update forcing move of object {} from shard {} to shard {}",
                       new Object[]{dbObj.getObjectID(),
                                    m_tableDef.getShardNumber(currDBObj),
                                    m_tableDef.getShardNumber(dbObj)});
        
        deleteObject(currDBObj);
        mergeAllFieldValues(dbObj, currDBObj);
        addBrandNewObject(currDBObj);
        return true;
    }
54616
def on_smart_contract_event(self, sc_event: NotifyEvent):
        
        if not isinstance(sc_event, NotifyEvent):
            logger.info("Not Notify Event instance")
            return
        if sc_event.ShouldPersist:
            if sc_event.notify_type in [NotifyType.TRANSFER, NotifyType.REFUND, NotifyType.MINT]:
                self._events_to_write.append(sc_event)
1163353
public void modifyRequest(ResponseBuilder rb, SearchComponent who,
      ShardRequest sreq) {
    if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false)
        && sreq.params.getBool(PARAM_MTAS_FACET, false)) {
      if ((sreq.purpose & ShardRequest.PURPOSE_GET_TOP_IDS) != 0) {
        // do nothing
      } else {
        // remove prefix for other requests
        Set<String> keys = MtasSolrResultUtil
            .getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_FACET);
        sreq.params.remove(PARAM_MTAS_FACET);
        for (String key : keys) {
          sreq.params.remove(
              PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_FIELD);
          sreq.params
              .remove(PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_KEY);
          Set<String> subKeys = MtasSolrResultUtil.getIdsFromParameters(
              rb.req.getParams(),
              PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY);
          for (String subKey : subKeys) {
            sreq.params.remove(
                PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY + "."
                    + subKey + "." + SUBNAME_MTAS_FACET_QUERY_TYPE);
            sreq.params.remove(
                PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY + "."
                    + subKey + "." + SUBNAME_MTAS_FACET_QUERY_VALUE);
            sreq.params.remove(
                PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY + "."
                    + subKey + "." + SUBNAME_MTAS_FACET_QUERY_PREFIX);
            sreq.params.remove(
                PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY + "."
                    + subKey + "." + SUBNAME_MTAS_FACET_QUERY_IGNORE);
            sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
                + NAME_MTAS_FACET_QUERY + "." + subKey + "."
                + SUBNAME_MTAS_FACET_QUERY_MAXIMUM_IGNORE_LENGTH);
            Set<String> subSubKeys = MtasSolrResultUtil
                .getIdsFromParameters(rb.req.getParams(),
                    PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY
                        + "." + subKey + "."
                        + SUBNAME_MTAS_FACET_QUERY_VARIABLE);
            for (String subSubKey : subSubKeys) {
              sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
                  + NAME_MTAS_FACET_QUERY + "." + subKey + "."
                  + SUBNAME_MTAS_FACET_QUERY_VARIABLE + "." + subSubKey + "."
                  + SUBNAME_MTAS_FACET_QUERY_VARIABLE_NAME);
              sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
                  + NAME_MTAS_FACET_QUERY + "." + subKey + "."
                  + SUBNAME_MTAS_FACET_QUERY_VARIABLE + "." + subSubKey + "."
                  + SUBNAME_MTAS_FACET_QUERY_VARIABLE_VALUE);
            }
          }
          subKeys = MtasSolrResultUtil.getIdsFromParameters(rb.req.getParams(),
              PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE);
          for (String subKey : subKeys) {
            sreq.params.remove(
                PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
                    + subKey + "." + SUBNAME_MTAS_FACET_BASE_FIELD);
            sreq.params.remove(
                PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
                    + subKey + "." + SUBNAME_MTAS_FACET_BASE_TYPE);
            sreq.params.remove(
                PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
                    + subKey + "." + SUBNAME_MTAS_FACET_BASE_RANGE + "."
                    + SUBNAME_MTAS_FACET_BASE_RANGE_SIZE);
            sreq.params.remove(
                PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
                    + subKey + "." + SUBNAME_MTAS_FACET_BASE_RANGE + "."
                    + SUBNAME_MTAS_FACET_BASE_RANGE_BASE);
            sreq.params.remove(
                PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
                    + subKey + "." + SUBNAME_MTAS_FACET_BASE_MAXIMUM);
            sreq.params.remove(
                PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
                    + subKey + "." + SUBNAME_MTAS_FACET_BASE_MINIMUM);
            sreq.params.remove(
                PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
                    + subKey + "." + SUBNAME_MTAS_FACET_BASE_NUMBER);
            sreq.params.remove(
                PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
                    + subKey + "." + SUBNAME_MTAS_FACET_BASE_SORT_DIRECTION);
            sreq.params.remove(
                PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
                    + subKey + "." + SUBNAME_MTAS_FACET_BASE_SORT_TYPE);
            Set<String> subSubKeys = MtasSolrResultUtil
                .getIdsFromParameters(rb.req.getParams(),
                    PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE
                        + "." + subKey + "."
                        + SUBNAME_MTAS_FACET_BASE_FUNCTION);
            for (String subSubKey : subSubKeys) {
              sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
                  + NAME_MTAS_FACET_BASE + "." + subKey + "."
                  + SUBNAME_MTAS_FACET_BASE_FUNCTION + "." + subSubKey + "."
                  + SUBNAME_MTAS_FACET_BASE_FUNCTION_EXPRESSION);
              sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
                  + NAME_MTAS_FACET_BASE + "." + subKey + "."
                  + SUBNAME_MTAS_FACET_BASE_FUNCTION + "." + subSubKey + "."
                  + SUBNAME_MTAS_FACET_BASE_FUNCTION_KEY);
              sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
                  + NAME_MTAS_FACET_BASE + "." + subKey + "."
                  + SUBNAME_MTAS_FACET_BASE_FUNCTION + "." + subSubKey + "."
                  + SUBNAME_MTAS_FACET_BASE_FUNCTION_TYPE);
            }
          }
        }
      }
    }
  }
489561
@Override
    public void notifyChange() throws CouldNotPerformException, InterruptedException {
        logger.debug("Notify data change of " + this);
        // synchronized by manageable lock to prevent reinit between validateInitialization and publish
        M newData;
        manageLock.lockWrite(this);
        try {
            try {
                validateInitialization();
            } catch (final NotInitializedException ex) {
                // only forward if instance was not destroyed before otherwise skip notification.
                if (destroyed) {
                    return;
                }
                throw ex;
            }

            // update the current data builder before updating to allow implementations to change data beforehand
            newData = updateDataToPublish(cloneDataBuilder());
            Event event = new Event(informer.getScope(), newData.getClass(), newData);
            event.getMetaData().setUserTime(RPCHelper.USER_TIME_KEY, System.nanoTime());

            if (isActive()) {
                try {
                    waitForMiddleware(NOTIFICATILONG_TIMEOUT, TimeUnit.MILLISECONDS);
                    informer.publish(event);
                } catch (TimeoutException ex) {
                    ExceptionPrinter.printHistory(new CouldNotPerformException("Skip data update notification because middleware is not ready since "+TimeUnit.MILLISECONDS.toSeconds(NOTIFICATILONG_TIMEOUT)+" seconds of " + this + "!", ex), logger, LogLevel.WARN);
                } catch (CouldNotPerformException ex) {
                    ExceptionPrinter.printHistory(new CouldNotPerformException("Could not inform about data change of " + this + "!", ex), logger);
                }
            }
        } finally {
            manageLock.unlockWrite(this);
        }

        // Notify data update
        try {
            notifyDataUpdate(newData);
        } catch (CouldNotPerformException ex) {
            ExceptionPrinter.printHistory(new CouldNotPerformException("Could not notify data update!", ex), logger);
        }

        dataObserver.notifyObservers(newData);
    }
346193
public void notifyAccountDataChanged() {
        switch(accountManager.size()) {
            default:
            case 3:
                this.setThirdAccountPhoto(findAccountNumber(MaterialAccount.THIRD_ACCOUNT).getCircularPhoto());
            case 2:
                this.setSecondAccountPhoto(findAccountNumber(MaterialAccount.SECOND_ACCOUNT).getCircularPhoto());
            case 1:
                this.setFirstAccountPhoto(currentAccount.getCircularPhoto());
                this.setDrawerHeaderImage(currentAccount.getBackground());
                this.setUsername(currentAccount.getTitle());
                this.setUserEmail(currentAccount.getSubTitle());
            case 0:
        }
    }
1149283
public final void notifyContentItemMoved(int fromPosition, int toPosition) {
        if (fromPosition < 0 || toPosition < 0 || fromPosition >= contentItemCount || toPosition >= contentItemCount) {
            throw new IndexOutOfBoundsException("The given fromPosition " + fromPosition + " or toPosition "
                    + toPosition + " is not within the position bounds for content items [0 - " + (contentItemCount - 1) + "].");
        }
        notifyItemMoved(fromPosition + headerItemCount, toPosition + headerItemCount);
    }