Examples of MutableBoolean


Examples of org.apache.commons.lang.mutable.MutableBoolean

        List<Versioned<byte[]>> vals = new ArrayList<Versioned<byte[]>>();
        vals.add(new Versioned<byte[]>(key, fetchedClock1));
        vals.add(new Versioned<byte[]>(key, onlineClock1));
        vals.add(new Versioned<byte[]>(key, fetchedClock2));
        vals.add(new Versioned<byte[]>(key, onlineClock2));
        MutableBoolean didPrune = new MutableBoolean();

        vals = pruneAndResolve(vals, didPrune);
        assertEquals("Must have pruned something", true, didPrune.booleanValue());
        assertEquals("Must have two winning versions", 2, vals.size());
        assertEquals("Must have onlineClock1", onlineClock1, vals.get(0).getVersion());
        assertEquals("Must have onlineClock2", onlineClock2, vals.get(1).getVersion());

        // case where key has not received any writes before the prune job
        vals = new ArrayList<Versioned<byte[]>>();
        vals.add(new Versioned<byte[]>(key, fetchedClock1));
        vals.add(new Versioned<byte[]>(key, fetchedClock2));
        didPrune = new MutableBoolean();

        vals = pruneAndResolve(vals, didPrune);
        assertEquals("Must have pruned something", true, didPrune.booleanValue());
        // Note that since 0 is not a master in both fetched clocks, there will
        // be one version. If 0 were to be a master, there will be one version,
        // since master clock will trump non-master clock
        assertEquals("Must have one winning version", 1, vals.size());
        assertEquals("Must resolve to [0:ts] clock",
View Full Code Here

Examples of org.apache.commons.lang.mutable.MutableBoolean

        List<Versioned<byte[]>> vals2 = new ArrayList<Versioned<byte[]>>();
        vals2.add(new Versioned<byte[]>(key, fetchedClock));
        vals2.add(new Versioned<byte[]>(onlineVal, onlineClock1));

        // job fixes server 1
        vals1 = pruneAndResolve(vals1, new MutableBoolean());
        assertEquals("Must have one winning version", 1, vals1.size());
        assertEquals("Must resolve to onlineClock", onlineClock1, vals1.get(0).getVersion());

        // reads only from pruned server
        List<Versioned<byte[]>> resolvedVersions = resolver.resolveConflicts(vals1);
View Full Code Here

Examples of org.apache.commons.lang.mutable.MutableBoolean

                KeyLockHandle<byte[]> lockHandle = null;
                try {
                    lockHandle = engine.getAndLock(key);
                    List<Versioned<byte[]>> vals = lockHandle.getValues();
                    List<Integer> keyReplicas = routingPlan.getReplicationNodeList(routingPlan.getMasterPartitionId(key.get()));
                    MutableBoolean didPrune = new MutableBoolean(false);
                    List<Versioned<byte[]>> prunedVals = pruneNonReplicaEntries(vals,
                                                                                keyReplicas,
                                                                                didPrune);
                    // Only write something back if some pruning actually
                    // happened. Optimization to reduce load on storage
                    if(didPrune.booleanValue()) {
                        List<Versioned<byte[]>> resolvedVals = VectorClockUtils.resolveVersions(prunedVals);
                        // TODO this is only implemented for BDB for now
                        lockHandle.setValues(resolvedVals);
                        engine.putAndUnlock(key, lockHandle);
                        numPrunedKeys = this.numKeysUpdatedThisRun.incrementAndGet();
View Full Code Here

Examples of org.apache.commons.lang.mutable.MutableBoolean

            }
            return bindings;
        }

        private static Collection<Binding> wire(final Bound bound, final BindingContext context, final Field field) {
            final MutableBoolean didBind = new MutableBoolean();
            final List<Binding> bindings = Lists.newArrayList();
            Reflections.visitClassHierarchy(field.getType(), new Visitor<Class<?>>() {
                public void visit(Class<?> klass){
                    if (didBind.booleanValue()) {
                        return;
                    }
                    WiringHarness<Bound, Field> wiringHarness = wiringHarnesses.get(klass);
                    if (wiringHarness == null) {
                        return;
                    }
                    try {
                        bindings.addAll(wiringHarness.wire(bound, context, field));
                        didBind.setValue(true);
                    } catch (Exception e) {
                        throw Throwables.throwUncheckedException(e);
                    }
                }
            });
            if (!didBind.booleanValue()) {
                throw new BindingException("don't know how to wire up @Bound field: " + field.getName());
            }
            return bindings;
        }
View Full Code Here

Examples of org.apache.commons.lang.mutable.MutableBoolean

     * @param annotation annotation to look for
     * @return true is a class in this passed object's type hierarchy is annotated with the
     * passed {@link Annotation}
     */
    public static boolean isClassAnnotatedForClassHierarchy(Object object, final Class<? extends Annotation> annotation) {
        final MutableBoolean bool = new MutableBoolean(false);
        visitClassHierarchy(object.getClass(), new Visitor<Class<?>>() {
            public void visit(Class<?> klass) {
                if (klass.isAnnotationPresent(annotation)) {
                    bool.setValue(true);
                }
            }
        });
        return bool.booleanValue();
    }
View Full Code Here

Examples of org.apache.commons.lang.mutable.MutableBoolean

      if (curPeer.fromCache) remainingCacheTries--;
      DomainPeer peer = (DomainPeer)curPeer.peer;
      Slot slot = null;
      ShortCircuitCache cache = clientContext.getShortCircuitCache();
      try {
        MutableBoolean usedPeer = new MutableBoolean(false);
        slot = cache.allocShmSlot(datanode, peer, usedPeer,
            new ExtendedBlockId(block.getBlockId(), block.getBlockPoolId()),
            clientName);
        if (usedPeer.booleanValue()) {
          if (LOG.isTraceEnabled()) {
            LOG.trace(this + ": allocShmSlot used up our previous socket " +
              peer.getDomainSocket() + ".  Allocating a new one...");
          }
          curPeer = nextDomainPeer();
View Full Code Here

Examples of org.apache.commons.lang.mutable.MutableBoolean

      }
    }
    fsIn.close();
    GenericTestUtils.waitFor(new Supplier<Boolean>() {
      public Boolean get() {
        final MutableBoolean finished = new MutableBoolean(false);
        cache.accept(new CacheVisitor() {
          @Override
          public void visit(int numOutstandingMmaps,
              Map<ExtendedBlockId, ShortCircuitReplica> replicas,
              Map<ExtendedBlockId, InvalidToken> failedLoads,
              Map<Long, ShortCircuitReplica> evictable,
              Map<Long, ShortCircuitReplica> evictableMmapped) {
            finished.setValue(evictableMmapped.isEmpty());
          }
        });
        return finished.booleanValue();
      }
    }, 10, 60000);

    cache.accept(new CountingVisitor(0, -1, -1, -1));
   
View Full Code Here

Examples of org.apache.commons.lang.mutable.MutableBoolean

        final boolean expectedIsAnchored, final int expectedOutstandingMmaps)
          throws Exception {
    GenericTestUtils.waitFor(new Supplier<Boolean>() {
      @Override
      public Boolean get() {
        final MutableBoolean result = new MutableBoolean(false);
        cache.accept(new CacheVisitor() {
          @Override
          public void visit(int numOutstandingMmaps,
              Map<ExtendedBlockId, ShortCircuitReplica> replicas,
              Map<ExtendedBlockId, InvalidToken> failedLoads,
              Map<Long, ShortCircuitReplica> evictable,
              Map<Long, ShortCircuitReplica> evictableMmapped) {
            Assert.assertEquals(expectedOutstandingMmaps, numOutstandingMmaps);
            ShortCircuitReplica replica =
                replicas.get(ExtendedBlockId.fromExtendedBlock(block));
            Assert.assertNotNull(replica);
            Slot slot = replica.getSlot();
            if ((expectedIsAnchorable != slot.isAnchorable()) ||
                (expectedIsAnchored != slot.isAnchored())) {
              LOG.info("replica " + replica + " has isAnchorable = " +
                slot.isAnchorable() + ", isAnchored = " + slot.isAnchored() +
                ".  Waiting for isAnchorable = " + expectedIsAnchorable +
                ", isAnchored = " + expectedIsAnchored);
              return;
            }
            result.setValue(true);
          }
        });
        return result.toBoolean();
      }
    }, 10, 60000);
  }
