List of usage examples for org.apache.commons.lang3.mutable MutableBoolean isFalse
public boolean isFalse()
false
. From source file:fr.duminy.jbackup.core.JBackupImplTest.java
private void waitTaskStarted(MutableBoolean taskStarted, MutableObject<Cancellable> actualCancellable) throws InterruptedException { long start = currentTimeMillis(); do {/*ww w . ja v a 2 s.c o m*/ Thread.sleep(100); } while (((actualCancellable.getValue() == null) || taskStarted.isFalse()) && ((currentTimeMillis() - start) < 1000)); }
From source file:de.uni_potsdam.hpi.asg.logictool.mapping.SequenceBasedAndGateDecomposer.java
private boolean categoriseSequences(BDD bdd, SortedSet<IOBehaviour> sequences, List<IOBehaviour> falling, List<IOBehaviour> rising, List<IOBehaviour> constant) { for (IOBehaviour beh : sequences) { BDD startBDD = bdd;//from ww w . jav a 2 s . c o m MutableBoolean resultStart = new MutableBoolean(); if (!evaluateBDD(resultStart, startBDD, beh.getStart())) { logger.error("Something went wrong"); return false; } BDD endBDD = bdd; MutableBoolean resultEnd = new MutableBoolean(); if (!evaluateBDD(resultEnd, endBDD, beh.getEnd())) { logger.error("Something went wrong"); return false; } if (resultStart.isTrue() && resultEnd.isFalse()) { falling.add(beh); //System.out.println("uups? falling?"); } else if (resultStart.isFalse() && resultEnd.isTrue()) { rising.add(beh); } else if (resultStart.isFalse() && resultEnd.isFalse()) { constant.add(beh); } else { logger.error("Const 1 should not happen"); return false; } //System.out.println(resultStart.booleanValue() + "=>" + resultEnd.booleanValue() + " : " + beh); } return true; }
From source file:forge.game.card.Card.java
@Override public final boolean canBeTargetedBy(final SpellAbility sa) { if (sa == null) { return true; }/*from ww w. j a v a 2 s . c o m*/ // CantTarget static abilities for (final Card ca : getGame().getCardsIn(ZoneType.listValueOf("Battlefield,Command"))) { final Iterable<StaticAbility> staticAbilities = ca.getStaticAbilities(); for (final StaticAbility stAb : staticAbilities) { if (stAb.applyAbility("CantTarget", this, sa)) { return false; } } } // keywords don't work outside battlefield if (!isInZone(ZoneType.Battlefield)) { return true; } if (hasProtectionFrom(sa.getHostCard())) { return false; } if (isPhasedOut()) { return false; } final Card source = sa.getHostCard(); final MutableBoolean result = new MutableBoolean(true); visitKeywords(currentState, new Visitor<String>() { @Override public void visit(String kw) { if (result.isFalse()) { return; } switch (kw) { case "Shroud": StringBuilder sb = new StringBuilder(); sb.append("Can target CardUID_").append(String.valueOf(getId())); sb.append(" with spells and abilities as though it didn't have shroud."); if (!sa.getActivatingPlayer().hasKeyword(sb.toString())) { result.setFalse(); } break; case "Hexproof": if (sa.getActivatingPlayer().getOpponents().contains(getController())) { if (!sa.getActivatingPlayer() .hasKeyword("Spells and abilities you control can target hexproof creatures")) { result.setFalse(); } } break; case "CARDNAME can't be the target of Aura spells.": if (source.isAura() && sa.isSpell()) { result.setFalse(); } break; case "CARDNAME can't be enchanted.": if (source.isAura()) { result.setFalse(); } break; case "CARDNAME can't be equipped.": if (source.isEquipment()) { result.setFalse(); } break; case "CARDNAME can't be the target of red spells or abilities from red sources.": if (source.isRed()) { result.setFalse(); } break; case "CARDNAME can't be the target of black spells.": if (source.isBlack() && sa.isSpell()) { result.setFalse(); } break; case "CARDNAME can't be the target of blue spells.": if (source.isBlue() && sa.isSpell()) { result.setFalse(); } break; case "CARDNAME can't be the target of spells.": if (sa.isSpell()) { result.setFalse(); } break; } } }); if (result.isFalse()) { return false; } if (sa.isSpell() && source.hasStartOfKeyword("SpellCantTarget")) { final int keywordPosition = source.getKeywordPosition("SpellCantTarget"); final String parse = source.getKeywords().get(keywordPosition); final String[] k = parse.split(":"); final String[] restrictions = k[1].split(","); if (isValid(restrictions, source.getController(), source)) { return false; } } return true; }
From source file:org.apache.pulsar.broker.loadbalance.impl.OverloadShedder.java
/** * Attempt to shed some bundles off every broker which is overloaded. * * @param loadData// w w w . ja v a 2s . com * The load data to used to make the unloading decision. * @param conf * The service configuration. * @return A map from bundles to unload to the brokers on which they are loaded. */ public Multimap<String, String> findBundlesForUnloading(final LoadData loadData, final ServiceConfiguration conf) { selectedBundlesCache.clear(); final double overloadThreshold = conf.getLoadBalancerBrokerOverloadedThresholdPercentage() / 100.0; final Map<String, Long> recentlyUnloadedBundles = loadData.getRecentlyUnloadedBundles(); // Check every broker and select loadData.getBrokerData().forEach((broker, brokerData) -> { final LocalBrokerData localData = brokerData.getLocalData(); final double currentUsage = localData.getMaxResourceUsage(); if (currentUsage < overloadThreshold) { if (log.isDebugEnabled()) { log.debug("[{}] Broker is not overloaded, ignoring at this point", broker); } return; } // We want to offload enough traffic such that this broker will go below the overload threshold // Also, add a small margin so that this broker won't be very close to the threshold edge. double percentOfTrafficToOffload = currentUsage - overloadThreshold + ADDITIONAL_THRESHOLD_PERCENT_MARGIN; double brokerCurrentThroughput = localData.getMsgThroughputIn() + localData.getMsgThroughputOut(); double minimumThroughputToOffload = brokerCurrentThroughput * percentOfTrafficToOffload; log.info( "Attempting to shed load on {}, which has max resource usage above threshold {}% > {}% -- Offloading at least {} MByte/s of traffic", broker, currentUsage, overloadThreshold, minimumThroughputToOffload / 1024 / 1024); MutableDouble trafficMarkedToOffload = new MutableDouble(0); MutableBoolean atLeastOneBundleSelected = new MutableBoolean(false); if (localData.getBundles().size() > 1) { // Sort bundles by throughput, then pick the biggest N which combined make up for at least the minimum throughput to offload loadData.getBundleData().entrySet().stream().map((e) -> { // Map to throughput value // Consider short-term byte rate to address system resource burden String bundle = e.getKey(); BundleData bundleData = e.getValue(); TimeAverageMessageData shortTermData = bundleData.getShortTermData(); double throughput = shortTermData.getMsgThroughputIn() + shortTermData.getMsgThroughputOut(); return Pair.of(bundle, throughput); }).filter(e -> { // Only consider bundles that were not already unloaded recently return !recentlyUnloadedBundles.containsKey(e.getLeft()); }).sorted((e1, e2) -> { // Sort by throughput in reverse order return Double.compare(e2.getRight(), e1.getRight()); }).forEach(e -> { if (trafficMarkedToOffload.doubleValue() < minimumThroughputToOffload || atLeastOneBundleSelected.isFalse()) { selectedBundlesCache.put(broker, e.getLeft()); trafficMarkedToOffload.add(e.getRight()); atLeastOneBundleSelected.setTrue(); } }); } else if (localData.getBundles().size() == 1) { log.warn( "HIGH USAGE WARNING : Sole namespace bundle {} is overloading broker {}. " + "No Load Shedding will be done on this broker", localData.getBundles().iterator().next(), broker); } else { log.warn("Broker {} is overloaded despite having no bundles", broker); } }); return selectedBundlesCache; }
From source file:org.jbpm.bpmn2.IntermediateEventTest.java
@Test public void testSignalBoundaryNonEffectiveEvent() throws Exception { final String signal = "signalTest"; final MutableBoolean eventAfterNodeLeftTriggered = new MutableBoolean(false); KieBase kbase = createKnowledgeBase("BPMN2-BoundaryEventWithNonEffectiveSignal.bpmn2"); StatefulKnowledgeSession ksession = createKnowledgeSession(kbase); TestWorkItemHandler handler = new TestWorkItemHandler(); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler); ksession.addEventListener(new DefaultProcessEventListener() { @Override/* ww w.j av a 2 s .co m*/ public void afterNodeLeft(ProcessNodeLeftEvent event) { // BoundaryEventNodeInstance if (signal.equals(event.getNodeInstance().getNodeName())) { eventAfterNodeLeftTriggered.setTrue(); } } }); ProcessInstance processInstance = ksession.startProcess("BoundaryEventWithNonEffectiveSignal"); ksession.signalEvent(signal, signal); // outer human work ksession.getWorkItemManager().completeWorkItem(handler.getWorkItem().getId(), null); // inner human task ksession.getWorkItemManager().completeWorkItem(handler.getWorkItem().getId(), null); assertProcessInstanceFinished(processInstance, ksession); assertThat(eventAfterNodeLeftTriggered.isFalse()).isTrue(); }