int destinationSize = (int) (entry.getDestination() != null ? destinationMap.unsynchronizedGet(entry.getDestination()).size() : regionStatistics.getDestinations().getCount()); if (destinationSize >= entry.getMaxDestinations()) { if (entry.getDestination() != null) { throw new IllegalStateException( "The maxmimum number of destinations allowed ("+ entry.getMaxDestinations() + ") for the policy " + entry.getDestination() + " has already been reached.");
/** * Find a matching PolicyEntry by looking up the Set of entries from the map and * then comparing the destination to find the exact match. This lets us be able to * find the correct policy entry to update even though there might be multiple that * are returned from the get method of the PolicyMap. * * @param runtimeBroker * @param entry * @return */ public static PolicyEntry findEntryByDestination(AbstractRuntimeConfigurationBroker runtimeBroker, PolicyEntry entry) { PolicyMap existingMap = runtimeBroker.getBrokerService().getDestinationPolicy(); @SuppressWarnings("unchecked") Set<PolicyEntry> existingEntries = existingMap.get(entry.getDestination()); //First just look up by the destination type to see if anything matches PolicyEntry existingEntry = null; for (PolicyEntry ee: existingEntries) { if (ee.getDestination().equals(entry.getDestination())) { existingEntry = ee; break; } } return existingEntry; }
public void addNewPolicyEntry(PolicyEntry addition) { PolicyMap existingMap = getBrokerService().getDestinationPolicy(); existingMap.put(addition.getDestination(), addition); PolicyEntryUtil.applyRetrospectively(this, addition, null); info("added policy for: " + addition.getDestination()); }
existingMap.put(existing.getDestination(), existing); existingEntry = existing; existingMap.remove(existingEntry.getDestination(), existingEntry); existingMap.put(existing.getDestination(), existing); this.info("updated policy for: " + existingEntry.getDestination()); } else { throw new IllegalArgumentException("The policy can not be updated because it either does not exist or the PolicyEntry" + " reference does not match an existing PolicyEntry in the PolicyMap. To replace an" + " entry (versus modifying) or add, set createOrReplace to true. " + existing + ", destination:" + existing.getDestination());
@Override public void addNew(Object o) { PolicyEntry addition = fromDto(o, new PolicyEntry()); PolicyMap existingMap = plugin.getBrokerService().getDestinationPolicy(); existingMap.put(addition.getDestination(), addition); applyRetrospectively(addition); plugin.info("added policy for: " + addition.getDestination()); }
@Override public void modify(Object existing, Object candidate) { PolicyEntry updatedEntry = fromDto(candidate, new PolicyEntry()); //Look up an existing entry that matches the candidate //First just look up by the destination type to see if anything matches PolicyEntry existingEntry = PolicyEntryUtil.findEntryByDestination(plugin, updatedEntry); if (existingEntry != null) { //if found, update the policy and apply the updates to existing destinations updatedEntry = fromDto(candidate, existingEntry); applyRetrospectively(updatedEntry); plugin.info("updated policy for: " + updatedEntry.getDestination()); } else { plugin.info("cannot find policy entry candidate to update: " + updatedEntry + ", destination:" + updatedEntry.getDestination()); } }
int destinationSize = (int) (entry.getDestination() != null ? destinationMap.unsynchronizedGet(entry.getDestination()).size() : regionStatistics.getDestinations().getCount()); if (destinationSize >= entry.getMaxDestinations()) { if (entry.getDestination() != null) { throw new IllegalStateException( "The maxmimum number of destinations allowed ("+ entry.getMaxDestinations() + ") for the policy " + entry.getDestination() + " has already been reached.");
int destinationSize = (int) (entry.getDestination() != null ? destinationMap.unsynchronizedGet(entry.getDestination()).size() : regionStatistics.getDestinations().getCount()); if (destinationSize >= entry.getMaxDestinations()) { if (entry.getDestination() != null) { throw new IllegalStateException( "The maxmimum number of destinations allowed ("+ entry.getMaxDestinations() + ") for the policy " + entry.getDestination() + " has already been reached.");
int destinationSize = (int) (entry.getDestination() != null ? destinationMap.unsynchronizedGet(entry.getDestination()).size() : regionStatistics.getDestinations().getCount()); if (destinationSize >= entry.getMaxDestinations()) { if (entry.getDestination() != null) { throw new IllegalStateException( "The maxmimum number of destinations allowed ("+ entry.getMaxDestinations() + ") for the policy " + entry.getDestination() + " has already been reached.");
PolicyEntry updatedEntry, Set<String> includedProperties) { RegionBroker regionBroker = (RegionBroker) runtimeBroker.getBrokerService().getRegionBroker(); for (Destination destination : regionBroker.getDestinations(updatedEntry.getDestination())) {