View Full Code Here

Examples of org.apache.commons.lang.mutable.MutableBoolean

    }

    categories = ImmutableList.of(getAttribute(ATTR_CATEGORY, ""), getAttribute(ATTR_CATEGORY2, ""));

    // Eventually use a list of classes
    MutableBoolean oauthMarker = new MutableBoolean(false);
    Set<ElementVisitor> visitors = ImmutableSet.of(
        new FeatureVisitor(oauthMarker),
        new PreloadVisitor(),
        new OAuthVisitor(oauthMarker),
        new IconVisitor(),
View Full Code Here

Examples of org.apache.commons.lang.mutable.MutableBoolean

    assertEquals(2, model.getNumUsersWithPreferenceFor(123, 234));
  }

  @Test
  public void testRefresh() throws Exception {
    final MutableBoolean initialized = new MutableBoolean(false);
    Runnable initializer = new Runnable() {
      @Override
      public void run() {
        try {
          model.getNumUsers();
          initialized.setValue(true);
        } catch (TasteException te) {
          // oops
        }
      }
    };
    new Thread(initializer).start();
    Thread.sleep(1000L); // wait a second for thread to start and call getNumUsers()
    model.getNumUsers(); // should block
    assertTrue(initialized.booleanValue());
    assertEquals(4, model.getNumUsers());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.